Skip to content

Commit 169c0aa

Browse files
icklejnikula
authored andcommitted
drm/i915/gt: Drop the timeline->mutex as we wait for retirement
As we have pinned the timeline (using tl->active_count), we can safely drop the tl->mutex as we wait for what we believe to be the final request on that timeline. This is useful for ensuring that we do not block the engine heartbeat by hogging the kernel_context's timeline on a dead GPU. References: https://gitlab.freedesktop.org/drm/intel/issues/1364 Fixes: 058179e ("drm/i915/gt: Replace hangcheck by heartbeats") Fixes: f33a8a5 ("drm/i915: Merge wait_for_timelines with retire_request") Signed-off-by: Chris Wilson <[email protected]> Cc: Mika Kuoppala <[email protected]> Reviewed-by: Mika Kuoppala <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 82126e5) Signed-off-by: Jani Nikula <[email protected]>
1 parent 08f56f8 commit 169c0aa

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,32 @@ long intel_gt_retire_requests_timeout(struct intel_gt *gt, long timeout)
147147

148148
fence = i915_active_fence_get(&tl->last_request);
149149
if (fence) {
150+
mutex_unlock(&tl->mutex);
151+
150152
timeout = dma_fence_wait_timeout(fence,
151153
interruptible,
152154
timeout);
153155
dma_fence_put(fence);
156+
157+
/* Retirement is best effort */
158+
if (!mutex_trylock(&tl->mutex)) {
159+
active_count++;
160+
goto out_active;
161+
}
154162
}
155163
}
156164

157165
if (!retire_requests(tl) || flush_submission(gt))
158166
active_count++;
167+
mutex_unlock(&tl->mutex);
159168

160-
spin_lock(&timelines->lock);
169+
out_active: spin_lock(&timelines->lock);
161170

162-
/* Resume iteration after dropping lock */
171+
/* Resume list iteration after reacquiring spinlock */
163172
list_safe_reset_next(tl, tn, link);
164173
if (atomic_dec_and_test(&tl->active_count))
165174
list_del(&tl->link);
166175

167-
mutex_unlock(&tl->mutex);
168176

169177
/* Defer the final release to after the spinlock */
170178
if (refcount_dec_and_test(&tl->kref.refcount)) {

0 commit comments

Comments
 (0)