]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/i915: Replace empty conditional with continue in eb_relocate_vma()
authorSebastian Brzezinka <sebastian.brzezinka@intel.com>
Fri, 18 Jul 2025 10:28:19 +0000 (10:28 +0000)
committerAndi Shyti <andi.shyti@linux.intel.com>
Thu, 24 Jul 2025 13:05:40 +0000 (15:05 +0200)
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
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

index 0801d4a140e35398ff05a22902527a50bb7c1ac3..f243f8a5215d8c074e077edd451e0fc6763a9dd3 100644 (file)
@@ -1568,36 +1568,36 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
                do {
                        u64 offset = eb_relocate_entry(eb, ev, r);
 
-                       if (likely(offset == 0)) {
-                       } else if ((s64)offset < 0) {
+                       if (likely(offset == 0))
+                               continue;
+
+                       if ((s64)offset < 0) {
                                remain = (int)offset;
                                goto out;
-                       } else {
-                               /*
-                                * Note that reporting an error now
-                                * leaves everything in an inconsistent
-                                * state as we have *already* changed
-                                * the relocation value inside the
-                                * object. As we have not changed the
-                                * reloc.presumed_offset or will not
-                                * change the execobject.offset, on the
-                                * call we may not rewrite the value
-                                * inside the object, leaving it
-                                * dangling and causing a GPU hang. Unless
-                                * userspace dynamically rebuilds the
-                                * relocations on each execbuf rather than
-                                * presume a static tree.
-                                *
-                                * We did previously check if the relocations
-                                * were writable (access_ok), an error now
-                                * would be a strange race with mprotect,
-                                * having already demonstrated that we
-                                * can read from this userspace address.
-                                */
-                               offset = gen8_canonical_addr(offset & ~UPDATE);
-                               __put_user(offset,
-                                          &urelocs[r - stack].presumed_offset);
                        }
+                       /*
+                        * Note that reporting an error now
+                        * leaves everything in an inconsistent
+                        * state as we have *already* changed
+                        * the relocation value inside the
+                        * object. As we have not changed the
+                        * reloc.presumed_offset or will not
+                        * change the execobject.offset, on the
+                        * call we may not rewrite the value
+                        * inside the object, leaving it
+                        * dangling and causing a GPU hang. Unless
+                        * userspace dynamically rebuilds the
+                        * relocations on each execbuf rather than
+                        * presume a static tree.
+                        *
+                        * We did previously check if the relocations
+                        * were writable (access_ok), an error now
+                        * would be a strange race with mprotect,
+                        * having already demonstrated that we
+                        * can read from this userspace address.
+                        */
+                       offset = gen8_canonical_addr(offset & ~UPDATE);
+                       __put_user(offset, &urelocs[r - stack].presumed_offset);
                } while (r++, --count);
                urelocs += ARRAY_SIZE(stack);
        } while (remain);