Skip to content

Commit

Permalink
drm/i915: Check for error before calling cmpxchg()
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191206160428.1503343-1-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Dec 6, 2019
1 parent b66ecd0 commit 5e6a947
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpu/drm/i915/i915_sw_fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */

0 comments on commit 5e6a947

Please sign in to comment.