From patchwork Wed Feb 1 15:07:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1735669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=jNMYXgE3; 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=IDN8lp0D; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6QKj5vGpz23gY for ; Thu, 2 Feb 2023 02:08:41 +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:References:In-Reply-To: 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: List-Owner; bh=kmwspJIdit3dbjhACy0ffTxLZUcnkfts5F5z0e8ndQU=; b=jNMYXgE3T6llU4 FttCgbklyDLTD4Dqape/Q+FOhczkBhdw16jHFnepOvWwIp1fLSz7jEwaqo8PEW0c23qJutujH/au7 ngC30URV5IE/whQkprTh0uOWaGsbHu751MYV86kzSUYxMzPzkYuHpimPdqm6iUprggbyHgE2oJzw5 dYPrKWhBpoUn+yt1aTJ23WChuO8eiJlczxBRL9MWxYDWcqBC7PAI6FPudqPJkj/Tn5Qx82jZIns18 HBEOx0SK/EeGMC/c4gFzhDgS9xvXnzyoc7f2WWTDfYwe+PnEY3n3gKLArT/sePX2fxoBviTZfVl2S a9CpnForc4f2NojIwVgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEip-00CaI4-8l; Wed, 01 Feb 2023 15:08:27 +0000 Received: from m126.mail.126.com ([123.126.96.242]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNEim-00CaGg-E7 for opensbi@lists.infradead.org; Wed, 01 Feb 2023 15:08:26 +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=bhdtG w8Wie9Dupk0mlkP2hkMsoNoGRcY6Fk6hoXRPUw=; b=IDN8lp0DP9Ed/HEfnF2vW Qvi9qNxHGckjEQDj5vUryrh4Q90ZHKjqfe5FMCo1kQofVifraE2ZoguPeyIjQjHC 3fkyqlmXHv7t3Ln6mdQiBcezViXpWzfEEVxaETU6Mi2+zNdlQHkKYSpJB51eiZ3p eTIeyovBEmfTUuXBlZo4yY= Received: from x390.lan (unknown [210.22.74.155]) by smtp14 (Coremail) with SMTP id fuRpCgDX3z9lgNpjT6g1Ag--.62276S4; Wed, 01 Feb 2023 23:08:22 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 2/4] lib: sbi: Optimize sbi_ipi Date: Wed, 1 Feb 2023 23:07:54 +0800 Message-Id: <20230201150756.161507-3-wxjstz@126.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230201150756.161507-1-wxjstz@126.com> References: <20230201150756.161507-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: fuRpCgDX3z9lgNpjT6g1Ag--.62276S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr13GFWfCF4fuFy8Xw4UXFb_yoW5JFyUpF yDWFZ0yw4IqryIqasxta1UZa15G3yvqr17WrW7K34xXr4UWFyrCF1fGr1Ut3W5GF9aqa4Y qw4qyryFkFyUArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRQo7_UUUUU= X-Originating-IP: [210.22.74.155] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5AYJOlpEFN80WgAAsq X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_070824_956261_146DE340 X-CRM114-Status: GOOD ( 11.62 ) 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: the original sbI_ipi will be processed by hart by hart, after optimization, send ipi first and finally wait together. Signed-off-by: Xiang W --- lib/sbi/sbi_ipi.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) 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 the original sbI_ipi will be processed by hart by hart, after optimization, send ipi first and finally wait together. Signed-off-by: Xiang W --- lib/sbi/sbi_ipi.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 1bcc2e4..92a33bd 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -31,7 +31,7 @@ static unsigned long ipi_data_off; static const struct sbi_ipi_device *ipi_dev = NULL; static const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX]; -static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, +static int sbi_ipi_update(struct sbi_scratch *scratch, u32 remote_hartid, u32 event, void *data) { int ret; @@ -69,6 +69,18 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_SENT); + return 0; +} + +static int sbi_ipi_sync(struct sbi_scratch *scratch, u32 event) +{ + const struct sbi_ipi_event_ops *ipi_ops; + + if ((SBI_IPI_EVENT_MAX <= event) || + !ipi_ops_array[event]) + return SBI_EINVAL; + ipi_ops = ipi_ops_array[event]; + if (ipi_ops->sync) ipi_ops->sync(scratch); @@ -83,7 +95,7 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) { int rc; - ulong i, m; + ulong i, m, n; struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); @@ -92,19 +104,37 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) if (rc) return rc; m &= hmask; + n = m; - /* Send IPIs */ + /* update IPIs */ for (i = hbase; m; i++, m >>= 1) { if (m & 1UL) - sbi_ipi_send(scratch, i, event, data); + sbi_ipi_update(scratch, i, event, data); + } + + /* sync IPIs */ + m = n; + for (i = hbase; m; i++, m >>= 1) { + if (m & 1UL) + sbi_ipi_sync(scratch, event); } } else { + /* update IPIs */ + hbase = 0; + while (!sbi_hsm_hart_interruptible_mask(dom, hbase, &m)) { + for (i = hbase; m; i++, m >>= 1) { + if (m & 1UL) + sbi_ipi_update(scratch, i, event, data); + } + hbase += BITS_PER_LONG; + } + + /* sync IPIs */ hbase = 0; while (!sbi_hsm_hart_interruptible_mask(dom, hbase, &m)) { - /* Send IPIs */ for (i = hbase; m; i++, m >>= 1) { if (m & 1UL) - sbi_ipi_send(scratch, i, event, data); + sbi_ipi_sync(scratch, event); } hbase += BITS_PER_LONG; }