Skip to contentSkip to conversation

dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`

PATCH In review Lars-Peter Clausen 3 participants 3 messages Oct 23, 2021 – Oct 25, 2021 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: dmaengine_desc_callback_valid(): Check for `callback_result`

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")
---
 drivers/dma/dmaengine.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dmaengine.h +1 -1
index 1bfbd64b1371..53f16d3f0029 100644
@@ -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);
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 25 lines · 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.

Quoted 5 lines

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")
Quoted 17 lines
---
  drivers/dma/dmaengine.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dmaengine.h +1 -1
index 1bfbd64b1371..53f16d3f0029 100644
@@ -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);
maintainer
#2 lore raw
In reply to Lars-Peter Clausen
Quoted 19 lines · 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);
	}
Quoted 8 lines

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

Signature · 1 line
~Vinod