From patchwork Fri Aug 27 16:03:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?= X-Patchwork-Id: 1521800 X-Patchwork-Delegate: trini@ti.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; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=Hg2KeFy/; 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 4GxD062l46z9sWd for ; Sat, 28 Aug 2021 07:49:58 +1000 (AEST) 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 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-Disposition: inline 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 */ From patchwork Fri Aug 27 16:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pierre-Cl=C3=A9ment_Tosi?= X-Patchwork-Id: 1521801 X-Patchwork-Delegate: trini@ti.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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=PPwvXn8x; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GxD0L12c5z9sWk for ; Sat, 28 Aug 2021 07:50:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37B6F832CA; Fri, 27 Aug 2021 23:49:54 +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="PPwvXn8x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D5202831DB; Fri, 27 Aug 2021 18:04:17 +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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 0946282BFA for ; Fri, 27 Aug 2021 18:04:15 +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-wr1-x42a.google.com with SMTP id q11so11166751wrr.9 for ; Fri, 27 Aug 2021 09:04:15 -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=HgHvl/nHWYa/1r6gOaaxS3/K1aoifJ/zXhZRzFEmMS4=; b=PPwvXn8xlQrbD/F70xSZpFly0io2r+r1ttMiCK82U6/H6sJ7B6JCWYCJTqC5nrbQVH idAg7H/lXKLh/AkNT/zanUMBAzNKqoZEM0lR2YlXx1UPws11lsKnCO2/cPpscfX8LrRG jL56/NjZmiR8ddmEvltwz/xxPy+yzrOq6kVqwlgS66972xX9b+OFyUAMy89pcuYDdr7k O3LM1tUyG2Yw5bwmEqXXTMe4z0+wfLVihM8lxhCva7S5U8zWLOpMFrujFIDwpeqmfNOK BAl1R/yx9eRh6gY5mBv1Ye2vpWI3r+xDNsvY0hSuLfOEJtl8DShOPdKi4aU5Qd4vKPXw znzg== 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=HgHvl/nHWYa/1r6gOaaxS3/K1aoifJ/zXhZRzFEmMS4=; b=Ar3xAz2VtiuunKW1WdpynCTgEriT4pzqaMvkFQv2ZlpcrZAtWlpIsMdn+nlhxukwpG C+H2xnDznVh2GMCX+HBsz8ZpU5XatdqqT6J9h2yv2rrqFiD+873LZs6jg3lrTzSePcNZ G0Nv/fhbHAzJpw1tOD/jeVWCsXFUtp3UUxtrs7Lork7wIfwoSkzFW3gcXM5xHpw2Xhmn yjhW2OPahEkSwTeGJ3xPgXI21QRV5B6/hOK93JyuP471GbcJ1fupaM2WP4m314b8c6Aj Dm9ZBiVWC3u9QF1TIkS9u2LzLHEHW4PPxVFbsSZHtQ3Xov4W+W2r5eCn838P+sz2bJ8V 56dw== X-Gm-Message-State: AOAM531Wh/EcaA3Z0zEmsxXrTgDy46WdTXXqsphA7hbU0yf6eKHz52+4 5gQ3W+ep7a+S0cGCXWa+Kq3/bpSbQPnXSA== X-Google-Smtp-Source: ABdhPJwwzzzIY1p3HUBRlYFdA1wgH0xQs+9MiqS8JTvpM9+r+nNurf9hdBw7fKl1afsqp2iXvVe7og== X-Received: by 2002:a5d:5107:: with SMTP id s7mr10923518wrt.283.1630080254248; Fri, 27 Aug 2021 09:04:14 -0700 (PDT) Received: from google.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id b62sm1217458wmb.17.2021.08.27.09.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:04:13 -0700 (PDT) Date: Fri, 27 Aug 2021 18:04:10 +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 2/2] armv8/cache.S: Triple with single instruction Message-ID: <20210827160410.pv2ws2ghy66hpodf@google.com> MIME-Version: 1.0 Content-Disposition: inline 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 Replace the current 2-instruction 2-step tripling code by a corresponding single instruction leveraging ARMv8-A's "flexible second operand as a register with optional shift". This has the added benefit (albeit arguably negligible) of reducing the final code size. Fix the comment as the tripled cache level is placed in x12, not x0. Signed-off-by: Pierre-Clément Tosi --- arch/arm/cpu/armv8/cache.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S index aabb3dff61..5051597f6f 100644 --- a/arch/arm/cpu/armv8/cache.S +++ b/arch/arm/cpu/armv8/cache.S @@ -80,8 +80,7 @@ ENTRY(__asm_dcache_all) /* x15 <- return address */ loop_level: - lsl x12, x0, #1 - add x12, x12, x0 /* x0 <- tripled cache level */ + add x12, x0, x0, lsl #1 /* x12 <- tripled cache level */ lsr x12, x10, x12 and x12, x12, #7 /* x12 <- cache type */ cmp x12, #2