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 7D2BCC433EF for ; Fri, 17 Jun 2022 10:49:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24E378445C; Fri, 17 Jun 2022 12:48:29 +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 header.i=@semihalf.com header.b="XSYHPELS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B7828445A; Fri, 17 Jun 2022 12:48:25 +0200 (CEST) Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) (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 2BAE384459 for ; Fri, 17 Jun 2022 12:48:23 +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=pan@semihalf.com Received: by mail-lj1-x230.google.com with SMTP id d18so4321305ljc.4 for ; Fri, 17 Jun 2022 03:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8+Axa1Zzfz0vwAJ5d/8M6C0fUjlmFfzYMPCv9Z1lOkg=; b=XSYHPELScqToUW7TNIKi0H6tghnudc88oeDRuKLGvwgT7C2EuewfNlvPbjjXakW9rv 7xY7XgHIkdWAHBjhQ9Lf1vWILPiNjHgfUkAdXEidxLxsggxpOjTsNBl//W8T+SQF68Bj BBed27tRZ1FDJB9Big2Squ7hQIk+hfa1vs3HVUNjIpxJXeb9VRhwppgX4a+g4PyR+N3a hdYwYKPZpbPBfqCcdaZvZ/UBiotElGtyvPioChkuIxaKa44J18BszWfnaD7ilFHFy752 pPCGgwPy27lFNM/zC/FXBUrwjBspCP/IUtLKZ9c0x6RW+bfPWpnJWWg+9cEHMIOuN2sf 30CA== 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=8+Axa1Zzfz0vwAJ5d/8M6C0fUjlmFfzYMPCv9Z1lOkg=; b=Dt7PhHqQuvS8hGgvg90rHsDZl7zTY4poZd/sXtv7YXsEqsTBasZMnRZys5GVgBKCWg 9djoxXbnxB3o2qlR59ktMWYgMNRsroUU04zQJTtpykWCMajtZovMZzN8VQIGKxMFTa9Z 2WFrqYADtAqfb6K2hWtjs0BXxZ1IPkSpY7bce3A+DlzguKQ6rG5Dy+Nirs52RKQ7NBNW IrBT6aRlIHZDRBuUokaJrHd3V9eC1sc1Uc3gIng5JOUhS/dcBhmz3JVuybv9Cv+b6uK0 l/61Tl6VozzKxjtq3IrTT5lft/k9FnMPEk3VFebSRovQQFwOhem5hZBkSUI5/8A54LjB 1oQw== X-Gm-Message-State: AJIora8bfRPFSlg1tyPMFgykSI+y96NcENJ5uFcQU2fAf9NPdk3DT5l4 IzYcLaf2hXkGQF36p5YqIwi9+g== X-Google-Smtp-Source: AGRyM1tjVAGEHCrdpRTotocpfZZet6ZlsKN5+xJaMspTdytxCu6vVSkkDK2ZDv9i12mrRT7fI7RjqA== X-Received: by 2002:a05:651c:239:b0:255:a237:7ebd with SMTP id z25-20020a05651c023900b00255a2377ebdmr4934998ljn.401.1655462882474; Fri, 17 Jun 2022 03:48:02 -0700 (PDT) Received: from panikiel.roam.corp.google.com (staticline-31-182-204-250.toya.net.pl. [31.182.204.250]) by smtp.gmail.com with ESMTPSA id a17-20020ac25e71000000b00479342519e5sm592379lfr.210.2022.06.17.03.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 03:48:01 -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, upstream@semihalf.com, amstan@chromium.org, =?UTF-8?q?Pawe=C5=82=20Anikiel?= Subject: [PATCH v3 11/11] socfpga: arria10: Allow dcache_enable before relocation Date: Fri, 17 Jun 2022 12:47:26 +0200 Message-Id: <20220617104726.158688-12-pan@semihalf.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617104726.158688-1-pan@semihalf.com> References: <20220617104726.158688-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 Reviewed-by: Simon Glass --- 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.476.g0c4daa206d-goog