mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 06:24:53 +08:00
drm/i915: Skip switch to kernel context if already done
Some engines are never user or already sitting idle in the kernel context and for those we can skip flushing the current context for i915_gem_switch_to_kernel_context(). We used to perform this optimisation but that was removed for convenience of converting over to multiple timelines and handling the pending request queues. From the perspective of writing selftests, reducing the number of background operations on the engines makes defining assertions easier. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: http://patchwork.freedesktop.org/patch/msgid/20170114162334.10271-2-chris@chris-wilson.co.uk Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
This commit is contained in:
parent
6ffb7d0756
commit
f131e3562e
@ -4140,7 +4140,8 @@ static void assert_kernel_context_is_current(struct drm_i915_private *dev_priv)
|
||||
enum intel_engine_id id;
|
||||
|
||||
for_each_engine(engine, dev_priv, id)
|
||||
GEM_BUG_ON(!i915_gem_context_is_kernel(engine->last_retired_context));
|
||||
GEM_BUG_ON(engine->last_retired_context &&
|
||||
!i915_gem_context_is_kernel(engine->last_retired_context));
|
||||
}
|
||||
|
||||
int i915_gem_suspend(struct drm_i915_private *dev_priv)
|
||||
|
@ -877,6 +877,26 @@ int i915_switch_context(struct drm_i915_gem_request *req)
|
||||
return do_rcs_switch(req);
|
||||
}
|
||||
|
||||
static bool engine_has_kernel_context(struct intel_engine_cs *engine)
|
||||
{
|
||||
struct i915_gem_timeline *timeline;
|
||||
|
||||
list_for_each_entry(timeline, &engine->i915->gt.timelines, link) {
|
||||
struct intel_timeline *tl;
|
||||
|
||||
if (timeline == &engine->i915->gt.global_timeline)
|
||||
continue;
|
||||
|
||||
tl = &timeline->engine[engine->id];
|
||||
if (i915_gem_active_peek(&tl->last_request,
|
||||
&engine->i915->drm.struct_mutex))
|
||||
return false;
|
||||
}
|
||||
|
||||
return (!engine->last_retired_context ||
|
||||
i915_gem_context_is_kernel(engine->last_retired_context));
|
||||
}
|
||||
|
||||
int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv)
|
||||
{
|
||||
struct intel_engine_cs *engine;
|
||||
@ -885,10 +905,15 @@ int i915_gem_switch_to_kernel_context(struct drm_i915_private *dev_priv)
|
||||
|
||||
lockdep_assert_held(&dev_priv->drm.struct_mutex);
|
||||
|
||||
i915_gem_retire_requests(dev_priv);
|
||||
|
||||
for_each_engine(engine, dev_priv, id) {
|
||||
struct drm_i915_gem_request *req;
|
||||
int ret;
|
||||
|
||||
if (engine_has_kernel_context(engine))
|
||||
continue;
|
||||
|
||||
req = i915_gem_request_alloc(engine, dev_priv->kernel_context);
|
||||
if (IS_ERR(req))
|
||||
return PTR_ERR(req);
|
||||
|
Loading…
Reference in New Issue
Block a user