Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFD9EC433EF for ; Thu, 26 May 2022 14:44:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8DE3F84379; Thu, 26 May 2022 16:44:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=semihalf-com.20210112.gappssmtp.com header.i=@semihalf-com.20210112.gappssmtp.com header.b="l67IaOFn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C392B8437A; Thu, 26 May 2022 16:44:11 +0200 (CEST) Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7283984397 for ; Thu, 26 May 2022 16:39:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=semihalf.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=pan@semihalf.com Received: by mail-lj1-x235.google.com with SMTP id 1so1970271ljp.8 for ; Thu, 26 May 2022 07:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ATg4VlYBUvX1odx8Kx1eE7rqby+Bi4nJLJrbLIlyToU=; b=l67IaOFn1Cso1IF3+rrqJdBZ3PLrccBfD+yuyAmqchvAK5RRL2bwkq1pUjAoVEDjtM b8Y2xZJbMlDZ0N0IsgZ5sc7KEBNhKzpGXtv/KQ8TVIx52qAjekEB204+CC+R8ixjFRcj VtfPXBoY5TOR0JSegcugzDIgtYQv7Dv2P9qNmY9r4MvV7phmjTCUTTBJQBhJ/NQWKAi+ 72fw74iHzxn1hEX6j4ynExktJ0V3cd30bTKVFCFp7mAEDj40sTnO0BVpMkzOLUNt7qMk Bo8HFdepKySlL+BXHWW0d099IY8vAF0y7Kjg8z1KetwokooHP66b/CO24auvSJyS7Pf6 ah8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ATg4VlYBUvX1odx8Kx1eE7rqby+Bi4nJLJrbLIlyToU=; b=yeN8DwNlXEeBiQdBHUXszkue3QXNiDCwEoWwsVijJZHzovZmwOmaJVQjck76KQHgnd Rwe1mLjiVi3daS31injrqkprG7oyH7lFhQfUhWnlOpm9QqUlKiYyPu+kwZ+ZIpAaSWV9 yDXLlv0cxaalOhf+wq2/7w1g5dhLgFAPQ1Wj5WpH5S0sPIfR1Bity16ae9MKVqlaKlAX UsZ9fCo00foqnqtzxorljAHSxEuGGIbcOItJWW4ZvKpbQsOFIK1rkey2P4Z5haC235tM or5kkRIeQpf0pXcYWf6AfcMGFJwZNWu9EF0SKFfjLIlKnVuYoQgGP20LGh9wTpD7oN7x 3VDg== X-Gm-Message-State: AOAM533yFO2t/bv0yssAdw20sKU+lWrTR1JitvLBckmC6DV55g7J6pK8 +INedk2f0o/dbsP/ciA/WpPLUg== X-Google-Smtp-Source: ABdhPJxp0/ZdHB1DnXmaly169u2/uabGfOm6FqJgd8ym0aNklJFPhWaqBGmuK6wtt+RB/JXqh2v6yA== X-Received: by 2002:a2e:94c9:0:b0:24a:fe13:ce04 with SMTP id r9-20020a2e94c9000000b0024afe13ce04mr22579728ljh.52.1653575884472; Thu, 26 May 2022 07:38:04 -0700 (PDT) Received: from panikiel.wifi.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id s28-20020a05651c049c00b0024f3d1daea2sm464194ljc.42.2022.05.26.07.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 07:38:04 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Anikiel?= To: marex@denx.de, simon.k.r.goldschmidt@gmail.com, tien.fong.chee@intel.com, michal.simek@xilinx.com Cc: u-boot@lists.denx.de, sjg@chromium.org, festevam@denx.de, jagan@amarulasolutions.com, andre.przywara@arm.com, narmstrong@baylibre.com, pbrobinson@gmail.com, tharvey@gateworks.com, paul.liu@linaro.org, christianshewitt@gmail.com, adrian.fiergolski@fastree3d.com, marek.behun@nic.cz, wd@denx.de, elly.siew.chin.lim@intel.com, mw@semihalf.com, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH v2 11/11] socfpga: arria10: Allow dcache_enable before relocation Date: Thu, 26 May 2022 16:37:15 +0200 Message-Id: <20220526143715.277342-12-pan@semihalf.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog In-Reply-To: <20220526143715.277342-1-pan@semihalf.com> References: <20220526143715.277342-1-pan@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Before relocating to SDRAM, the ECC is initialized by clearing the whole SDRAM. In order to speed this up, dcache_enable is used (see sdram_init_ecc_bits). Since commit 503eea451903 ("arm: cp15: update DACR value to activate access control"), this no longer works, because running code in OCRAM with the XN bit set causes a page fault. Override dram_bank_mmu_setup to disable XN in the OCRAM and setup DRAM dcache before relocation. Signed-off-by: Paweł Anikiel --- arch/arm/mach-socfpga/misc_arria10.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm/mach-socfpga/misc_arria10.c b/arch/arm/mach-socfpga/misc_arria10.c index 0ed2adfd84..7ce888d197 100644 --- a/arch/arm/mach-socfpga/misc_arria10.c +++ b/arch/arm/mach-socfpga/misc_arria10.c @@ -246,3 +246,29 @@ int qspi_flash_software_reset(void) return 0; } #endif + +void dram_bank_mmu_setup(int bank) +{ + struct bd_info *bd = gd->bd; + u32 start, size; + int i; + + /* If we're still in OCRAM, don't set the XN bit on it */ + if (!(gd->flags & GD_FLG_RELOC)) { + set_section_dcache( + CONFIG_SYS_INIT_RAM_ADDR >> MMU_SECTION_SHIFT, + DCACHE_WRITETHROUGH); + } + + /* + * The default implementation of this function allows the DRAM dcache + * to be enabled only after relocation. However, to speed up ECC + * initialization, we want to be able to enable DRAM dcache before + * relocation, so we don't check GD_FLG_RELOC (this assumes bd->bi_dram + * is set first). + */ + start = bd->bi_dram[bank].start >> MMU_SECTION_SHIFT; + size = bd->bi_dram[bank].size >> MMU_SECTION_SHIFT; + for (i = start; i < start + size; i++) + set_section_dcache(i, DCACHE_DEFAULT_OPTION); +} -- 2.36.1.124.g0e6072fb45-goog