Message ID | 20200123224459.38128-2-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/i915: Check activity on i915_vma after confirming pin_count==0 | expand |
On 23/01/2020 22:44, Chris Wilson wrote: > Optimistically wait for the prior vma activity before taking the mutex > to minimise the mutex hold time while unbinding. We will then verify the > vma is idle with a second wait under the mutex to ensure it is safe to > unbind. > > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > --- > drivers/gpu/drm/i915/i915_vma.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c > index 4999882fbceb..84e03da0d5f9 100644 > --- a/drivers/gpu/drm/i915/i915_vma.c > +++ b/drivers/gpu/drm/i915/i915_vma.c > @@ -1279,16 +1279,21 @@ int i915_vma_unbind(struct i915_vma *vma) > /* XXX not always required: nop_clear_range */ > wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm); > > + /* Optimistic wait before taking the mutex */ > + err = i915_vma_sync(vma); > + if (err) > + goto out_rpm; > + > err = mutex_lock_interruptible(&vm->mutex); > if (err) > - return err; > + goto out_rpm; > > err = __i915_vma_unbind(vma); > mutex_unlock(&vm->mutex); > > +out_rpm: > if (wakeref) > intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref); > - > return err; > } > > Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Regards, Tvrtko
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index 4999882fbceb..84e03da0d5f9 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -1279,16 +1279,21 @@ int i915_vma_unbind(struct i915_vma *vma) /* XXX not always required: nop_clear_range */ wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm); + /* Optimistic wait before taking the mutex */ + err = i915_vma_sync(vma); + if (err) + goto out_rpm; + err = mutex_lock_interruptible(&vm->mutex); if (err) - return err; + goto out_rpm; err = __i915_vma_unbind(vma); mutex_unlock(&vm->mutex); +out_rpm: if (wakeref) intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref); - return err; }
Optimistically wait for the prior vma activity before taking the mutex to minimise the mutex hold time while unbinding. We will then verify the vma is idle with a second wait under the mutex to ensure it is safe to unbind. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> --- drivers/gpu/drm/i915/i915_vma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)