Message ID | 20200113140705.74605-2-jiaxun.yang@flygoat.com (mailing list archive) |
---|---|
State | Deferred |
Headers | show |
Series | [1/2] MIPS: Define pgprot_dmacoherent according to coherentio status | expand |
Hi Jiaxun, On Mon, Jan 13, 2020 at 10:07:05PM +0800, Jiaxun Yang wrote: > diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h > index 8c286bedff3e..2da2be40ad81 100644 > --- a/arch/mips/include/asm/mach-loongson64/boot_param.h > +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h > @@ -115,7 +115,8 @@ struct irq_source_routing_table { > u64 pci_io_start_addr; > u64 pci_io_end_addr; > u64 pci_config_addr; > - u32 dma_mask_bits; > + u16 dma_mask_bits; > + u16 dma_noncoherent; > } __packed; This struct is generated by the firmware, right? So does this change require that firmware be updated along with the kernel? Or was the kernel's definition always incorrect/incomplete? Thanks, Paul
14.01.2020, 02:52, "Paul Burton" <paulburton89@gmail.com>: > Hi Jiaxun, > > On Mon, Jan 13, 2020 at 10:07:05PM +0800, Jiaxun Yang wrote: >> diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h >> index 8c286bedff3e..2da2be40ad81 100644 >> --- a/arch/mips/include/asm/mach-loongson64/boot_param.h >> +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h >> @@ -115,7 +115,8 @@ struct irq_source_routing_table { >> u64 pci_io_start_addr; >> u64 pci_io_end_addr; >> u64 pci_config_addr; >> - u32 dma_mask_bits; >> + u16 dma_mask_bits; >> + u16 dma_noncoherent; >> } __packed; > > This struct is generated by the firmware, right? So does this change > require that firmware be updated along with the kernel? Or was the > kernel's definition always incorrect/incomplete? Hi Paul, This define added to the firmware by 2013 but somehow never upstream. That's what Loongson always doing. Some versions of Loongson-3B1500 failed to maintain DMA coherent. So they add this parameter to the firmware. As the maximum dma_mask_bits is 64, the upper 16bit of the old u32 will always be zero. Which means coherent DMA transformed into the new definition, that's the expected default behavior. Thus it's safe to do so even if firmware doesn't understand this parameter. Thanks > > Thanks, > Paul -- Jiaxun
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index d0b727daddb3..8b0cd692a43f 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -474,6 +474,7 @@ config MACH_LOONGSON64 select CSRC_R4K select CEVT_R4K select CPU_HAS_WB + select DMA_MAYBE_COHERENT select FORCE_PCI select ISA select I8259 diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 8c286bedff3e..2da2be40ad81 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -115,7 +115,8 @@ struct irq_source_routing_table { u64 pci_io_start_addr; u64 pci_io_end_addr; u64 pci_config_addr; - u32 dma_mask_bits; + u16 dma_mask_bits; + u16 dma_noncoherent; } __packed; struct interface_info { @@ -206,7 +207,7 @@ struct loongson_system_configuration { u64 poweroff_addr; u64 suspend_addr; u64 vgabios_addr; - u32 dma_mask_bits; + u16 dma_mask_bits; char ecname[32]; u32 nr_uarts; struct uart_device uarts[MAX_UARTS]; diff --git a/arch/mips/loongson64/env.c b/arch/mips/loongson64/env.c index 0daeb7bcf023..61e3d4874fe9 100644 --- a/arch/mips/loongson64/env.c +++ b/arch/mips/loongson64/env.c @@ -15,6 +15,7 @@ */ #include <linux/export.h> #include <asm/bootinfo.h> +#include <asm/dma-coherence.h> #include <loongson.h> #include <boot_param.h> #include <workarounds.h> @@ -128,6 +129,9 @@ void __init prom_init_env(void) loongson_sysconf.dma_mask_bits > 64) loongson_sysconf.dma_mask_bits = 32; + hw_coherentio = !eirq_source->dma_noncoherent; + pr_info("Firmware I/O coherency: %s\n", hw_coherentio?"ON":"OFF"); + loongson_sysconf.restart_addr = boot_p->reset_system.ResetWarm; loongson_sysconf.poweroff_addr = boot_p->reset_system.Shutdown; loongson_sysconf.suspend_addr = boot_p->reset_system.DoSuspend;
Set hw_iocoherency according to parameter passed from firmware. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/mips/Kconfig | 1 + arch/mips/include/asm/mach-loongson64/boot_param.h | 5 +++-- arch/mips/loongson64/env.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-)