Skip to content

Commit a46bfdc

Browse files
icklejlahtine-intel
authored andcommitted
drm/i915/gt: Wait for new requests in intel_gt_retire_requests()
Our callers fall into two categories, those passing timeout=0 who just want to flush request retirements and those passing a timeout that need to wait for submission completion (e.g. intel_gt_wait_for_idle()). Currently, we only wait for a snapshot of timelines at the start of the wait (but there was an expectation that new requests would cause timelines to appear at the end). However, our callers, such as intel_gt_wait_for_idle() before suspend, do require us to wait for the power management requests emitted by retirement as well. If we don't, then it takes an extra second or two for the background worker to flush the queue and mark the GT as idle. Fixes: 7e80576 ("drm/i915: Drop struct_mutex from around i915_retire_requests()") Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Reviewed-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 7936a22) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent 2a39b07 commit a46bfdc

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/gpu/drm/i915/gt/intel_gt_requests.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
3333
{
3434
struct intel_gt_timelines *timelines = &gt->timelines;
3535
struct intel_timeline *tl, *tn;
36-
unsigned long active_count = 0;
3736
unsigned long flags;
3837
bool interruptible;
3938
LIST_HEAD(free);
@@ -46,10 +45,8 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
4645

4746
spin_lock_irqsave(&timelines->lock, flags);
4847
list_for_each_entry_safe(tl, tn, &timelines->active_list, link) {
49-
if (!mutex_trylock(&tl->mutex)) {
50-
active_count++; /* report busy to caller, try again? */
48+
if (!mutex_trylock(&tl->mutex))
5149
continue;
52-
}
5350

5451
intel_timeline_get(tl);
5552
GEM_BUG_ON(!tl->active_count);
@@ -74,9 +71,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
7471

7572
/* Resume iteration after dropping lock */
7673
list_safe_reset_next(tl, tn, link);
77-
if (--tl->active_count)
78-
active_count += !!rcu_access_pointer(tl->last_request.fence);
79-
else
74+
if (!--tl->active_count)
8075
list_del(&tl->link);
8176

8277
mutex_unlock(&tl->mutex);
@@ -92,7 +87,7 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
9287
list_for_each_entry_safe(tl, tn, &free, link)
9388
__intel_timeline_free(&tl->kref);
9489

95-
return active_count ? timeout : 0;
90+
return list_empty(&timelines->active_list) ? 0 : timeout;
9691
}
9792

9893
int intel_gt_wait_for_idle(struct intel_gt *gt, long timeout)

0 commit comments

Comments
 (0)