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 03/12] lib: irqchip: add S-mode notification helpers
Date: Thu, 29 Oct 2026 11:59:20 -0400 [thread overview]
Message-ID: <20261029155929.586597-4-raymondmaoca@gmail.com> (raw)
In-Reply-To: <20261029155929.586597-1-raymondmaoca@gmail.com>
From: Raymond Mao <raymond.mao@riscstar.com>
Add irqchip helpers to set/clear S-mode notification (SEIP-based).
In addition to set/clear, expose a get API to read the current
notification state so upper layers can do edge-triggered notification.
Allow raw handlers to return SBI_EALREADY when physical completion is
deferred to the recipient, instead of issuing an immediate EOI. Preserve
ordinary completion behavior for other handler results.
Release handler storage when unregistering an interrupt handler so failed
courier setup can roll back without leaking memory.
Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
include/sbi/sbi_irqchip.h | 9 +++++++++
lib/sbi/sbi_irqchip.c | 21 +++++++++++++++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/include/sbi/sbi_irqchip.h b/include/sbi/sbi_irqchip.h
index f5dbf1c7..174fa930 100644
--- a/include/sbi/sbi_irqchip.h
+++ b/include/sbi/sbi_irqchip.h
@@ -172,4 +172,13 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch);
bool sbi_irqchip_is_hwirq_enabled(struct sbi_irqchip_device *chip,
u32 hwirq);
+/** Notify S-mode for a pending virtual interrupt on this hart. */
+int sbi_irqchip_notify_smode_set(void);
+
+/** Clear S-mode notification for virtual interrupts on this hart. */
+void sbi_irqchip_notify_smode_clear(void);
+
+/** Read S-mode notification state for virtual interrupts on this hart. */
+bool sbi_irqchip_notify_smode_get(void);
+
#endif
diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c
index 1664bd2d..f9afadc0 100644
--- a/lib/sbi/sbi_irqchip.c
+++ b/lib/sbi/sbi_irqchip.c
@@ -14,6 +14,7 @@
#include <sbi/sbi_list.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_scratch.h>
+#include <sbi/riscv_asm.h>
/** Internal irqchip hardware interrupt data */
struct sbi_irqchip_hwirq_data {
@@ -191,9 +192,8 @@ int sbi_irqchip_raw_handler_default(struct sbi_irqchip_device *chip, u32 hwirq)
if (h->callback)
rc = h->callback(hwirq, h->priv);
- if (chip->hwirq_eoi)
+ if (chip->hwirq_eoi && rc != SBI_EALREADY)
chip->hwirq_eoi(chip, hwirq);
-
return rc;
}
@@ -471,6 +471,7 @@ int sbi_irqchip_unregister_handler(struct sbi_irqchip_device *chip,
}
sbi_list_del(&fh->node);
+ sbi_free(fh);
return 0;
}
@@ -618,3 +619,19 @@ skip_migrate:
if (hd && hd->chip && hd->chip->process_hwirqs)
csr_clear(CSR_MIE, MIP_MEIP);
}
+
+int sbi_irqchip_notify_smode_set(void)
+{
+ csr_set(CSR_MIP, MIP_SEIP);
+ return 0;
+}
+
+void sbi_irqchip_notify_smode_clear(void)
+{
+ csr_clear(CSR_MIP, MIP_SEIP);
+}
+
+bool sbi_irqchip_notify_smode_get(void)
+{
+ return !!(csr_read(CSR_MIP) & MIP_SEIP);
+}
--
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 ` [PATCH v2 02/12] lib: sbi: add experimental Yield ECALL extension Raymond Mao
2026-10-29 15:59 ` Raymond Mao [this message]
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-4-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