From: Raymond Mao <raymondmaoca@gmail.com>
To: opensbi@lists.infradead.org
Cc: anup@brainfault.org, anup.patel@oss.qualcomm.com,
scott@riscstar.com, raymond.mao@riscstar.com,
robin.randhawa@sifive.com, samuel.holland@sifive.com,
peter.lin@sifive.com
Subject: [PATCH v2 02/12] lib: sbi: add experimental Yield ECALL extension
Date: Thu, 29 Oct 2026 11:59:19 -0400 [thread overview]
Message-ID: <20261029155929.586597-3-raymondmaoca@gmail.com> (raw)
In-Reply-To: <20261029155929.586597-1-raymondmaoca@gmail.com>
From: Raymond Mao <raymond.mao@riscstar.com>
Add a Yield extension with EID 0x0800594c and FID 0.
The ID is experimental and is not an official SBI assignment.
Complete the calling domain and hart's outstanding SYSIRQ batches
using the same completion mechanism as the next CLAIM. Return the number
completed, including partial progress on error, without claiming new IRQs.
Ask the backend to consider a drained return only after completion
succeeds.
Enable the extension with CONFIG_SBI_ECALL_YIELD and register it only
when SYSIRQ channels exist.
Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
include/sbi/sbi_ecall_interface.h | 6 +++++
lib/sbi/Kconfig | 9 +++++++
lib/sbi/objects.mk | 3 +++
lib/sbi/sbi_ecall_yield.c | 42 +++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+)
create mode 100644 lib/sbi/sbi_ecall_yield.c
diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h
index fd4e77ca..287d3151 100644
--- a/include/sbi/sbi_ecall_interface.h
+++ b/include/sbi/sbi_ecall_interface.h
@@ -39,6 +39,9 @@
#define SBI_EXT_FWFT 0x46574654
#define SBI_EXT_MPXY 0x4D505859
+/* SBI extension ID for Yield. */
+#define SBI_EXT_YIELD 0x0800594c
+
/* SBI function IDs for BASE extension*/
#define SBI_EXT_BASE_GET_SPEC_VERSION 0x0
#define SBI_EXT_BASE_GET_IMP_ID 0x1
@@ -122,6 +125,9 @@
#define SBI_EXT_DBTR_TRIGGER_ENABLE 0x6
#define SBI_EXT_DBTR_TRIGGER_DISABLE 0x7
+/* SBI function IDs for the Yield extension. */
+#define SBI_EXT_YIELD_YIELD 0x0
+
/* SBI function IDs for FW feature extension */
#define SBI_EXT_FWFT_SET 0x0
#define SBI_EXT_FWFT_GET 0x1
diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig
index 24132eaa..894ce22f 100644
--- a/lib/sbi/Kconfig
+++ b/lib/sbi/Kconfig
@@ -76,6 +76,15 @@ config SBI_ECALL_LEGACY
bool "SBI v0.1 legacy extensions"
default y
+config SBI_ECALL_YIELD
+ bool "Yield extension"
+ default y
+ help
+ Enable the Yield ECALL extension.
+ Yield completes the calling domain and hart's claimed SYSIRQs.
+ A delivery backend may request a context return once work is drained.
+ Interrupt claiming still uses RPMI SYSTEM_IRQ through SBI MPXY.
+
config SBI_ECALL_VENDOR
bool "Platform-defined vendor extensions"
default y
diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk
index ae27d0c5..16c141fe 100644
--- a/lib/sbi/objects.mk
+++ b/lib/sbi/objects.mk
@@ -64,6 +64,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_SSE) += sbi_ecall_sse.o
carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_MPXY) += ecall_mpxy
libsbi-objs-$(CONFIG_SBI_ECALL_MPXY) += sbi_ecall_mpxy.o
+carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_YIELD) += ecall_yield
+libsbi-objs-$(CONFIG_SBI_ECALL_YIELD) += sbi_ecall_yield.o
+
libsbi-objs-y += sbi_bitmap.o
libsbi-objs-y += sbi_bitops.o
libsbi-objs-y += sbi_console.o
diff --git a/lib/sbi/sbi_ecall_yield.c b/lib/sbi/sbi_ecall_yield.c
new file mode 100644
index 00000000..fddc2d6c
--- /dev/null
+++ b/lib/sbi/sbi_ecall_yield.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: BSD-2-Clause
+/*
+ * Copyright (c) 2026 RISCstar Solutions Corporation.
+ *
+ * Author: Raymond Mao <raymond.mao@riscstar.com>
+ */
+
+#include <sbi/sbi_ecall.h>
+#include <sbi/sbi_ecall_interface.h>
+#include <sbi/sbi_error.h>
+#include <sbi_utils/sysirq/rpmi_sysirq.h>
+
+static int sbi_ecall_yield_handler(unsigned long extid, unsigned long funcid,
+ struct sbi_trap_regs *regs,
+ struct sbi_ecall_return *out)
+{
+ u32 completed = 0;
+ int rc;
+
+ if (funcid != SBI_EXT_YIELD_YIELD)
+ return SBI_ENOTSUPP;
+ rc = rpmi_sysirq_complete_thishart(&completed);
+ out->value = completed;
+ return rc;
+}
+
+struct sbi_ecall_extension ecall_yield;
+
+static int sbi_ecall_yield_register_extensions(void)
+{
+ if (!rpmi_sysirq_available())
+ return SBI_OK;
+ return sbi_ecall_register_extension(&ecall_yield);
+}
+
+struct sbi_ecall_extension ecall_yield = {
+ .name = "yield",
+ .extid_start = SBI_EXT_YIELD,
+ .extid_end = SBI_EXT_YIELD,
+ .register_extensions = sbi_ecall_yield_register_extensions,
+ .handle = sbi_ecall_yield_handler,
+};
--
2.25.1
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-10-29 15:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 15:59 [PATCH v2 00/12] Introduce Virtual IRQ (VIRQ) framework Raymond Mao
2026-10-29 15:59 ` [PATCH v2 01/12] lib: utils: add RPMI SYSTEM_IRQ service support Raymond Mao
2026-10-29 15:59 ` Raymond Mao [this message]
2026-10-29 15:59 ` [PATCH v2 03/12] lib: irqchip: add S-mode notification helpers Raymond Mao
2026-10-29 15:59 ` [PATCH v2 04/12] lib: sbi: domain: support VIRQ couriering domain context switch Raymond Mao
2026-10-29 15:59 ` [PATCH v2 05/12] lib: sbi: domain: ensure boot_hartid is assigned Raymond Mao
2026-10-29 15:59 ` [PATCH v2 06/12] lib: sbi: Add Virtual IRQ (VIRQ) subsystem Raymond Mao
2026-10-29 15:59 ` [PATCH v2 07/12] lib: sbi: domain: add domain lookup by name Raymond Mao
2026-10-29 15:59 ` [PATCH v2 08/12] lib: utils: irqchip: derive APLIC targets from sysirq nodes Raymond Mao
2026-10-29 15:59 ` [PATCH v2 09/12] lib: utils: irqchip: Add helper to register VIRQ courier handler Raymond Mao
2026-10-29 15:59 ` [PATCH v2 10/12] lib: utils: fdt: parse sysirq routing from DT Raymond Mao
2026-10-29 15:59 ` [PATCH v2 11/12] docs: domain: document sysirq VIRQ mapping and routing rules Raymond Mao
2026-10-29 15:59 ` [PATCH v2 12/12] [NOT-FOR-UPSTREAM] platform: generic: Add sample dts overlays for testing hwirq/domain route rules Raymond Mao
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=20261029155929.586597-3-raymondmaoca@gmail.com \
--to=raymondmaoca@gmail.com \
--cc=anup.patel@oss.qualcomm.com \
--cc=anup@brainfault.org \
--cc=opensbi@lists.infradead.org \
--cc=peter.lin@sifive.com \
--cc=raymond.mao@riscstar.com \
--cc=robin.randhawa@sifive.com \
--cc=samuel.holland@sifive.com \
--cc=scott@riscstar.com \
/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