ethosu_init() enables the clocks directly to reset and query the NPU
before runtime PM takes over. If runtime-PM setup fails, the error path
returns while those clocks remain enabled.

Disable the clocks before returning the setup error to balance the
initial direct resume.

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

diff --git a/drivers/accel/ethosu/ethosu_drv.c 
b/drivers/accel/ethosu/ethosu_drv.c
index 2c8d735767b2..9d063daa1aa7 100644
--- a/drivers/accel/ethosu/ethosu_drv.c
+++ b/drivers/accel/ethosu/ethosu_drv.c
@@ -311,8 +311,10 @@ static int ethosu_init(struct ethosu_device *ethosudev)
        pm_runtime_set_autosuspend_delay(ethosudev->base.dev, 50);
        pm_runtime_use_autosuspend(ethosudev->base.dev);
        ret = devm_pm_runtime_set_active_enabled(ethosudev->base.dev);
-       if (ret)
+       if (ret) {
+               ethosu_device_suspend(ethosudev->base.dev);
                return ret;
+       }
        pm_runtime_get_noresume(ethosudev->base.dev);
 
        ethosudev->npu_info.id = id = readl_relaxed(ethosudev->regs + 
NPU_REG_ID);

-- 
2.53.0

Reply via email to