Skip to content

Commit b4e440c

Browse files
FlyGoatgregkh
authored andcommitted
MIPS: Loongson64: Enable DMA noncoherent support
commit edc0378 upstream. 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: stable@vger.kernel.org Fixes: 71e2f4d ("MIPS: Fork loongson2ef from loongson64") Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d52a517 commit b4e440c

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
@@ -483,6 +483,7 @@ config MACH_LOONGSON2EF
483483

484484
config MACH_LOONGSON64
485485
bool "Loongson 64-bit family of machines"
486+
select ARCH_DMA_DEFAULT_COHERENT
486487
select ARCH_SPARSEMEM_ENABLE
487488
select ARCH_MIGHT_HAVE_PC_PARPORT
488489
select ARCH_MIGHT_HAVE_PC_SERIO
@@ -1304,6 +1305,7 @@ config CPU_LOONGSON64
13041305
select CPU_SUPPORTS_MSA
13051306
select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT
13061307
select CPU_MIPSR2_IRQ_VI
1308+
select DMA_NONCOHERENT
13071309
select WEAK_ORDERING
13081310
select WEAK_REORDERING_BEYOND_LLSC
13091311
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
@@ -121,7 +121,8 @@ struct irq_source_routing_table {
121121
u64 pci_io_start_addr;
122122
u64 pci_io_end_addr;
123123
u64 pci_config_addr;
124-
u32 dma_mask_bits;
124+
u16 dma_mask_bits;
125+
u16 dma_noncoherent;
125126
} __packed;
126127

127128
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, wuzhangjin@gmail.com
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)