DMA Engine development
 help / color / mirror / Atom feed
From: Andrea Merello <andrea.merello@gmail.com>
To: vkoul@kernel.org, dan.j.williams@intel.com, dmaengine@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, radhey.shyam.pandey@xilinx.com,
	Andrea Merello <andrea.merello@gmail.com>
Subject: dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result
Date: Fri, 16 Nov 2018 14:56:28 +0100	[thread overview]
Message-ID: <20181116135628.19388-1-andrea.merello@gmail.com> (raw)

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

             reply	other threads:[~2018-11-16 13:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 13:56 Andrea Merello [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-11-20 17:24 dmaengine: fix dmaengine_desc_callback_valid() doesn't check for callback_result Radhey Shyam Pandey
2019-01-04 14:51 Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116135628.19388-1-andrea.merello@gmail.com \
    --to=andrea.merello@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radhey.shyam.pandey@xilinx.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox