[PATCH 3/8] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
Jonathan Cameron
jonathan.cameron at huawei.com
Mon Oct 20 10:29:49 PDT 2025
On Fri, 17 Oct 2025 14:23:46 +0100
Sudeep Holla <sudeep.holla at arm.com> wrote:
> Switch SCMI core plumbing from struct device_node* to struct
> fwnode_handle* so transports and core code work with both DT and
> ACPI firmware descriptions.
>
> This change:
> - Replaces of_* property lookups with fwnode_property_*() helpers.
> - Switches child enumeration to
> fwnode_for_each_available_child_node_scoped().
> - Plumbs fwnode through the SCMI device creation and channel setup
> paths and updates transport ->chan_available() signatures to take a
> fwnode.
> - Stores the per-protocol child fwnodes in info->active_protocols so
> the core can later locate the descriptor for a given protocol ID.
> - Update mailbox/optee/smc/virtio transports to accept fwnode and
> map to OF nodes where needed
>
> DT-only transports (mailbox/optee/smc) still parse DT properties by
> mapping the fwnode back to an OF node; on non-DT (e.g. ACPI) systems
> these transports will report no channel available.
>
> This refactor is a prerequisite for adding an ACPI-first transport like
> PCC and brings the SCMI core closer to DT/ACPI parity. This is a mechanical
> step towards firmware-node neutrality; DT users continue to work unchanged,
> and ACPI paths can be enabled on top.
>
> No functional change is expected on DT platforms; ACPI platforms can now
> discover and participate in SCMI where a suitable transport is present.
>
> Signed-off-by: Sudeep Holla <sudeep.holla at arm.com>
Hi Sudeep
A few comments inline. The reference counting on fwnodes gets a bit complex in
here so my review more or less skips that bit (it's end of day!)
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index bd56a877fdfc..bc5fea11b5db 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2820,7 +2820,7 @@ static int scmi_chan_destroy(int id, void *p, void *idr)
> struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
> struct scmi_device *sdev = to_scmi_dev(cinfo->dev);
>
> - of_node_put(cinfo->dev->of_node);
> + fwnode_handle_put(dev_fwnode(cinfo->dev));
This may follow on from earlier thing about device_set_node().
I think this is freeing a reference that will never have been gotten if you
follow what I suggest there. Note that I'm fairly sure it was never
gotten for acpi anyway. However this might be a different fwnode, I'm lost
on that front.
> scmi_device_destroy(info->dev, id, sdev->name);
> cinfo->dev = NULL;
> }
> @@ -3118,8 +3119,8 @@ static const struct scmi_desc *scmi_transport_setup(struct device *dev)
> trans->desc.max_msg);
>
> /* System wide atomic threshold for atomic ops .. if any */
> - if (!of_property_read_u32(dev->of_node, "atomic-threshold-us",
> - &trans->desc.atomic_threshold))
> + if (!fwnode_property_read_u32(dev_fwnode(dev), "atomic-threshold-us",
device_property_read_u32() Same for all the other places where the fwnode
is simple dev_fwnode(dev) and there is a suitable helper.
> + &trans->desc.atomic_threshold))
> dev_info(dev,
> "SCMI System wide atomic threshold set to %u us\n",
> trans->desc.atomic_threshold);
> @@ -3262,10 +3262,10 @@ static int scmi_probe(struct platform_device *pdev)
>
> scmi_enable_matching_quirks(info);
>
> - for_each_available_child_of_node(np, child) {
> + fwnode_for_each_available_child_node_scoped(dev_fwnode(dev), child) {
I don't think there is an exit path in here, so this is functionally the same
as the non scoped version.
Also, if you are gong to use dev_fwnode use
device_for_each_child_node() and don't worry about the available.
I think the patch merged that made device_for_each_child_node() only
consider the available ones for all firmware types.
> u32 prot_id;
>
> - if (of_property_read_u32(child, "reg", &prot_id))
> + if (fwnode_property_read_u32(child, "reg", &prot_id))
> continue;
>
> if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id))
> @@ -3278,10 +3278,11 @@ static int scmi_probe(struct platform_device *pdev)
> }
>
> /*
> - * Save this valid DT protocol descriptor amongst
> + * Save this valid fwnode protocol descriptor amongst
> * @active_protocols for this SCMI instance/
> */
> - ret = idr_alloc(&info->active_protocols, child,
> + ret = idr_alloc(&info->active_protocols,
> + fwnode_handle_get(child),
This change is a little subtle to be buried in here and I'm fairly sure
it is an unintended functional change. If idr_alloc() fails the continue
and loop iterator magic, will drop the reference held by the loop but
not this one. So it will leak a reference.
If this does make sense, do it in a precursor patch before changing away
from of only.
> prot_id, prot_id + 1, GFP_KERNEL);
> if (ret != prot_id) {
> dev_err(dev, "SCMI protocol %d already activated. Skip\n",
> @@ -3289,7 +3290,6 @@ static int scmi_probe(struct platform_device *pdev)
> continue;
> }
>
> - of_node_get(child);
> scmi_create_protocol_devices(child, info, prot_id, NULL);
> }
>
More information about the linux-arm-kernel
mailing list