dma: Revert "dmaengine: mic_x100: add missing spin_unlock"
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
@@ -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
Quoted 6 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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
Signed-off-by Ashutosh Dixit <[email protected]>--- drivers/dma/mic_x100_dma.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)drivers/dma/mic_x100_dma.c +0
-1@@ -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
-5result =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
-2struct 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
Quoted 8 lines · Saurabh Sengar
Quoted 6 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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_unlockon 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
Signed-off-by Ashutosh Dixit <[email protected]>--- drivers/dma/mic_x100_dma.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)drivers/dma/mic_x100_dma.c +0
-4@@ -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_unlockshouldn'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
-1spin_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
Quoted 6 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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
Signed-off-by Ashutosh Dixit <[email protected]>--- drivers/dma/mic_x100_dma.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)drivers/dma/mic_x100_dma.c +5
-10@@ -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
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").
Quoted 8 lines
Quoted 3 lines
The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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.
Quoted 18 lines · Lars-Peter Clausen
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").Quoted 8 lines
Quoted 3 lines
The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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
Quoted 8 lines · Vinod
Quoted 6 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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.
Quoted 21 lines · Ashutosh Dixit
Quoted 8 lines · Vinod
Quoted 6 lines · Ashutosh Dixit
This reverts commit
e958e079e254("dmaengine:mic_x100: add missingspin_unlock").The above patch is incorrect. There is nothing wrong with the original code. The
spin_lockis 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_dmadriver still allows a client to prepare and submit multiple descriptors and triggers the hardware only whenissue_pendingis called (or a threshold is exceeded). Identical coding patterns exist in the IOAT dma driver, on which themic_x100_dmadriver is based.
Quoted 4 lines
Further,
mic_x100dma 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 bymic_x100_dma. We do not envisage a wider use of themic_x100_dmadriver 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