dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
PATCH 1/1 dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
There are two flavors of DMA completion callbacks: callback() and callback_result(); the latter takes an additional parameter that carries result information.
Most dmaengine helper functions that work with callbacks take care of both flavors i.e. dmaengine_desc_get_callback_invoke() first checks for callback_result() to be not NULL, and eventually it calls this one; otherwise it goes on checking for callback().
It seems however that dmaengine_desc_callback_valid() does not care about callback_result(), and it returns false in case callback() is NULL but callback_result() is not; unless there is a (hidden to me) reason for doing so then I'd say this is wrong.
I've hit this by using a DMA controller driver (xilinx_dma) that doesn't trigger any callback invocation unless dmaengine_desc_callback_valid() returns true, while I had only callback_result() implemented in my client driver (which AFAICT is always fine since dmaengine documentation says that callback() will be deprecated).
This patch fixes this by making dmaengine_desc_callback_valid() to return true in the said scenario.
--- drivers/dma/dmaengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dmaengine.h +1 -1
@@ -168,7 +168,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); }#endif
Quoted 23 lines
-----Original Message-----
From: Andrea Merello <[email protected]>
Sent: Friday, November 16, 2018 7:26 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; Radhey Shyam Pandey <[email protected]>; Andrea Merello <[email protected]>
Subject: [PATCH] dmaengine: fixdmaengine_desc_callback_valid()doesn't check forcallback_resultThere are two flavors of DMA completion callbacks:
callback()andcallback_result(); the latter takes an additional parameter that carries result information.Most dmaengine helper functions that work with callbacks take care of both flavors i.e.
dmaengine_desc_get_callback_invoke()first checks forcallback_result()to be not NULL, and eventually it calls this one; otherwise it goes on checking forcallback().It seems however that
dmaengine_desc_callback_valid()does not care aboutcallback_result(), and it returns false in casecallback()is NULL butcallback_result()is not; unless there is a (hidden to me) reason for doing so then I'd say this is wrong.
Quoted 5 lines
I've hit this by using a DMA controller driver (
xilinx_dma) that doesn't trigger any callback invocation unlessdmaengine_desc_callback_valid()returns true, while I had onlycallback_result()implemented in my client driver (which AFAICT is always fine since dmaengine documentation says thatcallback()will be deprecated).
Thanks for the patch. In xilinx_dma driver call to _desc_callback_valid can be safely removed as callback ptrs are anyway checked in invoke(). There is no much benefit in having redundant checks.
Related to dmaengine_desc_callback_valid extension will let Vinod comment.
Quoted 25 lines
This patch fixes this by making
dmaengine_desc_callback_valid()to return true in the said scenario.Signed-off-by Andrea Merello <[email protected]>--- drivers/dma/dmaengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/dmaengine.h +1
-1@@ -168,7 +168,7 @@ dmaengine_desc_get_callback_invoke(structdma_async_tx_descriptor *tx, static inline booldmaengine_desc_callback_valid (struct dmaengine_desc_callback *cb) { - return (cb->callback) ? true : false; + return (cb->callback || cb->callback_result); }#endif
--
2.17.1
Vinod Koul
maintainerQuoted 33 lines · Andrea Merello
There are two flavors of DMA completion callbacks:
callback()andcallback_result(); the latter takes an additional parameter that carries result information.Most dmaengine helper functions that work with callbacks take care of both flavors i.e.
dmaengine_desc_get_callback_invoke()first checks forcallback_result()to be not NULL, and eventually it calls this one; otherwise it goes on checking forcallback().It seems however that
dmaengine_desc_callback_valid()does not care aboutcallback_result(), and it returns false in casecallback()is NULL butcallback_result()is not; unless there is a (hidden to me) reason for doing so then I'd say this is wrong.I've hit this by using a DMA controller driver (
xilinx_dma) that doesn't trigger any callback invocation unlessdmaengine_desc_callback_valid()returns true, while I had onlycallback_result()implemented in my client driver (which AFAICT is always fine since dmaengine documentation says thatcallback()will be deprecated).This patch fixes this by making
dmaengine_desc_callback_valid()to return true in the said scenario.Signed-off-by Andrea Merello <[email protected]>--- drivers/dma/dmaengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/dmaengine.h +0
-0
drivers/dma/dmaengine.h dmaengine_desc_get_callback_invoke(struct dma_async_tx_descriptor *tx, · line 171
Quoted 5 lines
drivers/dma/dmaengine.h +1
-1@@ -168,7 +168,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);
So I do not think this one should take care of callback_result, it is supposed to check if the callback is valid or not.. Nothing more.
Ofcourse usage of this maybe incorrect which should be fixed. We do have dmaengine_desc_callback_invoke() which propagates the callback_result to user