From: Vedashree Vidwans <vvidwans@nvidia.com>
To: <salman.nabi@arm.com>, <lpieralisi@kernel.org>,
<mark.rutland@arm.com>, <sudeep.holla@arm.com>,
<andre.przywara@arm.com>
Cc: <ardb@kernel.org>, <chao.gao@intel.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-coco@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<sdonthineni@nvidia.com>, <vsethi@nvidia.com>,
<vwadekar@nvidia.com>, Vedashree Vidwans <vvidwans@nvidia.com>
Subject: [RFC PATCH 3/3] firmware: smccc: LFA: modify activation approach
Date: Wed, 8 Oct 2025 19:09:07 +0000 [thread overview]
Message-ID: <20251008190907.181412-4-vvidwans@nvidia.com> (raw)
In-Reply-To: <20251008190907.181412-1-vvidwans@nvidia.com>
Currently, on a LFA IRQ, all activable firmware components are primed
activated sequentially. Modify the approach to prime all firmware
components followed by activation of all components sequentially. This
approach will minimize the time where old and new firmware component
images co-exist.
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
---
drivers/firmware/smccc/lfa_fw.c | 74 +++++++++++++++++++++++++++++----
1 file changed, 66 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index b36b8d7457c30..dead2282cd04b 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -46,6 +46,10 @@
#define LFA_PRIME_CALL_AGAIN BIT(0)
#define LFA_ACTIVATE_CALL_AGAIN BIT(0)
+/* PRIME COMPLETE status */
+#define LFA_PRIME_COMPLETE_FALSE false
+#define LFA_PRIME_COMPLETE_TRUE true
+
/* Prime loop limits, TODO: tune after testing */
#define LFA_PRIME_BUDGET_US 30000000 /* 30s cap */
#define LFA_PRIME_POLL_DELAY_US 10 /* 10us between polls */
@@ -104,6 +108,7 @@ struct image_props {
bool may_reset_cpu;
bool cpu_rendezvous;
bool cpu_rendezvous_forced;
+ bool prime_complete;
struct kobject *image_dir;
struct kobj_attribute image_attrs[LFA_ATTR_NR_IMAGES];
};
@@ -229,6 +234,27 @@ static int call_lfa_activate(void *data)
}
static int activate_fw_image(struct image_props *attrs)
+{
+ int ret;
+
+ /*
+ * We want to force CPU rendezvous if either cpu_rendezvous or
+ * cpu_rendezvous_forced is set. The flag value is flipped as
+ * it is called skip_cpu_rendezvous in the spec.
+ */
+ if (!(attrs->cpu_rendezvous_forced || attrs->cpu_rendezvous)) {
+ pr_warn("CPU rendezvous is expected to be selected.");
+ return -EAGAIN;
+ }
+
+ ret = stop_machine(call_lfa_activate, attrs, cpu_online_mask);
+ if (ret != 0)
+ return lfa_cancel(attrs);
+
+ return ret;
+}
+
+static int prime_fw_image(struct image_props *attrs)
{
struct arm_smccc_1_2_regs args = { 0 };
struct arm_smccc_1_2_regs res = { 0 };
@@ -285,10 +311,6 @@ static int activate_fw_image(struct image_props *attrs)
return ret;
}
- ret = stop_machine(call_lfa_activate, attrs, cpu_online_mask);
- if (ret != 0)
- return lfa_cancel(attrs);
-
return ret;
}
@@ -396,6 +418,17 @@ static ssize_t activate_store(struct kobject *kobj, struct kobj_attribute *attr,
return -EAGAIN;
}
+ ret = prime_fw_image(attrs);
+ if (ret) {
+ pr_err("Firmware prime failed: %s\n",
+ lfa_error_strings[-ret]);
+ mutex_unlock(&lfa_lock);
+ return -ECANCELED;
+ }
+
+ /* Update prime complete status */
+ attrs->prime_complete = LFA_PRIME_COMPLETE_TRUE;
+
ret = activate_fw_image(attrs);
if (ret) {
pr_err("Firmware activation failed: %s\n",
@@ -469,6 +502,8 @@ static int create_fw_inventory(char *fw_uuid, int seq_id, u32 image_flags)
INIT_LIST_HEAD(&attrs->image_node);
attrs->image_name = image_name;
attrs->cpu_rendezvous_forced = 1;
+ /* Reset prime complete status */
+ attrs->prime_complete = LFA_PRIME_COMPLETE_FALSE;
set_image_flags(attrs, seq_id, image_flags);
/*
@@ -573,16 +608,39 @@ static irqreturn_t lfa_irq_thread(int irq, void *data)
if (ret != 0)
goto exit_unlock;
- /*
- * Execute PRIME and ACTIVATE for each FW component
- * Start from first FW component
- */
+ /* Execute PRIME for all FW components */
list_for_each_entry(attrs, &lfa_fw_images, image_node) {
if ((!attrs->activation_capable) || (!attrs->activation_pending)) {
/* LFA not applicable for this FW component, continue to next component */
continue;
}
+ ret = prime_fw_image(attrs);
+ if (ret) {
+ pr_err("Firmware %s prime failed: %s\n",
+ attrs->image_name, lfa_error_strings[-ret]);
+ goto exit_unlock;
+ }
+
+ /* Update prime complete status */
+ attrs->prime_complete = LFA_PRIME_COMPLETE_TRUE;
+ }
+
+ /* Execute ACTIVATE for all FW components */
+ list_for_each_entry(attrs, &lfa_fw_images, image_node) {
+ if ((!attrs->activation_capable) || (!attrs->activation_pending)) {
+ /* LFA not applicable for this FW component, continue to next component */
+ continue;
+ }
+
+ if (!attrs->prime_complete) {
+ /*
+ * ACTIVATE not applicable for this FW component,
+ * continue to next component
+ */
+ continue;
+ }
+
ret = activate_fw_image(attrs);
if (ret) {
pr_err("Firmware %s activation failed: %s\n",
--
2.25.1
prev parent reply other threads:[~2025-10-08 19:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-08 19:09 [RFC PATCH 0/3] Arm LFA: Improvements and interrupt support Vedashree Vidwans
2025-10-08 19:09 ` [RFC PATCH 1/3] firmware: smccc: LFA: use smcc 1.2 Vedashree Vidwans
2025-10-11 0:02 ` Andre Przywara
2025-10-13 20:59 ` Vedashree Vidwans
2025-10-08 19:09 ` [RFC PATCH 2/3] firmware: smccc: LFA: refactor, add device node support Vedashree Vidwans
2025-10-09 8:13 ` Sudeep Holla
2025-10-13 20:09 ` Vedashree Vidwans
2025-10-10 17:35 ` Salman Nabi
2025-10-13 20:47 ` Vedashree Vidwans
2025-10-14 10:58 ` Andre Przywara
2025-10-14 13:44 ` Salman Nabi
2025-10-11 0:03 ` Andre Przywara
2025-10-13 21:09 ` Vedashree Vidwans
2025-10-08 19:09 ` Vedashree Vidwans [this message]
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=20251008190907.181412-4-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;
as well as URLs for NNTP newsgroup(s).