Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1667976

[PATCH 28/44] sparc: remove arch specific dma_supported implementations

From Christoph Hellwig <hch@lst.de>
Newsgroups linux.kernel
Subject [PATCH 28/44] sparc: remove arch specific dma_supported implementations
Date 2017-06-16 20:20 +0200
Message-ID <tT40H-3II-51@gated-at.bofh.it> (permalink)
References <tT40F-3II-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Usually dma_supported decisions are done by the dma_map_ops instance.
Switch sparc to that model by providing a ->dma_supported instance for
sbus that always returns false, and implementations tailored to the sun4u
and sun4v cases for sparc64, and leave it unimplemented for PCI on
sparc32, which means always supported.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/include/asm/dma-mapping.h |  3 ---
 arch/sparc/kernel/iommu.c            | 40 +++++++++++++++---------------------
 arch/sparc/kernel/ioport.c           | 22 ++++++--------------
 arch/sparc/kernel/pci_sun4v.c        | 17 +++++++++++++++
 4 files changed, 39 insertions(+), 43 deletions(-)

diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 98da9f92c318..60bf1633d554 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -5,9 +5,6 @@
 #include <linux/mm.h>
 #include <linux/dma-debug.h>
 
-#define HAVE_ARCH_DMA_SUPPORTED 1
-int dma_supported(struct device *dev, u64 mask);
-
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 				  enum dma_data_direction dir)
 {
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index dafa316d978d..fcbcc031f615 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -746,6 +746,21 @@ static int dma_4u_mapping_error(struct device *dev, dma_addr_t dma_addr)
 	return dma_addr == SPARC_MAPPING_ERROR;
 }
 
+static int dma_4u_supported(struct device *dev, u64 device_mask)
+{
+	struct iommu *iommu = dev->archdata.iommu;
+
+	if (device_mask > DMA_BIT_MASK(32))
+		return 0;
+	if ((device_mask & iommu->dma_addr_mask) == iommu->dma_addr_mask)
+		return 1;
+#ifdef CONFIG_PCI
+	if (dev_is_pci(dev))
+		return pci64_dma_supported(to_pci_dev(dev), device_mask);
+#endif
+	return 0;
+}
+
 static const struct dma_map_ops sun4u_dma_ops = {
 	.alloc			= dma_4u_alloc_coherent,
 	.free			= dma_4u_free_coherent,
@@ -755,32 +770,9 @@ static const struct dma_map_ops sun4u_dma_ops = {
 	.unmap_sg		= dma_4u_unmap_sg,
 	.sync_single_for_cpu	= dma_4u_sync_single_for_cpu,
 	.sync_sg_for_cpu	= dma_4u_sync_sg_for_cpu,
+	.dma_supported		= dma_4u_supported,
 	.mapping_error		= dma_4u_mapping_error,
 };
 
 const struct dma_map_ops *dma_ops = &sun4u_dma_ops;
 EXPORT_SYMBOL(dma_ops);
-
-int dma_supported(struct device *dev, u64 device_mask)
-{
-	struct iommu *iommu = dev->archdata.iommu;
-	u64 dma_addr_mask = iommu->dma_addr_mask;
-
-	if (device_mask > DMA_BIT_MASK(32)) {
-		if (iommu->atu)
-			dma_addr_mask = iommu->atu->dma_addr_mask;
-		else
-			return 0;
-	}
-
-	if ((device_mask & dma_addr_mask) == dma_addr_mask)
-		return 1;
-
-#ifdef CONFIG_PCI
-	if (dev_is_pci(dev))
-		return pci64_dma_supported(to_pci_dev(dev), device_mask);
-#endif
-
-	return 0;
-}
-EXPORT_SYMBOL(dma_supported);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index dd081d557609..12894f259bea 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -401,6 +401,11 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
 	BUG();
 }
 
+static int sbus_dma_supported(struct device *dev, u64 mask)
+{
+	return 0;
+}
+
 static const struct dma_map_ops sbus_dma_ops = {
 	.alloc			= sbus_alloc_coherent,
 	.free			= sbus_free_coherent,
@@ -410,6 +415,7 @@ static const struct dma_map_ops sbus_dma_ops = {
 	.unmap_sg		= sbus_unmap_sg,
 	.sync_sg_for_cpu	= sbus_sync_sg_for_cpu,
 	.sync_sg_for_device	= sbus_sync_sg_for_device,
+	.dma_supported		= sbus_dma_supported,
 };
 
 static int __init sparc_register_ioport(void)
@@ -655,22 +661,6 @@ EXPORT_SYMBOL(pci32_dma_ops);
 const struct dma_map_ops *dma_ops = &sbus_dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
-
-/*
- * Return whether the given PCI device DMA address mask can be
- * supported properly.  For example, if your device can only drive the
- * low 24-bits during PCI bus mastering, then you would pass
- * 0x00ffffff as the mask to this function.
- */
-int dma_supported(struct device *dev, u64 mask)
-{
-	if (dev_is_pci(dev))
-		return 1;
-
-	return 0;
-}
-EXPORT_SYMBOL(dma_supported);
-
 #ifdef CONFIG_PROC_FS
 
 static int sparc_io_proc_show(struct seq_file *m, void *v)
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index 8e2a56f4c03a..24f21c726dfa 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -24,6 +24,7 @@
 
 #include "pci_impl.h"
 #include "iommu_common.h"
+#include "kernel.h"
 
 #include "pci_sun4v.h"
 
@@ -669,6 +670,21 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
 	local_irq_restore(flags);
 }
 
