All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Shijie <sjhuang@iluvatar.ai>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, dave.jiang@intel.com,
	radhey.shyam.pandey@xilinx.com, appana.durga.rao@xilinx.com,
	jmkrzyszt@gmail.com, gomonovych@gmail.com, keescook@chromium.org,
	horms+renesas@verge.net.au, geert+renesas@glider.be,
	shawnguo@kernel.org, baoyou.xie@linaro.org,
	michal.simek@xilinx.com, baohua@kernel.org,
	ludovic.desroches@microchip.com, linus.walleij@linaro.org,
	david.brown@linaro.org
Subject: [09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code
Date: Mon, 6 Aug 2018 11:28:47 +0800	[thread overview]
Message-ID: <20180806032847.GA4452@hsj-Precision-5520> (raw)

On Fri, Aug 03, 2018 at 10:55:25AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >    remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
> > ---
> >  drivers/dma/ti/cppi41.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
> > index 1497da367710..d2998a19ed2e 100644
> > --- a/drivers/dma/ti/cppi41.c
> > +++ b/drivers/dma/ti/cppi41.c
> > @@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device *pdev)
> >  		goto err_chans;
> >  	cdd->irq = irq;
> >  
> > -	ret = dma_async_device_register(&cdd->ddev);
> > +	ret = dmaenginem_async_device_register(&cdd->ddev);
> >  	if (ret)
> >  		goto err_chans;
> >  
> >  	ret = of_dma_controller_register(dev->of_node,
> >  			cppi41_dma_xlate, &cpp41_dma_info);
> >  	if (ret)
> > -		goto err_of;
> > +		goto err_chans;
> >  
> >  	pm_runtime_mark_last_busy(dev);
> >  	pm_runtime_put_autosuspend(dev);
> >  
> >  	return 0;
> > -err_of:
> > -	dma_async_device_unregister(&cdd->ddev);
> >  err_chans:
> >  	deinit_cppi41(dev, cdd);
> >  err_init_cppi:
> > @@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
> >  		dev_err(&pdev->dev, "%s could not pm_runtime_get: %i\n",
> >  			__func__, error);
> >  	of_dma_controller_free(pdev->dev.of_node);
> > -	dma_async_device_unregister(&cdd->ddev);
> 
> If I read the code right then this is not safe.
I read the code again, and find it is okay.

> We would have deinitalized cppi41 driver which is not functional, but we
> will still have the dma device registered and if a channel is requested
> we will have kernel crash.
We cannot succeed to request a channel when the drv->remove() is called.

Please see __device_release_driver:
  ---------------------------------------------------------------------
		if (dev->bus && dev->bus->remove)
			dev->bus->remove(dev);
		else if (drv->remove)
			drv->remove(dev);

		device_links_driver_cleanup(dev);
		dma_deconfigure(dev);

		devres_release_all(dev);    ============> Devres release
  ---------------------------------------------------------------------

For the DMA engine driver, there is only one case which will calls drv->remove():
        Use the rmmod(or modprobe -r).

We do not use the device_link_add API for DMA engines.
And we not manually call the device_release_driver() for DMA engines.

But when we use the rmmod, the module state will be MODULE_STATE_GOING.
In the find_candidate(), dma_chan_get() will fail.
And we cannot get a channel.

Please correct me if I am wrong :)

Thanks
Huang Shijie
---
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Huang Shijie <sjhuang@iluvatar.ai>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: vkoul@kernel.org, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org, dave.jiang@intel.com,
	radhey.shyam.pandey@xilinx.com, appana.durga.rao@xilinx.com,
	jmkrzyszt@gmail.com, gomonovych@gmail.com, keescook@chromium.org,
	horms+renesas@verge.net.au, geert+renesas@glider.be,
	shawnguo@kernel.org, baoyou.xie@linaro.org,
	michal.simek@xilinx.com, baohua@kernel.org,
	ludovic.desroches@microchip.com, linus.walleij@linaro.org,
	david.brown@linaro.org
