From patchwork Wed Sep 4 01:24:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1980396 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=VEBnsp/+; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=LYVvvazs; 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 4Wz4Ym6vvzz1yg3 for ; Wed, 4 Sep 2024 11:25:31 +1000 (AEST) 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:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pitB8NJFIUNz8MxjyOV/El4j1lNCfwEISUcfV3hlqS4=; b=VEBnsp/+73UbfB jT8iuXRgbO8bViFUgT8izwH4C+tIk5sZ2tdXWSfwZ5j0OyetidSGJMfNNUlvND7lyIqBIfzZ2gm5o WpPrFobDelFDYSxIaQDGiaCIsJbufVYjcFSpeHuZYWHEyesknfxNRelxWW7QMiJpO7a4NdQiITN3i /I2CZWd7rUXSrbs47QK8kArqV1AuovU31l6m8Xz0nnDfWi3VPj2fkS1H7hdecu7YppRxcz5aDFpv3 wUtiueEYtJcYh19Y8td1yt3vvk/2bmw0toKFo3ygpRgP/kmlcF4Oh3ug+Y4zhsAGmGVsOcsTHrGt+ Yj9U3weBOtQlpc5d9hsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slelv-00000002TJo-09Zj; Wed, 04 Sep 2024 01:25:23 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slelm-00000002THE-1KtT for opensbi@lists.infradead.org; Wed, 04 Sep 2024 01:25:15 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-202508cb8ebso37250965ad.3 for ; Tue, 03 Sep 2024 18:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725413113; x=1726017913; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hg0uOY7m2aLOKp9gXuklfe/wOYARFELzyZbTS1IqX60=; b=LYVvvazsYvQhPL7rE2Ch+6DsRyzubDSFIhrZkIIq84tC7cTqWsVWRLqFc5wz1HI2H5 C1wl/WjeNQ7vHjkYYIhJNFKx4ZHMv3IKeq2S/PduO97HNbc+PyG26VZm9WFiazr8YoKy hBJhxt/LHMo+DZClnIL00CAA+GCLUMTp0hrFslYOssNNsTuAuhDIn3qZpxtPXkOX5qEF 1lmMKOgc4KFwJ+YXPtUhT9v1tR4lJpLhRacgqDcXCu+UnTR3mgdBP4IYexKyv2Y+KffE DSt+jg9OI3ONWAzLUIZb+W+XAWkTDSxxl2zkQRGX6NxZWaMUllg8f1brDQ31BSzXewnW +4YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725413113; x=1726017913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hg0uOY7m2aLOKp9gXuklfe/wOYARFELzyZbTS1IqX60=; b=UZBp7G2H9YyaKQCfIeQ4U8jPaPHwqKWHLtBGgNhbDJPPVU76JvgnWn5P9nKpYEGqAF FcKfAjE4/50SEAa+Kx4YUHlaWNBLgpjv8T90CijcPndQpPNavxyAy65ePkCfdb7iCUqh 0SX6MOh/0GuM0A2/gj6rbd0B1TbnvhKuVN8VGvrpRkJMAR6X9vfEFAtoyAZpMWhDQ59/ NJ2GKRRj/XX/K2143vtOhkS8p+pbl34SaxrjRzMfpUXWqcaElFXa44YrxhYDAOBQH7xP j+juZHE3rc0225VSXTAXBROqv66E5laeXflk5Fx/xK3xcNqNgGzaUllirA3vZ9C97PSP Rlng== X-Gm-Message-State: AOJu0YxTVZs92yp/TaD7Q2enRAJU/9MOhGgblt5hPDa/0ZDsZUQhEozO 71SarHKiGUi9KHfMF7G681wcX7yaTjQ8dPDz5/FT+889SduMVz99FPpYudAzFUVnhc/rNwhYm52 BdoSz8oFA80yEoJbBp2TaC/4mmtZoTvkTWmhfwzUipeJH7IirBxyZewJvuoM5Yrl44PlnRwTH1o /vKy4IbbTKIEsuEyovD3SZghXxfsM02l7B37xEEkC4a5Hijfwgl9I= X-Google-Smtp-Source: AGHT+IEPDlLJ7us51ExCaWguO793INat+x/mrZec6WFaTjyZwhDXo0lH5MhV5uh8iyzlzQszJunjUA== X-Received: by 2002:a17:902:db0f:b0:205:5f35:80b6 with SMTP id d9443c01a7336-2055f358700mr81201605ad.61.1725413112663; Tue, 03 Sep 2024 18:25:12 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea530casm3978835ad.184.2024.09.03.18.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 18:25:11 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 1/3] lib: sbi_ipi: Make .ipi_clear always target the current hart Date: Tue, 3 Sep 2024 18:24:10 -0700 Message-ID: <20240904012508.3626840-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240904012508.3626840-1-samuel.holland@sifive.com> References: <20240904012508.3626840-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_182514_391740_2F61B937 X-CRM114-Status: GOOD ( 17.66 ) X-Spam-Score: -2.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: All existing users of this operation target the current hart, and it seems unlikely that a future user will need to clear the pending IPI status of a remote hart. Simplify the logic by changing .ipi_c [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:631 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 All existing users of this operation target the current hart, and it seems unlikely that a future user will need to clear the pending IPI status of a remote hart. Simplify the logic by changing .ipi_clear (and its wrapper sbi_ipi_raw_clear()) to always operate on the current hart. This incidentally fixes a bug introduced in commit 78c667b6fc07 ("lib: sbi: Prefer hartindex over hartid in IPI framework"), which changed the .ipi_clear parameter from a hartid to a hart index, but failed to update the warm_init functions to match. Fixes: 78c667b6fc07 ("lib: sbi: Prefer hartindex over hartid in IPI framework") Signed-off-by: Samuel Holland --- This fix supersedes my previous patch [1] ("lib: utils/ipi: Fix hartid wrongly used as hart index"). [1]: http://lists.infradead.org/pipermail/opensbi/2024-August/007324.html include/sbi/sbi_ipi.h | 6 +++--- lib/sbi/sbi_init.c | 2 +- lib/sbi/sbi_ipi.c | 7 +++---- lib/utils/ipi/aclint_mswi.c | 13 ++++--------- lib/utils/ipi/andes_plicsw.c | 8 +++----- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h index d3962334..62d61304 100644 --- a/include/sbi/sbi_ipi.h +++ b/include/sbi/sbi_ipi.h @@ -26,8 +26,8 @@ struct sbi_ipi_device { /** Send IPI to a target HART index */ void (*ipi_send)(u32 hart_index); - /** Clear IPI for a target HART index */ - void (*ipi_clear)(u32 hart_index); + /** Clear IPI for the current hart */ + void (*ipi_clear)(void); }; enum sbi_ipi_update_type { @@ -87,7 +87,7 @@ void sbi_ipi_process(void); int sbi_ipi_raw_send(u32 hartindex); -void sbi_ipi_raw_clear(u32 hartindex); +void sbi_ipi_raw_clear(void); const struct sbi_ipi_device *sbi_ipi_get_device(void); diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index d80efe97..b07a201a 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -479,7 +479,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (hstate == SBI_HSM_STATE_SUSPENDED) { init_warm_resume(scratch, hartid); } else { - sbi_ipi_raw_clear(sbi_hartid_to_hartindex(hartid)); + sbi_ipi_raw_clear(); init_warm_startup(scratch, hartid); } } diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 048aaa66..0ce27ba1 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -233,10 +233,9 @@ void sbi_ipi_process(void) struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct sbi_ipi_data *ipi_data = sbi_scratch_offset_ptr(scratch, ipi_data_off); - u32 hartindex = sbi_hartid_to_hartindex(current_hartid()); sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_RECVD); - sbi_ipi_raw_clear(hartindex); + sbi_ipi_raw_clear(); ipi_type = atomic_raw_xchg_ulong(&ipi_data->ipi_type, 0); ipi_event = 0; @@ -271,10 +270,10 @@ int sbi_ipi_raw_send(u32 hartindex) return 0; } -void sbi_ipi_raw_clear(u32 hartindex) +void sbi_ipi_raw_clear(void) { if (ipi_dev && ipi_dev->ipi_clear) - ipi_dev->ipi_clear(hartindex); + ipi_dev->ipi_clear(); /* * Ensure that memory or MMIO writes after this diff --git a/lib/utils/ipi/aclint_mswi.c b/lib/utils/ipi/aclint_mswi.c index 4ae6bb1c..b572ad81 100644 --- a/lib/utils/ipi/aclint_mswi.c +++ b/lib/utils/ipi/aclint_mswi.c @@ -45,24 +45,19 @@ static void mswi_ipi_send(u32 hart_index) mswi->first_hartid]); } -static void mswi_ipi_clear(u32 hart_index) +static void mswi_ipi_clear(void) { u32 *msip; - struct sbi_scratch *scratch; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); struct aclint_mswi_data *mswi; - scratch = sbi_hartindex_to_scratch(hart_index); - if (!scratch) - return; - mswi = mswi_get_hart_data_ptr(scratch); if (!mswi) return; /* Clear ACLINT IPI */ msip = (void *)mswi->addr; - writel_relaxed(0, &msip[sbi_hartindex_to_hartid(hart_index) - - mswi->first_hartid]); + writel_relaxed(0, &msip[current_hartid() - mswi->first_hartid]); } static struct sbi_ipi_device aclint_mswi = { @@ -74,7 +69,7 @@ static struct sbi_ipi_device aclint_mswi = { int aclint_mswi_warm_init(void) { /* Clear IPI for current HART */ - mswi_ipi_clear(current_hartid()); + mswi_ipi_clear(); return 0; } diff --git a/lib/utils/ipi/andes_plicsw.c b/lib/utils/ipi/andes_plicsw.c index 413ac20e..626699f9 100644 --- a/lib/utils/ipi/andes_plicsw.c +++ b/lib/utils/ipi/andes_plicsw.c @@ -41,9 +41,9 @@ static void plicsw_ipi_send(u32 hart_index) writel_relaxed(BIT(pending_bit), (void *)pending_reg); } -static void plicsw_ipi_clear(u32 hart_index) +static void plicsw_ipi_clear(void) { - u32 target_hart = sbi_hartindex_to_hartid(hart_index); + u32 target_hart = current_hartid(); ulong reg = plicsw.addr + PLICSW_CONTEXT_BASE + PLICSW_CONTEXT_CLAIM + PLICSW_CONTEXT_STRIDE * target_hart; @@ -67,10 +67,8 @@ static struct sbi_ipi_device plicsw_ipi = { int plicsw_warm_ipi_init(void) { - u32 hartid = current_hartid(); - /* Clear PLICSW IPI */ - plicsw_ipi_clear(hartid); + plicsw_ipi_clear(); return 0; }