From patchwork Fri Oct 28 16:47:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13024055 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12FCEECAAA1 for ; Fri, 28 Oct 2022 16:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DqIJ6sL1SP9h/9E8zujxGid3w8KYc6Np4qqcBbBYHqs=; b=X4pX7iAtvcvX+6 2r0mnsL0juqgmubc5hr1o8Kh2U5938RfvdoC7W8PWalV8Xu+KwqmZMkTnydw8MOOxgZoMIi1yMduK LeePRxkkT6uspk5eeOkOW/UupojD+OXl0r6fRuHYiXAy9Mqm1wV/dPzhFppQoddYKFVtTdZZyCZWW Qxd/MEcpqOMglEyPVb84SCPePPRWvwtDSFnwegp3QXNQLrLmOhutQxsyvqMNP79OSXabRgQE54SZi javS/R19wxFTjthl4nWDCEGf2vCOxE/5aDEdc7M8xPiu8DdGWUrdeEitB4+bv9KEH2ONyeguJcLUm 1cI1yKwhynPTVVdyk9OQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYU-0011j4-UR; Fri, 28 Oct 2022 16:50:03 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYR-0010xX-17 for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:50:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QKytlREYiTLpgxfFh35rP21mKKtH4zCnPdMR02CiPB4=; b=tUYLUTBO4ITtmpwmX0vst1lWZZ DVnidmNbD/Q7dg/D0oMx6J93/GV4M4yHYoR8tkpq7920ihF9F+AkLTW5rjFNS9hWIJIt0zPwRzfWJ ufzAIXuYC6yl7KKuRcbvKLwSIW3F9p/cYgZl47J4oYVDBp5pFnr61O+9o6Ap7kxIVrjhHH2TF+rVa t0PTvqd37R1IF3iH4iWuFiptMNoT7phGxK81N6M1dmUp5Hujz+k8q+9lxX5lfLBBfDLHtVuGDmAML gm2Guc6v0yrxAtCMba0DDGai43H5vWv6isL/87B3MwJfJBr4zwuxDPh+czo2GVRqa6DDwxmWyT+Z/ LAX4cMqg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:55688 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooSWP-00006W-OE; Fri, 28 Oct 2022 17:47:53 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooSWP-000FDy-5t; Fri, 28 Oct 2022 17:47:53 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Yury Norov Cc: Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , Linus Torvalds , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/5] ARM: findbit: document ARMv5 bit offset calculation MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 28 Oct 2022 17:47:53 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_094959_086671_FF3DBE7E X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Document the ARMv5 bit offset calculation code. Signed-off-by: Russell King (Oracle) --- arch/arm/lib/findbit.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 7fd3600db8ef..4c584bc4704b 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -172,10 +172,10 @@ ENDPROC(_find_next_bit_be) .L_found: #if __LINUX_ARM_ARCH__ >= 5 rsb r0, r3, #0 - and r3, r3, r0 - clz r3, r3 - rsb r3, r3, #31 - add r0, r2, r3 + and r3, r3, r0 @ mask out lowest bit set + clz r3, r3 @ count high zero bits + rsb r3, r3, #31 @ offset of first set bit + add r0, r2, r3 @ add offset of first set bit #else tst r3, #0x0f addeq r2, r2, #4 From patchwork Fri Oct 28 16:47:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13024056 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF44EECAAA1 for ; Fri, 28 Oct 2022 16:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aWg3gAigeV4nU5r8n8OSxUVZzSJzLUMS7H1OEXsm/iU=; b=dbmRBpOf8dvmq5 VbyZhD2Xdcw4eyZ7Yz7j9BLbqCVDSFIHjENy5PR3JZQAN4dNtsg53+TaWMnWNzdyU6EuXHMe0k5yz zeviwJf0z9rOdiGy6Je85ZdNAf5KzdZRkip81wNWA64Sn1qjU85eEKLvhr8Hr/U+9HVw0fjwY2r5Q z6IXRwf0GrCEWyZ+nI5qZD4Z/accvuGefDurko+OYp67FvswYjPh+4KSni1PjJglXsy/6gSQR74fu XCz/n64qRYCiFJnyJ0NBjKPDowlcKZQ+HRgBdubSbdPAx2k1iI2lT1eZDfWT8sMaGdje5v9+dt7DP uhpYnW1Dr3rC9yRMDFTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYi-0011oO-IZ; Fri, 28 Oct 2022 16:50:16 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYV-0010zS-AN for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:50:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=noL9/NeDUTGkTM9TkwKb+qB4g92MFSxxMDGz/3I26JY=; b=tTloeFQWZ0uoDO5GJamaoriva2 cIFPvVdZJsD4tqdlzlbICcPKZ7oX/ZY+D14hvxMfOE+WoHtE30EY66VVrh/WS/z13sIo3uWCMbyhm QFC5lsr6yq8M4lpXjTYjcE3JU8CqnfGeT5tHIKgpxxDcVg2Ghhh3Tym6zM4wrXQcWLclX501T6R3a mTs50+ZSY4ziba5+FuQlDKf2TEPIf9Ma+dnc18tsVY8VcD2LA+scbJScXjkglrg8bvjKMuh6tkJlc 3+QIcPkgxg85h+O+Pp1gzgO67hoiR1tQ1WjteSZI3bKACJ8dzRr1Q5+RLw2WitLDyWA4d7OGa9Dn7 bHS7g84Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:55696 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooSWU-00006h-RW; Fri, 28 Oct 2022 17:47:58 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooSWU-000FE4-9D; Fri, 28 Oct 2022 17:47:58 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Yury Norov Cc: Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , Linus Torvalds , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/5] ARM: findbit: provide more efficient ARMv7 implementation MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 28 Oct 2022 17:47:58 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_095003_391050_2E25707D X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide a more efficient ARMv7 implementation to determine the first set bit in the supplied value. Signed-off-by: Russell King (Oracle) --- arch/arm/lib/findbit.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 4c584bc4704b..256e095d490b 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -170,7 +170,11 @@ ENDPROC(_find_next_bit_be) * One or more bits in the LSB of r3 are assumed to be set. */ .L_found: -#if __LINUX_ARM_ARCH__ >= 5 +#if __LINUX_ARM_ARCH__ >= 7 + rbit r3, r3 @ reverse bits + clz r3, r3 @ count high zero bits + add r0, r2, r3 @ add offset of first set bit +#elif __LINUX_ARM_ARCH__ >= 5 rsb r0, r3, #0 and r3, r3, r0 @ mask out lowest bit set clz r3, r3 @ count high zero bits From patchwork Fri Oct 28 16:48:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13024057 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E324ECAAA1 for ; Fri, 28 Oct 2022 16:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bl2x9Rzx9EF6fbSxm7jN6IegLqbxg99aBWqj9Z8U+fQ=; b=eFGzeckyQagJ20 qunTfZ563yN+tY2X+yaVtPbJJuSiY/gbe7EZgF4W77Dla5rjZhc215Xm9tvK/2bgSyuAXFWHGc8vN jQho87brNEA8c9irASIHNqzC2G2gXvlV8AzH8uN2BnwbtfJuXkfuU6ttxuxuos1nljFyEeB9jz7GZ 8u7qAdbRWLrWplke4RuFeq8OTv64OKI4lqzzWN5zDwTv8aA1T+SSzWaQbZwiLd9e6URfuL1dFJEY7 11N7qkHRyhuuYmN+vUBuCfsSbM//OBxZmTRtzEmIQ3rqbDa00cdIQ/f4XFgnnL2Bkrh0Cywo+ig9B Fk3CbQuHNf9E4+TlvTXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYv-0011s8-GP; Fri, 28 Oct 2022 16:50:29 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYa-00111h-9m for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:50:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WkDjf+3IQgCyMglzhEzUvxitZ2xNrXhv5I3AR6iDziY=; b=M/Gbjsk9bvCVCw0Chxu+P8YgKs GaYtSL13ilKICTNDPb8tJ4/atXRKoeph3SLC8sixyssIPvIoQcXbbHQBdHo9xHp2tuikvozlov+QS U4g9MXMyB6nFkk6GRR7Sy4LQAswi9CxnUr+cwup5sG4I1qwIbjrd8y9nA5xcAXk4TZ4Zq5jCZoW4A Wz9uHo+PTHBsoXU2wnS8pkctAY1FZUYMdsErxsA8sn4NYeN8NaPsMxQCRgM5AVmHmhbuZGzfEpDaV AaseJ2fuTdmFPu1WTp5Z+WDeF5Bp26fgtkJGzTsl4R5/KQD7WQXJihwKRmvQOpg5tcnAgtAChjsu6 z9qUjezw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33780 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooSWZ-00006s-W3; Fri, 28 Oct 2022 17:48:04 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooSWZ-000FEA-CU; Fri, 28 Oct 2022 17:48:03 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Yury Norov Cc: Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , Linus Torvalds , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] ARM: findbit: convert to macros MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 28 Oct 2022 17:48:03 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_095008_384615_AC40D975 X-CRM114-Status: GOOD ( 12.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since the pairs of _find_first and _find_next functions are pretty similar, use macros to generate this code. This commit does not change the generated code. Signed-off-by: Russell King (Oracle) --- arch/arm/lib/findbit.S | 158 +++++++++++------------------------------ 1 file changed, 42 insertions(+), 116 deletions(-) diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 256e095d490b..8280f66d38a5 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -14,155 +14,81 @@ #include .text -/* - * Purpose : Find a 'zero' bit - * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit); - */ -ENTRY(_find_first_zero_bit_le) - teq r1, #0 + .macro find_first, endian, set, name +ENTRY(_find_first_\name\()bit_\endian) + teq r1, #0 beq 3f mov r2, #0 1: + .ifc \endian, be + eor r3, r2, #0x18 + ARM( ldrb r3, [r0, r3, lsr #3] ) + THUMB( lsr r3, #3 ) + THUMB( ldrb r3, [r0, r3] ) + .else ARM( ldrb r3, [r0, r2, lsr #3] ) THUMB( lsr r3, r2, #3 ) THUMB( ldrb r3, [r0, r3] ) + .endif + .ifeq \set eors r3, r3, #0xff @ invert bits + .else + movs r3, r3 + .endif bne .L_found @ any now set - found zero bit add r2, r2, #8 @ next bit pointer 2: cmp r2, r1 @ any more? blo 1b 3: mov r0, r1 @ no free bits ret lr -ENDPROC(_find_first_zero_bit_le) +ENDPROC(_find_first_\name\()bit_\endian) + .endm -/* - * Purpose : Find next 'zero' bit - * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset) - */ -ENTRY(_find_next_zero_bit_le) + .macro find_next, endian, set, name +ENTRY(_find_next_\name\()bit_\endian) cmp r2, r1 bhs 3b ands ip, r2, #7 beq 1b @ If new byte, goto old routine + .ifc \endian, be + eor r3, r2, #0x18 + ARM( ldrb r3, [r0, r3, lsr #3] ) + THUMB( lsr r3, #3 ) + THUMB( ldrb r3, [r0, r3] ) + .else ARM( ldrb r3, [r0, r2, lsr #3] ) THUMB( lsr r3, r2, #3 ) THUMB( ldrb r3, [r0, r3] ) + .endif + .ifeq \set eor r3, r3, #0xff @ now looking for a 1 bit + .endif movs r3, r3, lsr ip @ shift off unused bits bne .L_found orr r2, r2, #7 @ if zero, then no bits here add r2, r2, #1 @ align bit pointer b 2b @ loop for next bit -ENDPROC(_find_next_zero_bit_le) +ENDPROC(_find_next_\name\()bit_\endian) + .endm -/* - * Purpose : Find a 'one' bit - * Prototype: int find_first_bit(const unsigned long *addr, unsigned int maxbit); - */ -ENTRY(_find_first_bit_le) - teq r1, #0 - beq 3f - mov r2, #0 -1: - ARM( ldrb r3, [r0, r2, lsr #3] ) - THUMB( lsr r3, r2, #3 ) - THUMB( ldrb r3, [r0, r3] ) - movs r3, r3 - bne .L_found @ any now set - found zero bit - add r2, r2, #8 @ next bit pointer -2: cmp r2, r1 @ any more? - blo 1b -3: mov r0, r1 @ no free bits - ret lr -ENDPROC(_find_first_bit_le) + .macro find_bit, endian, set, name + find_first \endian, \set, \name + find_next \endian, \set, \name + .endm -/* - * Purpose : Find next 'one' bit - * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset) - */ -ENTRY(_find_next_bit_le) - cmp r2, r1 - bhs 3b - ands ip, r2, #7 - beq 1b @ If new byte, goto old routine - ARM( ldrb r3, [r0, r2, lsr #3] ) - THUMB( lsr r3, r2, #3 ) - THUMB( ldrb r3, [r0, r3] ) - movs r3, r3, lsr ip @ shift off unused bits - bne .L_found - orr r2, r2, #7 @ if zero, then no bits here - add r2, r2, #1 @ align bit pointer - b 2b @ loop for next bit -ENDPROC(_find_next_bit_le) +/* _find_first_zero_bit_le and _find_next_zero_bit_le */ + find_bit le, 0, zero_ -#ifdef __ARMEB__ +/* _find_first_bit_le and _find_next_bit_le */ + find_bit le, 1 -ENTRY(_find_first_zero_bit_be) - teq r1, #0 - beq 3f - mov r2, #0 -1: eor r3, r2, #0x18 @ big endian byte ordering - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) - eors r3, r3, #0xff @ invert bits - bne .L_found @ any now set - found zero bit - add r2, r2, #8 @ next bit pointer -2: cmp r2, r1 @ any more? - blo 1b -3: mov r0, r1 @ no free bits - ret lr -ENDPROC(_find_first_zero_bit_be) +#ifdef __ARMEB__ -ENTRY(_find_next_zero_bit_be) - cmp r2, r1 - bhs 3b - ands ip, r2, #7 - beq 1b @ If new byte, goto old routine - eor r3, r2, #0x18 @ big endian byte ordering - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) - eor r3, r3, #0xff @ now looking for a 1 bit - movs r3, r3, lsr ip @ shift off unused bits - bne .L_found - orr r2, r2, #7 @ if zero, then no bits here - add r2, r2, #1 @ align bit pointer - b 2b @ loop for next bit -ENDPROC(_find_next_zero_bit_be) +/* _find_first_zero_bit_be and _find_next_zero_bit_be */ + find_bit be, 0, zero_ -ENTRY(_find_first_bit_be) - teq r1, #0 - beq 3f - mov r2, #0 -1: eor r3, r2, #0x18 @ big endian byte ordering - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) - movs r3, r3 - bne .L_found @ any now set - found zero bit - add r2, r2, #8 @ next bit pointer -2: cmp r2, r1 @ any more? - blo 1b -3: mov r0, r1 @ no free bits - ret lr -ENDPROC(_find_first_bit_be) - -ENTRY(_find_next_bit_be) - cmp r2, r1 - bhs 3b - ands ip, r2, #7 - beq 1b @ If new byte, goto old routine - eor r3, r2, #0x18 @ big endian byte ordering - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) - movs r3, r3, lsr ip @ shift off unused bits - bne .L_found - orr r2, r2, #7 @ if zero, then no bits here - add r2, r2, #1 @ align bit pointer - b 2b @ loop for next bit -ENDPROC(_find_next_bit_be) +/* _find_first_bit_be and _find_next_bit_be */ + find_bit be, 1 #endif From patchwork Fri Oct 28 16:48:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13024058 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3066ECAAA1 for ; Fri, 28 Oct 2022 16:52:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XAkYtEkXjJLssmNy4lcbdTRcp1O9kFyeNGE6f8kS0oc=; b=PV6LrXhMLoxPNi 46z3P0r6MqHHiMvffGkFNxSSswfYBy6tzCqXNr0FTZcX17Lpem6ubdfEyB7xlDEm4N1SLvOFtFeuw EcsVuoiPGfETP5uCJ/a7vAwhor0vh1luJrfIfXl4sGpnfG+ycICCjgK4+PILHvI1aHoi00adcwyPM 1Mp5HsZfvDKztF+LJ6AnRm0OLmRDgrBmANrXUtDP5m8648wM4O1BujSHHCc9gFSI6j3wFfkktDj50 ga4UetqMoefkdNYfSoo7EUbhO+F5l2y2EuUeTq5scrJ6GoRR0anbYVEtNEhr84NneUUu+LQcT77gj MqiDn1ZzyXh+C/w7Ss7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSZD-0011yr-Hf; Fri, 28 Oct 2022 16:50:47 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYg-00114U-Mm for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:50:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=awLfhDYQKzr/5OLyGPM7CZguAgBNbZFtXaI32A3EvdI=; b=CO64jMczJw9bQw0Y3YstvDrriM M+W8fedhsaHxOfUSNWbJRsCBF9rAcxapIXf0Q+k955dpSOJDszQvU5HVXUWsWrkqzWJPK/g+/1k1i Z/3VObBwbMlz4Lj+7cCoKw3nsxnl7kWr15DLtET6C/fi3XOKJMgvZy5cHD1dz6pPzhukAgG/TZBMO x8EinmXLmk2YovZTrFKXEMB1CwzP1DSWAKLqosYnUJ4EBn10Efc57gXrVpn2e2HqO12vEjSyeu3zt Gfl/JjOzUvA9f27nbL2i0gtTAz5259q+dubis4/J1EQZQqAkFhxMBc7SgruCIV5YHCukHdTjHpZAJ BB0OGYoA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33794 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooSWf-000073-2Y; Fri, 28 Oct 2022 17:48:09 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooSWe-000FEG-G7; Fri, 28 Oct 2022 17:48:08 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Yury Norov Cc: Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , Linus Torvalds , linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] ARM: findbit: operate by words MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 28 Oct 2022 17:48:08 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_095014_791262_85861A19 X-CRM114-Status: GOOD ( 12.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Convert the implementations to operate on words rather than bytes which makes bitmap searching faster. Signed-off-by: Russell King (Oracle) --- arch/arm/include/asm/assembler.h | 6 +++ arch/arm/lib/findbit.S | 78 ++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h index 90fbe4a3f9c8..28e18f79c300 100644 --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -761,6 +761,12 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) .endif .endm + .if __LINUX_ARM_ARCH__ < 6 + .set .Lrev_l_uses_tmp, 1 + .else + .set .Lrev_l_uses_tmp, 0 + .endif + /* * bl_r - branch and link to register * diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 8280f66d38a5..6ec584d16d46 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -14,32 +14,32 @@ #include .text +#ifdef __ARMEB__ +#define SWAB_ENDIAN le +#else +#define SWAB_ENDIAN be +#endif + .macro find_first, endian, set, name ENTRY(_find_first_\name\()bit_\endian) teq r1, #0 beq 3f mov r2, #0 -1: - .ifc \endian, be - eor r3, r2, #0x18 - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) +1: ldr r3, [r0], #4 + .ifeq \set + mvns r3, r3 @ invert/test bits .else - ARM( ldrb r3, [r0, r2, lsr #3] ) - THUMB( lsr r3, r2, #3 ) - THUMB( ldrb r3, [r0, r3] ) + movs r3, r3 @ test bits .endif - .ifeq \set - eors r3, r3, #0xff @ invert bits + .ifc \endian, SWAB_ENDIAN + bne .L_found_swab .else - movs r3, r3 + bne .L_found @ found the bit? .endif - bne .L_found @ any now set - found zero bit - add r2, r2, #8 @ next bit pointer + add r2, r2, #32 @ next index 2: cmp r2, r1 @ any more? blo 1b -3: mov r0, r1 @ no free bits +3: mov r0, r1 @ no more bits ret lr ENDPROC(_find_first_\name\()bit_\endian) .endm @@ -48,24 +48,25 @@ ENDPROC(_find_first_\name\()bit_\endian) ENTRY(_find_next_\name\()bit_\endian) cmp r2, r1 bhs 3b - ands ip, r2, #7 - beq 1b @ If new byte, goto old routine - .ifc \endian, be - eor r3, r2, #0x18 - ARM( ldrb r3, [r0, r3, lsr #3] ) - THUMB( lsr r3, #3 ) - THUMB( ldrb r3, [r0, r3] ) - .else - ARM( ldrb r3, [r0, r2, lsr #3] ) - THUMB( lsr r3, r2, #3 ) - THUMB( ldrb r3, [r0, r3] ) + mov ip, r2, lsr #5 @ word index + add r0, r0, ip, lsl #2 + ands ip, r2, #31 @ bit position + beq 1b + ldr r3, [r0], #4 + .ifeq \set + mvn r3, r3 @ invert bits + .endif + .ifc \endian, SWAB_ENDIAN + rev_l r3, ip + .if .Lrev_l_uses_tmp + @ we need to recompute ip because rev_l will have overwritten + @ it. + and ip, r2, #31 @ bit position .endif - .ifeq \set - eor r3, r3, #0xff @ now looking for a 1 bit .endif movs r3, r3, lsr ip @ shift off unused bits bne .L_found - orr r2, r2, #7 @ if zero, then no bits here + orr r2, r2, #31 @ no zero bits add r2, r2, #1 @ align bit pointer b 2b @ loop for next bit ENDPROC(_find_next_\name\()bit_\endian) @@ -95,6 +96,8 @@ ENDPROC(_find_next_\name\()bit_\endian) /* * One or more bits in the LSB of r3 are assumed to be set. */ +.L_found_swab: + rev_l r3, ip .L_found: #if __LINUX_ARM_ARCH__ >= 7 rbit r3, r3 @ reverse bits @@ -107,13 +110,20 @@ ENDPROC(_find_next_\name\()bit_\endian) rsb r3, r3, #31 @ offset of first set bit add r0, r2, r3 @ add offset of first set bit #else - tst r3, #0x0f + mov ip, #~0 + tst r3, ip, lsr #16 @ test bits 0-15 + addeq r2, r2, #16 + moveq r3, r3, lsr #16 + tst r3, #0x00ff + addeq r2, r2, #8 + moveq r3, r3, lsr #8 + tst r3, #0x000f addeq r2, r2, #4 - movne r3, r3, lsl #4 - tst r3, #0x30 + moveq r3, r3, lsr #4 + tst r3, #0x0003 addeq r2, r2, #2 - movne r3, r3, lsl #2 - tst r3, #0x40 + moveq r3, r3, lsr #2 + tst r3, #0x0001 addeq r2, r2, #1 mov r0, r2 #endif From patchwork Fri Oct 28 16:48:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13024059 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24551ECAAA1 for ; Fri, 28 Oct 2022 16:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pWG7CjW5eugSAgcQcMayDy216QRm91oBLXS3h1k2ngI=; b=lYNOQkatOvS4Ae 5gF+QMh5Ia0Waa7a7rzouttsVyGAQmVE3N+b6FkvXaZZJnHLpHNx+bsazSoWvpUEvFRCbcpdnibif 6bDgnS3VT2rBqmNbXt8yjCeUknooQ+dWeT2BAanGmehpAAVxFmXD2aFPpep4zoZvzKGladHXM2kgR tn/9iXnfVmgNTQ+KANrbi4SQ7TeGo6e9AdCvsyAreDS0iOcj/Eoi38q+qCjEFMuHdqhADiTF/FQOD tU0gEGXrGMfamF07h185NtlcppAM4Rsiz6FEX4K66Mlh1gKIYPanooyTk3VqxDFpZ5mlj0VDakOhZ bLhFQragfyt32fwdBchg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSZU-00126c-50; Fri, 28 Oct 2022 16:51:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ooSYk-00115u-9f for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2022 16:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OhpOuWjeen7QG1He6lXTiBfyZaGo2Ecqc0tyM0FhmYY=; b=v89NSJvDt4HVfbfHi/VcP+62QL Ofplk8KUS2qWPd42RjzNexz3DmjfBpg8PzD9c2v5GuTPyzMoFy44N3/Jv78HT3WE/uiilcEzYHUxQ o1oc4SaoCnGcCwSKBoeIw6NMgj5gLP3EJ5lWbz+FDcU8raSg+IWRv/Bziz+7+wfnXvw4TVpS0MdY1 dtIXLR7Od74TtK6+5kQwWuxtbmXh6HJQPaSWikgd4+0OgyQt0R6KNE0swC+qYMfsPZstYOk6ais83 WwVSMXbUj2Pn3UJaAtcO0IJKnUV+0HGqa9qnyzPNaC56T8Hyd/CkW2lWmXgE8Qn/KGoPmb7VL5vq7 q/JkKMIg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:40014 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ooSWk-00007E-6D; Fri, 28 Oct 2022 17:48:14 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1ooSWj-000FEM-Jl; Fri, 28 Oct 2022 17:48:13 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Yury Norov Cc: Catalin Marinas , Mark Rutland , Will Deacon , Linux Kernel Mailing List , Linus Torvalds , linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/5] ARM: findbit: add unwinder information MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Fri, 28 Oct 2022 17:48:13 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221028_095018_360620_A381EBC4 X-CRM114-Status: GOOD ( 10.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add unwinder information so oops in the findbit functions can create a proper backtrace. Signed-off-by: Russell King (Oracle) --- arch/arm/lib/findbit.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S index 6ec584d16d46..b7ac2d3c0748 100644 --- a/arch/arm/lib/findbit.S +++ b/arch/arm/lib/findbit.S @@ -12,6 +12,7 @@ */ #include #include +#include .text #ifdef __ARMEB__ @@ -22,6 +23,7 @@ .macro find_first, endian, set, name ENTRY(_find_first_\name\()bit_\endian) + UNWIND( .fnstart) teq r1, #0 beq 3f mov r2, #0 @@ -41,11 +43,13 @@ ENTRY(_find_first_\name\()bit_\endian) blo 1b 3: mov r0, r1 @ no more bits ret lr + UNWIND( .fnend) ENDPROC(_find_first_\name\()bit_\endian) .endm .macro find_next, endian, set, name ENTRY(_find_next_\name\()bit_\endian) + UNWIND( .fnstart) cmp r2, r1 bhs 3b mov ip, r2, lsr #5 @ word index @@ -69,6 +73,7 @@ ENTRY(_find_next_\name\()bit_\endian) orr r2, r2, #31 @ no zero bits add r2, r2, #1 @ align bit pointer b 2b @ loop for next bit + UNWIND( .fnend) ENDPROC(_find_next_\name\()bit_\endian) .endm @@ -97,6 +102,7 @@ ENDPROC(_find_next_\name\()bit_\endian) * One or more bits in the LSB of r3 are assumed to be set. */ .L_found_swab: + UNWIND( .fnstart) rev_l r3, ip .L_found: #if __LINUX_ARM_ARCH__ >= 7 @@ -130,4 +136,4 @@ ENDPROC(_find_next_\name\()bit_\endian) cmp r1, r0 @ Clamp to maxbit movlo r0, r1 ret lr - + UNWIND( .fnend)