mirror of https://gitee.com/openkylin/linux.git
drm/i915: Create distinct lockclasses for execution vs user timelines
In order to simplify the lockdep annotation, as they become more complex in the future with deferred execution and multiple paths through the same functions, create a separate lockclass for the user timeline and the hardware execution timeline. We should only ever be locking the user timeline and the execution timeline in parallel so we only need to create two lock classes, rather than a separate class for every timeline. v2: Rename the lock classes to be more consistent with other lockdep. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/20161114204105.29171-2-chris@chris-wilson.co.uk
This commit is contained in:
parent
556b748710
commit
bb89485e99
|
@ -4432,9 +4432,7 @@ i915_gem_load_init(struct drm_device *dev)
|
||||||
|
|
||||||
mutex_lock(&dev_priv->drm.struct_mutex);
|
mutex_lock(&dev_priv->drm.struct_mutex);
|
||||||
INIT_LIST_HEAD(&dev_priv->gt.timelines);
|
INIT_LIST_HEAD(&dev_priv->gt.timelines);
|
||||||
err = i915_gem_timeline_init(dev_priv,
|
err = i915_gem_timeline_init__global(dev_priv);
|
||||||
&dev_priv->gt.global_timeline,
|
|
||||||
"[execution]");
|
|
||||||
mutex_unlock(&dev_priv->drm.struct_mutex);
|
mutex_unlock(&dev_priv->drm.struct_mutex);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_requests;
|
goto err_requests;
|
||||||
|
|
|
@ -346,7 +346,7 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
|
||||||
request->ring->vaddr + request->postfix);
|
request->ring->vaddr + request->postfix);
|
||||||
engine->submit_request(request);
|
engine->submit_request(request);
|
||||||
|
|
||||||
spin_lock_nested(&request->timeline->lock, SINGLE_DEPTH_NESTING);
|
spin_lock(&request->timeline->lock);
|
||||||
list_move_tail(&request->link, &timeline->requests);
|
list_move_tail(&request->link, &timeline->requests);
|
||||||
spin_unlock(&request->timeline->lock);
|
spin_unlock(&request->timeline->lock);
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,11 @@
|
||||||
|
|
||||||
#include "i915_drv.h"
|
#include "i915_drv.h"
|
||||||
|
|
||||||
int i915_gem_timeline_init(struct drm_i915_private *i915,
|
static int __i915_gem_timeline_init(struct drm_i915_private *i915,
|
||||||
struct i915_gem_timeline *timeline,
|
struct i915_gem_timeline *timeline,
|
||||||
const char *name)
|
const char *name,
|
||||||
|
struct lock_class_key *lockclass,
|
||||||
|
const char *lockname)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
u64 fences;
|
u64 fences;
|
||||||
|
@ -47,8 +49,11 @@ int i915_gem_timeline_init(struct drm_i915_private *i915,
|
||||||
|
|
||||||
tl->fence_context = fences++;
|
tl->fence_context = fences++;
|
||||||
tl->common = timeline;
|
tl->common = timeline;
|
||||||
|
#ifdef CONFIG_DEBUG_SPINLOCK
|
||||||
|
__raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass);
|
||||||
|
#else
|
||||||
spin_lock_init(&tl->lock);
|
spin_lock_init(&tl->lock);
|
||||||
|
#endif
|
||||||
init_request_active(&tl->last_request, NULL);
|
init_request_active(&tl->last_request, NULL);
|
||||||
INIT_LIST_HEAD(&tl->requests);
|
INIT_LIST_HEAD(&tl->requests);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +61,26 @@ int i915_gem_timeline_init(struct drm_i915_private *i915,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int i915_gem_timeline_init(struct drm_i915_private *i915,
|
||||||
|
struct i915_gem_timeline *timeline,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
static struct lock_class_key class;
|
||||||
|
|
||||||
|
return __i915_gem_timeline_init(i915, timeline, name,
|
||||||
|
&class, "&timeline->lock");
|
||||||
|
}
|
||||||
|
|
||||||
|
int i915_gem_timeline_init__global(struct drm_i915_private *i915)
|
||||||
|
{
|
||||||
|
static struct lock_class_key class;
|
||||||
|
|
||||||
|
return __i915_gem_timeline_init(i915,
|
||||||
|
&i915->gt.global_timeline,
|
||||||
|
"[execution]",
|
||||||
|
&class, "&global_timeline->lock");
|
||||||
|
}
|
||||||
|
|
||||||
void i915_gem_timeline_fini(struct i915_gem_timeline *tl)
|
void i915_gem_timeline_fini(struct i915_gem_timeline *tl)
|
||||||
{
|
{
|
||||||
lockdep_assert_held(&tl->i915->drm.struct_mutex);
|
lockdep_assert_held(&tl->i915->drm.struct_mutex);
|
||||||
|
|
|
@ -67,6 +67,7 @@ struct i915_gem_timeline {
|
||||||
int i915_gem_timeline_init(struct drm_i915_private *i915,
|
int i915_gem_timeline_init(struct drm_i915_private *i915,
|
||||||
struct i915_gem_timeline *tl,
|
struct i915_gem_timeline *tl,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
int i915_gem_timeline_init__global(struct drm_i915_private *i915);
|
||||||
void i915_gem_timeline_fini(struct i915_gem_timeline *tl);
|
void i915_gem_timeline_fini(struct i915_gem_timeline *tl);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue