Skip to content

Commit 11ddce1

Browse files
Christoph Hellwigmpe
authored andcommitted
dma-mapping, powerpc: simplify the arch dma_set_mask override
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> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 9b18114 commit 11ddce1

9 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎arch/powerpc/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ config FSL_SOC
886886

887887
config FSL_PCI
888888
bool
889+
select ARCH_HAS_DMA_SET_MASK
889890
select PPC_INDIRECT_PCI
890891
select PCI_QUIRKS
891892

‎arch/powerpc/include/asm/dma-mapping.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,5 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off)
110110
dev->archdata.dma_offset = off;
111111
}
112112

113-
#define HAVE_ARCH_DMA_SET_MASK 1
114-
115113
#endif /* __KERNEL__ */
116114
#endif /* _ASM_DMA_MAPPING_H */

‎arch/powerpc/include/asm/machdep.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct machdep_calls {
4747
#endif
4848
#endif /* CONFIG_PPC64 */
4949

50-
int (*dma_set_mask)(struct device *dev, u64 dma_mask);
50+
void (*dma_set_mask)(struct device *dev, u64 dma_mask);
5151

5252
int (*probe)(void);
5353
void (*setup_arch)(void); /* Optional, may be NULL */

‎arch/powerpc/kernel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ obj-$(CONFIG_UPROBES) += uprobes.o
105105
obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
106106
obj-$(CONFIG_STACKTRACE) += stacktrace.o
107107
obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o
108+
obj-$(CONFIG_ARCH_HAS_DMA_SET_MASK) += dma-mask.o
108109

109110
pci64-$(CONFIG_PPC64) += pci_dn.o pci-hotplug.o isa-bridge.o
110111
obj-$(CONFIG_PCI) += pci_$(BITS).o $(pci64-y) \

‎arch/powerpc/kernel/dma-mask.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/dma-mapping.h>
4+
#include <linux/export.h>
5+
#include <asm/machdep.h>
6+
7+
void arch_dma_set_mask(struct device *dev, u64 dma_mask)
8+
{
9+
if (ppc_md.dma_set_mask)
10+
ppc_md.dma_set_mask(dev, dma_mask);
11+
}
12+
EXPORT_SYMBOL(arch_dma_set_mask);

‎arch/powerpc/kernel/dma.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,6 @@ const struct dma_map_ops dma_nommu_ops = {
234234
};
235235
EXPORT_SYMBOL(dma_nommu_ops);
236236

237-
int dma_set_mask(struct device *dev, u64 dma_mask)
238-
{
239-
if (ppc_md.dma_set_mask)
240-
return ppc_md.dma_set_mask(dev, dma_mask);
241-
242-
if (!dev->dma_mask || !dma_supported(dev, dma_mask))
243-
return -EIO;
244-
*dev->dma_mask = dma_mask;
245-
return 0;
246-
}
247-
EXPORT_SYMBOL(dma_set_mask);
248-
249237
static int __init dma_init(void)
250238
{
251239
#ifdef CONFIG_IBMVIO

‎arch/powerpc/sysdev/fsl_pci.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ static void setup_swiotlb_ops(struct pci_controller *hose)
133133
static inline void setup_swiotlb_ops(struct pci_controller *hose) {}
134134
#endif
135135

136-
static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
136+
static void fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
137137
{
138-
if (!dev->dma_mask || !dma_supported(dev, dma_mask))
139-
return -EIO;
140-
141138
/*
142139
* Fix up PCI devices that are able to DMA to the large inbound
143140
* 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)
147144
set_dma_ops(dev, &dma_nommu_ops);
148145
set_dma_offset(dev, pci64_dma_offset);
149146
}
150-
151-
*dev->dma_mask = dma_mask;
152-
return 0;
153147
}
154148

155149
static int setup_one_atmu(struct ccsr_pci __iomem *pci,

‎kernel/dma/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ config ARCH_DMA_ADDR_T_64BIT
1616
config ARCH_HAS_DMA_COHERENCE_H
1717
bool
1818

19+
config ARCH_HAS_DMA_SET_MASK
20+
bool
21+
1922
config HAVE_GENERIC_DMA_COHERENT
2023
bool
2124

‎kernel/dma/mapping.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,23 @@ int dma_supported(struct device *dev, u64 mask)
316316
}
317317
EXPORT_SYMBOL(dma_supported);
318318

319-
#ifndef HAVE_ARCH_DMA_SET_MASK
319+
#ifdef CONFIG_ARCH_HAS_DMA_SET_MASK
320+
void arch_dma_set_mask(struct device *dev, u64 mask);
321+
#else
322+
#define arch_dma_set_mask(dev, mask) do { } while (0)
323+
#endif
324+
320325
int dma_set_mask(struct device *dev, u64 mask)
321326
{
322327
if (!dev->dma_mask || !dma_supported(dev, mask))
323328
return -EIO;
324329

330+
arch_dma_set_mask(dev, mask);
325331
dma_check_mask(dev, mask);
326332
*dev->dma_mask = mask;
327333
return 0;
328334
}
329335
EXPORT_SYMBOL(dma_set_mask);
330-
#endif
331336

332337
#ifndef CONFIG_ARCH_HAS_DMA_SET_COHERENT_MASK
333338
int dma_set_coherent_mask(struct device *dev, u64 mask)

0 commit comments

Comments
 (0)