drm/i915: Skip taking acquire mutex for no ref->active callback
If no active callback is defined for i915_active, we do not need to serialise its enabling with the mutex. We still do only want to call the debug activate once, and must still serialise with a concurrent retire. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200731085015.32368-2-chris@chris-wilson.co.uk Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
This commit is contained in:
parent
bde246d893
commit
04240e30ed
1 changed files with 16 additions and 8 deletions
|
@ -416,6 +416,14 @@ bool i915_active_acquire_if_busy(struct i915_active *ref)
|
||||||
return atomic_add_unless(&ref->count, 1, 0);
|
return atomic_add_unless(&ref->count, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __i915_active_activate(struct i915_active *ref)
|
||||||
|
{
|
||||||
|
spin_lock_irq(&ref->tree_lock); /* __active_retire() */
|
||||||
|
if (!atomic_fetch_inc(&ref->count))
|
||||||
|
debug_active_activate(ref);
|
||||||
|
spin_unlock_irq(&ref->tree_lock);
|
||||||
|
}
|
||||||
|
|
||||||
int i915_active_acquire(struct i915_active *ref)
|
int i915_active_acquire(struct i915_active *ref)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -423,19 +431,19 @@ int i915_active_acquire(struct i915_active *ref)
|
||||||
if (i915_active_acquire_if_busy(ref))
|
if (i915_active_acquire_if_busy(ref))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!ref->active) {
|
||||||
|
__i915_active_activate(ref);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
err = mutex_lock_interruptible(&ref->mutex);
|
err = mutex_lock_interruptible(&ref->mutex);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (likely(!i915_active_acquire_if_busy(ref))) {
|
if (likely(!i915_active_acquire_if_busy(ref))) {
|
||||||
if (ref->active)
|
err = ref->active(ref);
|
||||||
err = ref->active(ref);
|
if (!err)
|
||||||
if (!err) {
|
__i915_active_activate(ref);
|
||||||
spin_lock_irq(&ref->tree_lock); /* __active_retire() */
|
|
||||||
debug_active_activate(ref);
|
|
||||||
atomic_inc(&ref->count);
|
|
||||||
spin_unlock_irq(&ref->tree_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&ref->mutex);
|
mutex_unlock(&ref->mutex);
|
||||||
|
|
Loading…
Add table
Reference in a new issue