aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_sw_fence.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-12-06 16:04:26 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-12-06 19:09:33 +0000
commit5e6a94713be051c491cd47c85263661af07b629c (patch)
treec6c1963adcf71fe70a916320ddc2b4391cc62be9 /drivers/gpu/drm/i915/i915_sw_fence.h
parentdrm/i915/pmu: Report frequency as zero while GPU is sleeping (diff)
downloadlinux-dev-5e6a94713be051c491cd47c85263661af07b629c.tar.xz
linux-dev-5e6a94713be051c491cd47c85263661af07b629c.zip
drm/i915: Check for error before calling cmpxchg()
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
Diffstat (limited to 'drivers/gpu/drm/i915/i915_sw_fence.h')
-rw-r--r--drivers/gpu/drm/i915/i915_sw_fence.h3
1 files changed, 2 insertions, 1 deletions
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_ */