linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	workgroup.linux-kQvG35nSl+M@public.gmane.org,
	Qipan Li <Qipan.Li-kQvG35nSl+M@public.gmane.org>,
	Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
Subject: [PATCH 5/5] spi: sirf: fix spi full-duplex DMA transferring issue
Date: Mon, 14 Apr 2014 14:30:01 +0800	[thread overview]
Message-ID: <1397457001-5266-6-git-send-email-21cnbao@gmail.com> (raw)
In-Reply-To: <1397457001-5266-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Qipan Li <Qipan.Li-kQvG35nSl+M@public.gmane.org>

sometimes t->tx can be equal with t->rx. for example, spidev will make
tx and rx point to spidev->buffer at the same time. currently, for this
case, we map the buffer BIDIRECTION to fix the cache consistency.

Signed-off-by: Qipan Li <Qipan.Li-kQvG35nSl+M@public.gmane.org>
Signed-off-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
---
 drivers/spi/spi-sirf.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 3c12f39..0c039d4 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -383,7 +383,8 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t)
 		struct dma_async_tx_descriptor *rx_desc, *tx_desc;
 
 		sspi->dst_start = dma_map_single(&spi->dev,
-				sspi->rx, t->len, DMA_FROM_DEVICE);
+				sspi->rx, t->len, (t->tx_buf != t->rx_buf) ?
+				DMA_FROM_DEVICE : DMA_BIDIRECTIONAL);
 		rx_desc = dmaengine_prep_slave_single(sspi->rx_chan,
 			sspi->dst_start, t->len, DMA_DEV_TO_MEM,
 			DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
@@ -391,7 +392,9 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t)
 		rx_desc->callback_param = &sspi->rx_done;
 
 		sspi->src_start = dma_map_single(&spi->dev,
-				(void *)sspi->tx, t->len, DMA_TO_DEVICE);
+				(void *)sspi->tx, t->len,
+				(t->tx_buf != t->rx_buf) ?
+				DMA_TO_DEVICE : DMA_BIDIRECTIONAL);
 		tx_desc = dmaengine_prep_slave_single(sspi->tx_chan,
 			sspi->src_start, t->len, DMA_MEM_TO_DEV,
 			DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-04-14  6:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-14  6:29 [PATCH 0/5] spi : sirf: some chip-select, DMA and checkpatch fixes Barry Song
     [not found] ` <1397457001-5266-1-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14  6:29   ` [PATCH 1/5] spi: sirf: correct TXFIFO empty interrupt status bit Barry Song
     [not found]     ` <1397457001-5266-2-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14 20:02       ` Mark Brown
2014-04-14  6:29   ` [PATCH 2/5] spi: sirf: set SPI controller in RISC IO chipselect mode Barry Song
     [not found]     ` <1397457001-5266-3-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14 20:03       ` Mark Brown
2014-04-14  6:29   ` [PATCH 3/5] spi: sirf: make GPIO chipselect function work well Barry Song
     [not found]     ` <1397457001-5266-4-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14 20:03       ` Mark Brown
2014-04-14  6:30   ` [PATCH 4/5] spi: sirf: fix line over 80 characters style issue Barry Song
     [not found]     ` <1397457001-5266-5-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14 20:04       ` Mark Brown
2014-04-14  6:30   ` Barry Song [this message]
     [not found]     ` <1397457001-5266-6-git-send-email-21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-14 20:06       ` [PATCH 5/5] spi: sirf: fix spi full-duplex DMA transferring issue Mark Brown
     [not found]         ` <20140414200628.GX25182-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-15  1:43           ` Barry Song
     [not found]             ` <CAGsJ_4yO-LGJEkpNy=dizQWjSE3pHEBOrrPndho3jt1_YMRvHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-15  9:26               ` Mark Brown
     [not found]                 ` <20140415092609.GJ12304-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-04-15  9:57                   ` Barry Song
     [not found]                     ` <CAGsJ_4yWkBr2x=hLNaCsVwytDTua48kR+DEO86A6vH5x+jLEDg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-15 10:12                       ` Mark Brown

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=1397457001-5266-6-git-send-email-21cnbao@gmail.com \
    --to=21cnbao-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Baohua.Song-kQvG35nSl+M@public.gmane.org \
    --cc=Qipan.Li-kQvG35nSl+M@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=workgroup.linux-kQvG35nSl+M@public.gmane.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;
as well as URLs for NNTP newsgroup(s).