From: Raymond Mao <raymondmaoca@gmail.com>
To: opensbi@lists.infradead.org
Cc: scott@riscstar.com, dave.patel@riscstar.com,
raymond.mao@riscstar.com, robin.randhawa@sifive.com,
samuel.holland@sifive.com, anup.patel@qti.qualcomm.com,
anuppate@qti.qualcomm.com, dhaval@rivosinc.com,
peter.lin@sifive.com
Subject: [PATCH v2 1/2] lib: sbi: introduce abstraction for wired interrupt handling
Date: Mon, 2 Feb 2026 10:02:06 -0500 [thread overview]
Message-ID: <20260202150207.1331811-2-raymondmaoca@gmail.com> (raw)
In-Reply-To: <20260202150207.1331811-1-raymondmaoca@gmail.com>
From: Raymond Mao <raymond.mao@riscstar.com>
Add wired interrupt handling abstraction into irqchip.
This introduces a small provider interface based on
claim/complete/mask/unmak semantics, allowing to register a wired
interrupt controller as a provider.
Signed-off-by: Raymond Mao <raymond.mao@riscstar.com>
---
include/sbi/sbi_irqchip.h | 52 +++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/include/sbi/sbi_irqchip.h b/include/sbi/sbi_irqchip.h
index e0ae12f5..27b88765 100644
--- a/include/sbi/sbi_irqchip.h
+++ b/include/sbi/sbi_irqchip.h
@@ -27,6 +27,38 @@ struct sbi_irqchip_device {
int (*irq_handle)(void);
};
+/* Handler for a specified hwirq */
+typedef int (*sbi_irqchip_irq_handler_t)(void *priv);
+
+/* Provider operations */
+struct sbi_irqchip_provider_ops {
+ /*
+ * Claim a pending wired interrupt on current hart.
+ * Returns:
+ * SBI_OK : *hwirq is valid
+ * SBI_ENOENT : no pending wired interrupt
+ * <0 : error
+ */
+ int (*claim)(void *ctx, u32 *hwirq);
+
+ /*
+ * Complete/acknowledge a previously claimed wired interrupt
+ * (if required by HW).
+ * Some HW may not require an explicit completion.
+ */
+ void (*complete)(void *ctx, u32 hwirq);
+
+ /*
+ * mask/unmask a wired interrupt line.
+ *
+ * These are required for reliable couriering of level-triggered device
+ * interrupts to S-mode: mask in M-mode before enqueueing, and unmask
+ * after S-mode has cleared the device interrupt source.
+ */
+ void (*mask)(void *ctx, u32 hwirq);
+ void (*unmask)(void *ctx, u32 hwirq);
+};
+
/**
* Process external interrupts
*
@@ -46,4 +78,24 @@ int sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot);
/** Exit interrupt controllers */
void sbi_irqchip_exit(struct sbi_scratch *scratch);
+/*
+ * Register the active wired interrupt provider.
+ * - max_hwirq specifies the highest valid hwirq ID.
+ */
+int sbi_irqchip_register_provider(const struct sbi_irqchip_provider_ops *ops,
+ void *ctx, u32 max_hwirq);
+
+u32 sbi_irqchip_get_max_src(void);
+
+/* Set/clear handler for a specified hwirq */
+int sbi_irqchip_set_handler(u32 hwirq, sbi_irqchip_irq_handler_t handler,
+ void *priv);
+int sbi_irqchip_clear_handler(u32 hwirq);
+
+void sbi_irqchip_mask_irq(u32 hwirq);
+void sbi_irqchip_unmask_irq(u32 hwirq);
+
+/* external interrupt handler (irqchip device hook) */
+int sbi_irqchip_handle_external_irq(void);
+
#endif
--
2.25.1
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-02-02 15:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 15:02 [RFC v2 PATCH 0/2] Introduce irqchip and VIRQ layer prototypes Raymond Mao
2026-02-02 15:02 ` Raymond Mao [this message]
2026-02-07 10:10 ` [PATCH v2 1/2] lib: sbi: introduce abstraction for wired interrupt handling Anup Patel
2026-02-07 16:23 ` Raymond Mao
2026-02-02 15:02 ` [PATCH v2 2/2] lib: sbi: Add VIRQ interrupt abstraction Raymond Mao
2026-02-07 10:07 ` [RFC v2 PATCH 0/2] Introduce irqchip and VIRQ layer prototypes Anup Patel
2026-02-07 16:11 ` Raymond Mao
2026-02-08 13:23 ` Anup Patel
2026-02-08 18:50 ` Raymond Mao
2026-02-10 16:06 ` Anup Patel
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=20260202150207.1331811-2-raymondmaoca@gmail.com \
--to=raymondmaoca@gmail.com \
--cc=anup.patel@qti.qualcomm.com \
--cc=anuppate@qti.qualcomm.com \
--cc=dave.patel@riscstar.com \
--cc=dhaval@rivosinc.com \
--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