+static int dma_4v_supported(struct device *dev, u64 device_mask)
+{
+	struct iommu *iommu = dev->archdata.iommu;
+	u64 dma_addr_mask;
+
+	if (device_mask > DMA_BIT_MASK(32) && iommu->atu)
+		dma_addr_mask = iommu->atu->dma_addr_mask;
+	else
+		dma_addr_mask = iommu->dma_addr_mask;
+
+	if ((device_mask & dma_addr_mask) == dma_addr_mask)
+		return 1;
+	return pci64_dma_supported(to_pci_dev(dev), device_mask);
+}
+
 static int dma_4v_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
 	return dma_addr == SPARC_MAPPING_ERROR;
@@ -681,6 +697,7 @@ static const struct dma_map_ops sun4v_dma_ops = {
 	.unmap_page			= dma_4v_unmap_page,
 	.map_sg				= dma_4v_map_sg,
 	.unmap_sg			= dma_4v_unmap_sg,
+	.dma_supported			= dma_4v_supported,
 	.mapping_error			= dma_4v_mapping_error,
 };
 
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

clean up and modularize arch dma_mapping interface V2 Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 44/44] powerpc: merge __dma_set_mask into dma_set_mask Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 38/44] arm: implement ->dma_supported instead of ->set_dma_mask Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 36/44] dma-mapping: remove HAVE_ARCH_DMA_SUPPORTED Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 42/44] powerpc/cell: use the dma_supported method for ops switching Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
    Re: [PATCH 42/44] powerpc/cell: use the dma_supported method for  ops switching Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-06-17 23:00 +0200
      Re: [PATCH 42/44] powerpc/cell: use the dma_supported method for ops  switching Christoph Hellwig <hch@infradead.org> - 2017-06-18 09:20 +0200
        Re: [PATCH 42/44] powerpc/cell: use the dma_supported method for  ops switching Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-06-18 12:00 +0200
  [PATCH 27/44] sparc: remove leon_dma_ops Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 31/44] hexagon: remove arch-specific dma_supported implementation Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 34/44] arm: remove arch specific dma_supported implementation Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 29/44] dma-noop: remove dma_supported and mapping_error methods Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 40/44] tile: remove dma_supported and mapping_error methods Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 41/44] powerpc/cell: clean up fixed mapping dma_ops initialization Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 33/44] openrisc: remove arch-specific dma_supported implementation Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 39/44] xen-swiotlb: remove xen_swiotlb_set_dma_mask Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 17/44] hexagon: switch to use ->mapping_error for error reporting Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 35/44] x86: remove arch specific dma_supported implementation Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 32/44] hexagon: remove the unused dma_is_consistent prototype Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 13/44] openrisc: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 37/44] mips/loongson64: implement ->dma_supported instead of ->set_dma_mask Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 15/44] xtensa: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 24/44] x86: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 28/44] sparc: remove arch specific dma_supported implementations Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 02/44] ibmveth: properly unwind on init errors Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 01/44] firmware/ivc: use dma_mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 43/44] dma-mapping: remove the set_dma_mask method Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 30/44] dma-virt: remove dma_supported and mapping_error methods Christoph Hellwig <hch@lst.de> - 2017-06-16 20:20 +0200
  [PATCH 26/44] dma-mapping: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 16/44] arm64: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 21/44] powerpc: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 14/44] sh: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 19/44] s390: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 25/44] arm: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 23/44] x86/calgary: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 06/44] iommu/dma: don't rely on DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
    Re: [PATCH 06/44] iommu/dma: don't rely on DMA_ERROR_CODE Robin Murphy <robin.murphy@arm.com> - 2017-06-19 17:20 +0200
  [PATCH 18/44] iommu/amd: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 20/44] sparc: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 10/44] ia64: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 08/44] xen-swiotlb: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 03/44] dmaengine: ioat: don't use DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
    Re: [PATCH 03/44] dmaengine: ioat: don't use DMA_ERROR_CODE Alexander Duyck <alexander.duyck@gmail.com> - 2017-06-16 22:50 +0200
      Re: [PATCH 03/44] dmaengine: ioat: don't use DMA_ERROR_CODE Christoph Hellwig <hch@infradead.org> - 2017-06-18 09:10 +0200
  [PATCH 04/44] drm/exynos: don't use DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 09/44] c6x: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 07/44] xen-swiotlb: consolidate xen_swiotlb_dma_ops Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 11/44] m32r: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 22/44] x86/pci-nommu: implement ->mapping_error Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 12/44] microblaze: remove DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200
  [PATCH 05/44] drm/armada: don't abuse DMA_ERROR_CODE Christoph Hellwig <hch@lst.de> - 2017-06-16 20:30 +0200

csiph-web