Skip to contentSkip to conversation

dmaengine: mv_xor_v2: fixes and alignment for XOR-v2 driver

PATCH In review [email protected] 2 participants 8 messages Jul 17, 2018 – Jul 20, 2018 dmaengine

lore
Share & tools
lore
#1 lore raw

PATCH 1/5 dmaengine: mv_xor_v2: explicitly freeup irq

In reply to [email protected]

From: Hanna Hawa <[email protected]>

dmaengine device should explicitly call devm_free_irq() when using devm_request_irq().

The irq is still ON when devices remove is executed and irq should be quiesced before remove is completed.

---
 drivers/dma/mv_xor_v2.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/dma/mv_xor_v2.c +4 -0
index c6589cc..e16083a 100644
@@ -174,6 +174,7 @@ struct mv_xor_v2_device {
 	int desc_size;
 	unsigned int npendings;
 	unsigned int hw_queue_idx;
+	struct msi_desc *msi_desc;
 };
 
 /**
@@ -780,6 +781,7 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
 	msi_desc = first_msi_entry(&pdev->dev);
 	if (!msi_desc)
 		goto free_msi_irqs;
+	xor_dev->msi_desc = msi_desc;
 
 	ret = devm_request_irq(&pdev->dev, msi_desc->irq,
 			       mv_xor_v2_interrupt_handler, 0,
@@ -897,6 +899,8 @@ static int mv_xor_v2_remove(struct platform_device *pdev)
 			  xor_dev->desc_size * MV_XOR_V2_DESC_NUM,
 			  xor_dev->hw_desq_virt, xor_dev->hw_desq);
 
+	devm_free_irq(&pdev->dev, xor_dev->msi_desc->irq, xor_dev);
+
 	platform_msi_domain_free_irqs(&pdev->dev);
 
 	clk_disable_unprepare(xor_dev->clk);
#2 lore raw

PATCH 2/5 dmaengine: mv_xor_v2: kill the tasklets upon exit

In reply to [email protected]

From: Hanna Hawa <[email protected]>

The mv_xor_v2 driver uses a tasklet, initialized during the probe() routine. However, it forgets to cleanup the tasklet using tasklet_kill() function during the remove() routine, which this patch fixes. This prevents the tasklet from potentially running after the module has been removed.

Fixes 19a340b1a820 ("dmaengine: mv_xor_v2: new driver")
---
 drivers/dma/mv_xor_v2.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/mv_xor_v2.c +2 -0
index e16083a..e718498 100644
@@ -903,6 +903,8 @@ static int mv_xor_v2_remove(struct platform_device *pdev)
 
 	platform_msi_domain_free_irqs(&pdev->dev);
 
+	tasklet_kill(&xor_dev->irq_tasklet);
+
 	clk_disable_unprepare(xor_dev->clk);
 
 	return 0;
#3 lore raw

PATCH 3/5 dmaengine: mv_xor_v2: convert callback to helper function

In reply to [email protected]

From: Hanna Hawa <[email protected]>

This is in preperation of moving to a callback that provides results to the callback for the transaction. The conversion will maintain current behavior and the driver must convert to new callback mechanism at a later time in order to receive results.

---
 drivers/dma/mv_xor_v2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/mv_xor_v2.c +2 -3
index e718498..14e2a7a 100644
@@ -589,9 +589,8 @@ static void mv_xor_v2_tasklet(unsigned long data)
 			 */
 			dma_cookie_complete(&next_pending_sw_desc->async_tx);
 
-			if (next_pending_sw_desc->async_tx.callback)
-				next_pending_sw_desc->async_tx.callback(
-				next_pending_sw_desc->async_tx.callback_param);
+			dmaengine_desc_get_callback_invoke(
+					&next_pending_sw_desc->async_tx, NULL);
 
 			dma_descriptor_unmap(&next_pending_sw_desc->async_tx);
 		}
#5 lore raw

PATCH 4/5 dmaengine: mv_xor_v2: move unmap to before callback

In reply to [email protected]

From: Hanna Hawa <[email protected]>

Completion callback should happen after dma_descriptor_unmap() has happened. This allow the cache invalidate to happen and ensure that the data accessed by the upper layer is in memory that was from DMA rather than stale data. On some architecture this is done by the hardware, however we should make the code consistent to not cause confusion.

---
 drivers/dma/mv_xor_v2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/mv_xor_v2.c +1 -2
index 14e2a7a..d41d916 100644
@@ -589,10 +589,9 @@ static void mv_xor_v2_tasklet(unsigned long data)
 			 */
 			dma_cookie_complete(&next_pending_sw_desc->async_tx);
 
+			dma_descriptor_unmap(&next_pending_sw_desc->async_tx);
 			dmaengine_desc_get_callback_invoke(
 					&next_pending_sw_desc->async_tx, NULL);
-
-			dma_descriptor_unmap(&next_pending_sw_desc->async_tx);
 		}
 
 		dma_run_dependencies(&next_pending_sw_desc->async_tx);
#6 lore raw

PATCH 5/5 dmaengine: mv_xor_v2: enable COMPILE_TEST

In reply to [email protected]

From: Hanna Hawa <[email protected]>

To get more coverage, enable COMPILE_TEST for this driver.

---
 drivers/dma/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/Kconfig +1 -1
index ca1680a..1f76129 100644
@@ -366,7 +366,7 @@ config MV_XOR
 
 config MV_XOR_V2
 	bool "Marvell XOR engine version 2 support "
-	depends on ARM64
+	depends on ARM64 || COMPILE_TEST
 	select DMA_ENGINE
 	select DMA_ENGINE_RAID
 	select ASYNC_TX_ENABLE_CHANNEL_SWITCH
#0 lore raw

cover dmaengine: mv_xor_v2: fixes and alignment for XOR-v2 driver

From: Hanna Hawa <[email protected]>

This series bring some minor fixes & alignmnet to the driver of Marvell XOR-v2 engine.

Thanks,
Hanna

Hanna Hawa (5):
dmaengine: mv_xor_v2: explicitly freeup irq
dmaengine: mv_xor_v2: kill the tasklets upon exit
dmaengine: mv_xor_v2: convert callback to helper function
dmaengine: mv_xor_v2: move unmap to before callback
dmaengine: mv_xor_v2: enable COMPILE_TEST

 drivers/dma/Kconfig     |  2 +-
 drivers/dma/mv_xor_v2.c | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
maintainer
#4 lore raw

Re: [PATCH 3/5] dmaengine: mv_xor_v2: convert callback to helper function

In reply to [email protected]
Quoted 3 lines · On 17-07-18, 13:30, [email protected] wrote:

From: Hanna Hawa <[email protected]>

This is in preperation of moving to a callback that provides results to the

typo preperation

Quoted 25 lines

callback for the transaction. The conversion will maintain current behavior and the driver must convert to new callback mechanism at a later time in order to receive results.

---
 drivers/dma/mv_xor_v2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/mv_xor_v2.c +2 -3
index e718498..14e2a7a 100644
@@ -589,9 +589,8 @@ static void mv_xor_v2_tasklet(unsigned long data)
 			 */
 			dma_cookie_complete(&next_pending_sw_desc->async_tx);
 
-			if (next_pending_sw_desc->async_tx.callback)
-				next_pending_sw_desc->async_tx.callback(
-				next_pending_sw_desc->async_tx.callback_param);
+			dmaengine_desc_get_callback_invoke(
+					&next_pending_sw_desc->async_tx, NULL);
 
 			dma_descriptor_unmap(&next_pending_sw_desc->async_tx);
 		}