mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes
@ 2026-07-14  5:37 Adrian Ng Ho Yin
  2026-07-14  5:37 ` [PATCH v2 1/2] firmware: stratix10-svc: handle NO_RESPONSE in async poll Adrian Ng Ho Yin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Adrian Ng Ho Yin @ 2026-07-14  5:37 UTC (permalink / raw)
  To: Dinh Nguyen, linux-kernel; +Cc: tze.yee.ng, Adrian Ng Ho Yin

This series addresses two issues in the stratix10 service layer's
asynchronous transaction handling.

Patch 1 adds INTEL_SIP_SMC_STATUS_NO_RESPONSE (0x3) to the SMC status
definitions and handles it in stratix10_svc_async_poll() alongside
INTEL_SIP_SMC_STATUS_BUSY. Both statuses indicate the Secure Device
Manager has not yet produced a response and should cause callers to
retry rather than treating the poll as a hard failure. Without this,
the unrecognised status code falls through to the error path and is
mapped to -EINVAL, making "not ready yet" indistinguishable from a
real error.

Patch 2 fixes the teardown ordering in stratix10_svc_drv_remove()
reported by sashiko (https://lore.kernel.org/all/cd6460b2-7f53-4ac6-8f68-172e7853f63f@kernel.org/).
Previously, stratix10_svc_async_exit() was called before client
devices were unregistered, leaving a window where child devices could
issue service requests after the async infrastructure had already been
destroyed. The fix unregisters client devices first so all in-flight
calls drain before the underlying channels and threads are torn down.

---
changelog:
v1->v2:
* update commit message to include Fixes tag and Cc: stable@vger.kernel.org.
---
Adrian Ng Ho Yin (2):
  firmware: stratix10-svc: handle NO_RESPONSE in async poll
  firmware: stratix10-svc: fix teardown order in remove to prevent race

 drivers/firmware/stratix10-svc.c             | 9 +++++----
 include/linux/firmware/intel/stratix10-smc.h | 4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

-- 
2.49.GIT


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] firmware: stratix10-svc: handle NO_RESPONSE in async poll
  2026-07-14  5:37 [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Adrian Ng Ho Yin
@ 2026-07-14  5:37 ` Adrian Ng Ho Yin
  2026-07-14  5:37 ` [PATCH v2 2/2] firmware: stratix10-svc: fix teardown order in remove to prevent race Adrian Ng Ho Yin
  2026-07-14 22:26 ` [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Dinh Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Ng Ho Yin @ 2026-07-14  5:37 UTC (permalink / raw)
  To: Dinh Nguyen, linux-kernel; +Cc: tze.yee.ng, Adrian Ng Ho Yin, stable

Define INTEL_SIP_SMC_STATUS_NO_RESPONSE (0x3) and handle it in
stratix10_svc_async_poll() the same way as INTEL_SIP_SMC_STATUS_BUSY,
returning -EAGAIN so callers can retry instead of treating the poll as
a hard failure.

When the Secure Device Manager has not yet produced a response for an
asynchronous transaction, ATF is expected to return
INTEL_SIP_SMC_STATUS_NO_RESPONSE. Without this handling, the service
layer maps the status to -EINVAL and async clients cannot distinguish
"not ready yet" from a real error.

Fixes: bcb9f4f07061 ("firmware: stratix10-svc: Add support for async communication")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
---
 drivers/firmware/stratix10-svc.c             | 5 +++--
 include/linux/firmware/intel/stratix10-smc.h | 4 ++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index 4140cc488d96..e89fa198688f 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -1569,8 +1569,9 @@ int stratix10_svc_async_poll(struct stratix10_svc_chan *chan,
 			WARN_ON_ONCE(1);
 		}
 		return 0;
-	} else if (handle->res.a0 == INTEL_SIP_SMC_STATUS_BUSY) {
-		dev_dbg(ctrl->dev, "async message is still in progress\n");
+	} else if (handle->res.a0 == INTEL_SIP_SMC_STATUS_BUSY ||
+		   handle->res.a0 == INTEL_SIP_SMC_STATUS_NO_RESPONSE) {
+		dev_dbg(ctrl->dev, "async message is not ready yet\n");
 		return -EAGAIN;
 	}
 
diff --git a/include/linux/firmware/intel/stratix10-smc.h b/include/linux/firmware/intel/stratix10-smc.h
index daa693699c97..2bb7f8427a47 100644
--- a/include/linux/firmware/intel/stratix10-smc.h
+++ b/include/linux/firmware/intel/stratix10-smc.h
@@ -67,6 +67,9 @@
  * INTEL_SIP_SMC_STATUS_REJECTED:
  * Secure monitor software reject the service client's request.
  *
+ * INTEL_SIP_SMC_STATUS_NO_RESPONSE:
+ * Secure monitor software has no response for the request yet.
+ *
  * INTEL_SIP_SMC_STATUS_ERROR:
  * There is error during the process of service request.
  *
@@ -77,6 +80,7 @@
 #define INTEL_SIP_SMC_STATUS_OK				0x0
 #define INTEL_SIP_SMC_STATUS_BUSY			0x1
 #define INTEL_SIP_SMC_STATUS_REJECTED			0x2
