Skip to content

Commit 885014b

Browse files
Felix Fietkauralfbaechle
authored andcommitted
MIPS: improve checks for noncoherent DMA
Only one MIPS development board actually supports enabling/disabling DMA coherency at runtime, so it's not a good idea to push the overhead of checking that configuration setting onto every other supported target as well. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John Crispin <blogic@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/5912/
1 parent 5792bf6 commit 885014b

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎arch/mips/Kconfig‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ config MIPS_MALTA
301301
select CEVT_R4K
302302
select CSRC_R4K
303303
select CSRC_GIC
304-
select DMA_NONCOHERENT
304+
select DMA_MAYBE_COHERENT
305305
select GENERIC_ISA_DMA
306306
select HAVE_PCSPKR_PLATFORM
307307
select IRQ_CPU
@@ -893,6 +893,10 @@ config FW_CFE
893893
config ARCH_DMA_ADDR_T_64BIT
894894
def_bool (HIGHMEM && 64BIT_PHYS_ADDR) || 64BIT
895895

896+
config DMA_MAYBE_COHERENT
897+
select DMA_NONCOHERENT
898+
bool
899+
896900
config DMA_COHERENT
897901
bool
898902

‎arch/mips/include/asm/dma-coherence.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
#ifndef __ASM_DMA_COHERENCE_H
1010
#define __ASM_DMA_COHERENCE_H
1111

12+
#ifdef CONFIG_DMA_MAYBE_COHERENT
1213
extern int coherentio;
1314
extern int hw_coherentio;
15+
#else
16+
#ifdef CONFIG_DMA_COHERENT
17+
#define coherentio 1
18+
#else
19+
#define coherentio 0
20+
#endif
21+
#define hw_coherentio 0
22+
#endif /* CONFIG_DMA_MAYBE_COHERENT */
1423

1524
#endif

‎arch/mips/include/asm/mach-generic/dma-coherence.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)
4949

5050
static inline int plat_device_is_coherent(struct device *dev)
5151
{
52-
#ifdef CONFIG_DMA_COHERENT
53-
return 1;
54-
#else
5552
return coherentio;
56-
#endif
5753
}
5854

5955
#ifdef CONFIG_SWIOTLB

‎arch/mips/mm/dma-default.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <dma-coherence.h>
2525

26+
#ifdef CONFIG_DMA_MAYBE_COHERENT
2627
int coherentio = 0; /* User defined DMA coherency from command line. */
2728
EXPORT_SYMBOL_GPL(coherentio);
2829
int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */
@@ -42,6 +43,7 @@ static int __init setnocoherentio(char *str)
4243
return 0;
4344
}
4445
early_param("nocoherentio", setnocoherentio);
46+
#endif
4547

4648
static inline struct page *dma_addr_to_page(struct device *dev,
4749
dma_addr_t dma_addr)

0 commit comments

Comments
 (0)