From patchwork Fri Aug 30 15:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1979157 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=W04Y3kTG; 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=BlX6EeCt; 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 4WwPYr4xhFz1yhQ for ; Sat, 31 Aug 2024 03:01:20 +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=ivLhdDRGrOGmNVqHWME21RTNSU/qXFNnL8yqbqn5vXc=; b=W04Y3kTG1WSzWh Tz39WSZ003MHK0TS+98x3LoIllKjeFFkmccrnJXqPyNkZnH0fbEOMCDxUfwBlkcrhBRFUUP7N7/Vb bpbp3lAzg4Zz4uAhdQn6fSmFtJ0jy9yUYnR5FPGlyI0mOEA/Gt1BoPxOtUiCsHdSmXnIpycUSB3SU yd1MtkHbIJ6zs8xlp6idyE/qO3BNP+XpwyRtNE/t+0yl1hFdsVxXJVRWfADtQOZTgMCamPgg1znCJ xqhQ9RYsFGkXswTL0MI0fg3ZL0KxAk6lUyR4OzDuoyMv63VaPACC0wyj7tqTZ7JxIZ8P4xGogSFtI b4XiSCgVzrg3Af9bHGZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk4zo-0000000770f-295T; Fri, 30 Aug 2024 17:01:12 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3sX-00000006sVG-0I5Y for opensbi@lists.infradead.org; Fri, 30 Aug 2024 15:49:38 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-7cda0453766so706012a12.2 for ; Fri, 30 Aug 2024 08:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1725032976; x=1725637776; 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=ve78qUuJkOfrPFZpP6nI3eeoc4JVSY16HDCXI/zTvKk=; b=BlX6EeCt19FbcL3+iW3yHfLT8iYx3YtLS5znimY9jiFskOGKv7qwQ6RoMsHWuLcau4 +0N6DBu1zppQHIIp6ewPU/X/EcXlO6AKlGjuVeERmh4B3zVFnqNr2VcjBnuvxh4sdHgK UNwV5ZWuDoSUd5E6rGeJJfuSmYlF4M8v+O3BKL2YbodzDmFzpIwo1/IszmAxpAI56/7o sEYgiP1ah01PmxhFHC5MhH3f24qAQCDM3aj6O+e1iOqF8ZPvPjfaRcu5kx9cGVsUKSF+ o6TYojkWyRrlBqu4sxRjKiovzykGmWkuyVrSUIwsZkQB5zUUlX1H8H65aGVhRDtiIC1w ecEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725032976; x=1725637776; 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=ve78qUuJkOfrPFZpP6nI3eeoc4JVSY16HDCXI/zTvKk=; b=XTMjoa4ms995AmMl+uWUoLVJBX21VXNwS3PEs3arAld3/N/9Ffw8mnUpsHEWvPTFTV HZf3jKHXyp5Md9lYjxUIu+DR2uqypatKF0pty6OQEMnWwwerioxoXezKO0s7T80IklBT LiHpbKCecQintK5Q5whlIY9pevZjRFJH80afkJ2jSru4IkN/EzoiiuyMl2eo0ySUW6cx yM/HRKBydG1/12aJqtw52JrawMxYWGY6djEn0L89KzyaBnNUYyJL07iuUn6NAdHDWgbl xlHBvwUt5VcxmcsFQFXDiV8hjfuzwOHEshaVrYXJEYvozqNoBaRlcaI3YpyKYj8sMqzg HUlQ== X-Gm-Message-State: AOJu0YykA/jzgPCSHm2RB29zsLwd000Ki8qU1lIn46PtGTe67kgj3gsN VTWEGMouSlfuqAW7qv5UsqdhPJx7Iv2j1rjy5XDYsPpYM+HORP1hosif4zHcihoKrOOcR6ML94e 8S3KgYbUJb+xdLgXZB1AJEjHnasn4nj5U0EDjHIizmosAKgspSYJs/tQi+wo6jCjpAqAH4KBfD3 FbfypfJmf8b1hD9qto94ZPg2NSWyWhrTbhmNVmtLCH/EqHuAzmwro= X-Google-Smtp-Source: AGHT+IESBEYBaRbaJp+U4dUwuSagl8lN66wWmjjCWciZPlUu6dl7sics/mBi0VYo1oLjyR4K4b1UFg== X-Received: by 2002:a05:6a20:c6c2:b0:1c6:fb8b:df5a with SMTP id adf61e73a8af0-1cce10ab2b3mr6116497637.41.1725032975408; Fri, 30 Aug 2024 08:49:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 08:49:34 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH 03/12] lib: sbi: Use current_hartindex() where possible Date: Fri, 30 Aug 2024 08:49:07 -0700 Message-ID: <20240830154929.3971790-4-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_084937_135713_09B9FE00 X-CRM114-Status: GOOD ( 13.40 ) 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 avoids calls to the expensive sbi_hartid_to_hartindex() function and also makes the firmware smaller. Signed-off-by: Samuel Holland --- include/sbi/sbi_domain.h | 2 +- include/sbi/sbi_domain_context.h | 7 +++---- lib/sbi/sbi_domain_context.c | 6 +++--- lib/sbi/sbi_hsm.c | 2 +- lib/sbi/sbi_ipi.c | 2 +- 5 files changed, 9 insertions(+) [...] 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:52b 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 avoids calls to the expensive sbi_hartid_to_hartindex() function and also makes the firmware smaller. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- include/sbi/sbi_domain.h | 2 +- include/sbi/sbi_domain_context.h | 7 +++---- lib/sbi/sbi_domain_context.c | 6 +++--- lib/sbi/sbi_hsm.c | 2 +- lib/sbi/sbi_ipi.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index a6e99c63..2c905941 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -211,7 +211,7 @@ void sbi_update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom); /** Get pointer to sbi_domain for current HART */ #define sbi_domain_thishart_ptr() \ - sbi_hartindex_to_domain(sbi_hartid_to_hartindex(current_hartid())) + sbi_hartindex_to_domain(current_hartindex()) /** Index to domain table */ extern struct sbi_domain *domidx_to_domain_table[]; diff --git a/include/sbi/sbi_domain_context.h b/include/sbi/sbi_domain_context.h index 0d25884a..a92f338b 100755 --- a/include/sbi/sbi_domain_context.h +++ b/include/sbi/sbi_domain_context.h @@ -52,10 +52,9 @@ struct sbi_context { (__d)->hartindex_to_context_table[__hartindex] /** Macro to obtain the current hart's context pointer */ -#define sbi_domain_context_thishart_ptr() \ - sbi_hartindex_to_domain_context( \ - sbi_hartid_to_hartindex(current_hartid()), \ - sbi_domain_thishart_ptr()) +#define sbi_domain_context_thishart_ptr() \ + sbi_hartindex_to_domain_context(current_hartindex(), \ + sbi_domain_thishart_ptr()) /** * Enter a specific domain context synchronously diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c index 49a2f769..33cb6ed7 100755 --- a/lib/sbi/sbi_domain_context.c +++ b/lib/sbi/sbi_domain_context.c @@ -26,7 +26,7 @@ static void switch_to_next_domain_context(struct sbi_context *ctx, struct sbi_context *dom_ctx) { - u32 hartindex = sbi_hartid_to_hartindex(current_hartid()); + u32 hartindex = current_hartindex(); struct sbi_trap_context *trap_ctx; struct sbi_domain *current_dom = ctx->dom; struct sbi_domain *target_dom = dom_ctx->dom; @@ -91,7 +91,7 @@ int sbi_domain_context_enter(struct sbi_domain *dom) { struct sbi_context *ctx = sbi_domain_context_thishart_ptr(); struct sbi_context *dom_ctx = sbi_hartindex_to_domain_context( - sbi_hartid_to_hartindex(current_hartid()), dom); + current_hartindex(), dom); /* Validate the domain context existence */ if (!dom_ctx) @@ -107,7 +107,7 @@ int sbi_domain_context_enter(struct sbi_domain *dom) int sbi_domain_context_exit(void) { - u32 i, hartindex = sbi_hartid_to_hartindex(current_hartid()); + u32 i, hartindex = current_hartindex(); struct sbi_domain *dom; struct sbi_context *ctx = sbi_domain_context_thishart_ptr(); struct sbi_context *dom_ctx, *tmp; diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 3706acfb..ab11b119 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -261,7 +261,7 @@ int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) hdata = sbi_scratch_offset_ptr(rscratch, hart_data_offset); ATOMIC_INIT(&hdata->state, - (sbi_hartindex_to_hartid(i) == hartid) ? + (i == current_hartindex()) ? SBI_HSM_STATE_START_PENDING : SBI_HSM_STATE_STOPPED); ATOMIC_INIT(&hdata->start_ticket, 0); diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index 048aaa66..505aafd8 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -233,7 +233,7 @@ 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()); + u32 hartindex = current_hartindex(); sbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_RECVD); sbi_ipi_raw_clear(hartindex);