From nobody Tue Apr 7 00:43:19 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 396CB3A6F08 for ; Tue, 17 Mar 2026 10:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773743635; cv=none; b=eqFrnQo7RthGIqg9o36E8Io339jFmAl7s4jklPC9vGkvJbLyId8p7bfErwZhF5PgCIbPRw8+CCmTHcTXEmlYksDXntm1pnWtxXtaziSsHodE0HkoFLfO6hNfomPPvtHBR9bS44nQ18AKeIip7L201tTD+tyWD32XoAUVPhgOv24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773743635; c=relaxed/simple; bh=Ns3yvsR1TpZgxwW2qqqn+pk25xbdCKuVjIHfY9RVFso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qsqQ7CYGYzyH/4w9RoEVB0iSlwvH0+H7aBrgHuTjx6cVc0aQcl2kNU/u7IDf85qin/JKBon2jp8qUXm7CEAjBAm0YomYir4XtR6L7qpTrIuIQY2S5xwj9d5CZN2T5ll7JYcVVpm2nCboCg2K7d54Q9DZKCDHP6rTbk6x32xvUAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD80C1477; Tue, 17 Mar 2026 03:33:47 -0700 (PDT) Received: from e142021.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F29D53F7BD; Tue, 17 Mar 2026 03:33:51 -0700 (PDT) From: Andre Przywara To: Mark Rutland , Lorenzo Pieralisi , Sudeep Holla Cc: Salman Nabi , Vedashree Vidwans , Trilok Soni , Nirmoy Das , vsethi@nvidia.com, vwadekar@nvidia.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] firmware: smccc: lfa: Add timeout and trigger watchdog Date: Tue, 17 Mar 2026 11:33:30 +0100 Message-ID: <20260317103336.1273582-5-andre.przywara@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260317103336.1273582-1-andre.przywara@arm.com> References: <20260317103336.1273582-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Vedashree Vidwans Enhance PRIME/ACTIVATION functions to touch watchdog and implement timeout mechanism. This update ensures that any potential hangs are detected promptly and that the LFA process is allocated sufficient execution time before the watchdog timer expires. These changes improve overall system reliability by reducing the risk of undetected process stalls and unexpected watchdog resets. Signed-off-by: Vedashree Vidwans Signed-off-by: Andre Przywara --- drivers/firmware/smccc/lfa_fw.c | 43 ++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_f= w.c index 4831abf2b60e..d1b5cd29b8a0 100644 --- a/drivers/firmware/smccc/lfa_fw.c +++ b/drivers/firmware/smccc/lfa_fw.c @@ -5,11 +5,14 @@ =20 #include #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -38,6 +41,11 @@ #define LFA_PRIME_CALL_AGAIN BIT(0) #define LFA_ACTIVATE_CALL_AGAIN BIT(0) =20 +#define LFA_PRIME_BUDGET_MS 30000 /* 30s cap */ +#define LFA_PRIME_DELAY_MS 10 /* 10ms between polls */ +#define LFA_ACTIVATE_BUDGET_MS 10000 /* 10s cap */ +#define LFA_ACTIVATE_DELAY_MS 10 /* 10ms between polls */ + /* LFA return values */ #define LFA_SUCCESS 0 #define LFA_NOT_SUPPORTED 1 @@ -287,6 +295,7 @@ static int call_lfa_activate(void *data) struct fw_image *image =3D data; struct arm_smccc_1_2_regs reg =3D { 0 }, res; =20 + touch_nmi_watchdog(); reg.a0 =3D LFA_1_0_FN_ACTIVATE; reg.a1 =3D image->fw_seq_id; /* @@ -310,6 +319,7 @@ static int call_lfa_activate(void *data) =20 static int activate_fw_image(struct fw_image *image) { + ktime_t end =3D ktime_add_ms(ktime_get(), LFA_ACTIVATE_BUDGET_MS); int ret; =20 retry: @@ -324,8 +334,15 @@ static int activate_fw_image(struct fw_image *image) return 0; } =20 - if (ret =3D=3D -LFA_CALL_AGAIN) - goto retry; + if (ret =3D=3D -LFA_CALL_AGAIN) { + /* SMC returned with call_again flag set */ + if (ktime_before(ktime_get(), end)) { + msleep_interruptible(LFA_ACTIVATE_DELAY_MS); + goto retry; + } + + ret =3D -LFA_TIMED_OUT; + } =20 lfa_cancel(image); =20 @@ -338,6 +355,8 @@ static int activate_fw_image(struct fw_image *image) static int prime_fw_image(struct fw_image *image) { struct arm_smccc_1_2_regs reg =3D { 0 }, res; + ktime_t end =3D ktime_add_ms(ktime_get(), LFA_PRIME_BUDGET_MS); + int ret; =20 if (image->may_reset_cpu) { pr_err("CPU reset not supported by kernel driver\n"); @@ -345,6 +364,8 @@ static int prime_fw_image(struct fw_image *image) return -EINVAL; } =20 + touch_nmi_watchdog(); + reg.a0 =3D LFA_1_0_FN_PRIME; retry: /* @@ -363,8 +384,22 @@ static int prime_fw_image(struct fw_image *image) return res.a0; } =20 - if (res.a1 & LFA_PRIME_CALL_AGAIN) - goto retry; + if (res.a1 & LFA_PRIME_CALL_AGAIN) { + /* SMC returned with call_again flag set */ + if (ktime_before(ktime_get(), end)) { + msleep_interruptible(LFA_PRIME_DELAY_MS); + goto retry; + } + + pr_err("LFA_PRIME for image %s timed out", + get_image_name(image)); + + ret =3D lfa_cancel(image); + if (ret !=3D 0) + return ret; + + return -ETIMEDOUT; + } =20 return 0; } --=20 2.43.0