Re: [RFC PATCH 4/5] firmware: smccc: register as platform driver

From: Vedashree Vidwans

Date: Fri Dec 19 2025 - 03:26:39 EST




On 12/9/25 03:47, Sudeep Holla wrote:
On Mon, Dec 08, 2025 at 10:13:14PM +0000, Vedashree Vidwans wrote:
- Update driver to be in-built kernel module. This will ensure driver is
installed in kernel and would not require any user intervention.
- Register the LFA driver as a platform driver corresponding to
'armhf000' device. The driver will be invoked when the device is
detected on a platform.
- Add functionality to register LFA interrupt in the driver probe().
This LFA IRQ number will be retrived from the LFA device node.
- On IRQ, driver will query FW component details and trigger activation
of capable and pending FW component. The driver will loop to update FW
component details after every successful FW component activation.
- Mutex synchronization is implemented to avoid concurrent LFA updates
through interrupt and sysfs interfaces.

Device node snippet from LFA spec[1]:
fwu0 {
compatible = "arm,armhf000";
memory-region = <&fwu_payload>;
interrupt-parent = <&ic>;
interrupts = <0 100 1>; // SPI, Interrupt #100, Edge Rising
};


This will be gone in the latest beta of LFA, so please discuss and get
an agreement for the LFA device tree bindings.

We don't just use ACPI HID as devicetree compatibles. There are more
aligned with ACPI CID IIUC but I don't expect you to use ACPI CID just to
match DT compatible as ACPI HID will be defined for LFA.

Thank you for your comment.
Sorry I haven't completely understood the concern here. I am using the ACPI HID and device node compatible string provided by the LFA spec.
Please find below ACPI and device tree node from the spec for reference.
In case the LFA spec is updated, I will revise the driver implementation.

LFA spec: https://developer.arm.com/documentation/den0147/latest/

ACPI node:
DefinitionBlock ("", "SSDT", 2, "XXXXXX", "XXXXXXXX", 1) {
Scope (\_SB)
{
Device (FWU0) {
Name (_HID, "ARMHF000") // Arm HAFW DSDT table identifier.
Name (_CRS, ResourceTemplate () {

// Payload buffer description.
QWordMemory (,
,
MinFixed,
MaxFixed,
NonCacheable,
ReadWrite,
0x0,
0x2000, // base PA of payload buffer
0x2FFF, // top PA of payload buffer
0,
0x1000, // payload buffer length
,
,
)

// Interrupt signaling the updated Live Activation Store.
Interrupt(,
Edge, // Interrupt type (or interrupt mode)
ActiveHigh, // Interrupt level
,
,
,
) {100} // Note that this is an example interrupt.
// The interrupt ID is defined per-platform.
})

// _DSD -- Holds map between field names and objects within the _CRS
Name (_DSD, Package () {
ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa30") ,
Package() {
// Contains a set of packages of 2 entries each,
// the second entry is an index into the _CRS.
Package (2) {"payload-buffer", 1},
Package (2) {"fw-store-updated-interrupt", 2},
},
})
}
}
}

Device Tree node:
/dts-v1/;
/ {
#address-cells = <2>;
#size-cells = <2>;
ic: interrupt-controller@2f000000 {
compatible = "arm,gic-v3";
#interrupt-cells = <3>;
#address-cells = <2>;
#size-cells = <2>;
interrupt-controller;
reg = <0x0 0x2f000000 0x0 0x10000>,
<0x0 0x2f100000 0x0 0x200000>;
};

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
fwu_payload: fwu_payload@2000 {
reg = <0x0 0x2000 0x0 0x1000>;
no-map;
};
};

soc {
#address-cells = <2>;
#size-cells = <2>;
ranges;
fwu0 {
compatible = "arm,armhf000";
memory-region = <&fwu_payload>;
interrupt-parent = <&ic>;
interrupts = <0 100 1>; // SPI, Interrupt #100, Edge Rising
};
};
};

[1] https://developer.arm.com/documentation/den0147/latest/

Signed-off-by: Vedashree Vidwans <vvidwans@xxxxxxxxxx>
---
drivers/firmware/smccc/Kconfig | 3 +-
drivers/firmware/smccc/lfa_fw.c | 124 +++++++++++++++++++++++++++++++-
2 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/smccc/Kconfig b/drivers/firmware/smccc/Kconfig
index 48b98c14f770..c21be43fbfed 100644
--- a/drivers/firmware/smccc/Kconfig
+++ b/drivers/firmware/smccc/Kconfig
@@ -25,8 +25,9 @@ config ARM_SMCCC_SOC_ID
platforms providing some sysfs information about the SoC variant.
config ARM_LFA
- tristate "Arm Live Firmware activation support"
+ bool "Arm Live Firmware activation support"
depends on HAVE_ARM_SMCCC_DISCOVERY
+ default y
help
Include support for triggering Live Firmware Activation, which
allows to upgrade certain firmware components without a reboot.
diff --git a/drivers/firmware/smccc/lfa_fw.c b/drivers/firmware/smccc/lfa_fw.c
index 0e420cefa260..24916fc53420 100644
--- a/drivers/firmware/smccc/lfa_fw.c
+++ b/drivers/firmware/smccc/lfa_fw.c
@@ -19,7 +19,12 @@
#include <linux/nmi.h>
#include <linux/ktime.h>
#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#define DRIVER_NAME "ARM_LFA"
#define LFA_ERROR_STRING(name) \
[name] = #name
#undef pr_fmt
@@ -129,6 +134,7 @@ static const struct fw_image_uuid {
};
static struct kobject *lfa_dir;
+static DEFINE_MUTEX(lfa_lock);
static int get_nr_lfa_components(void)
{
@@ -374,17 +380,23 @@ static ssize_t activate_store(struct kobject *kobj, struct kobj_attribute *attr,
image_attrs[LFA_ATTR_ACTIVATE]);
int ret;
+ if (!mutex_trylock(&lfa_lock)) {
+ pr_err("Mutex locked, try again");
+ return -EAGAIN;
+ }
+
ret = activate_fw_image(attrs);
if (ret) {
pr_err("Firmware activation failed: %s\n",
lfa_error_strings[-ret]);
-
+ mutex_unlock(&lfa_lock);
return -ECANCELED;
}
pr_info("Firmware activation succeeded\n");
/* TODO: refresh image flags here*/
+ mutex_unlock(&lfa_lock);
return count;
}
@@ -510,6 +522,106 @@ static int create_fw_images_tree(void)
return 0;
}
+static irqreturn_t lfa_irq_thread(int irq, void *data)
+{
+ struct image_props *attrs = NULL;
+ int ret;
+ int num_of_components, curr_component;
+
+ mutex_lock(&lfa_lock);
+
+ /*
+ * As per LFA spec, after activation of a component, the caller
+ * is expected to re-enumerate the component states (using
+ * LFA_GET_INFO then LFA_GET_INVENTORY).
+ * Hence we need an unconditional loop.
+ */
+
+ do {
+ /* TODO: refresh image flags here */
+ /* If refresh fails goto exit_unlock */
+
+ /* Initialize counters to track list traversal */
+ num_of_components = get_nr_lfa_components();
+ curr_component = 0;
+
+ /* Execute PRIME and ACTIVATE for activable FW component */
+ list_for_each_entry(attrs, &lfa_fw_images, image_node) {
+ curr_component++;
+ if ((!attrs->activation_capable) || (!attrs->activation_pending)) {
+ /* LFA not applicable for this FW component */
+ continue;
+ }
+
+ ret = activate_fw_image(attrs);
+ if (ret) {
+ pr_err("Firmware %s activation failed: %s\n",
+ attrs->image_name, lfa_error_strings[-ret]);
+ goto exit_unlock;
+ }
+
+ pr_info("Firmware %s activation succeeded", attrs->image_name);
+ /* Refresh FW component details */
+ break;
+ }
+ } while (curr_component < num_of_components);
+
+ /* TODO: refresh image flags here */
+ /* If refresh fails goto exit_unlock */
+
+exit_unlock:
+ mutex_unlock(&lfa_lock);
+ return IRQ_HANDLED;
+}
+
+static int __init lfa_probe(struct platform_device *pdev)
+{
+ int err;
+ unsigned int irq;
+
+ err = platform_get_irq_byname_optional(pdev, "fw-store-updated-interrupt");

Nice, "fw-store-updated-interrupt" is not even mentioned in the example DT
node above, let alone proper DT bindings.

Thank you for pointing this out. The DT binding would have to be updated to below or the driver will fall back to platform_get_irq().

fwu0 {
compatible = "arm,armhf000";
memory-region = <&fwu_payload>;
interrupt-parent = <&ic>;
interrupts = <0 100 1>; // SPI, Interrupt #100, Edge Rising
interrupt-names = "fw-store-updated-interrupt";
};

Regards,
Veda