Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: stable@vger.kernel.org
Fixes: 71e2f4dd5a65 ("MIPS: Fork loongson2ef from loongson64")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
edc0378e 8f7aa77a

+13 -2
+2
arch/mips/Kconfig
··· 460 460 461 461 config MACH_LOONGSON64 462 462 bool "Loongson 64-bit family of machines" 463 + select ARCH_DMA_DEFAULT_COHERENT 463 464 select ARCH_SPARSEMEM_ENABLE 464 465 select ARCH_MIGHT_HAVE_PC_PARPORT 465 466 select ARCH_MIGHT_HAVE_PC_SERIO ··· 1252 1251 select CPU_SUPPORTS_MSA 1253 1252 select CPU_DIEI_BROKEN if !LOONGSON3_ENHANCEMENT 1254 1253 select CPU_MIPSR2_IRQ_VI 1254 + select DMA_NONCOHERENT 1255 1255 select WEAK_ORDERING 1256 1256 select WEAK_REORDERING_BEYOND_LLSC 1257 1257 select MIPS_ASID_BITS_VARIABLE
+2 -1
arch/mips/include/asm/mach-loongson64/boot_param.h
··· 117 117 u64 pci_io_start_addr; 118 118 u64 pci_io_end_addr; 119 119 u64 pci_config_addr; 120 - u32 dma_mask_bits; 120 + u16 dma_mask_bits; 121 + u16 dma_noncoherent; 121 122 } __packed; 122 123 123 124 struct interface_info {
+9 -1
arch/mips/loongson64/env.c
··· 13 13 * Copyright (C) 2009 Lemote Inc. 14 14 * Author: Wu Zhangjin, wuzhangjin@gmail.com 15 15 */ 16 + 17 + #include <linux/dma-map-ops.h> 16 18 #include <linux/export.h> 17 19 #include <linux/pci_ids.h> 18 20 #include <asm/bootinfo.h> ··· 149 147 150 148 loongson_sysconf.dma_mask_bits = eirq_source->dma_mask_bits; 151 149 if (loongson_sysconf.dma_mask_bits < 32 || 152 - loongson_sysconf.dma_mask_bits > 64) 150 + loongson_sysconf.dma_mask_bits > 64) { 153 151 loongson_sysconf.dma_mask_bits = 32; 152 + dma_default_coherent = true; 153 + } else { 154 + dma_default_coherent = !eirq_source->dma_noncoherent; 155 + } 156 + 157 + pr_info("Firmware: Coherent DMA: %s\n", dma_default_coherent ? "on" : "off"); 154 158 155 159 loongson_sysconf.restart_addr = boot_p->reset_system.ResetWarm; 156 160 loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown;