mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Sudeep Holla <sudeep.holla@kernel.org>
Cc: Salman Nabi <salman.nabi@arm.com>,
	Vedashree Vidwans <vvidwans@nvidia.com>,
	Trilok Soni <trilokkumar.soni@oss.qualcomm.com>,
	Nirmoy Das <nirmoyd@nvidia.com>,
	vsethi@nvidia.com, vwadekar@nvidia.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/8] firmware: smccc: lfa: Move image rescanning
Date: Tue, 17 Mar 2026 11:33:29 +0100	[thread overview]
Message-ID: <20260317103336.1273582-4-andre.przywara@arm.com> (raw)
In-Reply-To: <20260317103336.1273582-1-andre.przywara@arm.com>

From: Vedashree Vidwans <vvidwans@nvidia.com>

After an image activation, the list of firmware images might change, so
we have to re-iterate them through the SMC interface.
Move the corresponding code from the activate_fw_image() function into
update_fw_images_tree(), where it could be reused more easily, for
instance when triggered by an interrupt.

Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
[Andre: split off from another patch, rebased]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 drivers/firmware/smccc/lfa_fw.c | 46 ++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index 284b7c18d3d0..4831abf2b60e 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -310,7 +310,6 @@ static int call_lfa_activate(void *data)
 
 static int activate_fw_image(struct fw_image *image)
 {
-	struct kobject *kobj;
 	int ret;
 
 retry:
@@ -320,31 +319,8 @@ static int activate_fw_image(struct fw_image *image)
 		ret = call_lfa_activate(image);
 
 	if (!ret) {
-		/*
-		 * Invalidate fw_seq_ids (-1) for all images as the seq_ids
-		 * and the number of firmware images in the LFA agent may
-		 * change after a successful activation attempt.
-		 * Negate all image flags as well.
-		 */
-		spin_lock(&lfa_kset->list_lock);
-		list_for_each_entry(kobj, &lfa_kset->list, entry) {
-			struct fw_image *image = kobj_to_fw_image(kobj);
-
-			set_image_flags(image, -1, 0b1000, 0, 0);
-		}
-		spin_unlock(&lfa_kset->list_lock);
-
 		update_fw_images_tree();
 
-		/*
-		 * Removing non-valid image directories at the end of an
-		 * activation.
-		 * We can't remove the sysfs attributes while in the respective
-		 * _store() handler, so have to postpone the list removal to a
-		 * workqueue.
-		 */
-		queue_work(fw_images_update_wq, &fw_images_update_work);
-
 		return 0;
 	}
 
@@ -640,6 +616,7 @@ static int update_fw_images_tree(void)
 {
 	struct arm_smccc_1_2_regs reg = { 0 }, res;
 	struct uuid_regs image_uuid;
+	struct kobject *kobj;
 	char image_id_str[40];
 	int ret, num_of_components;
 
@@ -649,6 +626,19 @@ static int update_fw_images_tree(void)
 		return -ENODEV;
 	}
 
+	/*
+	 * Invalidate fw_seq_ids (-1) for all images as the seq_ids and the
+	 * number of firmware images in the LFA agent may change after a
+	 * successful activation attempt. Negate all image flags as well.
+	 */
+	spin_lock(&lfa_kset->list_lock);
+	list_for_each_entry(kobj, &lfa_kset->list, entry) {
+		struct fw_image *image = kobj_to_fw_image(kobj);
+
+		set_image_flags(image, -1, 0b1000, 0, 0);
+	}
+	spin_unlock(&lfa_kset->list_lock);
+
 	reg.a0 = LFA_1_0_FN_GET_INVENTORY;
 	for (int i = 0; i < num_of_components; i++) {
 		reg.a1 = i; /* fw_seq_id to be queried */
@@ -666,6 +656,14 @@ static int update_fw_images_tree(void)
 		}
 	}
 
+	/*
+	 * Removing non-valid image directories at the end of an activation.
+	 * We can't remove the sysfs attributes while in the respective
+	 * _store() handler, so have to postpone the list removal to a
+	 * workqueue.
+	 */
+	queue_work(fw_images_update_wq, &fw_images_update_work);
+
 	return 0;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-03-17 10:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-17 10:33 [PATCH v2 0/8] Arm Live Firmware Activation (LFA) support Andre Przywara
2026-03-17 10:33 ` [PATCH v2 1/8] dt-bindings: arm: Add Live Firmware Activation binding Andre Przywara
2026-03-18  8:04   ` Krzysztof Kozlowski
2026-03-18 16:00     ` Andre Przywara
2026-03-17 10:33 ` [PATCH v2 2/8] firmware: smccc: Add support for Live Firmware Activation (LFA) Andre Przywara
2026-03-18  8:09   ` Krzysztof Kozlowski
2026-03-18  8:12     ` Krzysztof Kozlowski
2026-03-18 15:39       ` Andre Przywara
2026-03-17 10:33 ` Andre Przywara [this message]
2026-03-17 10:33 ` [PATCH v2 4/8] firmware: smccc: lfa: Add timeout and trigger watchdog Andre Przywara
2026-06-24 20:46   ` Nirmoy Das
2026-03-17 10:33 ` [PATCH v2 5/8] firmware: smccc: lfa: Register ACPI notification Andre Przywara
2026-03-17 10:33 ` [PATCH v2 6/8] firmware: smccc: lfa: Add auto_activate sysfs file Andre Przywara
2026-03-18  8:05   ` Krzysztof Kozlowski
2026-06-24 19:45   ` Nirmoy Das
2026-07-06 14:34     ` Andre Przywara
2026-03-17 10:33 ` [PATCH v2 7/8] firmware: smccc: lfa: Register DT interrupt Andre Przywara
2026-03-18  8:14   ` Krzysztof Kozlowski
2026-03-18 11:35   ` kernel test robot
2026-03-18 14:21   ` kernel test robot
2026-03-18 14:21   ` kernel test robot
2026-03-19 12:52     ` Andre Przywara
2026-03-17 10:33 ` [PATCH v2 8/8] firmware: smccc: lfa: introduce SMC access lock Andre Przywara
2026-03-18  8:00 ` [PATCH v2 0/8] Arm Live Firmware Activation (LFA) support Krzysztof Kozlowski

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=20260317103336.1273582-4-andre.przywara@arm.com \
    --to=andre.przywara@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nirmoyd@nvidia.com \
    --cc=salman.nabi@arm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=trilokkumar.soni@oss.qualcomm.com \
    --cc=vsethi@nvidia.com \
    --cc=vvidwans@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

all inboxes | Powered by JetHome®