linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org, Christian Lamparter <chunkeey@gmail.com>
Subject: [PATCH 2/8] powerpc/dma: properly wire up the unmap_page and unmap_sg methods
Date: Sun, 16 Dec 2018 18:19:45 +0100	[thread overview]
Message-ID: <20181216171951.31306-3-hch@lst.de> (raw)
In-Reply-To: <20181216171951.31306-1-hch@lst.de>

The unmap methods need to transfer memory ownership back from the device
to the cpu by identical means as dma_sync_*_to_cpu.  I'm not sure powerpc
needs to do any work in this transfer direction, but given that it does
invalidate the caches in dma_sync_*_to_cpu already we should make sure
we also do so on unmapping.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/powerpc/kernel/dma.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index dbfc7056d7df..d442d23e182b 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -210,10 +210,15 @@ static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,
 	return nents;
 }
 
-static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
+static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,
 				int nents, enum dma_data_direction direction,
 				unsigned long attrs)
 {
+	struct scatterlist *sg;
+	int i;
+
+	for_each_sg(sgl, sg, nents, i)
+		__dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
 }
 
 static u64 dma_nommu_get_required_mask(struct device *dev)
@@ -247,6 +252,8 @@ static inline void dma_nommu_unmap_page(struct device *dev,
 					 enum dma_data_direction direction,
 					 unsigned long attrs)
 {
+	if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
+		__dma_sync(bus_to_virt(dma_address), size, dir);
 }
 
 #ifdef CONFIG_NOT_COHERENT_CACHE
-- 
2.19.2


  parent reply	other threads:[~2018-12-16 17:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16 17:19 small powerpc DMA fixes and cleanups Christoph Hellwig
2018-12-16 17:19 ` [PATCH 1/8] powerpc: allow NOT_COHERENT_CACHE for amigaone Christoph Hellwig
2018-12-22  9:54   ` [1/8] " Michael Ellerman
2018-12-16 17:19 ` Christoph Hellwig [this message]
2018-12-17  6:41   ` [PATCH 2/8] powerpc/dma: properly wire up the unmap_page and unmap_sg methods Christophe Leroy
2018-12-17  7:34     ` Christoph Hellwig
2018-12-17  7:39       ` Christophe Leroy
2018-12-17  8:16         ` Christoph Hellwig
2018-12-17 11:37   ` Michael Ellerman
2018-12-16 17:19 ` [PATCH 3/8] crypto4xx_core: don't abuse __dma_sync_page Christoph Hellwig
2018-12-16 18:28   ` Christian Lamparter
2018-12-17  7:27     ` Christoph Hellwig
2018-12-19 10:13   ` Christian Lamparter
2018-12-16 17:19 ` [PATCH 4/8] powerpc/dma: remove the unused ARCH_HAS_DMA_MMAP_COHERENT define Christoph Hellwig
2018-12-16 17:19 ` [PATCH 5/8] powerpc/dma: remove the unused ISA_DMA_THRESHOLD export Christoph Hellwig
2018-12-16 17:19 ` [PATCH 6/8] powerpc/dma: remove the unused dma_iommu_ops export Christoph Hellwig
2018-12-16 17:19 ` [PATCH 7/8] powerpc/dma: split the two __dma_alloc_coherent implementations Christoph Hellwig
2018-12-17  6:51   ` Christophe Leroy
2018-12-17  7:35     ` Christoph Hellwig
2018-12-17 21:34       ` Gerhard Pircher
2018-12-16 17:19 ` [PATCH 8/8] cxl: drop the dma_set_mask callback from vphb Christoph Hellwig
2018-12-16 23:10   ` Andrew Donnellan

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=20181216171951.31306-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=benh@kernel.crashing.org \
    --cc=chunkeey@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.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).