All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`
@ 2021-10-23 13:41 Lars-Peter Clausen
  2021-10-24 18:19 ` Dave Jiang
  2021-10-25  4:13 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Lars-Peter Clausen @ 2021-10-23 13:41 UTC (permalink / raw)
  To: Vinod Koul; +Cc: Dave Jiang, dmaengine, Lars-Peter Clausen

Before the `callback_result` callback was introduced drivers coded their
invocation to the callback in a similar way to:

	if (cb->callback) {
		spin_unlock(&dma->lock);
		cb->callback(cb->callback_param);
		spin_lock(&dma->lock);
	}

With the introduction of `callback_result` two helpers where introduced to
transparently handle both types of callbacks. And drivers where updated to
look like this:

	if (dmaengine_desc_callback_valid(cb)) {
		spin_unlock(&dma->lock);
		dmaengine_desc_callback_invoke(cb, ...);
		spin_lock(&dma->lock);
	}

dmaengine_desc_callback_invoke() correctly handles both `callback_result`
and `callback`. But we forgot to update the dmaengine_desc_callback_valid()
function to check for `callback_result`. As a result DMA descriptors that
use the `callback_result` rather than `callback` don't have their callback
invoked by drivers that follow the pattern above.

Fix this by checking for both `callback` and `callback_result` in
dmaengine_desc_callback_valid().

Fixes: f067025bc676 ("dmaengine: add support to provide error result from a DMA transation")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/dma/dmaengine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
index 1bfbd64b1371..53f16d3f0029 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -176,7 +176,7 @@ dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx,
 static inline bool
 dmaengine_desc_callback_valid(struct dmaengine_desc_callback *cb)
 {
-	return (cb->callback) ? true : false;
+	return cb->callback || cb->callback_result;
 }
 
 struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
-- 
2.20.1


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

* Re: [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`
  2021-10-23 13:41 [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result` Lars-Peter Clausen
@ 2021-10-24 18:19 ` Dave Jiang
  2021-10-25  4:13 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2021-10-24 18:19 UTC (permalink / raw)
  To: Lars-Peter Clausen, Vinod Koul; +Cc: dmaengine


On 10/23/2021 6:41 AM, Lars-Peter Clausen wrote:
> Before the `callback_result` callback was introduced drivers coded their
> invocation to the callback in a similar way to:
>
> 	if (cb->callback) {
> 		spin_unlock(&dma->lock);
> 		cb->callback(cb->callback_param);
> 		spin_lock(&dma->lock);
> 	}
>
> With the introduction of `callback_result` two helpers where introduced to
> transparently handle both types of callbacks. And drivers where updated to
> look like this:
>
> 	if (dmaengine_desc_callback_valid(cb)) {
> 		spin_unlock(&dma->lock);
> 		dmaengine_desc_callback_invoke(cb, ...);
> 		spin_lock(&dma->lock);
> 	}
>
> dmaengine_desc_callback_invoke() correctly handles both `callback_result`
> and `callback`. But we forgot to update the dmaengine_desc_callback_valid()
> function to check for `callback_result`. As a result DMA descriptors that
> use the `callback_result` rather than `callback` don't have their callback
> invoked by drivers that follow the pattern above.
>
> Fix this by checking for both `callback` and `callback_result` in
> dmaengine_desc_callback_valid().
>
> Fixes: f067025bc676 ("dmaengine: add support to provide error result from a DMA transation")
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Acked-by: Dave Jiang <dave.jiang@intel.com>


> ---
>   drivers/dma/dmaengine.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
> index 1bfbd64b1371..53f16d3f0029 100644
> --- a/drivers/dma/dmaengine.h
> +++ b/drivers/dma/dmaengine.h
> @@ -176,7 +176,7 @@ dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx,
>   static inline bool
>   dmaengine_desc_callback_valid(struct dmaengine_desc_callback *cb)
>   {
> -	return (cb->callback) ? true : false;
> +	return cb->callback || cb->callback_result;
>   }
>   
>   struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);

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

* Re: [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`
  2021-10-23 13:41 [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result` Lars-Peter Clausen
  2021-10-24 18:19 ` Dave Jiang
@ 2021-10-25  4:13 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-10-25  4:13 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Dave Jiang, dmaengine

On 23-10-21, 15:41, Lars-Peter Clausen wrote:
> Before the `callback_result` callback was introduced drivers coded their
> invocation to the callback in a similar way to:
> 
> 	if (cb->callback) {
> 		spin_unlock(&dma->lock);
> 		cb->callback(cb->callback_param);
> 		spin_lock(&dma->lock);
> 	}
> 
> With the introduction of `callback_result` two helpers where introduced to
> transparently handle both types of callbacks. And drivers where updated to
> look like this:
> 
> 	if (dmaengine_desc_callback_valid(cb)) {
> 		spin_unlock(&dma->lock);
> 		dmaengine_desc_callback_invoke(cb, ...);
> 		spin_lock(&dma->lock);
> 	}
> 
> dmaengine_desc_callback_invoke() correctly handles both `callback_result`
> and `callback`. But we forgot to update the dmaengine_desc_callback_valid()
> function to check for `callback_result`. As a result DMA descriptors that
> use the `callback_result` rather than `callback` don't have their callback
> invoked by drivers that follow the pattern above.
> 
> Fix this by checking for both `callback` and `callback_result` in
> dmaengine_desc_callback_valid().

Thanks for the fix, applied now

-- 
~Vinod

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

end of thread, other threads:[~2021-10-25  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-23 13:41 [PATCH] dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result` Lars-Peter Clausen
2021-10-24 18:19 ` Dave Jiang
2021-10-25  4:13 ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.