From patchwork Sat Jul 11 22:45:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 1327438 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cvf7Rnq6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B44ln23SSz9sQt for ; Sun, 12 Jul 2020 08:46:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C023B82178; Sun, 12 Jul 2020 00:46:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="cvf7Rnq6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CFA08217D; Sun, 12 Jul 2020 00:46:12 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (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 2EAD881F88 for ; Sun, 12 Jul 2020 00:46:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel.schwierzeck@gmail.com Received: by mail-wr1-x444.google.com with SMTP id s10so9323673wrw.12 for ; Sat, 11 Jul 2020 15:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=st4iy7CQ2tMleZ7N9DpiizdtewfClrPk3gbTjqySGq0=; b=cvf7Rnq6BpH/wQFrOit2erhcMvVcoa4i9wJYM3RTCD9+ehV3ifnq8JiaTLkVM9uWVh vctsJdqWsc7RpL3L+YtHBftql7ouIPjW+XbcOdB5ORHdegQAekHZR4H3RaACEMWlRtPa KXUmDtJAWRrvqhnuS3PhmL5Skvs+CwGVDw0lqav5SH/bwCBRniYyYlED3XfaKc1D5h5G ePU5y4L6iTQqUgWvsisIIbntZnHn1TXmOPR4mPPwLedLGzIpV+kDnchBOXuErfr/Zts/ qfoeSoUZq0uBoBgJgs0qrqVYZrf02veycTjRschf12Xxxu/ha17Q0+5oDOJZbbTiPF32 Po6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=st4iy7CQ2tMleZ7N9DpiizdtewfClrPk3gbTjqySGq0=; b=UwK5Thb9keDdW8qBo/QsszFTtyy9+gTWmNorPpTapu1GNaZf1bGIUvAB/GgdjTedBg OlZqo5w3+rw9r6G2kwgSrBgBT1Bk5UhGFvz8mlQ+a9u/hGmXugRXNwnhOa+VvugaZT0g csNcYsdvHLJ0acItrz6+Gcduwu2gi0X4PM52kqG7tZJHDZQaIBsxQq78HQdG8ZTWgLlg 6TBYSa9dBBLuFVGVOq72ReCXrJozvQBNZvwXMSXrWse4yIzeAkbSoYX9mEQSOTiFuo0X mPqSRqqI56alUHL8Um9WqRQofMKPZucYdnHthiHrI++cxWgsBhC45Z1zXIK/gGGUNea5 9Shw== X-Gm-Message-State: AOAM533DIsqjFQsAoy3hm0TjEIt6dYLhfdErRYS107xP2YI+T6SB/z/a s3p9snTI2yFnLD1QP6BJVzkao53O X-Google-Smtp-Source: ABdhPJyEE4i3g+zctXs6JhPlAGkDQP+y3TOYgGG3UIlJCMirL7Xd9OWpWdloNRMM9oMTvPRCRbTDpQ== X-Received: by 2002:adf:e3c5:: with SMTP id k5mr74142024wrm.121.1594507566509; Sat, 11 Jul 2020 15:46:06 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io ([2001:16b8:559e:4701:4026:74cf:a34a:dfa1]) by smtp.gmail.com with ESMTPSA id r28sm15886860wrr.20.2020.07.11.15.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 15:46:05 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Stefan Roese , Daniel Schwierzeck Subject: [PATCH 2/4] mips: add KSEG1 wrapper for change_k0_cca Date: Sun, 12 Jul 2020 00:45:55 +0200 Message-Id: <20200711224557.612848-3-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200711224557.612848-1-daniel.schwierzeck@gmail.com> References: <20200711224557.612848-1-daniel.schwierzeck@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean change_k0_cca() is called multiple times. Move the code for changing to KSEG1 to a macro to avoid code duplication. Also fix missing change to KSEG1 when changing to CONF_CM_CACHABLE_COW. Signed-off-by: Daniel Schwierzeck Reviewed-by: Stefan Roese Tested-by: Stefan Roese --- arch/mips/lib/cache_init.S | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/arch/mips/lib/cache_init.S b/arch/mips/lib/cache_init.S index cfad1d9c8a..2233d27137 100644 --- a/arch/mips/lib/cache_init.S +++ b/arch/mips/lib/cache_init.S @@ -79,6 +79,21 @@ .set pop .endm + /* + * The changing of Kernel mode cacheability must be done from KSEG1. + * If the code is executing from KSEG0, jump to KSEG1 during the execution + * of change_k0_cca. change_k0_cca itself clears all hazards when returning. + */ + .macro change_k0_cca_kseg1 mode + PTR_LA t0, change_k0_cca + li t1, CPHYSADDR(~0) + and t0, t0, t1 + PTR_LI t1, CKSEG1 + or t0, t0, t1 + li a0, \mode + jalr t0 + .endm + /* * mips_cache_reset - low level initialisation of the primary caches * @@ -317,18 +332,9 @@ l1_init: sync /* - * Enable use of the I-cache by setting Config.K0. The code for this - * must be executed from KSEG1. Jump from KSEG0 to KSEG1 to do this. - * Jump back to KSEG0 after caches are enabled and insert an - * instruction hazard barrier. + * Enable use of the I-cache by setting Config.K0. */ - PTR_LA t0, change_k0_cca - li t1, CPHYSADDR(~0) - and t0, t0, t1 - PTR_LI t1, CKSEG1 - or t0, t0, t1 - li a0, CONF_CM_CACHABLE_NONCOHERENT - jalr.hb t0 + change_k0_cca_kseg1 CONF_CM_CACHABLE_NONCOHERENT /* * then initialize D-cache. @@ -388,9 +394,7 @@ l2_unbypass: beqz t0, 2f /* Change Config.K0 to a coherent CCA */ - PTR_LA t0, change_k0_cca - li a0, CONF_CM_CACHABLE_COW - jalr t0 + change_k0_cca_kseg1 CONF_CM_CACHABLE_COW /* * Join the coherent domain such that the caches of this core are kept