From patchwork Wed Jun 7 20:04:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 9772755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EEE260393 for ; Wed, 7 Jun 2017 20:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F515284EA for ; Wed, 7 Jun 2017 20:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 644262852A; Wed, 7 Jun 2017 20:13:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDD3528533 for ; Wed, 7 Jun 2017 20:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751439AbdFGUN5 (ORCPT ); Wed, 7 Jun 2017 16:13:57 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:57796 "EHLO outils.crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751424AbdFGUN4 (ORCPT ); Wed, 7 Jun 2017 16:13:56 -0400 From: Paul Cercueil To: Ralf Baechle , Michael Turquette , Stephen Boyd , Rob Herring Cc: 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: [PATCH 13/15] MIPS: JZ4770: Workaround for corrupted DMA transfers Date: Wed, 7 Jun 2017 22:04:37 +0200 Message-Id: <20170607200439.24450-14-paul@crapouillou.net> In-Reply-To: <20170607200439.24450-1-paul@crapouillou.net> References: <20170607200439.24450-1-paul@crapouillou.net> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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 + if (usermem) { pr_info("User-defined physical RAM map:\n"); print_memory_map();