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
next reply other threads:[~2018-08-06 3:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-06 3:28 Huang Shijie [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-08-08 7:16 [09/46] dmaengine: cppi41: use dmaenginem_async_device_register to simplify the code Tony Lindgren
2018-08-07 7:16 Huang Shijie
2018-08-07 7:01 Peter Ujfalusi
2018-08-03 8:02 Huang Shijie
2018-08-03 7:55 Peter Ujfalusi
2018-08-03 7:19 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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox