mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sanjeev Sharma <sanjeev_sharma@mentor.com>
To: <linux@arm.linux.org.uk>, <m.szyprowski@samsung.com>,
	<will.deacon@arm.com>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	Sanjeev Sharma <sanjeev_sharma@mentor.com>
Subject: [PATCH] ARM:dma-mapping: Handle DMA_BIDIRECTIONAL in _dma_page_cpu_to_dev()
Date: Wed, 4 Nov 2015 15:26:48 +0530	[thread overview]
Message-ID: <1446631008-5854-1-git-send-email-sanjeev_sharma@mentor.com> (raw)

_dma_page_cpu_to_dev() treat DMA_BIDIRECTIONAL similar to DMA_TO_DEVICE
which means that destination buffer is device memory,means cpu may have
written some data to source buffer and data may be in cache line.For
cleaner operation we need to call outer_flush_range() which will
clean and invalidate outer cache lines.

Signed-off-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
---
 arch/arm/mm/dma-mapping.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index e62400e..e195235 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -850,12 +850,20 @@ static void __dma_page_cpu_to_dev(struct page *page, unsigned long off,
 	dma_cache_maint_page(page, off, size, dir, dmac_map_area);
 
 	paddr = page_to_phys(page) + off;
-	if (dir == DMA_FROM_DEVICE) {
-		outer_inv_range(paddr, paddr + size);
-	} else {
-		outer_clean_range(paddr, paddr + size);
+
+	switch (dir) {
+	case DMA_FROM_DEVICE:
+			outer_inv_range(paddr, paddr + size);
+			break;
+	case DMA_TO_DEVICE:
+			outer_clean_range(paddr, paddr + size);
+			break;
+	case DMA_BIDIRECTIONAL:
+			outer_flush_range(paddr, paddr + size);
+			break;
+	default:
+			break;
 	}
-	/* FIXME: non-speculating: flush on bidirectional mappings? */
 }
 
 static void __dma_page_dev_to_cpu(struct page *page, unsigned long off,
-- 
1.7.11.7


             reply	other threads:[~2015-11-04  9:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04  9:56 Sanjeev Sharma [this message]
2015-11-04 10:39 ` Will Deacon
2015-11-04 10:54   ` Russell King - ARM Linux
2015-11-05  5:56     ` Sharma, Sanjeev
     [not found]       ` <CAGUYZuQDiH_xzinEJ952rw9GuA9oUQSNASaNdOE1x_i97XCBrw@mail.gmail.com>
2015-11-09 10:08         ` Will Deacon
2015-11-09 10:15           ` Sharma, Sanjeev
2015-11-09 10:50             ` Robin Murphy
2015-11-09 12:00             ` Russell King - ARM Linux

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=1446631008-5854-1-git-send-email-sanjeev_sharma@mentor.com \
    --to=sanjeev_sharma@mentor.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=will.deacon@arm.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®