From patchwork Fri Oct 25 18:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 2002492 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=vEoTDwxX; 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=PLwHpEdr; 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 4XZstS5WnHz1xw0 for ; Sat, 26 Oct 2024 06:15:12 +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: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=iF3DVovl/KkZKXbZh9cPs5nhGzlFBH36FhLDJxE/QS8=; b=vEoTDwxX5RR8vc vyzR6gOwSsKFKYfFCktZbLeqs9TuOvNB9zSdGc9Yfcq0AQ7hwBEprYTNwdzqdL/XuM3K1xdY4La7a Rktg0GHoBxn3EvPKmyu/qMzuoD/+ajDHRmK6qbB/EFa7hpxbmF/ZSC2WZ5SHrWS+B5nbdLV8omzM0 lfaJtuNnVJggMAM7bF5Uup248telzqffJe4f+FxLJOYkYbzerNyGCwNPZsCGmlfxtdpPNJYvPyNA4 LwRv1lF6hNBvEtWdyyhMZ55/4oF4V1+RmIugmcrH5SE1xMhHjVDh6nRq15qMK87NgscbgMnFBbd2l i4ranqhXR+TIEW02AEBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t4Pm5-00000004v2I-02pG; Fri, 25 Oct 2024 19:15:05 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t4PXO-00000004ser-0HCg for opensbi@lists.infradead.org; Fri, 25 Oct 2024 18:59:55 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2e2e88cb0bbso1819283a91.3 for ; Fri, 25 Oct 2024 11:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1729882793; x=1730487593; 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=+SolzJs7+n65a3i+KJVFjgqOUK0x20cXLwWz+qa5PZg=; b=PLwHpEdr93wIbjxT2fL4RiuWHYccPWUQJHpB6XiJyfjn3yWhlXd2VKIObD7xIG7KbX oU6KtkTLlx7nIA7LJofNDKFWC9HJkNWXTpWABxE7ABwwAHv9wAV/yoeq4oL61B8fRQ2s PpXXIbWRXobu/92Wbm/6StrUvD4a8pzs0aNKZ5eyjBAJYmx50p9HUhoovACKVr3ut823 hxb9sKD/OEe3Jl7mXTw2IHM3e/+dDaD1MKnupu13ZtvmUM7doTpkM/0MKLEFqFRcmHD3 sJMcKAaRVUpMRsk48R03w5uwCxXaVI0fg31swCyi/5liRRA/nrSL193IiBGUgjxZsHRC s7dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729882793; x=1730487593; 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=+SolzJs7+n65a3i+KJVFjgqOUK0x20cXLwWz+qa5PZg=; b=dTpF1/XLaekqSqqEwC57jUtOhtHZdJUCefJBmPKhD23oZGB20PbcL+BJx6pNLieITT 7D1bKwAyTv+LMtv+7gUOLyHqtMfyTSqmtyy6ZKAxp6kXMAKMBsP25pJM2x1cn22Q1kYN qQHhnMAfZZ1Q67V3EnHHss5zC1x7K5iZNor7WuBBLZfkyTce0wA8eM0dKN05TnP9KuGQ 0BpqFmtYUxzYcireB4sy9sEU+iG2SAFBd3edqXmuTgy8WY9UpVJnNUXJnDkZ7/PC8rbz anbXJ7wT+CY8FyHYSG2ZGkBAOQEOID37i1nqWf4/hGlgGBT12VVzq8NN9Apnz3dB0+P8 Pcmg== X-Gm-Message-State: AOJu0Yy1MvbnQNEpSoFsckKwQhQYmVQkoW6Pgy2TDt9igvtpl2rj+t3M /9d4qL5xWwRd2Mweu5Er9jCdd2FldRRQ9hiRz1KP20J6tfrHnK1kgCwrjITwq2CVze7om5Sjufg vPKcC0oncrRmxT/Op/CfRP4a60YYlgNhaUXJ5REr94B5YCxwvkgCKpDPhrn2uovE6Gtt00Ofjc7 mTeYmPEKSiJsCKjeMe8ZxMRP5ETPTHv+BgY8WPtb3nL1AVmGjQ6xY= X-Google-Smtp-Source: AGHT+IFIjL8RfuUUXZ0ESF+2ikoDivzhUf6xbZGj1czZt+zFMyBXZ8vqGQHAT1C/8SYzeO3dSipgeg== X-Received: by 2002:a17:90a:e016:b0:2e2:e545:82c5 with SMTP id 98e67ed59e1d1-2e8f104f090mr423842a91.3.1729882793131; Fri, 25 Oct 2024 11:59:53 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e55d132sm3853359a91.39.2024.10.25.11.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:59:52 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH v2 1/3] lib: sbi_ipi: Make .ipi_clear always target the current hart Date: Fri, 25 Oct 2024 11:59:46 -0700 Message-ID: <20241025185950.1371610-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241025185950.1371610-1-samuel.holland@sifive.com> References: <20241025185950.1371610-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-20241025_115954_146707_88C58A0F X-CRM114-Status: GOOD ( 17.56 ) 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:102f listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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 --- Changes in v2: - Rebase on master branch (minor conflict with cae230c93556) 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 | 6 +++--- 5 files changed, 14 insertions(+), 20 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 cccd723d..8a2cfaef 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 337ed175..33b4d9b3 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -237,10 +237,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 = current_hartindex(); 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; @@ -275,10 +274,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 0ef3d003..2cd7a530 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_hartindex()); + mswi_ipi_clear(); return 0; } diff --git a/lib/utils/ipi/andes_plicsw.c b/lib/utils/ipi/andes_plicsw.c index 18c79e2b..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; @@ -68,7 +68,7 @@ static struct sbi_ipi_device plicsw_ipi = { int plicsw_warm_ipi_init(void) { /* Clear PLICSW IPI */ - plicsw_ipi_clear(current_hartindex()); + plicsw_ipi_clear(); return 0; }