lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aMRMWfwcAnkF7wwn@lizhi-Precision-Tower-5810>
Date: Fri, 12 Sep 2025 12:37:45 -0400
From: Frank Li <Frank.li@....com>
To: Marco Felsch <m.felsch@...gutronix.de>
Cc: Vinod Koul <vkoul@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	Pengutronix Kernel Team <kernel@...gutronix.de>,
	Fabio Estevam <festevam@...il.com>,
	Jiada Wang <jiada_wang@...tor.com>, dmaengine@...r.kernel.org,
	imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 08/10] dmaengine: imx-sdma: make use of
 devm_add_action_or_reset to unregiser the dma_device

On Fri, Sep 12, 2025 at 05:25:08PM +0200, Marco Felsch wrote:
> On 25-09-12, Frank Li wrote:
> > On Thu, Sep 11, 2025 at 11:56:49PM +0200, Marco Felsch wrote:
> > > Make use of the devm_add_action_or_reset() to register a custom devm_
> > > release hook. This is required to turn off the IRQs before calling
> > > dma_async_device_unregister().
> > >
> > > Furthermore it removes the last goto error handling within probe() and
> > > trims the remove().
> > >
> > > Make use of disable_irq() and let the devm-irq do the job to free the
> > > IRQ, because the only purpose of using devm_free_irq() was to disable
> > > the IRQ before calling dma_async_device_unregister().
> > >
> > > Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
> > > ---
> > >  drivers/dma/imx-sdma.c | 23 +++++++++++++++--------
> > >  1 file changed, 15 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> > > index d39589c20c4b2a26d0239feb86cce8d5a0f5acdd..d6d0d4300f540268a3ab4a6b14af685f7b93275a 100644
> > > --- a/drivers/dma/imx-sdma.c
> > > +++ b/drivers/dma/imx-sdma.c
> > > @@ -2264,6 +2264,14 @@ static struct dma_chan *sdma_xlate(struct of_phandle_args *dma_spec,
> > >  				     ofdma->of_node);
> > >  }
> > >
> > > +static void sdma_dma_device_unregister_action(void *data)
> > > +{
> > > +	struct sdma_engine *sdma = data;
> > > +
> > > +	disable_irq(sdma->irq);
> >
> > May not related this cleanup patch, I am just curious why not mask sdma irq
> > request.
>
> You mean by setting irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY)
> infront? Not sure if this is required since this is just the cleanup
> path.

It is not important for this patch.

>
> > > +	dma_async_device_unregister(&sdma->dma_device);
> > > +}
> > > +
> > >  static int sdma_probe(struct platform_device *pdev)
> > >  {
> > >  	struct device *dev = &pdev->dev;
> > > @@ -2388,10 +2396,16 @@ static int sdma_probe(struct platform_device *pdev)
> > >  		return ret;
> > >  	}
> > >
> > > +	ret = devm_add_action_or_reset(dev, sdma_dma_device_unregister_action, sdma);
> > > +	if (ret) {
> > > +		dev_err(dev, "Unable to register release hook\n");
> > > +		return ret;
> > > +	}
> >
> > why not use dev_err_probe() her?
>
> Please see my last patch.

You can direct use dev_err_probe() here, instead replace all in last one.

Frank

>
> Regards,
>   Marco
>
> >
> > > +
> > >  	ret = of_dma_controller_register(np, sdma_xlate, sdma);
> > >  	if (ret) {
> > >  		dev_err(dev, "failed to register controller\n");
> > > -		goto err_register;
> > > +		return ret;
> >
> > the same here.
> >
> > Frank
> > >  	}
> > >
> > >  	/*
> > > @@ -2410,11 +2424,6 @@ static int sdma_probe(struct platform_device *pdev)
> > >  	}
> > >
> > >  	return 0;
> > > -
> > > -err_register:
> > > -	dma_async_device_unregister(&sdma->dma_device);
> > > -
> > > -	return ret;
> > >  }
> > >
> > >  static void sdma_remove(struct platform_device *pdev)
> > > @@ -2423,8 +2432,6 @@ static void sdma_remove(struct platform_device *pdev)
> > >  	int i;
> > >
> > >  	of_dma_controller_free(sdma->dev->of_node);
> > > -	devm_free_irq(&pdev->dev, sdma->irq, sdma);
> > > -	dma_async_device_unregister(&sdma->dma_device);
> > >  	/* Kill the tasklet */
> > >  	for (i = 0; i < MAX_DMA_CHANNELS; i++) {
> > >  		struct sdma_channel *sdmac = &sdma->channel[i];
> > >
> > > --
> > > 2.47.3
> > >
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