+#define INTEL_SIP_SMC_STATUS_NO_RESPONSE		0x3
 #define INTEL_SIP_SMC_STATUS_ERROR			0x4
 #define INTEL_SIP_SMC_RSU_ERROR				0x7
 
-- 
2.49.GIT


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] firmware: stratix10-svc: fix teardown order in remove to prevent race
  2026-07-14  5:37 [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Adrian Ng Ho Yin
  2026-07-14  5:37 ` [PATCH v2 1/2] firmware: stratix10-svc: handle NO_RESPONSE in async poll Adrian Ng Ho Yin
@ 2026-07-14  5:37 ` Adrian Ng Ho Yin
  2026-07-14 22:26 ` [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Dinh Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Ng Ho Yin @ 2026-07-14  5:37 UTC (permalink / raw)
  To: Dinh Nguyen, linux-kernel; +Cc: tze.yee.ng, Adrian Ng Ho Yin, stable

In stratix10_svc_drv_remove(), stratix10_svc_async_exit() was called
before client devices were unregistered. This created a race window
where child devices could still be issuing service requests through
the async channels after the async infrastructure had already been
torn down.

Unregister client devices before tearing down the async threads and
channels to ensure all in-flight service calls drain before the
underlying infrastructure is destroyed.

Fixes: bcb9f4f07061 ("firmware: stratix10-svc: Add support for async communication")
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
---
 drivers/firmware/stratix10-svc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c
index e89fa198688f..bfc9aceb681b 100644
--- a/drivers/firmware/stratix10-svc.c
+++ b/drivers/firmware/stratix10-svc.c
@@ -2204,12 +2204,12 @@ static void stratix10_svc_drv_remove(struct platform_device *pdev)
 	struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev);
 	struct stratix10_svc *svc = ctrl->svc;
 
+	platform_device_unregister(svc->stratix10_svc_rsu);
+
 	stratix10_svc_async_exit(ctrl);
 
 	of_platform_depopulate(ctrl->dev);
 
-	platform_device_unregister(svc->stratix10_svc_rsu);
-
 	for (i = 0; i < SVC_NUM_CHANNEL; i++) {
 		if (ctrl->chans[i].task) {
 			kthread_stop(ctrl->chans[i].task);
-- 
2.49.GIT


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes
  2026-07-14  5:37 [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Adrian Ng Ho Yin
  2026-07-14  5:37 ` [PATCH v2 1/2] firmware: stratix10-svc: handle NO_RESPONSE in async poll Adrian Ng Ho Yin
  2026-07-14  5:37 ` [PATCH v2 2/2] firmware: stratix10-svc: fix teardown order in remove to prevent race Adrian Ng Ho Yin
@ 2026-07-14 22:26 ` Dinh Nguyen
  2 siblings, 0 replies; 4+ messages in thread
From: Dinh Nguyen @ 2026-07-14 22:26 UTC (permalink / raw)
  To: Adrian Ng Ho Yin, linux-kernel; +Cc: tze.yee.ng



On 7/14/26 00:37, Adrian Ng Ho Yin wrote:
> This series addresses two issues in the stratix10 service layer's
> asynchronous transaction handling.
> 
> Patch 1 adds INTEL_SIP_SMC_STATUS_NO_RESPONSE (0x3) to the SMC status
> definitions and handles it in stratix10_svc_async_poll() alongside
> INTEL_SIP_SMC_STATUS_BUSY. Both statuses indicate the Secure Device
> Manager has not yet produced a response and should cause callers to
> retry rather than treating the poll as a hard failure. Without this,
> the unrecognised status code falls through to the error path and is
> mapped to -EINVAL, making "not ready yet" indistinguishable from a
> real error.
> 
> Patch 2 fixes the teardown ordering in stratix10_svc_drv_remove()
> reported by sashiko (https://lore.kernel.org/all/cd6460b2-7f53-4ac6-8f68-172e7853f63f@kernel.org/).
> Previously, stratix10_svc_async_exit() was called before client
> devices were unregistered, leaving a window where child devices could
> issue service requests after the async infrastructure had already been
> destroyed. The fix unregisters client devices first so all in-flight
> calls drain before the underlying channels and threads are torn down.
> 
> ---
> changelog:
> v1->v2:
> * update commit message to include Fixes tag and Cc: stable@vger.kernel.org.
> ---
> Adrian Ng Ho Yin (2):
>    firmware: stratix10-svc: handle NO_RESPONSE in async poll
>    firmware: stratix10-svc: fix teardown order in remove to prevent race
> 

Both patches applied!

Thanks,
Dinh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-14 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-14  5:37 [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Adrian Ng Ho Yin
2026-07-14  5:37 ` [PATCH v2 1/2] firmware: stratix10-svc: handle NO_RESPONSE in async poll Adrian Ng Ho Yin
2026-07-14  5:37 ` [PATCH v2 2/2] firmware: stratix10-svc: fix teardown order in remove to prevent race Adrian Ng Ho Yin
2026-07-14 22:26 ` [PATCH v2 0/2] firmware: stratix10-svc: async and teardown fixes Dinh Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox