Skip to contentSkip to conversation

dma: Revert "dmaengine: mic_x100: add missing spin_unlock"

PATCH In review Ashutosh Dixit 4 participants 8 messages Dec 23, 2015 – Jan 6, 2016 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: Revert "dmaengine: mic_x100: add missing spin_unlock"

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

---
 drivers/dma/mic_x100_dma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/dma/mic_x100_dma.c +5 -10
index cddfa8d..068e920 100644
@@ -317,7 +317,6 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
 	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
 	struct device *dev = mic_dma_ch_to_device(mic_ch);
 	int result;
-	struct dma_async_tx_descriptor *tx = NULL;
 
 	if (!len && !flags)
 		return NULL;
@@ -325,13 +324,10 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
 	spin_lock(&mic_ch->prep_lock);
 	result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
 	if (result >= 0)
-		tx = allocate_tx(mic_ch);
-
-	if (!tx)
-		dev_err(dev, "Error enqueueing dma, error=%d\n", result);
-
+		return allocate_tx(mic_ch);
+	dev_err(dev, "Error enqueueing dma, error=%d\n", result);
 	spin_unlock(&mic_ch->prep_lock);
-	return tx;
+	return NULL;
 }
 
 static struct dma_async_tx_descriptor *
@@ -339,14 +335,13 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
 {
 	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
 	int ret;
-	struct dma_async_tx_descriptor *tx = NULL;
 
 	spin_lock(&mic_ch->prep_lock);
 	ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
 	if (!ret)
-		tx = allocate_tx(mic_ch);
+		return allocate_tx(mic_ch);
 	spin_unlock(&mic_ch->prep_lock);
-	return tx;
+	return NULL;
 }
 
 /* Return the status of the transaction */
Signature · 1 line
2.0.0.rc3.2.g998f840
#1 lore raw
Quoted 6 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

Hi Ashutosh,

If it is need to be released by submit function, we don't require the spin_unlock on success case as well.
am I correct ?

Quoted 19 lines
---
 drivers/dma/mic_x100_dma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/dma/mic_x100_dma.c +0 -1
index cddfa8d..068e920 100644
@@ -317,7 +317,6 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
        struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
        struct device *dev = mic_dma_ch_to_device(mic_ch);
        int result;
-       struct dma_async_tx_descriptor *tx = NULL;
 
        if (!len && !flags)
                return NULL;
@@ -325,13 +324,10 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
        spin_lock(&mic_ch->prep_lock);

drivers/dma/mic_x100_dma.c mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest, · line 329

Quoted 10 lines
drivers/dma/mic_x100_dma.c +2 -5
        result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
        if (result >= 0)
-               tx = allocate_tx(mic_ch);
-
-       if (!tx)
-               dev_err(dev, "Error enqueueing dma, error=%d\n", result);
-
+               return allocate_tx(mic_ch);
+       dev_err(dev, "Error enqueueing dma, error=%d\n", result);
        spin_unlock(&mic_ch->prep_lock);

This spin_unlock shouldn't be required as explained it is getting released by submit function

Quoted 7 lines
drivers/dma/mic_x100_dma.c +1 -1
-       return tx;
+       return NULL;
 }
 
 static struct dma_async_tx_descriptor *
@@ -339,14 +335,13 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
 {

drivers/dma/mic_x100_dma.c mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags) · line 343

Quoted 10 lines
drivers/dma/mic_x100_dma.c +1 -2
        struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
        int ret;
-       struct dma_async_tx_descriptor *tx = NULL;
 
        spin_lock(&mic_ch->prep_lock);
        ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
        if (!ret)
-               tx = allocate_tx(mic_ch);
+               return allocate_tx(mic_ch);
        spin_unlock(&mic_ch->prep_lock);

and this too ?

Quoted 8 lines
drivers/dma/mic_x100_dma.c +1 -2
-       return tx;
+       return NULL;
 }
 
 /* Return the status of the transaction */
--

2.0.0.rc3.2.g998f840

#2 lore raw
Quoted 8 lines · Saurabh Sengar
Quoted 6 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

Quoted 5 lines

Hi Ashutosh,

If it is need to be released by submit function, we don't require the spin_unlock on success case as well.
am I correct ?

No, you are wrong. In the prep functions, we are not using spin_unlock in success cases but in failure ones.

Quoted 24 lines
Quoted 24 lines
---
 drivers/dma/mic_x100_dma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/dma/mic_x100_dma.c +0 -4
index cddfa8d..068e920 100644
@@ -317,7 +317,6 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
        struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
        struct device *dev = mic_dma_ch_to_device(mic_ch);
        int result;
-       struct dma_async_tx_descriptor *tx = NULL;
 
        if (!len && !flags)
                return NULL;
@@ -325,13 +324,10 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
        spin_lock(&mic_ch->prep_lock);
        result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
        if (result >= 0)
-               tx = allocate_tx(mic_ch);
-
-       if (!tx)
Quoted 8 lines

drivers/dma/mic_x100_dma.c mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest, · line 329

Quoted 5 lines
drivers/dma/mic_x100_dma.c +2 -2
-               dev_err(dev, "Error enqueueing dma, error=%d\n", result);
-
+               return allocate_tx(mic_ch);
+       dev_err(dev, "Error enqueueing dma, error=%d\n", result);
        spin_unlock(&mic_ch->prep_lock);

This spin_unlock shouldn't be required as explained it is getting released by submit function

This is a failure case. Submit will not be called in this case so spin_unlock needs to be called here.

Quoted 11 lines
Quoted 11 lines
drivers/dma/mic_x100_dma.c +1 -2
-       return tx;
+       return NULL;
 }
 
 static struct dma_async_tx_descriptor *
@@ -339,14 +335,13 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
 {
        struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
        int ret;
-       struct dma_async_tx_descriptor *tx = NULL;
 
Quoted 8 lines

drivers/dma/mic_x100_dma.c mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags) · line 343

Quoted 6 lines
drivers/dma/mic_x100_dma.c +1 -1
        spin_lock(&mic_ch->prep_lock);
        ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
        if (!ret)
-               tx = allocate_tx(mic_ch);
+               return allocate_tx(mic_ch);
        spin_unlock(&mic_ch->prep_lock);

and this too ?

Yes, this too.

Quoted 8 lines
Quoted 8 lines
drivers/dma/mic_x100_dma.c +1 -2
-       return tx;
+       return NULL;
 }
 
 /* Return the status of the transaction */
--

2.0.0.rc3.2.g998f840

#3 lore raw
In reply to Ashutosh Dixit
Quoted 6 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

And going by dmaengine sematics, I do not think that is entrely right.

A user may choose to prepare multiple desciptors and then sumbit later, looking at code I do not see how that will work.

Please fix that

Quoted 55 lines
---
 drivers/dma/mic_x100_dma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/dma/mic_x100_dma.c +5 -10
index cddfa8d..068e920 100644
@@ -317,7 +317,6 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
 	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
 	struct device *dev = mic_dma_ch_to_device(mic_ch);
 	int result;
-	struct dma_async_tx_descriptor *tx = NULL;
 
 	if (!len && !flags)
 		return NULL;
@@ -325,13 +324,10 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
 	spin_lock(&mic_ch->prep_lock);
 	result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
 	if (result >= 0)
-		tx = allocate_tx(mic_ch);
-
-	if (!tx)
-		dev_err(dev, "Error enqueueing dma, error=%d\n", result);
-
+		return allocate_tx(mic_ch);
+	dev_err(dev, "Error enqueueing dma, error=%d\n", result);
 	spin_unlock(&mic_ch->prep_lock);
-	return tx;
+	return NULL;
 }
 
 static struct dma_async_tx_descriptor *
@@ -339,14 +335,13 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
 {
 	struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
 	int ret;
-	struct dma_async_tx_descriptor *tx = NULL;
 
 	spin_lock(&mic_ch->prep_lock);
 	ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
 	if (!ret)
-		tx = allocate_tx(mic_ch);
+		return allocate_tx(mic_ch);
 	spin_unlock(&mic_ch->prep_lock);
-	return tx;
+	return NULL;
 }
 
 /* Return the status of the transaction */
