summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/gt/intel_context.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-01-09 11:51:42 +0300
committerChris Wilson <chris@chris-wilson.co.uk>2020-01-09 15:50:26 +0300
commitfeed5c7be22c25e9c777c821bcf955a13cf010ab (patch)
treeb5ae1cafdef8160c2790ce8a49c08783b64cc67f /drivers/gpu/drm/i915/gt/intel_context.h
parent921f0c47f22891c90e2eb8f8612a083669c5d1ca (diff)
downloadlinux-feed5c7be22c25e9c777c821bcf955a13cf010ab.tar.xz
drm/i915: Pin the context as we work on it
Since we now allow the intel_context_unpin() to run unserialised, we risk our operations under the intel_context_lock_pinned() being run as the context is unpinned (and thus invalidating our state). We can atomically acquire the pin, testing to see if it is pinned in the process, thus ensuring that the state remains consistent during the course of the whole operation. Fixes: 841350223816 ("drm/i915/gt: Drop mutex serialisation between context pin/unpin") Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200109085142.871563-1-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/gt/intel_context.h')
-rw-r--r--drivers/gpu/drm/i915/gt/intel_context.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
index 0f5ae4ff3b10..63073ebc6cf1 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -76,9 +76,14 @@ static inline void intel_context_unlock_pinned(struct intel_context *ce)
int __intel_context_do_pin(struct intel_context *ce);
+static inline bool intel_context_pin_if_active(struct intel_context *ce)
+{
+ return atomic_inc_not_zero(&ce->pin_count);
+}
+
static inline int intel_context_pin(struct intel_context *ce)
{
- if (likely(atomic_inc_not_zero(&ce->pin_count)))
+ if (likely(intel_context_pin_if_active(ce)))
return 0;
return __intel_context_do_pin(ce);