From: Huacai Chen <chenhc@lemote.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Fuxin Zhang <zhangfx@lemote.com>,
linux-kernel@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
James Hogan <james.hogan@imgtec.com>,
linux-mips@linux-mips.org,
"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, Huacai Chen <chenhc@lemote.com>,
stable@vger.kernel.org
Subject: [PATCH V9 2/4] MIPS: Implement dma_map_ops::get_cache_alignment()
Date: Mon, 23 Oct 2017 15:12:45 +0800 [thread overview]
Message-ID: <1508742767-28366-2-git-send-email-chenhc@lemote.com> (raw)
In-Reply-To: <1508742767-28366-1-git-send-email-chenhc@lemote.com>
Currently, MIPS is an architecture which support coherent & noncoherent
devices co-exist. So implement get_cache_alignment() function pointer
in 'struct dma_map_ops' to return different dma alignments.
Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
arch/mips/cavium-octeon/dma-octeon.c | 3 ++-
arch/mips/include/asm/dma-coherence.h | 2 ++
arch/mips/include/asm/mach-loongson64/kmalloc.h | 6 ++++++
arch/mips/loongson64/common/dma-swiotlb.c | 1 +
arch/mips/mm/dma-default.c | 11 ++++++++++-
arch/mips/netlogic/common/nlm-dma.c | 3 ++-
6 files changed, 23 insertions(+), 3 deletions(-)
create mode 100644 arch/mips/include/asm/mach-loongson64/kmalloc.h
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
index c64bd87..41c29a85 100644
--- a/arch/mips/cavium-octeon/dma-octeon.c
+++ b/arch/mips/cavium-octeon/dma-octeon.c
@@ -324,7 +324,8 @@ static struct octeon_dma_map_ops _octeon_pci_dma_map_ops = {
.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
.sync_sg_for_device = octeon_dma_sync_sg_for_device,
.mapping_error = swiotlb_dma_mapping_error,
- .dma_supported = swiotlb_dma_supported
+ .dma_supported = swiotlb_dma_supported,
+ .get_cache_alignment = mips_dma_get_cache_alignment
},
};
diff --git a/arch/mips/include/asm/dma-coherence.h b/arch/mips/include/asm/dma-coherence.h
index 72d0eab..5f7a9fc 100644
--- a/arch/mips/include/asm/dma-coherence.h
+++ b/arch/mips/include/asm/dma-coherence.h
@@ -29,4 +29,6 @@ extern int hw_coherentio;
#define hw_coherentio 0
#endif /* CONFIG_DMA_MAYBE_COHERENT */
+int mips_dma_get_cache_alignment(struct device *dev);
+
#endif
diff --git a/arch/mips/include/asm/mach-loongson64/kmalloc.h b/arch/mips/include/asm/mach-loongson64/kmalloc.h
new file mode 100644
index 0000000..2731d9e
--- /dev/null
+++ b/arch/mips/include/asm/mach-loongson64/kmalloc.h
@@ -0,0 +1,6 @@
+#ifndef __ASM_MACH_LOONGSON64_KMALLOC_H
+#define __ASM_MACH_LOONGSON64_KMALLOC_H
+
+#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
+
+#endif /* __ASM_MACH_LOONGSON64_KMALLOC_H */
diff --git a/arch/mips/loongson64/common/dma-swiotlb.c b/arch/mips/loongson64/common/dma-swiotlb.c
index 34486c1..17b9897 100644
--- a/arch/mips/loongson64/common/dma-swiotlb.c
+++ b/arch/mips/loongson64/common/dma-swiotlb.c
@@ -119,6 +119,7 @@ static const struct dma_map_ops loongson_dma_map_ops = {
.sync_sg_for_device = loongson_dma_sync_sg_for_device,
.mapping_error = swiotlb_dma_mapping_error,
.dma_supported = loongson_dma_supported,
+ .get_cache_alignment = mips_dma_get_cache_alignment
};
void __init plat_swiotlb_setup(void)
diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
index c01bd20..e8f0659 100644
--- a/arch/mips/mm/dma-default.c
+++ b/arch/mips/mm/dma-default.c
@@ -394,6 +394,14 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
EXPORT_SYMBOL(dma_cache_sync);
+int mips_dma_get_cache_alignment(struct device *dev)
+{
+ if (plat_device_is_coherent(dev))
+ return 1;
+ else
+ return ARCH_DMA_MINALIGN;
+}
+
static const struct dma_map_ops mips_default_dma_map_ops = {
.alloc = mips_dma_alloc_coherent,
.free = mips_dma_free_coherent,
@@ -407,7 +415,8 @@ static const struct dma_map_ops mips_default_dma_map_ops = {
.sync_sg_for_cpu = mips_dma_sync_sg_for_cpu,
.sync_sg_for_device = mips_dma_sync_sg_for_device,
.mapping_error = mips_dma_mapping_error,
- .dma_supported = mips_dma_supported
+ .dma_supported = mips_dma_supported,
+ .get_cache_alignment = mips_dma_get_cache_alignment
};
const struct dma_map_ops *mips_dma_map_ops = &mips_default_dma_map_ops;
diff --git a/arch/mips/netlogic/common/nlm-dma.c b/arch/mips/netlogic/common/nlm-dma.c
index 0ec9d9d..e9a9ddc 100644
--- a/arch/mips/netlogic/common/nlm-dma.c
+++ b/arch/mips/netlogic/common/nlm-dma.c
@@ -79,7 +79,8 @@ const struct dma_map_ops nlm_swiotlb_dma_ops = {
.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
.sync_sg_for_device = swiotlb_sync_sg_for_device,
.mapping_error = swiotlb_dma_mapping_error,
- .dma_supported = swiotlb_dma_supported
+ .dma_supported = swiotlb_dma_supported,
+ .get_cache_alignment = mips_dma_get_cache_alignment
};
void __init plat_swiotlb_setup(void)
--
2.7.0
next prev parent reply other threads:[~2017-10-23 7:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171023071025epcas4p3e9b9c0af7c0a34561f0d57a20a4f9946@epcas4p3.samsung.com>
2017-10-23 7:12 ` [PATCH V9 1/4] dma-mapping: Rework dma_get_cache_alignment() Huacai Chen
2017-10-23 7:12 ` Huacai Chen [this message]
2017-11-06 18:21 ` [PATCH V9 2/4] MIPS: Implement dma_map_ops::get_cache_alignment() Christoph Hellwig
2017-10-23 7:12 ` [PATCH V9 3/4] scsi: Align block queue to dma_get_cache_alignment() Huacai Chen
2017-11-05 2:39 ` kbuild test robot
2017-10-23 7:12 ` [PATCH V9 4/4] libsas: Align sata_device's rps_resp on a cacheline Huacai Chen
2017-10-24 13:30 ` [PATCH V9 1/4] dma-mapping: Rework dma_get_cache_alignment() Marek Szyprowski
2017-10-25 1:22 ` 陈华才
2017-10-25 7:21 ` Marek Szyprowski
2017-10-26 6:33 ` 陈华才
2017-11-03 4:48 ` 陈华才
2017-11-03 5:14 ` Christoph Hellwig
2017-11-03 6:15 ` 陈华才
2017-10-24 19:11 ` Mark Greer
2017-11-06 18:18 ` Christoph Hellwig
2017-11-10 12:30 ` Christoph Hellwig
2017-11-13 8:37 ` 陈华才
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=1508742767-28366-2-git-send-email-chenhc@lemote.com \
--to=chenhc@lemote.com \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=james.hogan@imgtec.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=linux-scsi@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=martin.petersen@oracle.com \
--cc=ralf@linux-mips.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=zhangfx@lemote.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;
as well as URLs for NNTP newsgroup(s).