Skip to content

Commit 9407d3b

Browse files
committed
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
1 parent 5013eb8 commit 9407d3b

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ struct drm_i915_private {
19771977

19781978
struct i915_gt_timelines {
19791979
struct mutex mutex; /* protects list, tainted by GPU */
1980-
struct list_head list;
1980+
struct list_head active_list;
19811981

19821982
/* Pack multiple timelines' seqnos into the same page */
19831983
spinlock_t hwsp_lock;

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3246,7 +3246,7 @@ wait_for_timelines(struct drm_i915_private *i915,
32463246
return timeout;
32473247

32483248
mutex_lock(&gt->mutex);
3249-
list_for_each_entry(tl, &gt->list, link) {
3249+
list_for_each_entry(tl, &gt->active_list, link) {
32503250
struct i915_request *rq;
32513251

32523252
rq = i915_gem_active_get_unlocked(&tl->last_request);
@@ -3274,7 +3274,7 @@ wait_for_timelines(struct drm_i915_private *i915,
32743274

32753275
/* restart after reacquiring the lock */
32763276
mutex_lock(&gt->mutex);
3277-
tl = list_entry(&gt->list, typeof(*tl), link);
3277+
tl = list_entry(&gt->active_list, typeof(*tl), link);
32783278
}
32793279
mutex_unlock(&gt->mutex);
32803280

drivers/gpu/drm/i915/i915_reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ bool i915_gem_unset_wedged(struct drm_i915_private *i915)
856856
* No more can be submitted until we reset the wedged bit.
857857
*/
858858
mutex_lock(&i915->gt.timelines.mutex);
859-
list_for_each_entry(tl, &i915->gt.timelines.list, link) {
859+
list_for_each_entry(tl, &i915->gt.timelines.active_list, link) {
860860
struct i915_request *rq;
861861
long timeout;
862862

drivers/gpu/drm/i915/i915_timeline.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
120120
const char *name,
121121
struct i915_vma *hwsp)
122122
{
123-
struct i915_gt_timelines *gt = &i915->gt.timelines;
124123
void *vaddr;
125124

126125
/*
@@ -168,10 +167,6 @@ int i915_timeline_init(struct drm_i915_private *i915,
168167

169168
i915_syncmap_init(&timeline->sync);
170169

171-
mutex_lock(&gt->mutex);
172-
list_add(&timeline->link, &gt->list);
173-
mutex_unlock(&gt->mutex);
174-
175170
return 0;
176171
}
177172

@@ -180,7 +175,7 @@ void i915_timelines_init(struct drm_i915_private *i915)
180175
struct i915_gt_timelines *gt = &i915->gt.timelines;
181176

182177
mutex_init(&gt->mutex);
183-
INIT_LIST_HEAD(&gt->list);
178+
INIT_LIST_HEAD(&gt->active_list);
184179

185180
spin_lock_init(&gt->hwsp_lock);
186181
INIT_LIST_HEAD(&gt->hwsp_free_list);
@@ -189,6 +184,24 @@ void i915_timelines_init(struct drm_i915_private *i915)
189184
i915_gem_shrinker_taints_mutex(i915, &gt->mutex);
190185
}
191186

187+
static void timeline_add_to_active(struct i915_timeline *tl)
188+
{
189+
struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
190+
191+
mutex_lock(&gt->mutex);
192+
list_add(&tl->link, &gt->active_list);
193+
mutex_unlock(&gt->mutex);
194+
}
195+
196+
static void timeline_remove_from_active(struct i915_timeline *tl)
197+
{
198+
struct i915_gt_timelines *gt = &tl->i915->gt.timelines;
199+
200+
mutex_lock(&gt->mutex);
201+
list_del(&tl->link);
202+
mutex_unlock(&gt->mutex);
203+
}
204+
192205
/**
193206
* i915_timelines_park - called when the driver idles
194207
* @i915: the drm_i915_private device
@@ -205,7 +218,7 @@ void i915_timelines_park(struct drm_i915_private *i915)
205218
struct i915_timeline *timeline;
206219

207220
mutex_lock(&gt->mutex);
208-
list_for_each_entry(timeline, &gt->list, link) {
221+
list_for_each_entry(timeline, &gt->active_list, link) {
209222
/*
210223
* All known fences are completed so we can scrap
211224
* the current sync point tracking and start afresh,
@@ -219,15 +232,9 @@ void i915_timelines_park(struct drm_i915_private *i915)
219232

220233
void i915_timeline_fini(struct i915_timeline *timeline)
221234
{
222-
struct i915_gt_timelines *gt = &timeline->i915->gt.timelines;
223-
224235
GEM_BUG_ON(timeline->pin_count);
225236
GEM_BUG_ON(!list_empty(&timeline->requests));
226237

227-
mutex_lock(&gt->mutex);
228-
list_del(&timeline->link);
229-
mutex_unlock(&gt->mutex);
230-
231238
i915_syncmap_free(&timeline->sync);
232239
hwsp_free(timeline);
233240

@@ -274,6 +281,8 @@ int i915_timeline_pin(struct i915_timeline *tl)
274281
i915_ggtt_offset(tl->hwsp_ggtt) +
275282
offset_in_page(tl->hwsp_offset);
276283

284+
timeline_add_to_active(tl);
285+
277286
return 0;
278287

279288
unpin:
@@ -287,6 +296,8 @@ void i915_timeline_unpin(struct i915_timeline *tl)
287296
if (--tl->pin_count)
288297
return;
289298

299+
timeline_remove_from_active(tl);
300+
290301
/*
291302
* Since this timeline is idle, all bariers upon which we were waiting
292303
* 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)
310321
{
311322
struct i915_gt_timelines *gt = &i915->gt.timelines;
312323

313-
GEM_BUG_ON(!list_empty(&gt->list));
324+
GEM_BUG_ON(!list_empty(&gt->active_list));
314325
GEM_BUG_ON(!list_empty(&gt->hwsp_free_list));
315326

316327
mutex_destroy(&gt->mutex);

0 commit comments

Comments
 (0)