Skip to content

Commit c8bdf31

Browse files
sberbzAndi Shyti
authored andcommitted
drm/i915: Replace empty conditional with continue in eb_relocate_vma()
Simplifies the control flow by replacing an empty `if (likely(offset == 0))` block with a `continue` statement. This improves readability and avoids unnecessary nesting. Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://lore.kernel.org/r/20250718102752.684975-4-sebastian.brzezinka@intel.com
1 parent bf91bac commit c8bdf31

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,36 +1568,36 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
15681568
do {
15691569
u64 offset = eb_relocate_entry(eb, ev, r);
15701570

1571-
if (likely(offset == 0)) {
1572-
} else if ((s64)offset < 0) {
1571+
if (likely(offset == 0))
1572+
continue;
1573+
1574+
if ((s64)offset < 0) {
15731575
remain = (int)offset;
15741576
goto out;
1575-
} else {
1576-
/*
1577-
* Note that reporting an error now
1578-
* leaves everything in an inconsistent
1579-
* state as we have *already* changed
1580-
* the relocation value inside the
1581-
* object. As we have not changed the
1582-
* reloc.presumed_offset or will not
1583-
* change the execobject.offset, on the
1584-
* call we may not rewrite the value
1585-
* inside the object, leaving it
1586-
* dangling and causing a GPU hang. Unless
1587-
* userspace dynamically rebuilds the
1588-
* relocations on each execbuf rather than
1589-
* presume a static tree.
1590-
*
1591-
* We did previously check if the relocations
1592-
* were writable (access_ok), an error now
1593-
* would be a strange race with mprotect,
1594-
* having already demonstrated that we
1595-
* can read from this userspace address.
1596-
*/
1597-
offset = gen8_canonical_addr(offset & ~UPDATE);
1598-
__put_user(offset,
1599-
&urelocs[r - stack].presumed_offset);
16001577
}
1578+
/*
1579+
* Note that reporting an error now
1580+
* leaves everything in an inconsistent
1581+
* state as we have *already* changed
1582+
* the relocation value inside the
1583+
* object. As we have not changed the
1584+
* reloc.presumed_offset or will not
1585+
* change the execobject.offset, on the
1586+
* call we may not rewrite the value
1587+
* inside the object, leaving it
1588+
* dangling and causing a GPU hang. Unless
1589+
* userspace dynamically rebuilds the
1590+
* relocations on each execbuf rather than
1591+
* presume a static tree.
1592+
*
1593+
* We did previously check if the relocations
1594+
* were writable (access_ok), an error now
1595+
* would be a strange race with mprotect,
1596+
* having already demonstrated that we
1597+
* can read from this userspace address.
1598+
*/
1599+
offset = gen8_canonical_addr(offset & ~UPDATE);
1600+
__put_user(offset, &urelocs[r - stack].presumed_offset);
16011601
} while (r++, --count);
16021602
urelocs += ARRAY_SIZE(stack);
16031603
} while (remain);

0 commit comments

Comments
 (0)