Skip to content

Commit edc0378

Browse files
FlyGoattsbogend
authored andcommitted
MIPS: Loongson64: Enable DMA noncoherent support
There are some Loongson64 systems come with broken coherent DMA support, firmware will set a bit in boot_param and pass nocoherentio in cmdline. However nonconherent support was missed out when spin off Loongson-2EF form Loongson64, and that boot_param change never made itself into upstream. Support DMA noncoherent properly to get those systems working. Cc: [email protected] Fixes: 71e2f4d ("MIPS: Fork loongson2ef from loongson64") Signed-off-by: Jiaxun Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 8f7aa77 commit edc0378

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

arch/mips/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ config MACH_LOONGSON2EF
460460

461461
config MACH_LOONGSON64
462462
bool "Loongson 64-bit family of machines"
463+
select ARCH_DMA_DEFAULT_COHERENT
463464
select ARCH_SPARSEMEM_ENABLE
464465
select ARCH_MIGHT_HAVE_PC_PARPORT
465466
select ARCH_MIGHT_HAVE_PC_SERIO
@@ -1251,6 +1252,7 @@ config CPU_LOONGSON64
12511252
select CPU_SUPPORTS_MSA
12521253
select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT
12531254
select CPU_MIPSR2_IRQ_VI
1255+
select DMA_NONCOHERENT
12541256
select WEAK_ORDERING
12551257
select WEAK_REORDERING_BEYOND_LLSC
12561258
select MIPS_ASID_BITS_VARIABLE

arch/mips/include/asm/mach-loongson64/boot_param.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ struct irq_source_routing_table {
117117
u64 pci_io_start_addr;
118118
u64 pci_io_end_addr;
119119
u64 pci_config_addr;
120-
u32 dma_mask_bits;
120+
u16 dma_mask_bits;
121+
u16 dma_noncoherent;
121122
} __packed;
122123

123124
struct interface_info {

arch/mips/loongson64/env.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* Copyright (C) 2009 Lemote Inc.
1414
* Author: Wu Zhangjin, [email protected]
1515
*/
16+
17+
#include <linux/dma-map-ops.h>
1618
#include <linux/export.h>
1719
#include <linux/pci_ids.h>
1820
#include <asm/bootinfo.h>
@@ -147,8 +149,14 @@ void __init prom_lefi_init_env(void)
147149

148150
loongson_sysconf.dma_mask_bits = eirq_source->dma_mask_bits;
149151
if (loongson_sysconf.dma_mask_bits < 32 ||
150-
loongson_sysconf.dma_mask_bits > 64)
152+
loongson_sysconf.dma_mask_bits > 64) {
151153
loongson_sysconf.dma_mask_bits = 32;
154+
dma_default_coherent = true;
155+
} else {
156+
dma_default_coherent = !eirq_source->dma_noncoherent;
157+
}
158+
159+
pr_info("Firmware: Coherent DMA: %s\n", dma_default_coherent ? "on" : "off");
152160

153161
loongson_sysconf.restart_addr = boot_p->reset_system.ResetWarm;
154162
loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown;

0 commit comments

Comments
 (0)