From patchwork Mon Nov 27 12:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1868746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Zio57iFn; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=meS57G6q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Sf4tB0hCFz1ySP for ; Mon, 27 Nov 2023 23:40:01 +1100 (AEDT) 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:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=W69M42r4AZB3gkMzPK6WFfWdBFha6/ISMXpzG4x92oc=; b=Zio57iFnNLCI3V YMqREUjQiRr3G+K7BxWeeiPRgJpVTFIWWS0ogNa1zbSDXxlPwz05u6crOe5uz5/pQz0npvFYfagYm bx9kgZb8coHXL/3fmuPOBn4HqFF/6fydtKlzxFs/hZqejmJLCbWWggNQkFm2Dh/rkXQ7QzVHFY9gv Z2l8S9weN+K9FpF9lwHb1PT7eRzshCtYkHNY2YI6H3cIEg4pjgMqBMf4qxeD3+aXTqe5pHYh5k4yN S0T9irRG7AdWCDgMyEcbCemL7Qaqj5tmKZlAsz3tbs6ZnPRLf0SM6TpQkgOeP+OLrkBiQa5kiTMOM dcswxQXJZU9D+1XmtMLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7atw-002TDw-2u; Mon, 27 Nov 2023 12:39:48 +0000 Received: from m126.mail.126.com ([220.181.12.37]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7att-002TCy-1F for opensbi@lists.infradead.org; Mon, 27 Nov 2023 12:39:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=IaL2s 45m/uP5ZTWcas6sOnn3/7hscFwSG2jjQg19XjA=; b=meS57G6q+/GbotxmkIewO kkVqRI3I9kb6AiCgplLU599+GSsDLjwUzk+E2c27uUXlPvtmLr20Cdjjy/Up+2pD nIRwewtXzZML7bu3YyOzFZOvgFpeKYdiplrtkX6kC90vNyEzxHiFBJVEMttOaRav z4OHfcJPB9jWWq1YF+AH70= Received: from T490.lan (unknown [112.83.182.199]) by zwqz-smtp-mta-g4-0 (Coremail) with SMTP id _____wD3PucIjmRlHXaMDA--.7662S2; Mon, 27 Nov 2023 20:39:38 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH] lib: sbi: Improve sbi_hsm_hart_interruptible_mask Date: Mon, 27 Nov 2023 20:39:11 +0800 Message-ID: <20231127123933.48851-1-wxjstz@126.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CM-TRANSID: _____wD3PucIjmRlHXaMDA--.7662S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XFWfuFW3ZFy3KFWkXF13Jwb_yoWDJFc_Aa yxAa4FgrsxXrZ8tw1Ygw4rArWv9ws0g34agF18tayDWrs2yw45G3W8JFWDJrWDuw45Ar93 Gry3JFnakryagjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sREEdgtUUUUU== X-Originating-IP: [112.83.182.199] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdQY1OmSdLnd8OgABsb X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231127_043945_834355_433AEC15 X-CRM114-Status: UNSURE ( 6.32 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Improve bit scanning with for_each_set_bit. Signed-off-by: Xiang W --- lib/sbi/sbi_hsm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 147f954..bffac27 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -114,22 +114,18 @@ int sbi_hsm_hart_interruptible_mask(const struct [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Improve bit scanning with for_each_set_bit. Signed-off-by: Xiang W --- lib/sbi/sbi_hsm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 147f954..bffac27 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -114,22 +114,18 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom, ulong hbase, ulong *out_hmask) { int hstate; - ulong i, hmask, dmask; + ulong i, dmask; *out_hmask = 0; if (!sbi_hartid_valid(hbase)) return SBI_EINVAL; dmask = sbi_domain_get_assigned_hartmask(dom, hbase); - for (i = 0; i < BITS_PER_LONG; i++) { - hmask = 1UL << i; - if (!(dmask & hmask)) - continue; - + for_each_set_bit(i, &dmask, BITS_PER_LONG) { hstate = __sbi_hsm_hart_get_state(hbase + i); if (hstate == SBI_HSM_STATE_STARTED || hstate == SBI_HSM_STATE_SUSPENDED) - *out_hmask |= hmask; + *out_hmask |= 1UL << i; } return 0;