Re: [PATCH v4 03/31] accel: ethosu: Fix probe error cleanup
From: Rob Herring
Date: Thu Oct 29 2026 - 12:01:38 EST
On Thu, Oct 29, 2026 at 11:52:14AM -0400, Frank Li wrote:
> On Thu, Oct 29, 2026 at 08:35:50AM -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: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
> > ---
> > v2:
> > - Adjust for previous patch reworking runtime-PM suspend
> > ---
> > drivers/accel/ethosu/ethosu_drv.c | 13 ++++++++++++-
> > drivers/accel/ethosu/ethosu_job.c | 6 +-----
> > 2 files changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/accel/ethosu/ethosu_drv.c b/drivers/accel/ethosu/ethosu_drv.c
> > index ae7ebf29cb2f..9ee144c41550 100644
> > --- a/drivers/accel/ethosu/ethosu_drv.c
> > +++ b/drivers/accel/ethosu/ethosu_drv.c
> > @@ -375,9 +375,20 @@ static int ethosu_probe(struct platform_device *pdev)
> >
> > ret = ethosu_init(ethosudev);
> > if (ret)
> > - return ret;
> > + goto err_job_fini;
> >
> > ret = drm_dev_register(ðosudev->base, 0);
> > + if (ret)
> > + goto err_sram_free;
> > +
> > + return 0;
> > +
> > +err_sram_free:
> > + if (ethosudev->sram)
> > + gen_pool_free(ethosudev->srampool, (unsigned long)ethosudev->sram,
> > + ethosudev->npu_info.sram_size);
>
> Does worth add devm_gen_pool_dma_alloc()?
We want this backported to stable, so I think we want it as-is and then
perhaps later add a helper.
Rob