[PATCH 1/4] firmware: smccc: lfa: Stop PRIME retry after completion

Jiangtian Feng jiangtianfeng at linux.alibaba.com
Wed Dec 2 17:38:14 PST 2026


The PRIME retry flag is set after CALL_AGAIN but never cleared. Once
firmware reports completion, the driver can keep issuing PRIME calls
without sleeping or checking the timeout budget.

Return success immediately when CALL_AGAIN is clear, while retaining
the existing timeout, signal and CANCEL paths for incomplete or failed
operations.

Link: https://lore.kernel.org/all/705b63c3-297a-4bf8-9eb2-b826e280e7da@nvidia.com/
Signed-off-by: Jiangtian Feng <jiangtianfeng at linux.alibaba.com>
---
 drivers/firmware/smccc/lfa_fw.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index 3ff368dca949..383157ab7cea 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -495,7 +495,6 @@ 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 retry = false;
 	int ret = 0;
 
 	if (comp->may_reset_cpu) {
@@ -509,7 +508,7 @@ static int prime_fw_component(struct fw_component *comp)
 	 * be called again.
 	 * regs.a1 will become 0 once the prime process completes.
 	 */
-	do {
+	for (;;) {
 		struct arm_smccc_1_2_regs regs = {
 			.a0 = ARM_SMCCC_LFA_PRIME,
 		};
@@ -527,21 +526,21 @@ static int prime_fw_component(struct fw_component *comp)
 			return lfa_to_linux_errno((s64)regs.a0);
 		}
 
-		if ((regs.a1 & LFA_PRIME_CALL_AGAIN)) {
-			if (ktime_before(ktime_get(), end)) {
-				if (msleep_interruptible(LFA_PRIME_DELAY_MS)) {
-					ret = -EINTR;
-					break;
-				}
-			} else {
-				pr_err("LFA_PRIME for component %s timed out",
-				       kobject_name(&comp->kobj));
-				ret = -ETIMEDOUT;
+		if (!(regs.a1 & LFA_PRIME_CALL_AGAIN))
+			return 0;
+
+		if (ktime_before(ktime_get(), end)) {
+			if (msleep_interruptible(LFA_PRIME_DELAY_MS)) {
+				ret = -EINTR;
 				break;
 			}
-			retry = true;
+		} else {
+			pr_err("LFA_PRIME for component %s timed out\n",
+			       kobject_name(&comp->kobj));
+			ret = -ETIMEDOUT;
+			break;
 		}
-	} while (retry);
+	}
 
 	if (ret)
 		lfa_cancel(comp);
-- 
2.47.3




More information about the linux-arm-kernel mailing list