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]
Signed-off-by: Rob Herring (Arm) <[email protected]>
---
v4:
 - Use pm_runtime_barrier() and call ethosu_device_suspend() directly.
   This works in the case of !CONFIG_PM or power/control=on whereas
   pm_runtime_get_if_active() did not.

v3:
 - New patch
---
 drivers/accel/ethosu/ethosu_drv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/accel/ethosu/ethosu_drv.c 
b/drivers/accel/ethosu/ethosu_drv.c
index 38af57807cee..ae7ebf29cb2f 100644
--- a/drivers/accel/ethosu/ethosu_drv.c
+++ b/drivers/accel/ethosu/ethosu_drv.c
@@ -387,6 +387,11 @@ static void ethosu_remove(struct platform_device *pdev)
 
        drm_dev_unregister(&ethosudev->base);
        ethosu_job_fini(ethosudev);
+
+       pm_runtime_barrier(&pdev->dev);
+       if (!pm_runtime_status_suspended(&pdev->dev))
+               ethosu_device_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