Commit a4e57f90 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Teach execbuffer to take the engine wakeref not GT

In the next patch, we would like to couple into the engine wakeref to
free the batch pool on idling. The caveat here is that we therefore want
to track the engine wakeref more precisely and to hold it instead of the
broader GT wakeref as we process the ioctl.

v2: Avoid introducing odd semantics for a shortlived timeline->mutex
acquisition interface.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190804124826.30272-1-chris@chris-wilson.co.uk
parent 515b8b7e
...@@ -2139,14 +2139,40 @@ static int eb_pin_context(struct i915_execbuffer *eb, struct intel_context *ce) ...@@ -2139,14 +2139,40 @@ static int eb_pin_context(struct i915_execbuffer *eb, struct intel_context *ce)
if (err) if (err)
return err; return err;
/*
* Take a local wakeref for preparing to dispatch the execbuf as
* we expect to access the hardware fairly frequently in the
* process, and require the engine to be kept awake between accesses.
* Upon dispatch, we acquire another prolonged wakeref that we hold
* until the timeline is idle, which in turn releases the wakeref
* taken on the engine, and the parent device.
*/
err = intel_context_timeline_lock(ce);
if (err)
goto err_unpin;
intel_context_enter(ce);
intel_context_timeline_unlock(ce);
eb->engine = ce->engine; eb->engine = ce->engine;
eb->context = ce; eb->context = ce;
return 0; return 0;
err_unpin:
intel_context_unpin(ce);
return err;
} }
static void eb_unpin_context(struct i915_execbuffer *eb) static void eb_unpin_context(struct i915_execbuffer *eb)
{ {
intel_context_unpin(eb->context); struct intel_context *ce = eb->context;
struct intel_timeline *tl = ce->ring->timeline;
mutex_lock(&tl->mutex);
intel_context_exit(ce);
mutex_unlock(&tl->mutex);
intel_context_unpin(ce);
} }
static unsigned int static unsigned int
...@@ -2426,18 +2452,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, ...@@ -2426,18 +2452,9 @@ i915_gem_do_execbuffer(struct drm_device *dev,
if (unlikely(err)) if (unlikely(err))
goto err_destroy; goto err_destroy;
/*
* Take a local wakeref for preparing to dispatch the execbuf as
* we expect to access the hardware fairly frequently in the
* process. Upon first dispatch, we acquire another prolonged
* wakeref that we hold until the GPU has been idle for at least
* 100ms.
*/
intel_gt_pm_get(&eb.i915->gt);
err = i915_mutex_lock_interruptible(dev); err = i915_mutex_lock_interruptible(dev);
if (err) if (err)
goto err_rpm; goto err_context;
err = eb_select_engine(&eb, file, args); err = eb_select_engine(&eb, file, args);
if (unlikely(err)) if (unlikely(err))
...@@ -2602,8 +2619,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, ...@@ -2602,8 +2619,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
eb_unpin_context(&eb); eb_unpin_context(&eb);
err_unlock: err_unlock:
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
err_rpm: err_context:
intel_gt_pm_put(&eb.i915->gt);
i915_gem_context_put(eb.gem_context); i915_gem_context_put(eb.gem_context);
err_destroy: err_destroy:
eb_destroy(&eb); eb_destroy(&eb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment