Skip to content

Commit 69674c1

Browse files
committed
accel/amdxdna: Move RPM resume into job run function
Currently, amdxdna_pm_resume_get() is called during job creation, and amdxdna_pm_suspend_put() is called when the hardware notifies job completion. If a job is canceled before it is run, no hardware completion notification is generated, resulting in an unbalanced runtime PM resume/suspend pair. Fix this by moving amdxdna_pm_resume_get() to the job run path, ensuring runtime PM is only resumed for jobs that are actually executed. Fixes: 063db45 ("accel/amdxdna: Enhance runtime power management") Reviewed-by: Mario Limonciello (AMD) <[email protected]> Signed-off-by: Lizhi Hou <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent d19d963 commit 69674c1

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
306306
kref_get(&job->refcnt);
307307
fence = dma_fence_get(job->fence);
308308

309+
ret = amdxdna_pm_resume_get(hwctx->client->xdna);
310+
if (ret)
311+
goto out;
312+
309313
if (job->drv_cmd) {
310314
switch (job->drv_cmd->opcode) {
311315
case SYNC_DEBUG_BO:
@@ -332,6 +336,7 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
332336

333337
out:
334338
if (ret) {
339+
amdxdna_pm_suspend_put(hwctx->client->xdna);
335340
dma_fence_put(job->fence);
336341
aie2_job_put(job);
337342
mmput(job->mm);
@@ -988,23 +993,19 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
988993
goto free_chain;
989994
}
990995

991-
ret = amdxdna_pm_resume_get(xdna);
992-
if (ret)
993-
goto cleanup_job;
994-
995996
retry:
996997
ret = drm_gem_lock_reservations(job->bos, job->bo_cnt, &acquire_ctx);
997998
if (ret) {
998999
XDNA_WARN(xdna, "Failed to lock BOs, ret %d", ret);
999-
goto suspend_put;
1000+
goto cleanup_job;
10001001
}
10011002

10021003
for (i = 0; i < job->bo_cnt; i++) {
10031004
ret = dma_resv_reserve_fences(job->bos[i]->resv, 1);
10041005
if (ret) {
10051006
XDNA_WARN(xdna, "Failed to reserve fences %d", ret);
10061007
drm_gem_unlock_reservations(job->bos, job->bo_cnt, &acquire_ctx);
1007-
goto suspend_put;
1008+
goto cleanup_job;
10081009
}
10091010
}
10101011

@@ -1019,12 +1020,12 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10191020
msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
10201021
} else if (time_after(jiffies, timeout)) {
10211022
ret = -ETIME;
1022-
goto suspend_put;
1023+
goto cleanup_job;
10231024
}
10241025

10251026
ret = aie2_populate_range(abo);
10261027
if (ret)
1027-
goto suspend_put;
1028+
goto cleanup_job;
10281029
goto retry;
10291030
}
10301031
}
@@ -1050,8 +1051,6 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10501051

10511052
return 0;
10521053

1053-
suspend_put:
1054-
amdxdna_pm_suspend_put(xdna);
10551054
cleanup_job:
10561055
drm_sched_job_cleanup(&job->base);
10571056
free_chain:

0 commit comments

Comments
 (0)