linux-kernel.vger.kernel.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>,
	Olof Johansson <olof@lixom.net>
Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org,
	Christian Zigotzky <chzigotzky@xenosoft.de>
Subject: [PATCH 21/32] dma-mapping, powerpc: simplify the arch dma_set_mask override
Date: Wed, 13 Feb 2019 08:01:22 +0100	[thread overview]
Message-ID: <20190213070133.11259-22-hch@lst.de> (raw)
In-Reply-To: <20190213070133.11259-1-hch@lst.de>

Instead of letting the architecture supply all of dma_set_mask just
give it an additional hook selected by Kconfig.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
---
 arch/powerpc/Kconfig                   |  1 +
 arch/powerpc/include/asm/dma-mapping.h |  2 --
 arch/powerpc/include/asm/machdep.h     |  2 +-
 arch/powerpc/kernel/Makefile           |  1 +
 arch/powerpc/kernel/dma-mask.c         | 12 ++++++++++++
 arch/powerpc/kernel/dma.c              | 12 ------------
 arch/powerpc/sysdev/fsl_pci.c          |  8 +-------
 kernel/dma/Kconfig                     |  3 +++
 kernel/dma/mapping.c                   |  9 +++++++--
 9 files changed, 26 insertions(+), 24 deletions(-)
 create mode 100644 arch/powerpc/kernel/dma-mask.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8a4ae675c9ba..8af6a7d93148 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -883,6 +883,7 @@ config FSL_SOC
 
 config FSL_PCI
  	bool
+	select ARCH_HAS_DMA_SET_MASK
 	select PPC_INDIRECT_PCI
 	select PCI_QUIRKS
 
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index dc7f7bcdf65d..16d45518d9bb 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -110,7 +110,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)
 		dev->archdata.dma_offset = off;
 }
 
-#define HAVE_ARCH_DMA_SET_MASK 1
-
 #endif /* __KERNEL__ */
 #endif	/* _ASM_DMA_MAPPING_H */
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 7b70dcbce1b9..2f0ca6560e47 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -47,7 +47,7 @@ struct machdep_calls {
 #endif
 #endif /* CONFIG_PPC64 */
 
-	int		(*dma_set_mask)(struct device *dev, u64 dma_mask);
+	void		(*dma_set_mask)(struct device *dev, u64 dma_mask);
 
 	int		(*probe)(void);
 	void		(*setup_arch)(void); /* Optional, may be NULL */
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index cb7f0bb9ee71..9bb12cd642ef 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -105,6 +105,7 @@ obj-$(CONFIG_UPROBES)		+= uprobes.o
 obj-$(CONFIG_PPC_UDBG_16550)	+= legacy_serial.o udbg_16550.o
 obj-$(CONFIG_STACKTRACE)	+= stacktrace.o
 obj-$(CONFIG_SWIOTLB)		+= dma-swiotlb.o
+obj-$(CONFIG_ARCH_HAS_DMA_SET_MASK) += dma-mask.o
 
 pci64-$(CONFIG_PPC64)		+= pci_dn.o pci-hotplug.o isa-bridge.o
 obj-$(CONFIG_PCI)		+= pci_$(BITS).o $(pci64-y) \
diff --git a/arch/powerpc/kernel/dma-mask.c b/arch/powerpc/kernel/dma-mask.c
new file mode 100644
index 000000000000..ffbbbc432612
--- /dev/null
+++ b/arch/powerpc/kernel/dma-mask.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/dma-mapping.h>
+#include <linux/export.h>
+#include <asm/machdep.h>
+
+void arch_dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	if (ppc_md.dma_set_mask)
+		ppc_md.dma_set_mask(dev, dma_mask);
+}
+EXPORT_SYMBOL(arch_dma_set_mask);
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 1e191eb3f0ec..e422ca65d1cf 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -234,18 +234,6 @@ const struct dma_map_ops dma_nommu_ops = {
 };
 EXPORT_SYMBOL(dma_nommu_ops);
 
