drm_sched_stop() does not wait for a threaded IRQ handler that is already running, so call synchronize_irq() after it to make sure the handler has finished before the reset.
Before synchronize_irq(), mask the interrupt and clear the raw status, so that the NPU core cannot report a completion afterwards. Do this under job_lock, because the submit path sets the interrupt mask under the same lock. Only touch these registers when the device is powered: check with pm_runtime_get_if_active(), so that a register access with the power domain off cannot raise an SError. Suggested-by: Igor Paunovic <[email protected]> Signed-off-by: Jiaxing Hu <[email protected]> Tested-by: Igor Paunovic <[email protected]> # RK3588, three cores, induced reset, JOB_TIMEOUT_MS=2 --- drivers/accel/rocket/rocket_job.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c index b61bb4d242ce..8b4ad028bc9b 100644 --- a/drivers/accel/rocket/rocket_job.c +++ b/drivers/accel/rocket/rocket_job.c @@ -402,6 +402,16 @@ rocket_reset(struct rocket_core *core, struct drm_sched_job *bad) drm_sched_stop(&core->sched, bad); + scoped_guard(mutex, &core->job_lock) { + if (pm_runtime_get_if_active(core->dev) > 0) { + rocket_pc_writel(core, INTERRUPT_MASK, 0x0); + rocket_pc_writel(core, INTERRUPT_CLEAR, 0x1ffff); + pm_runtime_put_autosuspend(core->dev); + } + } + + synchronize_irq(core->irq); + /* * Remaining interrupts have been handled, but we might still have * stuck jobs. Let's make sure the PM counters stay balanced by -- 2.43.0