Signature · 1 line
2.0.0.rc3.2.g998f840
Signature · 1 line
~Vinod
#4 lore raw
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

Quoted 8 lines
Quoted 3 lines

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

And going by dmaengine sematics, I do not think that is entrely right.

A user may choose to prepare multiple desciptors and then sumbit later, looking at code I do not see how that will work.

The DMAengine API actually mandates that prep and submit must always be called in pairs, without any other DMAengine calls in between. The patch is correct.

Quoting from Documentation/dmaengine/client.txt:

Once a descriptor has been obtained, the callback information can be added and the descriptor must then be submitted. Some DMA engine drivers may hold a spinlock between a successful preparation and submission so it is important that these two operations are closely paired.

#5 lore raw
Quoted 18 lines · Lars-Peter Clausen
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

Quoted 8 lines
Quoted 3 lines

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

And going by dmaengine sematics, I do not think that is entrely right.

A user may choose to prepare multiple desciptors and then sumbit later, looking at code I do not see how that will work.

The DMAengine API actually mandates that prep and submit must always be called in pairs, without any other DMAengine calls in between. The patch is correct.

Quoted 7 lines

Quoting from Documentation/dmaengine/client.txt:

Once a descriptor has been obtained, the callback information can be added and the descriptor must then be submitted. Some DMA engine drivers may hold a spinlock between a successful preparation and submission so it is important that these two operations are closely paired.

This is true for slave cases as has been made clear in the Documentation. For non slave cases that is not entirely right. mic_x100 falls in latter category.

Thanks

Signature · 1 line
~Vinod
#6 lore raw
In reply to Vinod Koul
Quoted 8 lines · Vinod
Quoted 6 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

Quoted 6 lines

And going by dmaengine sematics, I do not think that is entrely right.

A user may choose to prepare multiple desciptors and then sumbit later, looking at code I do not see how that will work.

Please fix that

The mic_x100_dma driver still allows a client to prepare and submit multiple descriptors and triggers the hardware only when issue_pending is called (or a threshold is exceeded). Identical coding patterns exist in the IOAT dma driver, on which the mic_x100_dma driver is based.

Further, mic_x100 dma channels are private and used only by other MIC drivers such as SCIF (drivers/misc/mic/scif). These drivers obviously alternate prep and submit calls as required by mic_x100_dma. We do not envisage a wider use of the mic_x100_dma driver at this point.

A change such as allowing multiple prep's before a submit requires large scale changes in the driver. In the absence of a real use case, there is no plan to make such changes at present. At this point we only want the driver to be restored to its previously functional state for the 4.4 kernel. The patch in question results in system lockups so it is a serious v4.4 regression.

#7 lore raw
Quoted 21 lines · Ashutosh Dixit
Quoted 8 lines · Vinod
Quoted 6 lines · Ashutosh Dixit

This reverts commit e958e079e254 ("dmaengine: mic_x100: add missing spin_unlock").

The above patch is incorrect. There is nothing wrong with the original code. The spin_lock is acquired in the "prep" functions and released in "submit".

Quoted 6 lines

And going by dmaengine sematics, I do not think that is entrely right.

A user may choose to prepare multiple desciptors and then sumbit later, looking at code I do not see how that will work.

Please fix that

The mic_x100_dma driver still allows a client to prepare and submit multiple descriptors and triggers the hardware only when issue_pending is called (or a threshold is exceeded). Identical coding patterns exist in the IOAT dma driver, on which the mic_x100_dma driver is based.

Quoted 4 lines

Further, mic_x100 dma channels are private and used only by other MIC drivers such as SCIF (drivers/misc/mic/scif). These drivers obviously alternate prep and submit calls as required by mic_x100_dma. We do not envisage a wider use of the mic_x100_dma driver at this point.

The whole point of using an API is to create standard usages, future clients can come up and your argument is not future proof

Quoted 7 lines

A change such as allowing multiple prep's before a submit requires large scale changes in the driver. In the absence of a real use case, there is no plan to make such changes at present. At this point we only want the driver to be restored to its previously functional state for the 4.4 kernel. The patch in question results in system lockups so it is a serious v4.4 regression.

I will revert it but please fix the driver..

Signature · 1 line
~Vinod