Skip to content

Commit

Permalink
dma-mapping, powerpc: simplify the arch dma_set_mask override
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Michael Ellerman committed Feb 18, 2019
1 parent 9b18114 commit 11ddce1
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 24 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ config FSL_SOC

config FSL_PCI
bool
select ARCH_HAS_DMA_SET_MASK
select PPC_INDIRECT_PCI
select PCI_QUIRKS

Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/machdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
12 changes: 12 additions & 0 deletions arch/powerpc/kernel/dma-mask.c
Original file line number Diff line number Diff line change
@@ -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);
12 changes: 0 additions & 12 deletions arch/powerpc/kernel/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions arch/powerpc/sysdev/fsl_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions kernel/dma/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions kernel/dma/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 11ddce1

Please sign in to comment.