From patchwork Fri Aug 30 15:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979102 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=nvjO+Plo; 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=I7s+Kz/M; 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 4WwMzN61Pnz1yfX for ; Sat, 31 Aug 2024 01:49:52 +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=8/v80thK8xtlqNDMN8w1YI+AlE9Zu0b/tuW4TSIAs3g=; b=nvjO+PlolruqEq UB8TK5ENdhWVVsZ9JMOBaglk7N7JWTPXOeKgDsTF87B0gpelNbTE2j0qQXR3K6C+mobpX55ECNMbM HQNPBV+y06Ti/prr4gMihpGI0TUZIcKovNDVBc9eYWUWlEiiPptjdBExF0X2ssDselrHdEUQrgw9J 9OF9yeGrlhsAr4cm1c7QqS5a6uucfgpBZA8VqAJIKamVXh2/4sYUd8lOYEUfBtQCncV5WEGBojOo6 ht0Te4VPkT7o29voA2ouJzPmjubjiMQTpDsXR4iiApgnYENa8u3iGPNAEqjGGYllSQvZMZC5mVctL LdC/OZFgOVSbSrpzcrIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3sf-00000006saH-1cjN; Fri, 30 Aug 2024 15:49:45 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3sb-00000006sXo-3RMw for opensbi@lists.infradead.org; Fri, 30 Aug 2024 15:49:43 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-714114be925so1635184b3a.2 for ; Fri, 30 Aug 2024 08:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725032981; x=1725637781; 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=WJQ1aSTUDAbXD2MKqWzvIUjG0NvgmUkg2vX5boJ778E=; b=I7s+Kz/MvdzXAdWfS/Uz+DFJ+AQv+YQ6pFqQzwM6UTHjbsOjd+3MLjxv2APoRKY1fB 1N+Fuo7ZS+AzNPbIf5od5fi9JaKm2jqB05Ocy4/v4JMKjXvDn5YQ2aiqtEk5M7Fes5w9 2xs8IicdClFSCl5a/gK4Ih0AyhoBBsJvQhJbxDjPEnpjXXHqI/cE3UT00X1BUGO0Dxzu k6U+pixQrnqHCAFcfx8m7tdypvnbZf2qII7AfChxiOmE1TpvaZf7yJr7YvzgZu8YJzmY /PhBWL9SVOEp4/ckomYS1zFx5OY7KInf6GNzCHLtvmwsX2EiXIwRM5vRF3PE5cBbCodW GYgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725032981; x=1725637781; 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=WJQ1aSTUDAbXD2MKqWzvIUjG0NvgmUkg2vX5boJ778E=; b=cKhPzltJy/7n4xrKZfwtKjEsPSjs5+0PkgZXNTtUEi4Lbz/qcuaNql6FAh2GpcP67y +hdRUeSyX/npCtZ7+Z7a46tnFu6FPxT8XsF/eSF8G+KY/vawOcK03q6oBmcn0de877/J wLe8rz2m5zZVeqhZ+WeTWFmkL0AdNVaauW67aoi40VUOlBtQxrLXxyfAdQ/9l75yzTML hTlA7oEVxT2s830gFb4hxq6GU407KHGnYRFEYNPr7zg08sZT4BBuWZ4UAho421S21GgL oUGsxIYsyZTOMjJSu7i6Gs5ebJz82VRA92Xi65a1se8CPV/z4tCvRG++MLszsOoj0Bfk PzDg== X-Gm-Message-State: AOJu0YxpQYm1W1/5MSipLCN3Y3vFCzf9Kv22Q5OThQWmlvE8T0py6lAb FBQQzDlPWYpFASlIEiSm4B7qDCwh2FJ6AmQoumBcaduGDvoEvdvxedBYlV9dXxEow8yioJx5PFI 8UHojezCaJDhzuFSI89m4nSHddy+BxBN0/3n12ah/YyQBjyMZ82iGgRR1ZjPDkO3TppNQjZpehr ZAnhznnO9cVDtp8+fVpGYWtJYwtASFw9Rxfx8CHko95YtgJzkyTu4= X-Google-Smtp-Source: AGHT+IHNGYhShX6Bup2DWR33TCSWmRRSxmC5SqRDeRAXqmZpz03MxnvYq+MaxiI/RCWvRkx2LYL9KQ== X-Received: by 2002:a05:6a00:9159:b0:714:157a:bfd0 with SMTP id d2e1a72fcca58-715dfb46592mr7644263b3a.10.1725032980685; Fri, 30 Aug 2024 08:49:40 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e569e793sm2920817b3a.131.2024.08.30.08.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 08:49:40 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 07/12] lib: sbi: Simplify halt broadcast logic Date: Fri, 30 Aug 2024 08:49:11 -0700 Message-ID: <20240830154929.3971790-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240830154929.3971790-1-samuel.holland@sifive.com> References: <20240830154929.3971790-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-20240830_084941_882636_DB3E9C40 X-CRM114-Status: GOOD ( 11.41 ) 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: Use the IPI .update callback to exclude the local hart. This allows reusing the normal logic for broadcasting an IPI to all active harts. Signed-off-by: Samuel Holland --- Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 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 Message has at least one valid DKIM or DK signature -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 -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e listed in] [list.dnswl.org] -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 Use the IPI .update callback to exclude the local hart. This allows reusing the normal logic for broadcasting an IPI to all active harts. Signed-off-by: Samuel Holland --- lib/sbi/sbi_ipi.c | 10 ++++++++++ lib/sbi/sbi_system.c | 11 +---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 505aafd8..0cffa0af 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -208,6 +208,15 @@ void sbi_ipi_clear_smode(void) csr_clear(CSR_MIP, MIP_SSIP); } +static int sbi_ipi_update_halt(struct sbi_scratch *scratch, + struct sbi_scratch *remote_scratch, + u32 remote_hartindex, void *data) +{ + /* Never send a halt IPI to the local hart. */ + return scratch == remote_scratch ? + SBI_IPI_UPDATE_BREAK : SBI_IPI_UPDATE_SUCCESS; +} + static void sbi_ipi_process_halt(struct sbi_scratch *scratch) { sbi_hsm_hart_stop(scratch, true); @@ -215,6 +224,7 @@ static void sbi_ipi_process_halt(struct sbi_scratch *scratch) static struct sbi_ipi_event_ops ipi_halt_ops = { .name = "IPI_HALT", + .update = sbi_ipi_update_halt, .process = sbi_ipi_process_halt, }; diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index c068b725..f3c49bbd 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -65,20 +65,11 @@ bool sbi_system_reset_supported(u32 reset_type, u32 reset_reason) void __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason) { - ulong hbase = 0, hmask; - u32 cur_hartid = current_hartid(); struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); /* Send HALT IPI to every hart other than the current hart */ - while (!sbi_hsm_hart_interruptible_mask(dom, hbase, &hmask)) { - if ((hbase <= cur_hartid) - && (cur_hartid < hbase + BITS_PER_LONG)) - hmask &= ~(1UL << (cur_hartid - hbase)); - if (hmask) - sbi_ipi_send_halt(hmask, hbase); - hbase += BITS_PER_LONG; - } + sbi_ipi_send_halt(0, -1UL); /* Stop current HART */ sbi_hsm_hart_stop(scratch, false);