From patchwork Tue Jan 31 09:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1734703 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=OnVUYrlm; 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=cPqSS8VJ; 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 4P5fw823hVz23gY for ; Tue, 31 Jan 2023 20:32:24 +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=lq1k33fU+OsnRN+AcMy4X9vhJ4LWDCQ8hOGRnDYu+dM=; b=OnVUYrlmYqHoLQ efS6+HBNAibaWL2nRYtbNcfo1VTpqAjqq/J7HhjGq6dR2RkYOHRmkps+C2c7zf9IG/vJGaYLk00Ft o5IIfYCn8tj6f4gz9DHyo2ATFKS9HQ5SixMohTs2fro3k2f4R0++kgr25cwkU/zv1DkdH5HqaYoWC gdhfDoLytTRSv/C8YEL6mGd/+6Be5KHtwVyacVllKxCtp7ZSIs98aEDBQ2wC/s0m+j6KNQxscoNi1 Wc8v0WW/oIzOFIHU7+nH5KYYb5MglwRTs+0qNNKgAuvPQhuXhKZqF4e134TnmKaZ+yeKnoGpnkTWV uuIKraGwkJaw931qOWtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMmzq-0071QW-If; Tue, 31 Jan 2023 09:32:10 +0000 Received: from m126.mail.126.com ([220.181.12.36]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMmze-0071KQ-FO for opensbi@lists.infradead.org; Tue, 31 Jan 2023 09:32:00 +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=ZzNyw 9Syzti0bQBAD6dlJpwHf3nP6FdHP3d+K+PytMg=; b=cPqSS8VJZHOSx6L3EzGya 5vrd8or3lVBYCNzsjgesA7m9xA6DasCKDqTfel/uErQxhlFJOwP9FiK2cI1SU+qJ sSMmNikiCrnZL4D/DWiBWGcVRq2kqCUwlAGS8u4P1mZaFEUYi8FCn/gJbz/NVRkE 4mKB2ZG5kwcJsTp7VCpOGE= Received: from x390.lan (unknown [210.22.74.155]) by zwqz-smtp-mta-g2-1 (Coremail) with SMTP id _____wAXCVfz39hjRBD+AQ--.45045S3; Tue, 31 Jan 2023 17:31:48 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v2 2/3] lib: sbi: Optimize sbi_ipi Date: Tue, 31 Jan 2023 17:31:08 +0800 Message-Id: <20230131093107.52986-3-wxjstz@126.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230131093107.52986-2-wxjstz@126.com> References: <20230131093107.52986-2-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wAXCVfz39hjRBD+AQ--.45045S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCF1fJF1rGw13AF4DWw48JFb_yoW5GF4kpF yDWFZ0yw4IqryIqasxJa1UZa13G3yvqr17WrZrG34xXrWDWF95JF1rGr1Ut3W5GFyfta4Y qw4jvryFkFyUArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zi0PfXUUUUU= X-Originating-IP: [210.22.74.155] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi1wwIOl53aj07vgAAsS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_013158_866979_0C42DCC5 X-CRM114-Status: GOOD ( 12.03 ) X-Spam-Score: 1.1 (+) 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 | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) Content analysis details: (1.1 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] 1.3 RCVD_IN_VALIDITY_RPBL RBL: Relay in Validity RPBL, https://senderscore.org/blocklistlookup/ [220.181.12.36 listed in bl.score.senderscore.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 | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 1bcc2e4..79c7a4f 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; @@ -75,6 +75,21 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid, 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); + + return 0; +} + /** * As this this function only handlers scalar values of hart mask, it must be * set to all online harts if the intention is to send IPIs to all the harts. @@ -83,7 +98,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 +107,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; }