mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Vinod Koul <vinod.koul@intel.com>, Russell King <linux@arm.linux.org.uk>
Cc: Viresh Kumar <viresh.kumar@st.com>,
	Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	Shawn Guo <shawn.guo@linaro.org>,
	Javier Martin <javier.martin@vista-silicon.com>,
	Richard Zhao <richard.zhao@linaro.org>,
	Yong Wang <yong.y.wang@intel.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 3/3] dmaengine: Fixup dmaengine_prep_slave_single() to be actually useful
Date: Wed, 25 Apr 2012 20:50:53 +0200	[thread overview]
Message-ID: <1335379853-10122-3-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1335379853-10122-1-git-send-email-lars@metafoo.de>

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

dmaengine_prep_slave_single() is a helper function which is supposed to be used
to prepare a transfer of a single contingous buffer. Currently the function
takes a pointer to such a buffer from which it builds a scatterlist and passes
it on to device_prep_slave_sg. The dmaengine framework requires that any
scatterlist that is passed to device_prep_slave_sg is mapped and it may not be
unmapped until the DMA operation has completed. This is not the here and any use
of dmaengine_prep_slave_single() will lead to undefined behaviour (Most likely a
system crash).

This patch changes dmaengine_prep_slave_single() to take a dma_addr_t instead of
a pointer to a buffer and moves the responsibility of mapping and unmapping the
buffer up to the caller.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

---
Changes since v1:
	* Drop call to sg_set_page
	* Slightly reword commit message
---
 include/linux/dmaengine.h |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 676f967..0e6b595 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -615,11 +615,13 @@ static inline int dmaengine_slave_config(struct dma_chan *chan,
 }
 
 static inline struct dma_async_tx_descriptor *dmaengine_prep_slave_single(
-	struct dma_chan *chan, void *buf, size_t len,
+	struct dma_chan *chan, dma_addr_t buf, size_t len,
 	enum dma_transfer_direction dir, unsigned long flags)
 {
 	struct scatterlist sg;
-	sg_init_one(&sg, buf, len);
+	sg_init_table(&sg, 1);
+	sg_dma_address(&sg) = buf;
+	sg_dma_len(&sg) = len;
 
 	return chan->device->device_prep_slave_sg(chan, &sg, 1,
 						  dir, flags, NULL);
-- 
1.7.9.5


  parent reply	other threads:[~2012-04-25 18:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-25 18:50 [PATCH 1/3] dmaengine: Use sg_dma_address instead of sg_phys Lars-Peter Clausen
2012-04-25 18:50 ` [PATCH 2/3] dmaengine: Use dma_sg_len(sg) instead of sg->length Lars-Peter Clausen
2012-04-25 18:50 ` Lars-Peter Clausen [this message]
2012-04-25 18:51 ` [PATCH 1/3] dmaengine: Use sg_dma_address instead of sg_phys Russell King - ARM Linux
2012-04-26 21:28 ` Linus Walleij
2012-05-11  8:31   ` 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=1335379853-10122-3-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=javier.martin@vista-silicon.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=richard.zhao@linaro.org \
    --cc=shawn.guo@linaro.org \
    --cc=srinidhi.kasagar@stericsson.com \
    --cc=vinod.koul@intel.com \
    --cc=viresh.kumar@st.com \
    --cc=yong.y.wang@intel.com \
    /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

all inboxes | Powered by JetHome®