From patchwork Fri Aug 30 15:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979158 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=IV5KKLM4; 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=IeDsS6OD; 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 4WwPYs1wdnz1yhb for ; Sat, 31 Aug 2024 03:01:21 +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=NaDqUCTPi6eJ1YHjd+Hnt4rPkvQ6FvgJkPyxknNNVNk=; b=IV5KKLM4vS7tyO 8XJe0nJuwKEeUHtdw8WPu8jc16PB1/IRvBtfbkguXA1Ksk+cQD5blTQ2eLZbEKNcBJrGXZr0mU+N3 AdcPNcAHxgru6CfOZj4aGCImDo+9smMQL3jr0HkSdauVD8ZGUvZOTtrr0MbpZSGEhpMGXvIzDMi9e Y93rCGF31XBtySRQa/EgLiaxmfYGluhD3wbLTTz69vAcv70x2GMVIfRaUW3zjPQHN7J03ZbILd96e IQRL+axUZhnQVt/MifSbTHd3ZvqtDsL/3HkfA+zEjbZPl2hBIIQmEOhYxBuWxFYoZnhNLcQDylZk8 dVzXasN0OT5oWLnVT3XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk4zp-0000000771C-2BHG; Fri, 30 Aug 2024 17:01:13 +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 1sk3sc-00000006sYV-2dy4 for opensbi@lists.infradead.org; Fri, 30 Aug 2024 15:49:43 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-714263cb074so1524289b3a.1 for ; Fri, 30 Aug 2024 08:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725032982; x=1725637782; 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=8gpiIy7Cz4985JhNwpaXsijoNOlxAYijLhQD+FzI6rc=; b=IeDsS6ODnVm3re3knZmt09ofqUJSrZ0ogA4XKoLQNBZ3hvom+jziPC7Vw4HWRyhVs3 AyWaSgZxoH6T1qtqMDAUFhVRrpk4tDr4XtALT9EsaNB3cOqQvoLUlzlI2708cdr6V0wR 7l0Oqriy6xlsfNOArgNtkHUAkxLOaru9gMPRn28SSD0PhpkxokMSCSjxYs4FyYuxHpSa VQZ55ggsA0YLmcwRWT0R2ydBLGxlI7dk0FglTEiVm/5iX3IYwOCnqKefzyznwCDA/qgO nk+bdCGKP0S9vyNaE1/J3bOiQAPObGdYyzIJpPi5AgiS2vKu+O8W+A67hrlL8NEL1woX k1HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725032982; x=1725637782; 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=8gpiIy7Cz4985JhNwpaXsijoNOlxAYijLhQD+FzI6rc=; b=aV1xMdo24FLO0to1ys8Zp4w5VL/KjB42BcH2l46sOPanFwBeEvexFoFP0GRbQqm7/f AA0unceP46LP1bPMGz/NloRB0K8jcvISN1TzZKmGzUBK8aQR49jncfdLMp/f/0aoOr/Z 4x6hVti/HufkWBZCCK4VxK3aNf0ZgEK9nTwIGdbZejo3lZNBeXZD+MtcAtFqof6vSzxJ qsHFrctL0amjWxPgJ9tf0BTsGHF8F9Yttuj6QslFET2D3TpG34Ciec0mFYXgTGDeit7n FCpXlsuCwRxy4YuUScjf5BzTtYiZfY4uDax0Jm6HMVAlB9oww13WUxBNEihCkCLN2hnZ U05g== X-Gm-Message-State: AOJu0YyPeV0qQKczYQSEiBgQMzyCYREY/sGLMy5or9jQtFiFkDVHTrEZ j2nmPb26ns7YuWVelh0EyDrHbJCppUDwraATIoxsPfDZUBLyiBptct9f8bbaCe/shsncGQvo8oA XWhdlU06qzIur5bGiac7YNvNberHolD7oXrfB+ofmwptW9Kx+HkhHXh0/JgxjgZG/yFY0j2HJ+z //2W/EksJITz2uQeBIs41nHD4i8ag3CbDLuqnxWhFN7iU6eukg0yQ= X-Google-Smtp-Source: AGHT+IE5NmDIcqWIOzld2KMzt9r6JdFqbeCeQShQrpKq0gan3HU64aKmg3Q/Z2NFtRW1tCJOycgEXA== X-Received: by 2002:a05:6a20:6f08:b0:1c4:87b0:9157 with SMTP id adf61e73a8af0-1cce100e79fmr6056630637.22.1725032981842; Fri, 30 Aug 2024 08:49:41 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 08:49:41 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 08/12] lib: sbi: Update __sbi_hsm_hart_get_state() to take a hart index Date: Fri, 30 Aug 2024 08:49:12 -0700 Message-ID: <20240830154929.3971790-9-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_084942_692464_565D26F5 X-CRM114-Status: GOOD ( 12.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: This removes some hartindex conversions in sbi_system_suspend(), but is mostly intended to support refactoring sbi_hsm_hart_interruptible_mask() to work exclusively with struct sbi_hartmask. Signed-off-by: Samuel Holland --- 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:42e 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 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 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 This removes some hartindex conversions in sbi_system_suspend(), but is mostly intended to support refactoring sbi_hsm_hart_interruptible_mask() to work exclusively with struct sbi_hartmask. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_hsm.h | 2 +- lib/sbi/sbi_hsm.c | 12 ++++++++---- lib/sbi/sbi_system.c | 9 ++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index 4b5601ba..d8ca459d 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -72,7 +72,7 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type, ulong raddr, ulong rmode, ulong arg1); bool sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate, long newstate); -int __sbi_hsm_hart_get_state(u32 hartid); +int __sbi_hsm_hart_get_state(u32 hartindex); int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid); int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom, ulong hbase, ulong *out_hmask); diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index ab11b119..5af3c4af 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -60,12 +60,12 @@ bool sbi_hsm_hart_change_state(struct sbi_scratch *scratch, long oldstate, return __sbi_hsm_hart_change_state(hdata, oldstate, newstate); } -int __sbi_hsm_hart_get_state(u32 hartid) +int __sbi_hsm_hart_get_state(u32 hartindex) { struct sbi_hsm_data *hdata; struct sbi_scratch *scratch; - scratch = sbi_hartid_to_scratch(hartid); + scratch = sbi_hartindex_to_scratch(hartindex); if (!scratch) return SBI_EINVAL; @@ -75,10 +75,12 @@ int __sbi_hsm_hart_get_state(u32 hartid) int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid) { + u32 hartindex = sbi_hartid_to_hartindex(hartid); + if (!sbi_domain_is_assigned_hart(dom, hartid)) return SBI_EINVAL; - return __sbi_hsm_hart_get_state(hartid); + return __sbi_hsm_hart_get_state(hartindex); } /* @@ -120,6 +122,7 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom, { int hstate; ulong i, hmask, dmask; + u32 hartindex; *out_hmask = 0; if (!sbi_hartid_valid(hbase)) @@ -131,7 +134,8 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom, if (!(dmask & hmask)) continue; - hstate = __sbi_hsm_hart_get_state(hbase + i); + hartindex = sbi_hartid_to_hartindex(hbase + i); + hstate = __sbi_hsm_hart_get_state(hartindex); if (hstate == SBI_HSM_STATE_STARTED || hstate == SBI_HSM_STATE_SUSPENDED || hstate == SBI_HSM_STATE_RESUME_PENDING) diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index f3c49bbd..8e624fdd 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -142,9 +142,9 @@ int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque) struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr; - unsigned int hartid = current_hartid(); + unsigned int hartindex = current_hartindex(); unsigned long prev_mode; - unsigned long i, j; + unsigned long i; int ret; if (!dom || !dom->system_suspend_allowed) @@ -163,9 +163,8 @@ int sbi_system_suspend(u32 sleep_type, ulong resume_addr, ulong opaque) return SBI_EFAIL; spin_lock(&dom->assigned_harts_lock); - sbi_hartmask_for_each_hartindex(j, &dom->assigned_harts) { - i = sbi_hartindex_to_hartid(j); - if (i == hartid) + sbi_hartmask_for_each_hartindex(i, &dom->assigned_harts) { + if (i == hartindex) continue; if (__sbi_hsm_hart_get_state(i) != SBI_HSM_STATE_STOPPED) { spin_unlock(&dom->assigned_harts_lock);