Skip to content

Commit 14ac09a

Browse files
Christoph Hellwigtsbogend
authored andcommitted
MIPS: refactor the runtime coherent vs noncoherent DMA indicators
Replace the global coherentio enum, and the hw_coherentio (fake) boolean variables with a single boolean dma_default_coherent flag. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 3440caf commit 14ac09a

File tree

6 files changed

+16
-40
lines changed

6 files changed

+16
-40
lines changed

arch/mips/alchemy/common/setup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ void __init plat_mem_setup(void)
6565
/* Clear to obtain best system bus performance */
6666
clear_c0_config(1 << 19); /* Clear Config[OD] */
6767

68-
coherentio = alchemy_dma_coherent() ?
69-
IO_COHERENCE_ENABLED : IO_COHERENCE_DISABLED;
68+
dma_default_coherent = alchemy_dma_coherent();
7069

7170
board_setup(); /* board specific setup */
7271

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,14 @@
99
#ifndef __ASM_DMA_COHERENCE_H
1010
#define __ASM_DMA_COHERENCE_H
1111

12-
enum coherent_io_user_state {
13-
IO_COHERENCE_DEFAULT,
14-
IO_COHERENCE_ENABLED,
15-
IO_COHERENCE_DISABLED,
16-
};
17-
18-
#if defined(CONFIG_DMA_PERDEV_COHERENT)
19-
/* Don't provide (hw_)coherentio to avoid misuse */
20-
#elif defined(CONFIG_DMA_MAYBE_COHERENT)
21-
extern enum coherent_io_user_state coherentio;
22-
extern int hw_coherentio;
23-
12+
#ifdef CONFIG_DMA_MAYBE_COHERENT
13+
extern bool dma_default_coherent;
2414
static inline bool dev_is_dma_coherent(struct device *dev)
2515
{
26-
return coherentio == IO_COHERENCE_ENABLED ||
27-
(coherentio == IO_COHERENCE_DEFAULT && hw_coherentio);
16+
return dma_default_coherent;
2817
}
2918
#else
30-
#ifdef CONFIG_DMA_NONCOHERENT
31-
#define coherentio IO_COHERENCE_DISABLED
32-
#else
33-
#define coherentio IO_COHERENCE_ENABLED
19+
#define dma_default_coherent (!IS_ENABLED(CONFIG_DMA_NONCOHERENT))
3420
#endif
35-
#define hw_coherentio 0
36-
#endif /* CONFIG_DMA_MAYBE_COHERENT */
3721

3822
#endif

arch/mips/kernel/setup.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,22 +803,20 @@ arch_initcall(debugfs_mips);
803803
#endif
804804

805805
#ifdef CONFIG_DMA_MAYBE_COHERENT
806-
/* User defined DMA coherency from command line. */
807-
enum coherent_io_user_state coherentio = IO_COHERENCE_DEFAULT;
808-
EXPORT_SYMBOL_GPL(coherentio);
809-
int hw_coherentio; /* Actual hardware supported DMA coherency setting. */
806+
bool dma_default_coherent;
807+
EXPORT_SYMBOL_GPL(dma_default_coherent);
810808

811809
static int __init setcoherentio(char *str)
812810
{
813-
coherentio = IO_COHERENCE_ENABLED;
811+
dma_default_coherent = true;
814812
pr_info("Hardware DMA cache coherency (command line)\n");
815813
return 0;
816814
}
817815
early_param("coherentio", setcoherentio);
818816

819817
static int __init setnocoherentio(char *str)
820818
{
821-
coherentio = IO_COHERENCE_DISABLED;
819+
dma_default_coherent = true;
822820
pr_info("Software DMA cache coherency (command line)\n");
823821
return 0;
824822
}

arch/mips/mm/c-r4k.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,15 +1914,11 @@ void r4k_cache_init(void)
19141914
__local_flush_icache_user_range = local_r4k_flush_icache_user_range;
19151915

19161916
#ifdef CONFIG_DMA_NONCOHERENT
1917-
#ifdef CONFIG_DMA_MAYBE_COHERENT
1918-
if (coherentio == IO_COHERENCE_ENABLED ||
1919-
(coherentio == IO_COHERENCE_DEFAULT && hw_coherentio)) {
1917+
if (dma_default_coherent) {
19201918
_dma_cache_wback_inv = (void *)cache_noop;
19211919
_dma_cache_wback = (void *)cache_noop;
19221920
_dma_cache_inv = (void *)cache_noop;
1923-
} else
1924-
#endif /* CONFIG_DMA_MAYBE_COHERENT */
1925-
{
1921+
} else {
19261922
_dma_cache_wback_inv = r4k_dma_cache_wback_inv;
19271923
_dma_cache_wback = r4k_dma_cache_wback_inv;
19281924
_dma_cache_inv = r4k_dma_cache_inv;

arch/mips/mti-malta/malta-setup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void __init plat_setup_iocoherency(void)
9898
if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) {
9999
BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN;
100100
pr_info("Enabled Bonito CPU coherency\n");
101-
hw_coherentio = 1;
101+
dma_default_coherent = true;
102102
}
103103
if (strstr(fw_getcmdline(), "iobcuncached")) {
104104
BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;
@@ -118,12 +118,12 @@ static void __init plat_setup_iocoherency(void)
118118
pr_info("CMP IOCU detected\n");
119119
cfg = __raw_readl((u32 *)CKSEG1ADDR(ROCIT_CONFIG_GEN0));
120120
if (cfg & ROCIT_CONFIG_GEN0_PCI_IOCU)
121-
hw_coherentio = 1;
121+
dma_default_coherent = true;
122122
else
123123
pr_crit("IOCU OPERATION DISABLED BY SWITCH - DEFAULTING TO SW IO COHERENCY\n");
124124
}
125125

126-
if (hw_coherentio)
126+
if (dma_default_coherent)
127127
pr_info("Hardware DMA cache coherency enabled\n");
128128
else
129129
pr_info("Software DMA cache coherency enabled\n");

arch/mips/pci/pci-alchemy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,8 @@ static int alchemy_pci_probe(struct platform_device *pdev)
429429
ctx->alchemy_pci_ctrl.io_map_base = (unsigned long)virt_io;
430430

431431
/* Au1500 revisions older than AD have borked coherent PCI */
432-
if ((alchemy_get_cputype() == ALCHEMY_CPU_AU1500) &&
433-
(read_c0_prid() < 0x01030202) &&
434-
(coherentio == IO_COHERENCE_DISABLED)) {
432+
if (alchemy_get_cputype() == ALCHEMY_CPU_AU1500 &&
433+
read_c0_prid() < 0x01030202 && !dma_default_coherent) {
435434
val = __raw_readl(ctx->regs + PCI_REG_CONFIG);
436435
val |= PCI_CONFIG_NC;
437436
__raw_writel(val, ctx->regs + PCI_REG_CONFIG);

0 commit comments

Comments
 (0)