* [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
@ 2018-11-16 13:56 Andrea Merello
2018-11-20 17:24 ` Radhey Shyam Pandey
2019-01-04 14:51 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Andrea Merello @ 2018-11-16 13:56 UTC (permalink / raw)
To: vkoul, dan.j.williams, dmaengine
Cc: linux-kernel, radhey.shyam.pandey, Andrea Merello
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.
Signed-off-by: Andrea Merello <andrea.merello@gmail.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 501c0b063f85..0ba2c1f3c55d 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
2018-11-16 13:56 [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result Andrea Merello
@ 2018-11-20 17:24 ` Radhey Shyam Pandey
2019-01-04 14:51 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Radhey Shyam Pandey @ 2018-11-20 17:24 UTC (permalink / raw)
To: Andrea Merello, vkoul, dan.j.williams, dmaengine; +Cc: linux-kernel
> -----Original Message-----
> From: Andrea Merello <andrea.merello@gmail.com>
> Sent: Friday, November 16, 2018 7:26 PM
> To: vkoul@kernel.org; dan.j.williams@intel.com; dmaengine@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Radhey Shyam Pandey
> <radheys@xilinx.com>; Andrea Merello <andrea.merello@gmail.com>
> Subject: [PATCH] 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).
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.
>
> This patch fixes this by making dmaengine_desc_callback_valid() to return
> true in the said scenario.
>
> Signed-off-by: Andrea Merello <andrea.merello@gmail.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 501c0b063f85..0ba2c1f3c55d 100644
> --- a/drivers/dma/dmaengine.h
> +++ b/drivers/dma/dmaengine.h
> @@ -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
> --
> 2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
2018-11-16 13:56 [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result Andrea Merello
2018-11-20 17:24 ` Radhey Shyam Pandey
@ 2019-01-04 14:51 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2019-01-04 14:51 UTC (permalink / raw)
To: Andrea Merello
Cc: dan.j.williams, dmaengine, linux-kernel, radhey.shyam.pandey
On 16-11-18, 14:56, Andrea Merello wrote:
> 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.
>
> Signed-off-by: Andrea Merello <andrea.merello@gmail.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 501c0b063f85..0ba2c1f3c55d 100644
> --- a/drivers/dma/dmaengine.h
> +++ b/drivers/dma/dmaengine.h
> @@ -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
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-04 14:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 13:56 [PATCH] dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result Andrea Merello
2018-11-20 17:24 ` Radhey Shyam Pandey
2019-01-04 14:51 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).