-int dma_set_mask(struct device *dev, u64 dma_mask)
-{
-	if (ppc_md.dma_set_mask)
-		return ppc_md.dma_set_mask(dev, dma_mask);
-
-	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
-		return -EIO;
-	*dev->dma_mask = dma_mask;
-	return 0;
-}
-EXPORT_SYMBOL(dma_set_mask);
-
 static int __init dma_init(void)
 {
 #ifdef CONFIG_IBMVIO
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index b710cee023a2..0c6510f340cb 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -133,11 +133,8 @@ static void setup_swiotlb_ops(struct pci_controller *hose)
 static inline void setup_swiotlb_ops(struct pci_controller *hose) {}
 #endif
 
-static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
+static void fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
 {
-	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
-		return -EIO;
-
 	/*
 	 * Fix up PCI devices that are able to DMA to the large inbound
 	 * mapping that allows addressing any RAM address from across PCI.
@@ -147,9 +144,6 @@ static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
 		set_dma_ops(dev, &dma_nommu_ops);
 		set_dma_offset(dev, pci64_dma_offset);
 	}
-
-	*dev->dma_mask = dma_mask;
-	return 0;
 }
 
 static int setup_one_atmu(struct ccsr_pci __iomem *pci,
diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
index ca88b867e7fe..0711d18645de 100644
--- a/kernel/dma/Kconfig
+++ b/kernel/dma/Kconfig
@@ -16,6 +16,9 @@ config ARCH_DMA_ADDR_T_64BIT
 config ARCH_HAS_DMA_COHERENCE_H
 	bool
 
+config ARCH_HAS_DMA_SET_MASK
+	bool
+
 config HAVE_GENERIC_DMA_COHERENT
 	bool
 
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 40c0af744692..ef2aba503467 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -316,18 +316,23 @@ int dma_supported(struct device *dev, u64 mask)
 }
 EXPORT_SYMBOL(dma_supported);
 
-#ifndef HAVE_ARCH_DMA_SET_MASK
+#ifdef CONFIG_ARCH_HAS_DMA_SET_MASK
+void arch_dma_set_mask(struct device *dev, u64 mask);
+#else
+#define arch_dma_set_mask(dev, mask)	do { } while (0)
+#endif
+
 int dma_set_mask(struct device *dev, u64 mask)
 {
 	if (!dev->dma_mask || !dma_supported(dev, mask))
 		return -EIO;
 
+	arch_dma_set_mask(dev, mask);
 	dma_check_mask(dev, mask);
 	*dev->dma_mask = mask;
 	return 0;
 }
 EXPORT_SYMBOL(dma_set_mask);
-#endif
 
 #ifndef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
 int dma_set_coherent_mask(struct device *dev, u64 mask)
-- 
2.20.1


  parent reply	other threads:[~2019-02-13  7:03 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  7:01 use generic DMA mapping code in powerpc V7 Christoph Hellwig
2019-02-13  7:01 ` [PATCH 01/32] net: pasemi: set a 64-bit DMA mask on the DMA device Christoph Hellwig
2019-02-22  9:47   ` [01/32] " Michael Ellerman
2019-02-13  7:01 ` [PATCH 02/32] dma-direct: we might need GFP_DMA for 32-bit dma masks Christoph Hellwig
2019-02-13  7:01 ` [PATCH 03/32] powerpc/dma: untangle vio_dma_mapping_ops from dma_iommu_ops Christoph Hellwig
2019-02-13  7:01 ` [PATCH 04/32] powerpc/dma: handle iommu bypass in dma_iommu_ops Christoph Hellwig
2019-02-13  7:01 ` [PATCH 05/32] powerpc/pseries: unwind dma_get_required_mask_pSeriesLP a bit Christoph Hellwig
2019-02-13  7:01 ` [PATCH 06/32] powerpc/pseries: use the generic iommu bypass code Christoph Hellwig
2019-02-13  7:01 ` [PATCH 07/32] powerpc/cell: move dma direct window setup out of dma_configure Christoph Hellwig
2019-02-13  7:01 ` [PATCH 08/32] powerpc/cell: use the generic iommu bypass code Christoph Hellwig
2019-02-13  7:01 ` [PATCH 09/32] powerpc/dart: remove dead cleanup code in iommu_init_early_dart Christoph Hellwig
2019-02-13  7:01 ` [PATCH 10/32] powerpc/dart: use the generic iommu bypass code Christoph Hellwig
2019-02-13  7:01 ` [PATCH 11/32] powerpc/powernv: remove pnv_pci_ioda_pe_single_vendor Christoph Hellwig
2019-02-13  7:01 ` [PATCH 12/32] powerpc/powernv: remove pnv_npu_dma_set_mask Christoph Hellwig
2019-02-13  7:01 ` [PATCH 13/32] powerpc/powernv: use the generic iommu bypass code Christoph Hellwig
2019-02-13  7:01 ` [PATCH 14/32] powerpc/dma: stop overriding dma_get_required_mask Christoph Hellwig
2019-02-13  7:01 ` [PATCH 15/32] powerpc/pci: remove the dma_set_mask pci_controller ops methods Christoph Hellwig
2019-02-13  7:01 ` [PATCH 16/32] powerpc/dma: remove the iommu fallback for coherent allocations Christoph Hellwig
2019-02-13  7:01 ` [PATCH 17/32] powerpc/dma: remove get_pci_dma_ops Christoph Hellwig
2019-02-13  7:01 ` [PATCH 18/32] powerpc/dma: move pci_dma_dev_setup_swiotlb to fsl_pci.c Christoph Hellwig
2019-02-13  7:01 ` [PATCH 19/32] powerpc/dma: remove max_direct_dma_addr Christoph Hellwig
2019-02-13  7:01 ` [PATCH 20/32] powerpc/dma: fix an off-by-one in dma_capable Christoph Hellwig
2019-02-13  7:01 ` Christoph Hellwig [this message]
2019-02-13  7:01 ` [PATCH 22/32] powerpc/dma: use phys_to_dma instead of get_dma_offset Christoph Hellwig
2019-02-13  7:01 ` [PATCH 23/32] powerpc/dma: remove dma_nommu_mmap_coherent Christoph Hellwig
2019-02-13  7:01 ` [PATCH 24/32] powerpc/dma: remove dma_nommu_get_required_mask Christoph Hellwig
2019-02-13  7:01 ` [PATCH 25/32] powerpc/dma: remove dma_nommu_dma_supported Christoph Hellwig
2019-02-13  7:01 ` [PATCH 26/32] swiotlb: remove swiotlb_dma_supported Christoph Hellwig
2019-02-13  7:01 ` [PATCH 27/32] powerpc/dma: use the dma-direct allocator for coherent platforms Christoph Hellwig
2019-02-13  7:01 ` [PATCH 28/32] powerpc/dma: use the dma_direct mapping routines Christoph Hellwig
2019-02-13  7:01 ` [PATCH 29/32] powerpc/dma: use the generic direct mapping bypass Christoph Hellwig
2019-02-13  7:01 ` [PATCH 30/32] powerpc/dma: remove get_dma_offset Christoph Hellwig
2019-02-13  7:01 ` [PATCH 31/32] powerpc/dma: remove set_dma_offset Christoph Hellwig
2019-02-13  7:01 ` [PATCH 32/32] powerpc/dma: trim the fat from <asm/dma-mapping.h> Christoph Hellwig
2019-02-20 14:23 ` use generic DMA mapping code in powerpc V7 Christoph Hellwig

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=20190213070133.11259-22-hch@lst.de \
    --to=hch@lst.de \
    --cc=benh@kernel.crashing.org \
    --cc=chzigotzky@xenosoft.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=olof@lixom.net \
    --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).