[PATCH] firmware: smccc: lfa: Cancel PRIME after a partial failure
From: Jiangtian Feng
Date: Thu Dec 03 2026 - 00:57:13 EST
Once PRIME has returned CALL_AGAIN, a later firmware error currently
returns directly and skips the CANCEL used for timeout and interrupt
failures. This can leave a component primed while another transaction
starts.
Track the firmware-requested continuation and route subsequent errors
through the existing cancellation path. Preserve immediate first-call
errors and the existing timeout and interrupt behavior.
Qoder, an AI coding assistant, helped analyze the PRIME transaction
failure path and draft this change and description. The submitter
reviewed the change and is responsible for final validation.
Link: https://lore.kernel.org/all/20261203013817.1215179-2-jiangtianfeng@xxxxxxxxxxxxxxxxx/
Signed-off-by: Jiangtian Feng <jiangtianfeng@xxxxxxxxxxxxxxxxx>
---
drivers/firmware/smccc/lfa_fw.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index 0ddfe7b98f5d..d876262b93cb 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -493,6 +493,7 @@ static int activate_fw_component(struct fw_component *comp)
static int prime_fw_component(struct fw_component *comp)
{
ktime_t end = ktime_add_ms(ktime_get(), LFA_PRIME_BUDGET_MS);
+ bool prime_pending = false;
int ret = 0;
if (comp->may_reset_cpu) {
@@ -521,12 +522,16 @@ static int prime_fw_component(struct fw_component *comp)
pr_err("LFA_PRIME for component %s failed: %s (%ld)\n",
kobject_name(&comp->kobj),
lfa_error_string((s64)regs.a0), regs.a0);
- return lfa_to_linux_errno((s64)regs.a0);
+ ret = lfa_to_linux_errno((s64)regs.a0);
+ if (!prime_pending)
+ return ret;
+ break;
}
if (!(regs.a1 & LFA_PRIME_CALL_AGAIN))
return 0;
+ prime_pending = true;
if (ktime_before(ktime_get(), end)) {
if (msleep_interruptible(LFA_PRIME_DELAY_MS)) {
ret = -EINTR;
--
2.47.3