Skip to content

Commit a4e57f9

Browse files
committed
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: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190804124826.30272-1-chris@chris-wilson.co.uk
1 parent 515b8b7 commit a4e57f9

1 file changed

Lines changed: 29 additions & 13 deletions

File tree

‎drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c‎

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,14 +2139,40 @@ static int eb_pin_context(struct i915_execbuffer *eb, struct intel_context *ce)
21392139
if (err)
21402140
return err;
21412141

2142+
/*
2143+
* Take a local wakeref for preparing to dispatch the execbuf as
2144+
* we expect to access the hardware fairly frequently in the
2145+
* process, and require the engine to be kept awake between accesses.
2146+
* Upon dispatch, we acquire another prolonged wakeref that we hold
2147+
* until the timeline is idle, which in turn releases the wakeref
2148+
* taken on the engine, and the parent device.
2149+
*/
2150+
err = intel_context_timeline_lock(ce);
2151+
if (err)
2152+
goto err_unpin;
2153+
2154+
intel_context_enter(ce);
2155+
intel_context_timeline_unlock(ce);
2156+
21422157
eb->engine = ce->engine;
21432158
eb->context = ce;
21442159
return 0;
2160+
2161+
err_unpin:
2162+
intel_context_unpin(ce);
2163+
return err;
21452164
}
21462165

21472166
static void eb_unpin_context(struct i915_execbuffer *eb)
21482167
{
2149-
intel_context_unpin(eb->context);
2168+
struct intel_context *ce = eb->context;
2169+
struct intel_timeline *tl = ce->ring->timeline;
2170+
2171+
mutex_lock(&tl->mutex);
2172+
intel_context_exit(ce);
2173+
mutex_unlock(&tl->mutex);
2174+
2175+
intel_context_unpin(ce);
21502176
}
21512177

21522178
static unsigned int
@@ -2426,18 +2452,9 @@ i915_gem_do_execbuffer(struct drm_device *dev,
24262452
if (unlikely(err))
24272453
goto err_destroy;
24282454

2429-
/*
2430-
* Take a local wakeref for preparing to dispatch the execbuf as
2431-
* we expect to access the hardware fairly frequently in the
2432-
* process. Upon first dispatch, we acquire another prolonged
2433-
* wakeref that we hold until the GPU has been idle for at least
2434-
* 100ms.
2435-
*/
2436-
intel_gt_pm_get(&eb.i915->gt);
2437-
24382455
err = i915_mutex_lock_interruptible(dev);
24392456
if (err)
2440-
goto err_rpm;
2457+
goto err_context;
24412458

24422459
err = eb_select_engine(&eb, file, args);
24432460
if (unlikely(err))
@@ -2602,8 +2619,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
26022619
eb_unpin_context(&eb);
26032620
err_unlock:
26042621
mutex_unlock(&dev->struct_mutex);
2605-
err_rpm:
2606-
intel_gt_pm_put(&eb.i915->gt);
2622+
err_context:
26072623
i915_gem_context_put(eb.gem_context);
26082624
err_destroy:
26092625
eb_destroy(&eb);

0 commit comments

Comments
 (0)