Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751322AbeABQpR (ORCPT + 1 other); Tue, 2 Jan 2018 11:45:17 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:34541 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbeABQpP (ORCPT ); Tue, 2 Jan 2018 11:45:15 -0500 X-Google-Smtp-Source: ACJfBouy4PLP7SxS/BjeIc7WrQjp25BmtT/yKEpS3H5WDXbIleOY+z5oUbFYKmUdMKQxVnWbxVE4sCrIXID5BHfqDLM= MIME-Version: 1.0 In-Reply-To: <20180102150848.11314-13-paul@crapouillou.net> References: <20180102150848.11314-1-paul@crapouillou.net> <20180102150848.11314-13-paul@crapouillou.net> From: PrasannaKumar Muralidharan Date: Tue, 2 Jan 2018 22:15:14 +0530 Message-ID: Subject: Re: [PATCH v5 13/15] MIPS: JZ4770: Workaround for corrupted DMA transfers To: Paul Cercueil Cc: Ralf Baechle , Maarten ter Huurne , devicetree@vger.kernel.org, open list , linux-mips@linux-mips.org, linux-clk@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Paul, On 2 January 2018 at 20:38, Paul Cercueil wrote: > From: Maarten ter Huurne > > We have seen MMC DMA transfers read corrupted data from SDRAM when > a burst interval ends at physical address 0x10000000. To avoid this > problem, we remove the final page of low memory from the memory map. > > Signed-off-by: Maarten ter Huurne > --- > arch/mips/jz4740/setup.c | 24 ++++++++++++++++++++++++ > arch/mips/kernel/setup.c | 8 ++++++++ > 2 files changed, 32 insertions(+) > > v2: No change > v3: No change > v4: No change > v5: No change > > diff --git a/arch/mips/jz4740/setup.c b/arch/mips/jz4740/setup.c > index afd84ee966e8..6948b133a15d 100644 > --- a/arch/mips/jz4740/setup.c > +++ b/arch/mips/jz4740/setup.c > @@ -23,6 +23,7 @@ > > #include > #include > +#include > #include > > #include > @@ -102,6 +103,29 @@ void __init arch_init_irq(void) > irqchip_init(); > } > > +/* > + * We have seen MMC DMA transfers read corrupted data from SDRAM when a burst > + * interval ends at physical address 0x10000000. To avoid this problem, we > + * remove the final page of low memory from the memory map. > + */ > +void __init jz4770_reserve_unsafe_for_dma(void) > +{ > + int i; > + > + for (i = 0; i < boot_mem_map.nr_map; i++) { > + struct boot_mem_map_entry *entry = boot_mem_map.map + i; > + > + if (entry->type != BOOT_MEM_RAM) > + continue; > + > + if (entry->addr + entry->size != 0x10000000) > + continue; > + > + entry->size -= PAGE_SIZE; > + break; > + } > +} > + Just a wild idea (probably bad too). Changing the memory node in the device tree to skip this physical address would work I think. What is your opinion about that? > static int __init jz4740_machine_setup(void) > { > mips_machine_setup(); > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c > index 85bc601e9a0d..5a2c20145aee 100644 > --- a/arch/mips/kernel/setup.c > +++ b/arch/mips/kernel/setup.c > @@ -879,6 +879,14 @@ static void __init arch_mem_init(char **cmdline_p) > > parse_early_param(); > > +#ifdef CONFIG_MACH_JZ4770 > + if (current_cpu_type() == CPU_JZRISC && > + mips_machtype == MACH_INGENIC_JZ4770) { > + extern void __init jz4770_reserve_unsafe_for_dma(void); > + jz4770_reserve_unsafe_for_dma(); > + } > +#endif > + > if (usermem) { > pr_info("User-defined physical RAM map:\n"); > print_memory_map(); > -- > 2.11.0 > > Thanks, PrasannaKumar