]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/active: Use try_cmpxchg() in active_fence_cb()
authorUros Bizjak <ubizjak@gmail.com>
Thu, 3 Oct 2024 08:44:31 +0000 (10:44 +0200)
committerJani Nikula <jani.nikula@intel.com>
Wed, 23 Oct 2024 12:45:50 +0000 (15:45 +0300)
Replace this pattern in active_fence_cb():

    cmpxchg(*ptr, old, new) == old

... with the simpler and faster:

    try_cmpxchg(*ptr, &old, new)

The x86 CMPXCHG instruction returns success in the ZF flag,
so this change saves a compare after the CMPXCHG.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20241003084533.871524-1-ubizjak@gmail.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/i915_active.c

index 5ec293011d99029f211301d2789272603f7f3dde..35319228bc519a49639747af9282c41923bccb47 100644 (file)
@@ -212,7 +212,7 @@ active_fence_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
        struct i915_active_fence *active =
                container_of(cb, typeof(*active), cb);
 
-       return cmpxchg(__active_fence_slot(active), fence, NULL) == fence;
+       return try_cmpxchg(__active_fence_slot(active), &fence, NULL);
 }
 
 static void