From: Vedashree Vidwans <vvidwans@nvidia.com>
To: <salman.nabi@arm.com>, <sudeep.holla@arm.com>,
<andre.przywara@arm.com>, <lpieralisi@kernel.org>,
<mark.rutland@arm.com>
Cc: linux-kernel@vger.kernel.org, vwadekar@nvidia.com,
sdonthineni@nvidia.com, vsethi@nvidia.com,
linux-coco@lists.linux.dev, ardb@kernel.org,
linux-arm-kernel@lists.infradead.org, chao.gao@intel.com
Subject: [RFC PATCH 2/5] firmware: smccc: LFA: refactor
Date: Mon, 8 Dec 2025 22:13:12 +0000 [thread overview]
Message-ID: <20251208221319.1524888-3-vvidwans@nvidia.com> (raw)
In-Reply-To: <20251208221319.1524888-1-vvidwans@nvidia.com>
- Refactor LFA CANCEL logic into independent lfa_cancel() function.
- Use FW UUID as image_name for images not known by the driver.
- Move may_reset_cpu check to activate_fw_image(). This keeps all the
functionality within a function.
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
---
drivers/firmware/smccc/lfa_fw.c | 64 ++++++++++++++++++++-------------
1 file changed, 40 insertions(+), 24 deletions(-)
diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index bdde14b66606..df8b65324413 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -129,6 +129,31 @@ static int get_nr_lfa_components(void)
return reg.a1;
}
+static int lfa_cancel(struct image_props *attrs)
+{
+ struct arm_smccc_1_2_regs reg = { 0 };
+
+ reg.a0 = LFA_1_0_FN_CANCEL;
+ reg.a1 = attrs->fw_seq_id;
+ arm_smccc_1_2_invoke(®, ®);
+
+ /*
+ * When firmware activation is called with "skip_cpu_rendezvous=1",
+ * LFA_CANCEL can fail with LFA_BUSY if the activation could not be
+ * cancelled.
+ */
+ if (reg.a0 == LFA_SUCCESS) {
+ pr_info("Activation cancelled for image %s\n",
+ attrs->image_name);
+ } else {
+ pr_err("Firmware activation could not be cancelled: %s\n",
+ lfa_error_strings[-reg.a0]);
+ return -EINVAL;
+ }
+
+ return reg.a0;
+}
+
static int call_lfa_activate(void *data)
{
struct image_props *attrs = data;
@@ -160,6 +185,11 @@ static int activate_fw_image(struct image_props *attrs)
struct arm_smccc_1_2_regs res = { 0 };
int ret;
+ if (attrs->may_reset_cpu) {
+ pr_err("CPU reset not supported by kernel driver\n");
+ return -EINVAL;
+ }
+
/*
* LFA_PRIME/ACTIVATE will return 1 in res.a1 if the firmware
* priming/activation is still in progress. In that case
@@ -284,12 +314,6 @@ static ssize_t activate_store(struct kobject *kobj, struct kobj_attribute *attr,
image_attrs[LFA_ATTR_ACTIVATE]);
int ret;
- if (attrs->may_reset_cpu) {
- pr_err("Firmware component requires unsupported CPU reset\n");
-
- return -EINVAL;
- }
-
ret = activate_fw_image(attrs);
if (ret) {
pr_err("Firmware activation failed: %s\n",
@@ -309,25 +333,11 @@ static ssize_t cancel_store(struct kobject *kobj, struct kobj_attribute *attr,
{
struct image_props *attrs = container_of(attr, struct image_props,
image_attrs[LFA_ATTR_CANCEL]);
- struct arm_smccc_1_2_regs reg = { 0 };
-
- reg.a0 = LFA_1_0_FN_CANCEL;
- reg.a1 = attrs->fw_seq_id;
- arm_smccc_1_2_invoke(®, ®);
+ int ret;
- /*
- * When firmware activation is called with "skip_cpu_rendezvous=1",
- * LFA_CANCEL can fail with LFA_BUSY if the activation could not be
- * cancelled.
- */
- if (reg.a0 == LFA_SUCCESS) {
- pr_info("Activation cancelled for image %s\n",
- attrs->image_name);
- } else {
- pr_err("Firmware activation could not be cancelled: %s\n",
- lfa_error_strings[-reg.a0]);
- return -EINVAL;
- }
+ ret = lfa_cancel(attrs);
+ if (ret != 0)
+ return ret;
return count;
}
@@ -367,6 +377,8 @@ static int create_fw_inventory(char *fw_uuid, int seq_id, u32 image_flags)
for (int i = 0; i < ARRAY_SIZE(fw_images_uuids); i++) {
if (!strcmp(fw_images_uuids[i].uuid, fw_uuid))
image_name = fw_images_uuids[i].name;
+ else
+ image_name = fw_uuid;
}
attrs->image_dir = kobject_create_and_add(fw_uuid, lfa_dir);
@@ -414,6 +426,10 @@ static int create_fw_images_tree(void)
int ret, num_of_components;
num_of_components = get_nr_lfa_components();
+ if (num_of_components <= 0) {
+ pr_err("Error getting number of LFA components");
+ return -ENODEV;
+ }
for (int i = 0; i < num_of_components; i++) {
reg.a0 = LFA_1_0_FN_GET_INVENTORY;
--
2.43.0
next prev parent reply other threads:[~2025-12-08 22:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 22:13 [RFC PATCH 0/5] Arm LFA: Improvements and interrupt support Vedashree Vidwans
2025-12-08 22:13 ` [RFC PATCH 1/5] firmware: smccc: LFA: use smcc 1.2 Vedashree Vidwans
2025-12-09 11:42 ` Sudeep Holla
2025-12-19 8:47 ` Vedashree Vidwans
2025-12-19 10:37 ` Sudeep Holla
2025-12-08 22:13 ` Vedashree Vidwans [this message]
2025-12-08 22:13 ` [RFC PATCH 3/5] firmware: smccc: add timeout, touch wdt Vedashree Vidwans
2025-12-08 22:13 ` [RFC PATCH 4/5] firmware: smccc: register as platform driver Vedashree Vidwans
2025-12-09 11:47 ` Sudeep Holla
2025-12-19 8:26 ` Vedashree Vidwans
2025-12-19 10:40 ` Sudeep Holla
2025-12-12 15:31 ` Matt Ochs
2025-12-18 21:41 ` Vedashree Vidwans
2026-01-20 14:07 ` Salman Nabi
2025-12-08 22:13 ` [RFC PATCH 5/5] firmware: smccc: lfa: refresh fw details Vedashree Vidwans
2025-12-12 15:37 ` Matt Ochs
2025-12-18 21:40 ` Vedashree Vidwans
2026-01-19 19:50 ` Salman Nabi
2025-12-09 11:39 ` [RFC PATCH 0/5] Arm LFA: Improvements and interrupt support Sudeep Holla
2025-12-19 8:38 ` Vedashree Vidwans
2025-12-19 10:32 ` Sudeep Holla
2026-01-13 17:30 ` Andre Przywara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251208221319.1524888-3-vvidwans@nvidia.com \
--to=vvidwans@nvidia.com \
--cc=andre.przywara@arm.com \
--cc=ardb@kernel.org \
--cc=chao.gao@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mark.rutland@arm.com \
--cc=salman.nabi@arm.com \
--cc=sdonthineni@nvidia.com \
--cc=sudeep.holla@arm.com \
--cc=vsethi@nvidia.com \
--cc=vwadekar@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox