aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_timeline.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-01-28 18:18:12 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-01-28 19:07:13 +0000
commit9407d3bdb048d52fa0fd45fa624a6c9f00072169 (patch)
tree14d05921a34ff86736f22440ffef863d626974d9 /drivers/gpu/drm/i915/i915_timeline.c
parent5013eb8cd601c31e6d7d1b9d3291b24e933b77b2 (diff)
drm/i915: Track active timelines
Now that we pin timelines around use, we have a clearly defined lifetime and convenient points at which we can track only the active timelines. This allows us to reduce the list iteration to only consider those active timelines and not all. 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/20190128181812.22804-6-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_timeline.c')
-rw-r--r--drivers/gpu/drm/i915/i915_timeline.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/i915_timeline.c b/drivers/gpu/drm/i915/i915_timeline.c
index e4c11414a824..79838d89bdb9 100644
--- a/drivers/gpu/drm/i915/i915_timeline.c
+++ b/drivers/gpu/drm/i915/i915_timeline.c
@@ -120,7 +120,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
const char *name,
struct i915_vma *hwsp)
{
- struct i915_gt_timelines *gt = &i915->gt.timelines;
void *vaddr;
/*
@@ -168,10 +167,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
i915_syncmap_init(&timeline->sync);
- mutex_lock(&gt->mutex);
- list_add(&timeline->link, &gt->list);
- mutex_unlock(&gt->mutex);
-
return 0;
}
@@ -180,7 +175,7 @@ void i915_timelines_init(struct drm_i915_private *i915)
struct i915_gt_timelines *gt = &i915->gt.timelines;
mutex_init(&gt->mutex);
- INIT_LIST_HEAD(&gt->list);
+ INIT_LIST_HEAD(&gt->active_list);
spin_lock_init(&gt->hwsp_lock);
INIT_LIST_HEAD(&gt->hwsp_free_list);
@@ -189,6 +184,24 @@ void i915_timelines_init(struct drm_i915_private *i915)
i915_gem_shrinker_taints_mutex(i915, &gt->mutex);
}
+static void timeline_add_to_active(struct i915_timeline *tl)
+{
+ struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
+
+ mutex_lock(&gt->mutex);
+ list_add(&tl->link, &gt->active_list);
+ mutex_unlock(&gt->mutex);
+}
+
+static void timeline_remove_from_active(struct i915_timeline *tl)
+{
+ struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
+
+ mutex_lock(&gt->mutex);
+ list_del(&tl->link);
+ mutex_unlock(&gt->mutex);
+}
+
/**
* i915_timelines_park - called when the driver idles
* @i915: the drm_i915_private device
@@ -205,7 +218,7 @@ void i915_timelines_park(struct drm_i915_private *i915)
struct i915_timeline *timeline;
mutex_lock(&gt->mutex);
- list_for_each_entry(timeline, &gt->list, link) {
+ list_for_each_entry(timeline, &gt->active_list, link) {
/*
* All known fences are completed so we can scrap
* the current sync point tracking and start afresh,
@@ -219,15 +232,9 @@ void i915_timelines_park(struct drm_i915_private *i915)
void i915_timeline_fini(struct i915_timeline *timeline)
{
- struct i915_gt_timelines *gt = &timeline->i915->gt.timelines;
-
GEM_BUG_ON(timeline->pin_count);
GEM_BUG_ON(!list_empty(&timeline->requests));
- mutex_lock(&gt->mutex);
- list_del(&timeline->link);
- mutex_unlock(&gt->mutex);
-
i915_syncmap_free(&timeline->sync);
hwsp_free(timeline);
@@ -274,6 +281,8 @@ int i915_timeline_pin(struct i915_timeline *tl)
i915_ggtt_offset(tl->hwsp_ggtt) +
offset_in_page(tl->hwsp_offset);
+ timeline_add_to_active(tl);
+
return 0;
unpin:
@@ -287,6 +296,8 @@ void i915_timeline_unpin(struct i915_timeline *tl)
if (--tl->pin_count)
return;
+ timeline_remove_from_active(tl);
+
/*
* Since this timeline is idle, all bariers upon which we were waiting
* must also be complete and so we can discard the last used barriers
@@ -310,7 +321,7 @@ void i915_timelines_fini(struct drm_i915_private *i915)
{
struct i915_gt_timelines *gt = &i915->gt.timelines;
- GEM_BUG_ON(!list_empty(&gt->list));
+ GEM_BUG_ON(!list_empty(&gt->active_list));
GEM_BUG_ON(!list_empty(&gt->hwsp_free_list));
mutex_destroy(&gt->mutex);