* [PATCH v3 1/4] dt-bindings: firmware: Add interrupt specification for Intel Stratix 10 Service Layer.
2026-08-13 6:35 [PATCH v3 0/4] stratix10: Add Interrupt support for asynchronous communication with SDM tze.yee.ng
@ 2026-08-13 6:35 ` tze.yee.ng
2026-08-13 6:35 ` [PATCH v3 2/4] dts: stratix10: Add support for SDM mailbox interrupt for Intel Stratix10 SoC FPGA tze.yee.ng
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: tze.yee.ng @ 2026-08-13 6:35 UTC (permalink / raw)
To: Dinh Nguyen, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Mahesh Rao, linux-kernel, devicetree
From: Mahesh Rao <mahesh.rao@altera.com>
Add interrupt specification for Intel Stratix10 Service layer for
asynchronous communication.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Mahesh Rao <mahesh.rao@altera.com>
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
Changes in v3:
- Reflow commit message body to ~75 columns (fix Dinh's comment in v2
review)
- No functional change
- Drop Reviewed-by: Matthew Gerlach (no longer at Altera)
- Add Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
.../bindings/firmware/intel,stratix10-svc.yaml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/intel,stratix10-svc.yaml b/Documentation/devicetree/bindings/firmware/intel,stratix10-svc.yaml
index b42cfa78b28b..1af8ee3f1f3b 100644
--- a/Documentation/devicetree/bindings/firmware/intel,stratix10-svc.yaml
+++ b/Documentation/devicetree/bindings/firmware/intel,stratix10-svc.yaml
@@ -55,6 +55,12 @@ properties:
reserved memory region for the service layer driver to
communicate with the secure device manager.
+ interrupts:
+ maxItems: 1
+ description:
+ This interrupt is used by the Secure Device Manager (SDM) to signal
+ completion of an asynchronous operation to service layer driver.
+
iommus:
maxItems: 1
@@ -82,6 +88,8 @@ additionalProperties: false
examples:
- |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
@@ -99,6 +107,8 @@ examples:
compatible = "intel,stratix10-svc";
method = "smc";
memory-region = <&service_reserved>;
+ interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-parent = <&intc0>;
fpga-mgr {
compatible = "intel,stratix10-soc-fpga-mgr";
--
2.43.7
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v3 4/4] firmware: stratix10-svc: Add for SDM mailbox doorbell interrupt
2026-08-13 6:35 [PATCH v3 0/4] stratix10: Add Interrupt support for asynchronous communication with SDM tze.yee.ng
` (2 preceding siblings ...)
2026-08-13 6:35 ` [PATCH v3 3/4] dts: agilex: Add support for SDM mailbox interrupt for Intel Agilex " tze.yee.ng
@ 2026-08-13 6:35 ` tze.yee.ng
2026-08-13 6:51 ` sashiko-bot
3 siblings, 1 reply; 6+ messages in thread
From: tze.yee.ng @ 2026-08-13 6:35 UTC (permalink / raw)
To: Dinh Nguyen, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Mahesh Rao, linux-kernel, devicetree
From: Mahesh Rao <mahesh.rao@altera.com>
Add support for SDM (Secure Device Manager) mailbox doorbell interrupt for
async transactions. On interrupt, a workqueue is triggered which polls the
ATF for pending responses and retrieves the bitmap of all retrieved and
unprocessed transaction ids of mailbox responses from SDM. It then triggers
the corresponding registered callbacks.
Signed-off-by: Mahesh Rao <mahesh.rao@altera.com>
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
Changes in v3:
- Reflow commit message body to ~75 columns (fix Dinh's comment in v2
review)
- Add a newline before stratix10_async_workqueue_handler
description (fix Dinh's comment in v2 review)
- Treat of_irq_get() failure as irq <= 0, since 0 is also a
failing value (fix Dinh's comment in v2 review)
- Fix IRQ disable race: only call disable_irq_nosync() when
queue_work() newly queues work, and disable the fired irq
argument rather than actrl->irq
- Do not invoke client callbacks under trx_list_lock; copy
cb/cb_arg under the lock and call the callback after unlock
- Use disable_irq() + flush_work() + devm_free_irq() on
teardown, and treat unset IRQ as 0
- Demote successful IRQ registration log from dev_alert() to
dev_info(), and demote async poll failure log from
dev_err() to dev_dbg()
- Clarify INTEL_SIP_SMC_ASYNC_POLL_ON_IRQ kdoc to match
a1-a4 bitmap usage
- Drop Reviewed-by: Matthew Gerlach (no longer at Altera)
- Add Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
drivers/firmware/stratix10-svc.c | 135 +++++++++++++++++--
include/linux/firmware/intel/stratix10-smc.h | 21 +++
2 files changed, 145 insertions(+), 11 deletions(-)
diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 08395fe3ddaa..3035bf46b65b 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -10,12 +10,14 @@
#include <linux/genalloc.h>
#include <linux/hashtable.h>
#include <linux/idr.h>
+#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kfifo.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -24,6 +26,7 @@
#include <linux/firmware/intel/stratix10-smc.h>
#include <linux/firmware/intel/stratix10-svc-client.h>
#include <linux/types.h>
+#include <linux/workqueue.h>
/**
* SVC_NUM_DATA_IN_FIFO - number of struct stratix10_svc_data in the FIFO
@@ -219,6 +222,7 @@ struct stratix10_async_chan {
* @supported: Flag indicating whether the system supports async operations
* @initialized: Flag indicating whether the control structure has
* been initialized
+ * @irq: Interrupt request number associated with the asynchronous control
* @invoke_fn: Function pointer for invoking Stratix10 service calls
* to EL3 secure firmware
* @async_id_pool: Pointer to the ID pool used for asynchronous
@@ -229,12 +233,14 @@ struct stratix10_async_chan {
* structure
* @trx_list_lock: Spinlock for protecting the transaction list
* operations
+ * @async_work: Work structure for scheduling asynchronous work
* @trx_list: Hash table for managing asynchronous transactions
*/
struct stratix10_async_ctrl {
bool supported;
bool initialized;
+ int irq;
void (*invoke_fn)(struct stratix10_async_ctrl *actrl,
const struct arm_smccc_1_2_regs *args,
struct arm_smccc_1_2_regs *res);
@@ -243,6 +249,7 @@ struct stratix10_async_ctrl {
struct stratix10_async_chan *common_async_chan;
/* spinlock to protect trx_list hash table */
spinlock_t trx_list_lock;
+ struct work_struct async_work;
DECLARE_HASHTABLE(trx_list, ASYNC_TRX_HASH_BITS);
};
@@ -1595,7 +1602,7 @@ int stratix10_svc_async_poll(struct stratix10_svc_chan *chan,
return -EAGAIN;
}
- dev_err(ctrl->dev,
+ dev_dbg(ctrl->dev,
"Failed to poll async message ,got status as %ld\n",
handle->res.a0);
return -EINVAL;
@@ -1658,14 +1665,96 @@ static inline void stratix10_smc_1_2(struct stratix10_async_ctrl *actrl,
arm_smccc_1_2_smc(args, res);
}
+static irqreturn_t stratix10_svc_async_irq_handler(int irq, void *dev_id)
+{
+ struct stratix10_svc_controller *ctrl = dev_id;
+ struct stratix10_async_ctrl *actrl = &ctrl->actrl;
+
+ /*
+ * Only disable the IRQ when work is newly queued. If the work is
+ * already pending/running, queue_work() returns false; an extra
+ * disable_irq_nosync() would leave the IRQ disabled permanently
+ * after enable_irq() in the work handler.
+ */
+ if (queue_work(system_bh_wq, &actrl->async_work))
+ disable_irq_nosync(irq);
+ return IRQ_HANDLED;
+}
+
+/**
+ * stratix10_async_workqueue_handler - Handler for the asynchronous
+ * workqueue in Stratix10 service controller.
+ * @work: Pointer to the work structure that contains the asynchronous
+ * workqueue handler.
+ *
+ * This function is the handler for the asynchronous workqueue. It performs
+ * the following tasks:
+ * - Invokes the asynchronous polling on interrupt supervisory call.
+ * - On success, it retrieves the bitmap of pending transactions from mailbox
+ * fifo in ATF.
+ * - It processes each pending transaction by calling the corresponding
+ * callback function.
+ *
+ * The function ensures that the IRQ is enabled after processing the
+ * transactions.
+ */
+static void stratix10_async_workqueue_handler(struct work_struct *work)
+{
+ struct stratix10_async_ctrl *actrl =
+ container_of(work, struct stratix10_async_ctrl, async_work);
+ struct arm_smccc_1_2_regs
+ args = { .a0 = INTEL_SIP_SMC_ASYNC_POLL_ON_IRQ }, res;
+ DECLARE_BITMAP(pend_on_irq, TOTAL_TRANSACTION_IDS);
+ struct stratix10_svc_async_handler *handler;
+ unsigned long transaction_id = 0;
+ u64 bitmap_array[4];
+ async_callback_t cb;
+ void *cb_arg;
+
+ actrl->invoke_fn(actrl, &args, &res);
+ if (res.a0 == INTEL_SIP_SMC_STATUS_OK) {
+ bitmap_array[0] = res.a1;
+ bitmap_array[1] = res.a2;
+ bitmap_array[2] = res.a3;
+ bitmap_array[3] = res.a4;
+ bitmap_from_arr64(pend_on_irq, bitmap_array, TOTAL_TRANSACTION_IDS);
+ do {
+ transaction_id = find_next_bit(pend_on_irq,
+ TOTAL_TRANSACTION_IDS,
+ transaction_id);
+ if (transaction_id >= TOTAL_TRANSACTION_IDS)
+ break;
+
+ cb = NULL;
+ cb_arg = NULL;
+ spin_lock(&actrl->trx_list_lock);
+ hash_for_each_possible(actrl->trx_list, handler,
+ next, transaction_id) {
+ if (handler->transaction_id == transaction_id) {
+ cb = handler->cb;
+ cb_arg = handler->cb_arg;
+ break;
+ }
+ }
+ spin_unlock(&actrl->trx_list_lock);
+ if (cb)
+ cb(cb_arg);
+
+ transaction_id++;
+ } while (transaction_id < TOTAL_TRANSACTION_IDS);
+ }
+ enable_irq(actrl->irq);
+}
+
/**
* stratix10_svc_async_init - Initialize the Stratix10 service
* controller for asynchronous operations.
* @controller: Pointer to the Stratix10 service controller structure.
*
* This function initializes the asynchronous service controller by
- * setting up the necessary data structures and initializing the
- * transaction list.
+ * setting up the necessary data structures ,initializing the
+ * transaction list and registering the IRQ handler for asynchronous
+ * transactions.
*
* Return: 0 on success, -EINVAL if the controller is NULL or already
* initialized, -ENOMEM if memory allocation fails,
@@ -1678,7 +1767,7 @@ static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)
struct stratix10_async_ctrl *actrl;
struct arm_smccc_res res;
struct device *dev;
- int ret;
+ int ret, irq;
if (!controller)
return -EINVAL;
@@ -1726,6 +1815,22 @@ static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)
hash_init(actrl->trx_list);
atomic_set(&actrl->common_achan_refcount, 0);
+ irq = of_irq_get(dev_of_node(dev), 0);
+ if (irq <= 0) {
+ dev_warn(dev, "Failed to get IRQ, falling back to polling mode\n");
+ } else {
+ ret = devm_request_any_context_irq(dev, irq, stratix10_svc_async_irq_handler,
+ IRQF_NO_AUTOEN, "stratix10_svc", controller);
+ if (ret == 0) {
+ dev_info(dev,
+ "Registered IRQ %d for sip async operations\n",
+ irq);
+ actrl->irq = irq;
+ INIT_WORK(&actrl->async_work, stratix10_async_workqueue_handler);
+ enable_irq(actrl->irq);
+ }
+ }
+
actrl->initialized = true;
return 0;
}
@@ -1735,13 +1840,14 @@ static int stratix10_svc_async_init(struct stratix10_svc_controller *controller)
* service controller
* @ctrl: Pointer to the stratix10_svc_controller structure
*
- * This function performs the necessary cleanup for the asynchronous
- * service controller. It checks if the controller is valid and if it
- * has been initialized. It then locks the transaction list and safely
- * removes and deallocates each handler in the list. The function also
- * removes any asynchronous clients associated with the controller's
- * channels and destroys the asynchronous ID pool. Finally, it resets
- * the asynchronous ID pool and invoke function pointers to NULL.
+ * This function performs the necessary cleanup for the asynchronous service
+ * controller. It checks if the controller is valid and if it has been
+ * initialized. Also If the controller has an IRQ assigned, it frees the IRQ
+ * and flushes any pending asynchronous work. It then locks the transaction
+ * list and safely removes and deallocates each handler in the list.
+ * The function also removes any asynchronous clients associated with the
+ * controller's channels and destroys the asynchronous ID pool. Finally, it
+ * resets the asynchronous ID pool and invoke function pointers to NULL.
*
* Return: 0 on success, -EINVAL if the controller is invalid or not
* initialized.
@@ -1763,6 +1869,13 @@ static int stratix10_svc_async_exit(struct stratix10_svc_controller *ctrl)
actrl->initialized = false;
+ if (actrl->irq > 0) {
+ disable_irq(actrl->irq);
+ flush_work(&actrl->async_work);
+ devm_free_irq(ctrl->dev, actrl->irq, ctrl);
+ actrl->irq = 0;
+ }
+
scoped_guard(spinlock_bh, &actrl->trx_list_lock) {
hash_for_each_safe(actrl->trx_list, i, tmp, handler, next) {
ida_free(&handler->achan->job_id_pool,
diff --git a/include/linux/firmware/intel/stratix10-smc.h b/include/linux/firmware/intel/stratix10-smc.h
index ce1d2c7203b8..355a74b2134d 100644
--- a/include/linux/firmware/intel/stratix10-smc.h
+++ b/include/linux/firmware/intel/stratix10-smc.h
@@ -718,6 +718,27 @@ INTEL_SIP_SMC_FAST_CALL_VAL(INTEL_SIP_SMC_FUNCID_FPGA_CONFIG_COMPLETED_WRITE)
#define INTEL_SIP_SMC_ASYNC_POLL \
INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_POLL)
+/**
+ * Request INTEL_SIP_SMC_ASYNC_POLL_ON_IRQ
+ * Async call used by service driver at EL1 to retrieve the transaction IDs
+ * of available responses from the SDM mailbox (typically after an IRQ).
+ *
+ * Call register usage:
+ * a0 INTEL_SIP_SMC_ASYNC_POLL_ON_IRQ
+ * a1-a17 not used
+ *
+ * Return status
+ * a0 INTEL_SIP_SMC_STATUS_OK
+ * a1-a4 contain a bitmap of pending transaction IDs (set bit positions)
+ * a5-a17 not used
+ * Or
+ * a0 INTEL_SIP_SMC_STATUS_NO_RESPONSE
+ * a1-a17 not used
+ */
+#define INTEL_SIP_SMC_ASYNC_FUNC_ID_IRQ_POLL (0xC9)
+#define INTEL_SIP_SMC_ASYNC_POLL_ON_IRQ \
+ INTEL_SIP_SMC_ASYNC_VAL(INTEL_SIP_SMC_ASYNC_FUNC_ID_IRQ_POLL)
+
/**
* Request INTEL_SIP_SMC_ASYNC_HWMON_READTEMP
* Async call to request temperature
--
2.43.7
^ permalink raw reply related [flat|nested] 6+ messages in thread