On Thu, Aug 27, 2026 at 03:33:05PM -0500, Rob Herring (Arm) wrote:
> Once the job scheduler has been initialized, failures from ethosu_init()
> or drm_dev_register() return from probe without tearing it down. The
> registration failure also leaves the SRAM-pool allocation in use, because
> the platform remove callback is not called after a failed probe.
>
> Unwind the initialized resources on both paths. Also do not call
> drm_sched_fini() after a failed drm_sched_init(): the scheduler initializer
> already unwinds its partial setup, while drm_sched_fini() requires a
> successfully initialized scheduler.
>
> Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")
> Cc: [email protected]
> Assisted-by: LLM
> Signed-off-by: Rob Herring (Arm) <[email protected]>
> ---
>  drivers/accel/ethosu/ethosu_drv.c | 14 ++++++++++++--
>  drivers/accel/ethosu/ethosu_job.c |  6 +-----
>  2 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/accel/ethosu/ethosu_drv.c 
> b/drivers/accel/ethosu/ethosu_drv.c
> index f1af7b3ea038..41ecfc623d42 100644
> --- a/drivers/accel/ethosu/ethosu_drv.c
> +++ b/drivers/accel/ethosu/ethosu_drv.c
> @@ -371,13 +371,23 @@ static int ethosu_probe(struct platform_device *pdev)
>
>       ret = ethosu_init(ethosudev);
>       if (ret)
> -             return ret;
> +             goto err_job_fini;
>
>       ret = drm_dev_register(&ethosudev->base, 0);

Does this involve any hardware access by callbck? I suppose
pm_runtime_put_autosuspend() should be end of ethosu_init().

>       if (ret)
> -             pm_runtime_dont_use_autosuspend(ethosudev->base.dev);
> +             goto err_pm_runtime;
> +
> +     pm_runtime_put_autosuspend(ethosudev->base.dev);
> +     return 0;
>
> +err_pm_runtime:
> +     pm_runtime_dont_use_autosuspend(ethosudev->base.dev);

it should be call by pm_runtime_disable_action().

Frank
>       pm_runtime_put_autosuspend(ethosudev->base.dev);
> +     if (ethosudev->sram)
> +             gen_pool_free(ethosudev->srampool, (unsigned 
> long)ethosudev->sram,
> +                           ethosudev->npu_info.sram_size);
> +err_job_fini:
> +     ethosu_job_fini(ethosudev);
>       return ret;
>  }
>
> diff --git a/drivers/accel/ethosu/ethosu_job.c 
> b/drivers/accel/ethosu/ethosu_job.c
> index 0982722a9195..7cadd75ad0ba 100644
> --- a/drivers/accel/ethosu/ethosu_job.c
> +++ b/drivers/accel/ethosu/ethosu_job.c
> @@ -349,14 +349,10 @@ int ethosu_job_init(struct ethosu_device *edev)
>       ret = drm_sched_init(&edev->sched, &args);
>       if (ret) {
>               dev_err(dev, "Failed to create scheduler: %d\n", ret);
> -             goto err_sched;
> +             return ret;
>       }
>
>       return 0;
> -
> -err_sched:
> -     drm_sched_fini(&edev->sched);
> -     return ret;
>  }
>
>  void ethosu_job_fini(struct ethosu_device *dev)
>
> --
> 2.53.0
>

Reply via email to