Skip to contentSkip to conversation

dmaengine: altera-msgdma: correct mutex locking order

PATCH In review Nam Cao 2 participants 2 messages May 29, 2022 – May 31, 2022

Subsystems (2)
lore
Share & tools
lore

Nam Cao

author
#0 lore raw

PATCH v2 1/1 dmaengine: altera-msgdma: correct mutex locking order

The order of spin_unlock and spin_lock seems wrong. Correct it.

---
Changes in v2:
- Get rid of dirty index problem due to the patch being manually editted.

 drivers/dma/altera-msgdma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/altera-msgdma.c +2 -2
index 6f56dfd375e3..e35096c12abc 100644
@@ -591,9 +591,9 @@ static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
 
 		dmaengine_desc_get_callback(&desc->async_tx, &cb);
 		if (dmaengine_desc_callback_valid(&cb)) {
-			spin_unlock(&mdev->lock);
-			dmaengine_desc_callback_invoke(&cb, NULL);
 			spin_lock(&mdev->lock);
+			dmaengine_desc_callback_invoke(&cb, NULL);
+			spin_unlock(&mdev->lock);
 		}
 
 		/* Run any dependencies, then free the descriptor */
Signature · 1 line
2.25.1
#1 lore raw
Quoted 29 lines · Nam Cao

The order of spin_unlock and spin_lock seems wrong. Correct it.

---
Changes in v2:
- Get rid of dirty index problem due to the patch being manually editted.

 drivers/dma/altera-msgdma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/altera-msgdma.c +2 -2
index 6f56dfd375e3..e35096c12abc 100644
@@ -591,9 +591,9 @@ static void msgdma_chan_desc_cleanup(struct msgdma_device *mdev)
 
 		dmaengine_desc_get_callback(&desc->async_tx, &cb);
 		if (dmaengine_desc_callback_valid(&cb)) {
-			spin_unlock(&mdev->lock);
-			dmaengine_desc_callback_invoke(&cb, NULL);
 			spin_lock(&mdev->lock);
+			dmaengine_desc_callback_invoke(&cb, NULL);
+			spin_unlock(&mdev->lock);
 		}
 
 		/* Run any dependencies, then free the descriptor */
Signature · 1 line
2.25.1

Hello,

the lock is first grabbed in msgdma_tasklet.

Kr,

Olivier