Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D21C432BE for ; Fri, 27 Aug 2021 21:49:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5085C60FD8 for ; Fri, 27 Aug 2021 21:49:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5085C60FD8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6678682EBB; Fri, 27 Aug 2021 23:49:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.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=google.com header.i=@google.com header.b="Hg2KeFy/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1A00831DB; Fri, 27 Aug 2021 18:03:59 +0200 (CEST) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 C371882BFA for ; Fri, 27 Aug 2021 18:03:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ptosi@google.com Received: by mail-wm1-x32a.google.com with SMTP id f9-20020a05600c1549b029025b0f5d8c6cso9601159wmg.4 for ; Fri, 27 Aug 2021 09:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding; bh=Ms0XW+cWKLBlQ0D6I5TpsJfpKyXaoxyLNQFumULYtxM=; b=Hg2KeFy/9J+RS1RniEMCf1hnGM441mYda6qzcNfP76j29VyDORE83kNacWfA+7aALm iiSqRrOh3skOdsZwzaEssaTC0/2ryBfVTaL01Orz4PkGbBh1IIJAtw7pBL09LV9d/PWF OVWkGKx7lgRFNg9NhHjoPu3WmlvLl+VxFmDF5rDhDB2lOR/fwH4kUyuDOuBQp9uxW1PX aq3HmKSlorYzpD5Tab+wMcTNpNNRnxYQfKQOCSepZoEaKRDBqlA79gja/kFFn0O+g0QG n3vOQFIGDk7I6WZUttWpOSOhpfe3NWwFzKnGlfw9vIeUGmlT6AMFAxhaXed2Hr3dJpk+ T5Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=Ms0XW+cWKLBlQ0D6I5TpsJfpKyXaoxyLNQFumULYtxM=; b=s9kAMLOoUQuVhZJVfV69SanQiYcRexKWKw9OF8FMut+qdajGRGWJUFOwJijDMeERa/ TV3Wv/idb9zfefd3HWVDF+cTRVXHlRAdE4JaGIK3eVWVsjwdEYIJYM+UsxE1pS/y4d5R j0kW87VeqGhkMc4osZt1Ujx6Ph3DubVH1vc9pEktht22zxnkgflsTix2p0C18eBhDqCa 3PvTj920G33/edX+HFpM5oIWTIlmwNhn4KNpgOGOAhd6WMDjNQmCnD4ryR64+Yux0+4v RhMjH5NtfBXbT4/6nc4kMUkfJ/8vGyIgVG67QgGiZTVk8S4F3DoCmnvdjnwsIKgB82M+ npyg== X-Gm-Message-State: AOAM5304uWRTD08jPSNE1MKsUtriWiRNAMlXBZFOvlLa8NqaOtlHEZ/m tx8LgV58NHSpull3uKrtdfq5kewYYx+MIQ== X-Google-Smtp-Source: ABdhPJwQM23bDTw0Ei4JLX8SwqTxX/CysYPapDCc/2ek2RW+3CZA6CUPaYKGwvd77nmJvZ+SYUE+RQ== X-Received: by 2002:a7b:c3d8:: with SMTP id t24mr19877872wmj.88.1630080235920; Fri, 27 Aug 2021 09:03:55 -0700 (PDT) Received: from google.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id d9sm6464471wrm.21.2021.08.27.09.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:03:55 -0700 (PDT) Date: Fri, 27 Aug 2021 18:03:45 +0200 From: =?utf-8?Q?Pierre-Cl=C3=A9ment?= Tosi To: u-boot@lists.denx.de Cc: =?utf-8?Q?Pierre-Cl=C3=A9ment?= Tosi , Stephen Warren , Simon Glass Subject: [PATCH 1/2] armv8/cache.S: Read sysreg fields through ubfx Message-ID: <20210827160345.olbtl4jnfzc5rsmr@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 27 Aug 2021 23:49:50 +0200 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.103.2 at phobos.denx.de X-Virus-Status: Clean Improve the file's readability and conciseness by using the appropriate Aarch64 instruction: ubfx (unsigned bitfield extract). This makes the code easier to follow as it directly manipulates the offsets and widths of the fields read from system registers, as they are expressed in the Standard (ARM ARM). This has the added benefit (albeit arguably negligible) of reducing the final code size. Signed-off-by: Pierre-Clément Tosi --- arch/arm/cpu/armv8/cache.S | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S index 443d94c262..aabb3dff61 100644 --- a/arch/arm/cpu/armv8/cache.S +++ b/arch/arm/cpu/armv8/cache.S @@ -27,13 +27,11 @@ ENTRY(__asm_dcache_level) msr csselr_el1, x12 /* select cache level */ isb /* sync change of cssidr_el1 */ mrs x6, ccsidr_el1 /* read the new cssidr_el1 */ - and x2, x6, #7 /* x2 <- log2(cache line size)-4 */ + ubfx x2, x6, #0, #3 /* x2 <- log2(cache line size)-4 */ + ubfx x3, x6, #3, #10 /* x3 <- number of cache ways - 1 */ + ubfx x4, x6, #13, #15 /* x4 <- number of cache sets - 1 */ add x2, x2, #4 /* x2 <- log2(cache line size) */ - mov x3, #0x3ff - and x3, x3, x6, lsr #3 /* x3 <- max number of #ways */ clz w5, w3 /* bit position of #ways */ - mov x4, #0x7fff - and x4, x4, x6, lsr #13 /* x4 <- max number of #sets */ /* x12 <- cache level << 1 */ /* x2 <- line length offset */ /* x3 <- number of cache ways - 1 */ @@ -72,8 +70,7 @@ ENTRY(__asm_dcache_all) mov x1, x0 dsb sy mrs x10, clidr_el1 /* read clidr_el1 */ - lsr x11, x10, #24 - and x11, x11, #0x7 /* x11 <- loc */ + ubfx x11, x10, #24, #3 /* x11 <- loc */ cbz x11, finished /* if loc is 0, exit */ mov x15, lr mov x0, #0 /* start flush at cache level 0 */ @@ -131,8 +128,7 @@ ENDPROC(__asm_invalidate_dcache_all) .pushsection .text.__asm_flush_dcache_range, "ax" ENTRY(__asm_flush_dcache_range) mrs x3, ctr_el0 - lsr x3, x3, #16 - and x3, x3, #0xf + ubfx x3, x3, #16, #4 mov x2, #4 lsl x2, x2, x3 /* cache line size */ @@ -158,7 +154,7 @@ ENDPROC(__asm_flush_dcache_range) .pushsection .text.__asm_invalidate_dcache_range, "ax" ENTRY(__asm_invalidate_dcache_range) mrs x3, ctr_el0 - ubfm x3, x3, #16, #19 + ubfx x3, x3, #16, #4 mov x2, #4 lsl x2, x2, x3 /* cache line size */ -- 2.33.0.259.gc128427fd7-goog -- Pierre