PCIe host controller from Loongson-3B6000/3C6000 and newer revisions of LS7A2000 supports WriteCombine (WUC) now. So detect it via IOCSR dynamically instead of configure it statically. However you can still override the detection result via writecombine=on/off boot parameter. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- arch/loongarch/Kconfig | 16 ---------------- arch/loongarch/include/asm/loongarch.h | 1 + arch/loongarch/kernel/env.c | 5 +++++ arch/loongarch/kernel/setup.c | 7 +------ 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index b5ed4881d3c0..33ece05f1968 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -586,22 +586,6 @@ config ARCH_IOREMAP protection support. However, you can enable LoongArch DMW-based ioremap() for better performance. -config ARCH_WRITECOMBINE - bool "Enable WriteCombine (WUC) for ioremap()" - help - LoongArch maintains cache coherency in hardware, but when paired - with LS7A chipsets the WUC attribute (Weak-ordered UnCached, which - is similar to WriteCombine) is out of the scope of cache coherency - machanism for PCIe devices (this is a PCIe protocol violation, which - may be fixed in newer chipsets). - - This means WUC can only used for write-only memory regions now, so - this option is disabled by default, making WUC silently fallback to - SUC for ioremap(). You can enable this option if the kernel is ensured - to run on hardware without this bug. - - You can override this setting via writecombine=on/off boot parameter. - config ARCH_STRICT_ALIGN bool "Enable -mstrict-align to prevent unaligned accesses" if EXPERT default y diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h index b26d0e1b2634..32e5e7a66702 100644 --- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -1189,6 +1189,7 @@ #define IOCSRF_VM BIT_ULL(11) #define IOCSRF_AVEC BIT_ULL(15) #define IOCSRF_REDIRECT BIT_ULL(16) +#define IOCSRF_WUC BIT_ULL(17) #define LOONGARCH_IOCSR_VENDOR 0x10 diff --git a/arch/loongarch/kernel/env.c b/arch/loongarch/kernel/env.c index c529a14deb18..c1f114cc8faa 100644 --- a/arch/loongarch/kernel/env.c +++ b/arch/loongarch/kernel/env.c @@ -32,6 +32,11 @@ void __init init_environ(void) early_memunmap(cmdline, COMMAND_LINE_SIZE); efi_system_table = fw_arg2; + + if (cpu_has_iocsr) { + wc_enabled = iocsr_read32(LOONGARCH_IOCSR_FEATURES) & IOCSRF_WUC; + pr_info("Hardware WriteCombine detection: %s\n", wc_enabled ? "on" : "off"); + } } static int __init init_cpu_fullname(void) diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index f66f5b6229cc..baa40121de3b 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -165,12 +165,7 @@ static void __init smbios_parse(void) dmi_walk(find_tokens, NULL); } -#ifdef CONFIG_ARCH_WRITECOMBINE -bool wc_enabled = true; -#else -bool wc_enabled = false; -#endif - +bool wc_enabled; EXPORT_SYMBOL(wc_enabled); static int __init setup_writecombine(char *p) -- 2.52.0