Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752493AbdFZNiF (ORCPT ); Mon, 26 Jun 2017 09:38:05 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:51714 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751308AbdFZNiC (ORCPT ); Mon, 26 Jun 2017 09:38:02 -0400 X-Greylist: delayed 346 seconds by postgrey-1.27 at vger.kernel.org; Mon, 26 Jun 2017 09:38:01 EDT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 26 Jun 2017 15:32:12 +0200 From: Paul Cercueil To: Marcin Nowakowski Cc: Ralf Baechle , Michael Turquette , Stephen Boyd , Rob Herring , Paul Burton , Maarten ter Huurne , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, linux-clk@vger.kernel.org Subject: Re: [PATCH v2 15/17] MIPS: JZ4770: Workaround for corrupted DMA transfers In-Reply-To: References: <20170607200439.24450-2-paul@crapouillou.net> <20170620151855.19399-1-paul@crapouillou.net> <20170620151855.19399-15-paul@crapouillou.net> Message-ID: <30175ba3ce2d1bd6f83ccb515f179aec@crapouillou.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2725 Lines: 91 Hi, Le 2017-06-22 09:21, Marcin Nowakowski a écrit : > Hi Paul, Maarten, > > On 20.06.2017 17:18, 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 >> >> 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; >> + } >> +} >> + >> 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 89785600fde4..cccfd7ba89fe 100644 >> --- a/arch/mips/kernel/setup.c >> +++ b/arch/mips/kernel/setup.c >> @@ -838,6 +838,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 >> + > > This part doesn't look good in the platform-agnostic code ... is there > a reason why you wouldn't do that from within plat_mem_setup()? > I agree, but, doing it in plat_mem_setup() is too early, as the 'boot mem map' hasn't been initialized yet then... >> if (usermem) { >> pr_info("User-defined physical RAM map:\n"); >> print_memory_map(); >> > > > Marcin