Skip to content

Commit 1dccb59

Browse files
arndbctmarinas
authored andcommitted
arm64: simplify dma_get_ops
Including linux/acpi.h from asm/dma-mapping.h causes tons of compile-time warnings, e.g. drivers/isdn/mISDN/dsp_ecdis.h:43:0: warning: "FALSE" redefined drivers/isdn/mISDN/dsp_ecdis.h:44:0: warning: "TRUE" redefined drivers/net/fddi/skfp/h/targetos.h:62:0: warning: "TRUE" redefined drivers/net/fddi/skfp/h/targetos.h:63:0: warning: "FALSE" redefined However, it looks like the dependency should not even there as I do not see why __generic_dma_ops() cares about whether we have an ACPI based system or not. The current behavior is to fall back to the global dma_ops when a device has not set its own dma_ops, but only for DT based systems. This seems dangerous, as a random device might have different requirements regarding IOMMU or coherency, so we should really never have that fallback and just forbid DMA when we have not initialized DMA for a device. This removes the global dma_ops variable and the special-casing for ACPI, and just returns the dma ops that got set for the device, or the dummy_dma_ops if none were present. The original code has apparently been copied from arm32 where we rely on it for ISA devices things like the floppy controller, but we should have no such devices on ARM64. Signed-off-by: Arnd Bergmann <[email protected]> [[email protected]: removed acpi_disabled check in arch_setup_dma_ops()] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 4fee9f3 commit 1dccb59

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

arch/arm64/include/asm/dma-mapping.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,23 @@
1818

1919
#ifdef __KERNEL__
2020

21-
#include <linux/acpi.h>
2221
#include <linux/types.h>
2322
#include <linux/vmalloc.h>
2423

2524
#include <xen/xen.h>
2625
#include <asm/xen/hypervisor.h>
2726

2827
#define DMA_ERROR_CODE (~(dma_addr_t)0)
29-
extern struct dma_map_ops *dma_ops;
3028
extern struct dma_map_ops dummy_dma_ops;
3129

3230
static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
3331
{
34-
if (unlikely(!dev))
35-
return dma_ops;
36-
else if (dev->archdata.dma_ops)
32+
if (dev && dev->archdata.dma_ops)
3733
return dev->archdata.dma_ops;
38-
else if (acpi_disabled)
39-
return dma_ops;
4034

4135
/*
42-
* When ACPI is enabled, if arch_set_dma_ops is not called,
43-
* we will disable device DMA capability by setting it
44-
* to dummy_dma_ops.
36+
* We expect no ISA devices, and all other DMA masters are expected to
37+
* have someone call arch_setup_dma_ops at device creation time.
4538
*/
4639
return &dummy_dma_ops;
4740
}

arch/arm64/mm/dma-mapping.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <linux/gfp.h>
21+
#include <linux/acpi.h>
2122
#include <linux/export.h>
2223
#include <linux/slab.h>
2324
#include <linux/genalloc.h>
@@ -28,9 +29,6 @@
2829

2930
#include <asm/cacheflush.h>
3031

31-
struct dma_map_ops *dma_ops;
32-
EXPORT_SYMBOL(dma_ops);
33-
3432
static pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot,
3533
bool coherent)
3634
{
@@ -515,13 +513,7 @@ EXPORT_SYMBOL(dummy_dma_ops);
515513

516514
static int __init arm64_dma_init(void)
517515
{
518-
int ret;
519-
520-
dma_ops = &swiotlb_dma_ops;
521-
522-
ret = atomic_pool_init();
523-
524-
return ret;
516+
return atomic_pool_init();
525517
}
526518
arch_initcall(arm64_dma_init);
527519

@@ -991,8 +983,8 @@ static void __iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
991983
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
992984
struct iommu_ops *iommu, bool coherent)
993985
{
994-
if (!acpi_disabled && !dev->archdata.dma_ops)
995-
dev->archdata.dma_ops = dma_ops;
986+
if (!dev->archdata.dma_ops)
987+
dev->archdata.dma_ops = &swiotlb_dma_ops;
996988

997989
dev->archdata.dma_coherent = coherent;
998990
__iommu_setup_dma_ops(dev, dma_base, size, iommu);

0 commit comments

Comments
 (0)