linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Huang Shijie <sjhuang@iluvatar.ai>,
	Alexandre Bailon <abailon@baylibre.com>,
	Tony Lindgren <tony@atomide.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: Tue, 7 Aug 2018 10:01:47 +0300	[thread overview]
Message-ID: <0f35be3f-24c0-f7e4-66c8-e9b7e5c01590@ti.com> (raw)
In-Reply-To: <20180806032847.GA4452@hsj-Precision-5520>

Hi,

On 2018-08-06 06:28, Huang Shijie wrote:
> 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 :)

You are perfectly right.

It might be only me, but I like to keep the resource teardown in a
reverse order of their creation. If everything is devm then it is granted.

In case of cppi4 it looks safe after reading in to the DMAengine core,
module core and platform core code.

But does the removed three lines worth over the clarity of how the
module removal is proceeding?

Alexandre and Tony put lots of effort to the cppi4 driver, I let them
decide.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2018-08-07  7:02 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03  7:19 [PATCH 00/46] Use dmaenginem_async_device_register to simplify code Huang Shijie
2018-08-03  7:19 ` [PATCH 01/46] dmaengine: zx_dma: use dmaenginem_async_device_register to simplify the code Huang Shijie
2018-08-03  7:19 ` [PATCH 02/46] dmaengine: zynqmp_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 03/46] dmaengine: xilinx_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 04/46] dmaengine: xgene-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 05/46] dmaengine: txx9dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 06/46] dmaengine: timb_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 07/46] dmaengine: omap-dma: " Huang Shijie
2018-08-03  7:47   ` Peter Ujfalusi
2018-08-03  7:52     ` Huang Shijie
2018-08-09  2:36     ` Vinod
2018-08-03  7:19 ` [PATCH 08/46] dmaengine: edma: " Huang Shijie
2018-08-03  7:50   ` Peter Ujfalusi
2018-08-03  7:54     ` Huang Shijie
2018-08-03  7:19 ` [PATCH 09/46] dmaengine: cppi41: " Huang Shijie
2018-08-03  7:55   ` Peter Ujfalusi
2018-08-03  8:02     ` Huang Shijie
2018-08-06  3:28     ` Huang Shijie
2018-08-07  7:01       ` Peter Ujfalusi [this message]
2018-08-07  7:16         ` Huang Shijie
2018-08-08  7:16         ` Tony Lindgren
2018-08-03  7:19 ` [PATCH 10/46] dmaengine: tegra210-adma: use helper dmaenginem_async_device_register Huang Shijie
2018-08-03  7:19 ` [PATCH 11/46] dmaengine: tegra20-apb-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 12/46] dmaengine: sun6i-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 13/46] dmaengine: sun4i-dma: use dmaenginem_async_device_register to simplify the code Huang Shijie
2018-08-03  7:19 ` [PATCH 14/46] dmaengine: coh901318: " Huang Shijie
2018-08-03  7:19 ` [PATCH 15/46] dmaengine: s3c24xx-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 16/46] dmaengine: ste_dma40: " Huang Shijie
2018-08-03  7:19 ` [PATCH 17/46] dmaengine: stm32-mdma: " Huang Shijie
2018-08-03  8:10   ` Pierre Yves MORDRET
2018-08-03  7:19 ` [PATCH 18/46] dmaengine: stm32-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 19/46] dmaengine: sprd-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 20/46] dmaengine: sirf-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 21/46] dmaengine: bam_dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 22/46] dmaengine: sudmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 23/46] dmaengine: sa11x0-dma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 24/46] dmaengine: nbpfaxi: " Huang Shijie
2018-08-03  7:19 ` [PATCH 25/46] dmaengine: mmp_tdma: " Huang Shijie
2018-08-03  7:19 ` [PATCH 26/46] dmaengine: shdmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 27/46] dmaengine: usb-dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 28/46] dmaengine: rcar-dmac: " Huang Shijie
2018-08-03  7:19 ` [PATCH 29/46] dmaengine: hidma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 30/46] dmaengine: pxa_dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 31/46] dmaengine: moxart-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 32/46] dmaengine: pl330: " Huang Shijie
2018-08-03  7:20 ` [PATCH 33/46] dmaengine: pch_dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 34/46] dmaengine: mxs-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 35/46] dmaengine: mtk-hsdma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 36/46] dmaengine: k3dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 37/46] dmaengine: imx-sdma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 38/46] dmaengine: imx-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 39/46] dmaengine: img-mdc-dma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 40/46] dmaengine: fsl-edma: " Huang Shijie
2018-08-03  7:20 ` [PATCH 41/46] dmaengine: at_hdmac: " Huang Shijie
2018-08-03  7:20 ` [PATCH 42/46] dmaengine: at_xdmac: " Huang Shijie
2018-08-03  7:20 ` [PATCH 43/46] dmaengine: dma-jz4780: " Huang Shijie
2018-08-03  7:20 ` [PATCH 44/46] dmaengine: dma-jz4740: " Huang Shijie
2018-08-03  7:20 ` [PATCH 45/46] dmaengine: dma-axi-dmac: " Huang Shijie
2018-08-03  7:20 ` [PATCH 46/46] dmaengine: add COMPILE_TEST for the drivers Huang Shijie
2018-08-03  7:51 ` [PATCH 00/46] Use dmaenginem_async_device_register to simplify code 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=0f35be3f-24c0-f7e4-66c8-e9b7e5c01590@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=abailon@baylibre.com \
    --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=radhey.shyam.pandey@xilinx.com \
    --cc=shawnguo@kernel.org \
    --cc=sjhuang@iluvatar.ai \
    --cc=tony@atomide.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).