Skip to content

Commit d845a20

Browse files
Jack Xiaoalexdeucher
authored andcommitted
drm/amdgpu: fix preemption unit test
Remove signaled jobs from job list and ensure the job was indeed preempted. Signed-off-by: Jack Xiao <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 7d65a57 commit d845a20

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,27 +1295,37 @@ static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched)
12951295
static void amdgpu_ib_preempt_mark_partial_job(struct amdgpu_ring *ring)
12961296
{
12971297
struct amdgpu_job *job;
1298-
struct drm_sched_job *s_job;
1298+
struct drm_sched_job *s_job, *tmp;
12991299
uint32_t preempt_seq;
13001300
struct dma_fence *fence, **ptr;
13011301
struct amdgpu_fence_driver *drv = &ring->fence_drv;
13021302
struct drm_gpu_scheduler *sched = &ring->sched;
1303+
bool preempted = true;
13031304

13041305
if (ring->funcs->type != AMDGPU_RING_TYPE_GFX)
13051306
return;
13061307

13071308
preempt_seq = le32_to_cpu(*(drv->cpu_addr + 2));
1308-
if (preempt_seq <= atomic_read(&drv->last_seq))
1309-
return;
1309+
if (preempt_seq <= atomic_read(&drv->last_seq)) {
1310+
preempted = false;
1311+
goto no_preempt;
1312+
}
13101313

13111314
preempt_seq &= drv->num_fences_mask;
13121315
ptr = &drv->fences[preempt_seq];
13131316
fence = rcu_dereference_protected(*ptr, 1);
13141317

1318+
no_preempt:
13151319
spin_lock(&sched->job_list_lock);
1316-
list_for_each_entry(s_job, &sched->ring_mirror_list, node) {
1320+
list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) {
1321+
if (dma_fence_is_signaled(&s_job->s_fence->finished)) {
1322+
/* remove job from ring_mirror_list */
1323+
list_del_init(&s_job->node);
1324+
sched->ops->free_job(s_job);
1325+
continue;
1326+
}
13171327
job = to_amdgpu_job(s_job);
1318-
if (job->fence == fence)
1328+
if (preempted && job->fence == fence)
13191329
/* mark the job as preempted */
13201330
job->preemption_status |= AMDGPU_IB_PREEMPTED;
13211331
}

0 commit comments

Comments
 (0)