Subject: Re: [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code
Date: Mon, 6 Aug 2018 11:28:47 +0800	[thread overview]
Message-ID: <20180806032847.GA4452@hsj-Precision-5520> (raw)
In-Reply-To: <43458794-d124-13df-c944-e473dc8ee1c2@ti.com>

On Fri, Aug 03, 2018 at 10:55:25AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2018-08-03 10:19, Huang Shijie wrote:
> > Use dmaenginem_async_device_register to simplify the code:
> >    remove dma_async_device_unregister
> > 
> > Signed-off-by: Huang Shijie <sjhuang@iluvatar.ai>
> > ---
> >  drivers/dma/ti/cppi41.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/cppi41.c b/drivers/dma/ti/cppi41.c
> > index 1497da367710..d2998a19ed2e 100644
> > --- a/drivers/dma/ti/cppi41.c
> > +++ b/drivers/dma/ti/cppi41.c
> > @@ -1096,21 +1096,19 @@ static int cppi41_dma_probe(struct platform_device *pdev)
> >  		goto err_chans;
> >  	cdd->irq = irq;
> >  
> > -	ret = dma_async_device_register(&cdd->ddev);
> > +	ret = dmaenginem_async_device_register(&cdd->ddev);
> >  	if (ret)
> >  		goto err_chans;
> >  
> >  	ret = of_dma_controller_register(dev->of_node,
> >  			cppi41_dma_xlate, &cpp41_dma_info);
> >  	if (ret)
> > -		goto err_of;
> > +		goto err_chans;
> >  
> >  	pm_runtime_mark_last_busy(dev);
> >  	pm_runtime_put_autosuspend(dev);
> >  
> >  	return 0;
> > -err_of:
> > -	dma_async_device_unregister(&cdd->ddev);
> >  err_chans:
> >  	deinit_cppi41(dev, cdd);
> >  err_init_cppi:
> > @@ -1132,7 +1130,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
> >  		dev_err(&pdev->dev, "%s could not pm_runtime_get: %i\n",
> >  			__func__, error);
> >  	of_dma_controller_free(pdev->dev.of_node);
> > -	dma_async_device_unregister(&cdd->ddev);
> 
> If I read the code right then this is not safe.
I read the code again, and find it is okay.

> We would have deinitalized cppi41 driver which is not functional, but we
> will still have the dma device registered and if a channel is requested
> we will have kernel crash.
We cannot succeed to request a channel when the drv->remove() is called.

Please see __device_release_driver:
  ---------------------------------------------------------------------
		if (dev->bus && dev->bus->remove)
			dev->bus->remove(dev);
		else if (drv->remove)
			drv->remove(dev);

		device_links_driver_cleanup(dev);
		dma_deconfigure(dev);

		devres_release_all(dev);    ============> Devres release
  ---------------------------------------------------------------------

For the DMA engine driver, there is only one case which will calls drv->remove():
        Use the rmmod(or modprobe -r).

We do not use the device_link_add API for DMA engines.
And we not manually call the device_release_driver() for DMA engines.

But when we use the rmmod, the module state will be MODULE_STATE_GOING.
In the find_candidate(), dma_chan_get() will fail.
And we cannot get a channel.

Please correct me if I am wrong :)

