diff mbox series

[1/3] drm/i915: Check for error before calling cmpxchg()

Message ID 20191206160428.1503343-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/i915: Check for error before calling cmpxchg() | expand

Commit Message

Chris Wilson Dec. 6, 2019, 4:04 p.m. UTC
Only do the locked compare of the existing fence->error if we actually
need to set an error. As we tend to call i915_sw_fence_set_error_once()
unconditionally, it saves on typing to put the common has-error check
into the inline.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_sw_fence.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Matthew Auld Dec. 6, 2019, 6:54 p.m. UTC | #1
On Fri, 6 Dec 2019 at 16:04, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Only do the locked compare of the existing fence->error if we actually
> need to set an error. As we tend to call i915_sw_fence_set_error_once()
> unconditionally, it saves on typing to put the common has-error check
> into the inline.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

For the series:
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
index 1e90d9a51bd2..19e806ce43bc 100644
--- a/drivers/gpu/drm/i915/i915_sw_fence.h
+++ b/drivers/gpu/drm/i915/i915_sw_fence.h
@@ -112,7 +112,8 @@  static inline void i915_sw_fence_wait(struct i915_sw_fence *fence)
 static inline void
 i915_sw_fence_set_error_once(struct i915_sw_fence *fence, int error)
 {
-	cmpxchg(&fence->error, 0, error);
+	if (unlikely(error))
+		cmpxchg(&fence->error, 0, error);
 }
 
 #endif /* _I915_SW_FENCE_H_ */