If device removal occurs before an auto-suspend timeout occurs, the
suspend is cancelled and the device will be left with clocks running.
Make the remove() callback check this and force a suspend if the device
is currently active.

Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")
Reported-by: [email protected]
Assisted-by: LLM
Signed-off-by: Rob Herring (Arm) <[email protected]>
---
v3:
 - New patch
---
 drivers/accel/ethosu/ethosu_drv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/accel/ethosu/ethosu_drv.c 
b/drivers/accel/ethosu/ethosu_drv.c
index df76253d01a6..1f6fb5d18cf2 100644
--- a/drivers/accel/ethosu/ethosu_drv.c
+++ b/drivers/accel/ethosu/ethosu_drv.c
@@ -387,6 +387,10 @@ static void ethosu_remove(struct platform_device *pdev)
 
        drm_dev_unregister(&ethosudev->base);
        ethosu_job_fini(ethosudev);
+
+       if (pm_runtime_get_if_active(&pdev->dev))
+               pm_runtime_put_sync_suspend(&pdev->dev);
+
        if (ethosudev->sram)
                gen_pool_free(ethosudev->srampool, (unsigned 
long)ethosudev->sram,
                              ethosudev->npu_info.sram_size);

-- 
2.53.0

Reply via email to