Thanks
Huang Shijie

             reply	other threads:[~2018-08-06  3:28 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06  3:28 Huang Shijie [this message]
2018-08-06  3:28 ` [PATCH 09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code Huang Shijie
  -- strict thread matches above, loose matches on Subject: below --
2018-08-09  2:36 [07/46] dmaengine: omap-dma: " Vinod Koul
2018-08-09  2:36 ` [PATCH 07/46] " Vinod
2018-08-08  7:16 [09/46] dmaengine: cppi41: " Tony Lindgren
2018-08-08  7:16 ` [PATCH 09/46] " Tony Lindgren
2018-08-07  7:16 [09/46] " Huang Shijie
2018-08-07  7:16 ` [PATCH 09/46] " Huang Shijie
2018-08-07  7:01 [09/46] " Peter Ujfalusi
2018-08-07  7:01 ` [PATCH 09/46] " Peter Ujfalusi
2018-08-03  8:10 [17/46] dmaengine: stm32-mdma: " Pierre Yves MORDRET
2018-08-03  8:10 ` [PATCH 17/46] " Pierre Yves MORDRET
2018-08-03  8:02 [09/46] dmaengine: cppi41: " Huang Shijie
2018-08-03  8:02 ` [PATCH 09/46] " Huang Shijie
2018-08-03  7:55 [09/46] " Peter Ujfalusi
2018-08-03  7:55 ` [PATCH 09/46] " Peter Ujfalusi
2018-08-03  7:54 [08/46] dmaengine: edma: " Huang Shijie
2018-08-03  7:54 ` [PATCH 08/46] " Huang Shijie
2018-08-03  7:52 [07/46] dmaengine: omap-dma: " Huang Shijie
2018-08-03  7:52 ` [PATCH 07/46] " Huang Shijie
2018-08-03  7:50 [08/46] dmaengine: edma: " Peter Ujfalusi
2018-08-03  7:50 ` [PATCH 08/46] " Peter Ujfalusi
2018-08-03  7:47 [07/46] dmaengine: omap-dma: " Peter Ujfalusi
2018-08-03  7:47 ` [PATCH 07/46] " Peter Ujfalusi
2018-08-03  7:20 [46/46] dmaengine: add COMPILE_TEST for the drivers Huang Shijie
2018-08-03  7:20 ` [PATCH 46/46] " Huang Shijie
2018-08-03  7:20 [45/46] dmaengine: dma-axi-dmac: use dmaenginem_async_device_register to simplify the code Huang Shijie
2018-08-03  7:20 ` [PATCH 45/46] " Huang Shijie
2018-08-03  7:20 [44/46] dmaengine: dma-jz4740: " Huang Shijie
2018-08-03  7:20 ` [PATCH 44/46] " Huang Shijie
2018-08-03  7:20 [43/46] dmaengine: dma-jz4780: " Huang Shijie
2018-08-03  7:20 ` [PATCH 43/46] " Huang Shijie
2018-08-03  7:20 [42/46] dmaengine: at_xdmac: " Huang Shijie
2018-08-03  7:20 ` [PATCH 42/46] " Huang Shijie
2018-08-03  7:20 [41/46] dmaengine: at_hdmac: " Huang Shijie
2018-08-03  7:20 ` [PATCH 41/46] " Huang Shijie
2018-08-03  7:20 [40/46] dmaengine: fsl-edma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 40/46] " Huang Shijie
2018-08-03  7:20 [39/46] dmaengine: img-mdc-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 39/46] " Huang Shijie
2018-08-03  7:20 [38/46] dmaengine: imx-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 38/46] " Huang Shijie
2018-08-03  7:20 [37/46] dmaengine: imx-sdma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 37/46] " Huang Shijie
2018-08-03  7:20 [36/46] dmaengine: k3dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 36/46] " Huang Shijie
2018-08-03  7:20 [35/46] dmaengine: mtk-hsdma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 35/46] " Huang Shijie
2018-08-03  7:20 [34/46] dmaengine: mxs-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 34/46] " Huang Shijie
2018-08-03  7:20 [33/46] dmaengine: pch_dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 33/46] " Huang Shijie
2018-08-03  7:20 [32/46] dmaengine: pl330: " Huang Shijie
2018-08-03  7:20 ` [PATCH 32/46] " Huang Shijie
2018-08-03  7:20 [31/46] dmaengine: moxart-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 31/46] " Huang Shijie
2018-08-03  7:20 [30/46] dmaengine: pxa_dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 30/46] " Huang Shijie
2018-08-03  7:19 [29/46] dmaengine: hidma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 29/46] " Huang Shijie
2018-08-03  7:19 [28/46] dmaengine: rcar-dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 28/46] " Huang Shijie
2018-08-03  7:19 [27/46] dmaengine: usb-dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 27/46] " Huang Shijie
2018-08-03  7:19 [26/46] dmaengine: shdmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 26/46] " Huang Shijie
2018-08-03  7:19 [25/46] dmaengine: mmp_tdma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 25/46] " Huang Shijie
2018-08-03  7:19 [24/46] dmaengine: nbpfaxi: " Huang Shijie
2018-08-03  7:19 ` [PATCH 24/46] " Huang Shijie
2018-08-03  7:19 [23/46] dmaengine: sa11x0-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 23/46] " Huang Shijie
2018-08-03  7:19 [22/46] dmaengine: sudmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 22/46] " Huang Shijie
2018-08-03  7:19 [21/46] dmaengine: bam_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 21/46] " Huang Shijie
2018-08-03  7:19 [20/46] dmaengine: sirf-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 20/46] " Huang Shijie
2018-08-03  7:19 [19/46] dmaengine: sprd-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 19/46] " Huang Shijie
2018-08-03  7:19 [18/46] dmaengine: stm32-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 18/46] " Huang Shijie
2018-08-03  7:19 [17/46] dmaengine: stm32-mdma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 17/46] " Huang Shijie
2018-08-03  7:19 [16/46] dmaengine: ste_dma40: " Huang Shijie
2018-08-03  7:19 ` [PATCH 16/46] " Huang Shijie
2018-08-03  7:19 [15/46] dmaengine: s3c24xx-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 15/46] " Huang Shijie
2018-08-03  7:19 [14/46] dmaengine: coh901318: " Huang Shijie
2018-08-03  7:19 ` [PATCH 14/46] " Huang Shijie
2018-08-03  7:19 [13/46] dmaengine: sun4i-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 13/46] " Huang Shijie
2018-08-03  7:19 [12/46] dmaengine: sun6i-dma: use helper dmaenginem_async_device_register Huang Shijie
2018-08-03  7:19 ` [PATCH 12/46] " Huang Shijie
2018-08-03  7:19 [11/46] dmaengine: tegra20-apb-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 11/46] " Huang Shijie
2018-08-03  7:19 [10/46] dmaengine: tegra210-adma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 10/46] " Huang Shijie
2018-08-03  7:19 [09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code Huang Shijie
2018-08-03  7:19 ` [PATCH 09/46] " Huang Shijie
2018-08-03  7:19 [08/46] dmaengine: edma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 08/46] " Huang Shijie
2018-08-03  7:19 [07/46] dmaengine: omap-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 07/46] " Huang Shijie
2018-08-03  7:19 [06/46] dmaengine: timb_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 06/46] " Huang Shijie
2018-08-03  7:19 [05/46] dmaengine: txx9dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 05/46] " Huang Shijie
2018-08-03  7:19 [04/46] dmaengine: xgene-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 04/46] " Huang Shijie
2018-08-03  7:19 [03/46] dmaengine: xilinx_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 03/46] " Huang Shijie
2018-08-03  7:19 [02/46] dmaengine: zynqmp_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 02/46] " Huang Shijie
2018-08-03  7:19 [01/46] dmaengine: zx_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 01/46] " Huang Shijie
2018-08-03  7:19 [PATCH 00/46] Use dmaenginem_async_device_register to simplify code Huang Shijie
2018-08-03  7:51 ` Lars-Peter Clausen
2018-08-03  7:59   ` Huang Shijie
2018-08-03  8:20 ` Peter Ujfalusi
2018-08-03  8:48   ` Huang Shijie
2018-08-05  1:03   ` Huang Shijie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180806032847.GA4452@hsj-Precision-5520 \
    --to=sjhuang@iluvatar.ai \
    --cc=appana.durga.rao@xilinx.com \
    --cc=baohua@kernel.org \
    --cc=baoyou.xie@linaro.org \
    --cc=dave.jiang@intel.com \
    --cc=david.brown@linaro.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gomonovych@gmail.com \
    --cc=horms+renesas@verge.net.au \
    --cc=jmkrzyszt@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=michal.simek@xilinx.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=radhey.shyam.pandey@xilinx.com \
    --cc=shawnguo@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.