mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xie Bo <xb@ultrarisc.com>
To: linux-riscv@lists.infradead.org
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, linux-kernel@vger.kernel.org,
	Xie Bo <xb@ultrarisc.com>
Subject: [RFC PATCH 1/3] riscv: sbi: Add FWFT get helper
Date: Tue, 21 Jul 2026 15:58:10 +0800	[thread overview]
Message-ID: <20260721075812.82708-2-xb@ultrarisc.com> (raw)
In-Reply-To: <20260721075812.82708-1-xb@ultrarisc.com>

The SBI FWFT extension supports querying a feature's value on the local
hart, but the RISC-V SBI wrapper currently only exposes SET operations.

Add a generic GET helper which maps SBI errors to Linux errno values and
only updates the caller's output on success.

Signed-off-by: Xie Bo <xb@ultrarisc.com>
---
 arch/riscv/include/asm/sbi.h |  1 +
 arch/riscv/kernel/sbi.c      | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 5725e0c..b1773b1 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -607,6 +607,7 @@ int sbi_remote_hfence_vvma_asid(const struct cpumask *cpu_mask,
 				unsigned long asid);
 long sbi_probe_extension(int ext);
 
+int sbi_fwft_get(u32 feature, unsigned long *value);
 int sbi_fwft_set(u32 feature, unsigned long value, unsigned long flags);
 int sbi_fwft_set_cpumask(const cpumask_t *mask, u32 feature,
 			 unsigned long value, unsigned long flags);
diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index c443337..51e0c58 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -318,6 +318,35 @@ static void cpu_sbi_fwft_set(void *arg)
 		atomic_set(&req->error, ret);
 }
 
+/**
+ * sbi_fwft_get() - Get a feature value on the local hart
+ * @feature: The feature ID to get
+ * @value: Where to store the feature value
+ *
+ * Return: 0 on success, appropriate Linux error code otherwise.
+ */
+int sbi_fwft_get(u32 feature, unsigned long *value)
+{
+	struct sbiret ret;
+	int error;
+
+	if (!sbi_fwft_supported)
+		return -EOPNOTSUPP;
+
+	if (!value)
+		return -EINVAL;
+
+	ret = sbi_ecall(SBI_EXT_FWFT, SBI_EXT_FWFT_GET,
+			feature, 0, 0, 0, 0, 0);
+	error = sbi_err_map_linux_errno(ret.error);
+	if (error)
+		return error;
+
+	*value = ret.value;
+
+	return 0;
+}
+
 /**
  * sbi_fwft_set() - Set a feature on the local hart
  * @feature: The feature ID to be set
-- 
2.17.1


  reply	other threads:[~2026-07-21  7:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  7:58 [RFC PATCH 0/3] riscv: Add supervisor pointer masking infrastructure Xie Bo
2026-07-21  7:58 ` Xie Bo [this message]
2026-07-21  7:58 ` [RFC PATCH 2/3] riscv: kexec: Select HOTPLUG_CPU for KEXEC_FILE Xie Bo
2026-07-21  7:58 ` [RFC PATCH 3/3] riscv: Add supervisor pointer masking control Xie Bo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260721075812.82708-2-xb@ultrarisc.com \
    --to=xb@ultrarisc.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®