public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation
@ 2014-08-05 13:09 Vignesh Raman
  2014-08-05 13:09 ` [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver Vignesh Raman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vignesh Raman @ 2014-08-05 13:09 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams, dmaengine, linux-kernel; +Cc: Jiada_Wang

This is a patch set which contains two patches which modify's sdma_remove 
operation and add tasklet_kill in sdma_remove function.

Vignesh Raman (2):
  dma: imx-sdma: use module_platform_driver for SDMA driver
  dma: imx-sdma: Adding tasklet_kill() in sdma_remove function.

 drivers/dma/imx-sdma.c |   31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver
  2014-08-05 13:09 [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vignesh Raman
@ 2014-08-05 13:09 ` Vignesh Raman
  2014-08-05 13:09 ` [PATCH v2 2/2] dma: imx-sdma: Adding tasklet_kill() in sdma_remove function Vignesh Raman
  2014-08-19 15:22 ` [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vignesh Raman @ 2014-08-05 13:09 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams, dmaengine, linux-kernel; +Cc: Jiada_Wang

Currently there is no module_exit declared in SDMA driver, so that once
sdma module is inserted, it's shown with permanent attribute by lsmod,
and it can't be removed.
Use module_platform_driver to register/unregister SDMA driver and modify
SDMA's remove operation, to make SDMA driver possible to be removed.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
---
 drivers/dma/imx-sdma.c |   24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 14867e3..5cefc7d 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1596,6 +1596,8 @@ static int __init sdma_probe(struct platform_device *pdev)
 	sdma->dma_device.dev->dma_parms = &sdma->dma_parms;
 	dma_set_max_seg_size(sdma->dma_device.dev, 65535);
 
+	platform_set_drvdata(pdev, sdma);
+
 	ret = dma_async_device_register(&sdma->dma_device);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to register\n");
@@ -1633,7 +1635,20 @@ err_irq:
 
 static int sdma_remove(struct platform_device *pdev)
 {
-	return -EBUSY;
+	struct sdma_engine *sdma = platform_get_drvdata(pdev);
+	struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	int irq = platform_get_irq(pdev, 0);
+
+	dma_async_device_unregister(&sdma->dma_device);
+	kfree(sdma->script_addrs);
+	free_irq(irq, sdma);
+	iounmap(sdma->regs);
+	release_mem_region(iores->start, resource_size(iores));
+	kfree(sdma);
+
+	platform_set_drvdata(pdev, NULL);
+	dev_info(&pdev->dev, "Removed...\n");
+	return 0;
 }
 
 static struct platform_driver sdma_driver = {
@@ -1643,13 +1658,10 @@ static struct platform_driver sdma_driver = {
 	},
 	.id_table	= sdma_devtypes,
 	.remove		= sdma_remove,
+	.probe		= sdma_probe,
 };
 
-static int __init sdma_module_init(void)
-{
-	return platform_driver_probe(&sdma_driver, sdma_probe);
-}
-module_init(sdma_module_init);
+module_platform_driver(sdma_driver);
 
 MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
 MODULE_DESCRIPTION("i.MX SDMA driver");
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] dma: imx-sdma: Adding tasklet_kill() in sdma_remove function.
  2014-08-05 13:09 [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vignesh Raman
  2014-08-05 13:09 ` [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver Vignesh Raman
@ 2014-08-05 13:09 ` Vignesh Raman
  2014-08-19 15:22 ` [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vignesh Raman @ 2014-08-05 13:09 UTC (permalink / raw)
  To: vinod.koul, dan.j.williams, dmaengine, linux-kernel; +Cc: Jiada_Wang

Several dma drivers calls tasklet_kill() in remove function. This is done
because all running tasklets should be killed on remove. This is missing
in imx sdma driver, so adding tasklet_kill() in sdma_remove function.

Signed-off-by: Vignesh Raman <Vignesh_Raman@mentor.com>
---
 drivers/dma/imx-sdma.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 5cefc7d..3961c72 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1638,12 +1638,19 @@ static int sdma_remove(struct platform_device *pdev)
 	struct sdma_engine *sdma = platform_get_drvdata(pdev);
 	struct resource *iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	int irq = platform_get_irq(pdev, 0);
+	int i;
 
 	dma_async_device_unregister(&sdma->dma_device);
 	kfree(sdma->script_addrs);
 	free_irq(irq, sdma);
 	iounmap(sdma->regs);
 	release_mem_region(iores->start, resource_size(iores));
+	/* Kill the tasklet */
+	for (i = 0; i < MAX_DMA_CHANNELS; i++) {
+		struct sdma_channel *sdmac = &sdma->channel[i];
+
+		tasklet_kill(&sdmac->tasklet);
+	}
 	kfree(sdma);
 
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation
  2014-08-05 13:09 [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vignesh Raman
  2014-08-05 13:09 ` [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver Vignesh Raman
  2014-08-05 13:09 ` [PATCH v2 2/2] dma: imx-sdma: Adding tasklet_kill() in sdma_remove function Vignesh Raman
@ 2014-08-19 15:22 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2014-08-19 15:22 UTC (permalink / raw)
  To: Vignesh Raman; +Cc: dan.j.williams, dmaengine, linux-kernel, Jiada_Wang

On Tue, Aug 05, 2014 at 06:39:40PM +0530, Vignesh Raman wrote:
> This is a patch set which contains two patches which modify's sdma_remove 
> operation and add tasklet_kill in sdma_remove function.
Applied, thanks

-- 
~Vinod


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-19 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-05 13:09 [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vignesh Raman
2014-08-05 13:09 ` [PATCH v2 1/2] dma: imx-sdma: use module_platform_driver for SDMA driver Vignesh Raman
2014-08-05 13:09 ` [PATCH v2 2/2] dma: imx-sdma: Adding tasklet_kill() in sdma_remove function Vignesh Raman
2014-08-19 15:22 ` [PATCH v2 0/2] dma: imx-sdma: Modify SDMA's remove operation Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox