firmware: arm_scmi: Refactoring and enablement of ACPI PCC transport
Sudeep Holla
maintainerv3 cover firmware: arm_scmi: Refactoring and enablement of ACPI PCC transport
The SCMI can be utilized in systems using either the FDT or ACPI specification. While FDT-based systems can natively use SCMI, ACPI-based systems often need to abstract the functionality provided by SCMI under ASL methods. So far, there has been no need to support SCMI natively on ACPI systems.
However, with the addition of a few new protocols such as Powercap and Telemetry, which lack abstractions in the ACPI specification, there is now a need to run SCMI natively for those use cases. ACPI for System Control and Management Interface document[1] provides a mechanism which allows ACPI-based systems to discover whether a platform supports SCMI and to natively use SCMI for selected/limited subset of SCMI protocols.
This patch series introduces ACPI PCC transport support for the Arm SCMI framework, alongside several foundational refactors and enhancements to achieve firmware-node neutrality between Device Tree (DT) and ACPI systems.
The key changes include:
1. ACPI/DT abstraction and fwnode transition
Converted the core SCMI code to use fwnode_handle instead of DT-specific structures, ensuring seamless operation across both ACPI and DT environments. All property lookups, child enumeration, and device association paths have been updated accordingly.
2. Unified transport registration for ACPI and DT
Extended the SCMI transport driver macros to support ACPI match tables, enabling transports to probe using ACPI device IDs while maintaining backward compatibility with DT-only systems.
3. Protocol device initialization and refactoring
Refactored the protocol device creation and validation logic into a new helper for improved readability and maintainability. Enhanced the initialization logic to handle ACPI-based SCMI devices without explicit child fwnodes.
4. Introduction of ACPI PCC transport
Added a new SCMI transport driver leveraging ACPI PCCT (Platform Communications Channel Table) subspaces via the Linux PCC mailbox framework. This enables SCMI communication over PCC on ACPI-based platforms.
Collectively, these changes lay the groundwork for robust SCMI operation on ACPI platforms, achieving near parity with DT systems where applicable, while enabling the new PCC transport path for firmware communication.
Note: SCMI will not be run natively for all existing protocols other than Powercap and Telemetry, as they must continue to use ACPI abstractions.
[1] https://developer.arm.com/documentation/111115/latest
-->8
Device (SCM0) {
Name(_HID, "ARML0001")
Name (_UID, 0)
Name (_DSD, Package () {
ToUUID("84a2d1c6-86b6-4199-8dac-9c17449d5e03"), // SCMI Properties UUID
Package () {
Package(2) {
"arm-arml0001-transport-pcc", // Key
Package () { // Value
1, // Revision
3, // Count
Package(){4, 0, 1}, // PCCT Idx, TransportUID, A2P Common
Package(){7, 1, 0}, // PCCT Idx, TransportUID, A2P Exclusive
Package(){9, 2, 2} // PCCT Idx, TransportUID, P2A Exclusive
} // Value
},
Package(2) {
"arm-arml0001-protocol-pcap", // Key
Package () { // Value
1, // Revision
Package() { // Protocol Exclusive Transport Package
// Empty; A2P Common
},
Package() {} // Protocol Association Package
} // Value
},
Package(2) {
"arm-arml0001-protocol-telemetry", // Key
Package () { // Value
1, // Revision
Package() { // Protocol Exclusive Transport Package
Package (2) {1, 0}, // UID=1; Flags=0; A2P Exclusive
Package (2) {2, 0} // UID=2; Flags=0; P2A Exclusive
},
Package() {} // Protocol Association Package
} // Value
},
} // Device Properties
}) // _DSD
} // SCM0---
Changes in v3:
- Reworked ACPI _DSD parsing with stricter validation and order-independent transport/protocol processing.
- Added per-fwnode PCC transport maps, serialized access, multi-instance validation, and module-exit cleanup.
- Corrected PCC completion flags and validated shared-memory capacity and signature.
- Restricted protocol enumeration to ACPI-backed instances, handled optional protocols without spurious errors, and fixed CONFIG_ACPI=n builds.
- Removed redundant ACPI companion assignment.
- Enabled the ACPI PCC transport by default when its dependencies are met.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Fixed SCMI fwnode lifetime handling by taking a reference when assigning protocol device fwnodes and releasing it from the device release path.
- Reworked ACPI PCC _DSD parsing to validate package types,
revisions, counts, UID ranges, flags, duplicate UIDs, and channel mappings.
- Parse the SCMI ACPI _DSD UUID package directly as we moved to SCMI specific UUID from the generic device properties UUID and reject malformed or unsupported protocol association data.
- Tightened PCC channel selection so each protocol gets at most one Tx and one Rx channel, with exactly one common A2P channel and at most
one common P2A channel.
- Only set the PCC interrupt-enable flag when the mailbox channel has a txdone IRQ.
- Added the SCMI Telemetry protocol ID(Temporary to get the build working, must come from Cristian's Telemetry support patched)
- Link to v1: https://patch.msgid.link/[email protected]
---
Sudeep Holla (9):
firmware: arm_scmi: Set fwnode for the generated SCMI platform device
firmware: arm_scmi: Extend transport driver macro to support ACPI
firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent
firmware: arm_scmi: Pass protocol ID to chan_available() transport callback
firmware: arm_scmi: Refactor protocol device creation logic
firmware: arm_scmi: Add ACPI PCC transport
firmware: arm_scmi: Initialise known ACPI protocol devices and channels
firmware: arm_scmi: Validate PCC shared memory signature
drivers/firmware/arm_scmi/bus.c | 37 +- drivers/firmware/arm_scmi/common.h | 35 +- drivers/firmware/arm_scmi/driver.c | 201 ++++--- drivers/firmware/arm_scmi/transports/Kconfig | 13 + drivers/firmware/arm_scmi/transports/Makefile | 2 + drivers/firmware/arm_scmi/transports/mailbox.c | 7 +- drivers/firmware/arm_scmi/transports/optee.c | 7 +- drivers/firmware/arm_scmi/transports/pcc.c | 799 +++++++++++++++++++++++++ drivers/firmware/arm_scmi/transports/smc.c | 12 +- drivers/firmware/arm_scmi/transports/virtio.c | 3 +- include/linux/scmi_protocol.h | 1 + 11 files changed, 1012 insertions(+), 105 deletions(-)
---
base-commit: 89a765b2532d1c130d683c3d2bcb64800a34562a
change-id: 20251017-acpi_scmi_pcc-e44e1233eae3
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 1/9 firmware: arm_scmi: Set fwnode for the generated SCMI platform device
Add a call to device_set_node() in the SCMI probe helper to associate generated SCMI platform device with the firmware node of its supplier transport device.
This complements device_set_of_node_from_dev() and ensures that firmware node information is propagated correctly for both Device Tree and non-DT (e.g. ACPI) based systems.
--- drivers/firmware/arm_scmi/common.h | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/arm_scmi/common.h +1 -0
@@ -650,6 +650,7 @@ static int __tag##_probe(struct platform_device *pdev) \ } \ \device_set_of_node_from_dev (&spdev->dev, dev); \ +device_set_node (&spdev->dev,dev_fwnode (dev)); \ \ strans.supplier = supplier; \memcpy (&strans.desc, &(__desc),sizeof (strans.desc)); \
Signature · 1 line
2.43.0
Re: [PATCH v3 1/9] firmware: arm_scmi: Set fwnode for the generated SCMI platform device
Quoted 7 lines · On Thu, 13 Aug 2026 12:32:56 +0100 Sudeep Holla <[email protected]> wrote:
Add a call to
device_set_node()in the SCMI probe helper to associate generated SCMI platform device with the firmware node of its supplier transport device.This complements
device_set_of_node_from_dev()and ensures that firmware node information is propagated correctly for both Device Tree and non-DT (e.g. ACPI) based systems.
Hi Sudeep,
When you say 'complement' I'd like to see a little more. The guts of both calls includes setting dev->ofnode() adn the extra bit in device_set_of_node_from_dev() is about ensuring we drop existing node reference (there isn't one) and increment the reference for what is the parent of_node.
I may be wrong, but I think that is unnecessary and if I'm wrong I'd like to see more info here on why it is needed.
Also, if this is commonly needed why doesn't device_set_node() include that dance?
Unless I fumbled the command, a grep suggests there are no instances in tree of these both being called near each other.
Jonathan
Quoted 19 lines
Signed-off-by Sudeep Holla <[email protected]>--- drivers/firmware/arm_scmi/common.h | 1 + 1 file changed, 1 insertion(+)drivers/firmware/arm_scmi/common.h +1
-0@@ -650,6 +650,7 @@ static int __tag##_probe(struct platform_device *pdev) \ } \ \device_set_of_node_from_dev (&spdev->dev, dev); \ +device_set_node (&spdev->dev,dev_fwnode (dev)); \ \ strans.supplier = supplier; \memcpy (&strans.desc, &(__desc),sizeof (strans.desc)); \
Sudeep Holla
maintainerRe: [PATCH v3 1/9] firmware: arm_scmi: Set fwnode for the generated SCMI platform device
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 13 Aug 2026 12:32:56 +0100 Sudeep Holla <[email protected]> wrote:
Add a call to
device_set_node()in the SCMI probe helper to associate generated SCMI platform device with the firmware node of its supplier transport device.
Quoted 6 lines
Quoted 3 lines
This complements
device_set_of_node_from_dev()and ensures that firmware node information is propagated correctly for both Device Tree and non-DT (e.g. ACPI) based systems.Hi Sudeep,
Hi Jonathan,
Thanks for all the reviews. I was away for a while and started to look at addressing these now.
Quoted 6 lines
When you say 'complement' I'd like to see a little more. The guts of both calls includes setting
dev->ofnode()adn the extra bit indevice_set_of_node_from_dev()is about ensuring we drop existing node reference (there isn't one) and increment the reference for what is the parentof_node.
Yes I agree. At the time, when I hacked this up, I was supposed to take a look at it again which I never did.
Quoted 3 lines
I may be wrong, but I think that is unnecessary and if I'm wrong I'd like to see more info here on why it is needed.
No your concerns are valid. For reference-counted non-OF fwnodes like ACPI or software node, platform_device_release() drops the fwnode reference, but device_set_node() does not acquire one.
Quoted 3 lines
Also, if this is commonly needed why doesn't
device_set_node()include that dance?
I think there are new helpers added recently in the tree, thinking of using then. See below.
Quoted 3 lines
Unless I fumbled the command, a grep suggests there are no instances in tree of these both being called near each other.
I did that too before adding but somehow kept it for future investigation.
Quoted 8 lines
Jonathan
Quoted 6 lines
Signed-off-by Sudeep Holla <[email protected]>--- drivers/firmware/arm_scmi/common.h | 1 + 1 file changed, 1 insertion(+)
Quoted 9 lines
drivers/firmware/arm_scmi/common.h static int __tag##_probe(struct platform_device *pdev) \ · line 653
Quoted 9 lines
drivers/firmware/arm_scmi/common.h +1
-0@@ -650,6 +650,7 @@ static int __tag##_probe(struct platform_device *pdev) \ } \ \device_set_of_node_from_dev (&spdev->dev, dev); \ +device_set_node (&spdev->dev,dev_fwnode (dev)); \
How about something like this instead of above 2 lines:
if (is_of_node(dev_fwnode(dev)))
platform_device_set_of_node_from_dev(spdev, dev); else platform_device_set_fwnode(spdev, dev_fwnode(dev));
Signature · 2 lines
Regards, Sudeep
Re: [PATCH v3 1/9] firmware: arm_scmi: Set fwnode for the generated SCMI platform device
Quoted 72 lines · On Wed, 2 Sep 2026 08:51:10 +0100 Sudeep Holla <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 13 Aug 2026 12:32:56 +0100 Sudeep Holla <[email protected]> wrote:
Add a call to
device_set_node()in the SCMI probe helper to associate generated SCMI platform device with the firmware node of its supplier transport device.Quoted 6 lines
Quoted 3 lines
This complements
device_set_of_node_from_dev()and ensures that firmware node information is propagated correctly for both Device Tree and non-DT (e.g. ACPI) based systems.Hi Sudeep,
Hi Jonathan,
Thanks for all the reviews. I was away for a while and started to look at addressing these now.
Quoted 6 lines
When you say 'complement' I'd like to see a little more. The guts of both calls includes setting
dev->ofnode()adn the extra bit indevice_set_of_node_from_dev()is about ensuring we drop existing node reference (there isn't one) and increment the reference for what is the parentof_node.Yes I agree. At the time, when I hacked this up, I was supposed to take a look at it again which I never did.
Quoted 3 lines
I may be wrong, but I think that is unnecessary and if I'm wrong I'd like to see more info here on why it is needed.
No your concerns are valid. For reference-counted non-OF fwnodes like ACPI or software node,
platform_device_release()drops the fwnode reference, butdevice_set_node()does not acquire one.Quoted 3 lines
Also, if this is commonly needed why doesn't
device_set_node()include that dance?I think there are new helpers added recently in the tree, thinking of using then. See below.
Quoted 3 lines
Unless I fumbled the command, a grep suggests there are no instances in tree of these both being called near each other.
I did that too before adding but somehow kept it for future investigation.
Quoted 8 lines
Jonathan
Quoted 6 lines
Signed-off-by Sudeep Holla <[email protected]>--- drivers/firmware/arm_scmi/common.h | 1 + 1 file changed, 1 insertion(+)Quoted 9 lines
drivers/firmware/arm_scmi/common.h static int __tag##_probe(struct platform_device *pdev) \ · line 653
Quoted 9 lines
drivers/firmware/arm_scmi/common.h +1
-0@@ -650,6 +650,7 @@ static int __tag##_probe(struct platform_device *pdev) \ } \ \device_set_of_node_from_dev (&spdev->dev, dev); \ + device_set_node(&spdev->dev, dev_fwnode(dev)); \How about something like this instead of above 2 lines:
Quoted 5 lines
if (is_of_node(dev_fwnode(dev)))
platform_device_set_of_node_from_dev(spdev, dev); else platform_device_set_fwnode(spdev, dev_fwnode(dev));
To me, if the reference counting is useful (and I'm a bit doubtful about that) platform_device_set_fwnode() should be doing it. +CC those who might have more insight on this.
Jonathan
Re: [PATCH v3 1/9] firmware: arm_scmi: Set fwnode for the generated SCMI platform device
Quoted 9 lines · Jonathan Cameron
Quoted 8 lines
How about something like this instead of above 2 lines:
if (is_of_node(dev_fwnode(dev)))
platform_device_set_of_node_from_dev(spdev, dev); else platform_device_set_fwnode(spdev, dev_fwnode(dev));
Quoted 4 lines
To me, if the reference counting is useful (and I'm a bit doubtful about that)
platform_device_set_fwnode()should be doing it. +CC those who might have more insight on this.
I should have that insight. platform_device_set_fwnode() *does* the reference counting but it should be used for platform devices created with platform_device_alloc().
Bart
Sudeep Holla
maintainerPATCH v3 2/9 firmware: arm_scmi: Extend transport driver macro to support ACPI
In reply to Sudeep HollaExtend the SCMI transport driver helper to support ACPI-based systems. Introduce an internal helper macro that accepts both OF and ACPI match tables, and expose two wrappers:
- DEFINE_SCMI_TRANSPORT_DRIVER(...) for DT/OF transports
- DEFINE_SCMI_ACPI_TRANSPORT_DRIVER(...) for ACPI transports
For ACPI, set the generated platform_driver .acpi_match_table via ACPI_PTR(). The ACPI wrapper relies on the firmware-node propagation provided by the preceding change so fwnode lookups on the spawned platform device see the correct firmware description.
Keep existing DT users unchanged while allowing transports to be probed using struct acpi_device_id tables on ACPI platforms.
--- drivers/firmware/arm_scmi/common.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/common.h +11 -2
@@ -9,6 +9,7 @@#ifndef _SCMI_COMMON_H#define _SCMI_COMMON_H +#include <linux/acpi.h> #include <linux/bitfield.h> #include <linux/completion.h> #include <linux/device.h>
@@ -615,7 +616,8 @@ struct scmi_transport_supplier __supplier = { \ .th.supplier_put = scmi_transport_supplier_put, \ } -#define DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ +#define __DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __of_match, \ + __acpi_match, __core_ops) \ static void __tag##_dev_free(void *data) \ { \ struct platform_device *spdev = data; \
@@ -679,11 +681,18 @@ err_mem: \static struct platform_driver __drv = { \ .driver = { \ .name = #__tag "_transport", \ - .of_match_table = __match, \ + .of_match_table = __of_match, \ + .acpi_match_table =ACPI_PTR (__acpi_match), \ }, \ .probe = __tag##_probe, \ } +#define DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ + __DEFINE_SCMI_TRANSPORT_DRIVER(__tag, __drv, __desc, __match, NULL, __core_ops) + +#define DEFINE_SCMI_ACPI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ + __DEFINE_SCMI_TRANSPORT_DRIVER(__tag, __drv, __desc, NULL, __match, __core_ops) +void scmi_notification_instance_data_set (const struct scmi_handle *handle,void *priv);void *scmi_notification_instance_data_get (const struct scmi_handle *handle);
Signature · 1 line
2.43.0
Re: [PATCH v3 2/9] firmware: arm_scmi: Extend transport driver macro to support ACPI
Quoted 9 lines · On Thu, 13 Aug 2026 12:32:57 +0100 Sudeep Holla <[email protected]> wrote:
Extend the SCMI transport driver helper to support ACPI-based systems. Introduce an internal helper macro that accepts both OF and ACPI match tables, and expose two wrappers:
-
DEFINE_SCMI_TRANSPORT_DRIVER(...)for DT/OF transports
-DEFINE_SCMI_ACPI_TRANSPORT_DRIVER(...)for ACPI transportsFor ACPI, set the generated
platform_driver.acpi_match_table viaACPI_PTR().
ACPI_PTR() is often more trouble that it is worth because of need to guard the tables if they turn up in code where ACPI might not be present.
Now if someone fancied doing the work to make it work like pm_ptr() then that would nicer. That one lets the compiler both see the stuff beyond the pointer, but also do dead code removal on it later.
Anyhow, doesn't actually matter either way here because you only use that with a non NULL pointer in a driver that is ACPI only.
If you really want to do it, maybe pair with of_match_ptr() but that one is even worse as maybe some will be having fun with SCMI and PRP0001.
Anyhow, random diversion aside, it makes no difference in practice.
Quoted 8 lines
The ACPI wrapper relies on the firmware-node propagation provided by the preceding change so fwnode lookups on the spawned platform device see the correct firmware description.
Keep existing DT users unchanged while allowing transports to be probed using struct
acpi_device_idtables on ACPI platforms.Signed-off-by Sudeep Holla <[email protected]>
Quoted 47 lines
--- drivers/firmware/arm_scmi/common.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/firmware/arm_scmi/common.h +11
-2@@ -9,6 +9,7 @@#ifndef _SCMI_COMMON_H#define _SCMI_COMMON_H +#include <linux/acpi.h> #include <linux/bitfield.h> #include <linux/completion.h> #include <linux/device.h> @@ -615,7 +616,8 @@ struct scmi_transport_supplier __supplier = { \ .th.supplier_put = scmi_transport_supplier_put, \ } -#define DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ +#define __DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __of_match, \ + __acpi_match, __core_ops) \ static void __tag##_dev_free(void *data) \ { \ struct platform_device *spdev = data; \@@ -679,11 +681,18 @@ err_mem: \static struct platform_driver __drv = { \ .driver = { \ .name = #__tag "_transport", \ - .of_match_table = __match, \ + .of_match_table = __of_match, \ + .acpi_match_table =ACPI_PTR (__acpi_match), \ }, \ .probe = __tag##_probe, \ } +#define DEFINE_SCMI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ + __DEFINE_SCMI_TRANSPORT_DRIVER(__tag, __drv, __desc, __match, NULL, __core_ops) + +#define DEFINE_SCMI_ACPI_TRANSPORT_DRIVER (__tag, __drv, __desc, __match, __core_ops)\ + __DEFINE_SCMI_TRANSPORT_DRIVER(__tag, __drv, __desc, NULL, __match, __core_ops) +void scmi_notification_instance_data_set (const struct scmi_handle *handle,void *priv);void *scmi_notification_instance_data_get (const struct scmi_handle *handle);
Sudeep Holla
maintainerRe: [PATCH v3 2/9] firmware: arm_scmi: Extend transport driver macro to support ACPI
Quoted 20 lines · Jonathan Cameron
Quoted 9 lines · On Thu, 13 Aug 2026 12:32:57 +0100 Sudeep Holla <[email protected]> wrote:
Extend the SCMI transport driver helper to support ACPI-based systems. Introduce an internal helper macro that accepts both OF and ACPI match tables, and expose two wrappers:
-
DEFINE_SCMI_TRANSPORT_DRIVER(...)for DT/OF transports
-DEFINE_SCMI_ACPI_TRANSPORT_DRIVER(...)for ACPI transportsFor ACPI, set the generated
platform_driver.acpi_match_table viaACPI_PTR().
ACPI_PTR()is often more trouble that it is worth because of need to guard the tables if they turn up in code where ACPI might not be present.Now if someone fancied doing the work to make it work like
pm_ptr()then that would nicer. That one lets the compiler both see the stuff beyond the pointer, but also do dead code removal on it later.
Quoted 7 lines
Anyhow, doesn't actually matter either way here because you only use that with a non NULL pointer in a driver that is ACPI only.
If you really want to do it, maybe pair with
of_match_ptr()but that one is even worse as maybe some will be having fun with SCMI and PRP0001.
Agree with your analysis.
Quoted 2 lines
Anyhow, random diversion aside, it makes no difference in practice.
I just had to use it to keep build bots happy IIRC.
Quoted 11 lines
Quoted 8 lines
The ACPI wrapper relies on the firmware-node propagation provided by the preceding change so fwnode lookups on the spawned platform device see the correct firmware description.
Keep existing DT users unchanged while allowing transports to be probed using struct
acpi_device_idtables on ACPI platforms.Signed-off-by Sudeep Holla <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>
Thanks!
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 3/9 firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
In reply to Sudeep HollaSwitch SCMI core plumbing from struct device_node * to struct fwnode_handle * so the core can describe SCMI instances and protocols using firmware nodes rather than OF nodes directly.
This change:
- Replaces core 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.
- Updates transport ->chan_available() callbacks to take a fwnode.
- Stores per-protocol child fwnodes in info->active_protocols so the core can later locate the descriptor for a given protocol ID.
- Updates mailbox/optee/smc/virtio transports to accept fwnodes and map back to OF nodes where their existing parsing remains DT-specific.
DT-only transports such as mailbox, OP-TEE and SMC still parse DT properties by mapping the fwnode back to an OF node. On non-DT systems these transports report no channel available.
This is a mechanical step towards firmware-node neutrality and prepares the SCMI core for non-DT transports, such as an ACPI/PCC transport. DT users continue to work unchanged; no non-DT transport is enabled by this patch.
--- drivers/firmware/arm_scmi/bus.c | 37 ++++----- drivers/firmware/arm_scmi/common.h | 9 +- drivers/firmware/arm_scmi/driver.c | 110 +++++++++++++------------ drivers/firmware/arm_scmi/transports/mailbox.c | 6 +- drivers/firmware/arm_scmi/transports/optee.c | 6 +- drivers/firmware/arm_scmi/transports/smc.c | 11 ++- drivers/firmware/arm_scmi/transports/virtio.c | 2 +- 7 files changed, 98 insertions(+), 83 deletions(-)
drivers/firmware/arm_scmi/bus.c +18 -19
@@ -9,7 +9,7 @@#include <linux/types.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/property.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/device.h>
@@ -429,17 +429,16 @@ static void scmi_device_release(struct device *dev)struct scmi_device *scmi_dev =to_scmi_dev (dev);scmi_device_release_resources (scmi_dev); -of_node_put (dev->of_node); +fwnode_handle_put (dev_fwnode (dev));kfree_const (scmi_dev->name);kfree (scmi_dev); }static void __scmi_device_destroy (struct scmi_device *scmi_dev) { -pr_debug ("(%pOF) Destroying SCMI device '%s' for protocol 0x%x (%s)\n" , - scmi_dev->dev.parent->of_node, -dev_name (&scmi_dev->dev), scmi_dev->protocol_id, - scmi_dev->name); +pr_debug ("(%pfwf) Destroying SCMI device '%s' for protocol 0x%x (%s)\n" , +dev_fwnode (&scmi_dev->dev),dev_name (&scmi_dev->dev), + scmi_dev->protocol_id, scmi_dev->name);device_del (&scmi_dev->dev);scmi_device_release_resources (scmi_dev);
@@ -447,7 +446,7 @@ static void __scmi_device_destroy(struct scmi_device *scmi_dev) }static struct scmi_device * -__scmi_device_create (struct device_node *np,struct device *parent, +__scmi_device_create (struct fwnode_handle *fwnode,struct device *parent,int protocol,const char *name) {int id, retval;
@@ -458,7 +457,7 @@ __scmi_device_create(struct device_node *np, struct device *parent,* If the same protocol/name device already exist under the same parent * (i.e. SCMI instance) just return the existent device. * This avoids any race between the SCMI driver, creating devices for -* each DT defined protocol at probe time, and the concurrent +* each fwnode defined protocol at probe time, and the concurrent * registration of SCMI drivers. */ scmi_dev =scmi_child_dev_find_get (parent, protocol, name);
@@ -495,7 +494,7 @@ __scmi_device_create(struct device_node *np, struct device *parent, scmi_dev->id = id; scmi_dev->dev.parent = parent; -device_set_node (&scmi_dev->dev,of_fwnode_handle (of_node_get (np))); +device_set_node (&scmi_dev->dev,fwnode_handle_get (fwnode)); scmi_dev->dev.bus = &scmi_bus_type; scmi_dev->dev.release = scmi_device_release;dev_set_name (&scmi_dev->dev,"scmi_dev.%d" , id);
@@ -504,8 +503,8 @@ __scmi_device_create(struct device_node *np, struct device *parent,if (retval) goto put_dev; -pr_debug ("(%pOF) Created SCMI device '%s' for protocol 0x%x (%s)\n" , - parent->of_node,dev_name (&scmi_dev->dev), protocol, name); +pr_debug ("(%pfwf) Created SCMI device '%s' - protocol 0x%x (%s)\n" , + fwnode,dev_name (&scmi_dev->dev), protocol, name);return scmi_dev; put_dev:
@@ -521,15 +520,15 @@ __scmi_device_create(struct device_node *np, struct device *parent, }static struct scmi_device * -_scmi_device_create (struct device_node *np,struct device *parent, +_scmi_device_create (struct fwnode_handle *fwnode,struct device *parent,int protocol,const char *name) {struct scmi_device *sdev; - sdev =__scmi_device_create (np, parent, protocol, name); + sdev =__scmi_device_create (fwnode, parent, protocol, name);if (!sdev) -pr_err ("(%pOF) Failed to create device for protocol 0x%x (%s)\n" , - parent->of_node, protocol, name); +pr_err ("(%pfwf) Failed to create device - protocol 0x%x (%s)\n" , + fwnode, protocol, name);return sdev; }
@@ -537,7 +536,7 @@ _scmi_device_create(struct device_node *np, struct device *parent,/** * scmi_device_create - A method to create one or more SCMI devices * -* @np: A reference to the device node to use for the new device(s) +* @fwnode: A reference to the device node to use for the new device(s) * @parent: The parent device to use identifying a specific SCMI instance * @protocol: The SCMI protocol to be associated with this device * @name: The requested-name of the device to be created; this is optional
@@ -557,7 +556,7 @@ _scmi_device_create(struct device_node *np, struct device *parent,* could have been potentially created for a whole protocol, unless no * device was found to have been requested for that specific protocol. */ -struct scmi_device *scmi_device_create (struct device_node *np, +struct scmi_device *scmi_device_create (struct fwnode_handle *fwnode,struct device *parent,int protocol,const char *name) {
@@ -566,7 +565,7 @@ struct scmi_device *scmi_device_create(struct device_node *np,struct scmi_device *scmi_dev =NULL ;if (name) -return _scmi_device_create (np, parent, protocol, name); +return _scmi_device_create (fwnode, parent, protocol, name);mutex_lock (&scmi_requested_devices_mtx); phead =idr_find (&scmi_requested_devices, protocol);
@@ -580,7 +579,7 @@ struct scmi_device *scmi_device_create(struct device_node *np,list_for_each_entry (rdev, phead, node) {struct scmi_device *sdev; - sdev =_scmi_device_create (np, parent, + sdev =_scmi_device_create (fwnode, parent, rdev->id_table->protocol_id, rdev->id_table->name);if (sdev)
drivers/firmware/arm_scmi/common.h +5 -4
@@ -153,7 +153,7 @@ extern const struct bus_type scmi_bus_type;#define SCMI_BUS_NOTIFY_DEVICE_UNREQUEST 1extern struct blocking_notifier_head scmi_requested_devices_nh; -struct scmi_device *scmi_device_create (struct device_node *np, +struct scmi_device *scmi_device_create (struct fwnode_handle *fwnode,struct device *parent,int protocol,const char *name);void scmi_device_destroy (struct device *parent,int protocol,const char *name);
@@ -207,7 +207,7 @@ struct scmi_chan_info {* @poll_done: Callback to poll transfer status */ struct scmi_transport_ops { -bool (*chan_available)(struct device_node *of_node,int idx); +bool (*chan_available)(struct fwnode_handle *fwnode,int idx);int (*chan_setup)(struct scmi_chan_info *cinfo,struct device *dev,bool tx);int (*chan_free)(int id,void *p,void *data);
@@ -233,7 +233,7 @@ struct scmi_transport_ops {* be pending simultaneously in the system. May be overridden by the * get_max_msg op. * @max_msg_size: Maximum size of data payload per message that can be handled. -* @atomic_threshold: Optional system wide DT-configured threshold, expressed +* @atomic_threshold: Optional system wide fwnode-configured threshold, expressed * in microseconds, for atomic operations. * Only SCMI synchronous commands reported by the platform * to have an execution latency lesser-equal to the threshold
@@ -241,7 +241,8 @@ struct scmi_transport_ops {* decision is finally left up to the SCMI drivers. * @no_completion_irq: Flag to indicate that this transport has no completion * interrupt and has to be polled. This is similar to the -* force_polling below, except this is set via DT property. +* force_polling below, except this is set via fwnode +* property. * @force_polling: Flag to force this whole transport to use SCMI core polling * mechanism instead of completion interrupts even if available. * @sync_cmds_completed_on_ret: Flag to indicate that the transport assures
drivers/firmware/arm_scmi/driver.c +56 -54
298 lines not on this page · raw message
drivers/firmware/arm_scmi/transports/mailbox.c +5 -1
@@ -77,9 +77,13 @@ static void rx_callback(struct mbox_client *cl, void *m) core->shmem->read_header(smbox->shmem), NULL); } -static bool mailbox_chan_available (struct device_node *of_node,int idx) +static bool mailbox_chan_available (struct fwnode_handle *fwnode,int idx) {int num_mb; +struct device_node *of_node =to_of_node (fwnode); + +if (!of_node) +return false;/* * Just check if bidirrectional channels are involved, and check the
drivers/firmware/arm_scmi/transports/optee.c +5 -1
@@ -314,9 +314,13 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_treturn 0 ; } -static bool scmi_optee_chan_available (struct device_node *of_node,int idx) +static bool scmi_optee_chan_available (struct fwnode_handle *fwnode,int idx) {u32 channel_id; +struct device_node *of_node =to_of_node (fwnode); + +if (!of_node) +return false;return !of_property_read_u32_index (of_node,"linaro,optee-channel-id" , idx, &channel_id);
drivers/firmware/arm_scmi/transports/smc.c +8 -3
@@ -84,10 +84,15 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)return IRQ_HANDLED ; } -static bool smc_chan_available (struct device_node *of_node,int idx) +static bool smc_chan_available (struct fwnode_handle *fwnode,int idx) { - struct device_node *np __free(device_node) = -of_parse_phandle (of_node,"shmem" ,0 ); +struct device_node *of_node =to_of_node (fwnode); + struct device_node *np __free(device_node) = NULL; + +if (!of_node) +return false; + + np =of_parse_phandle (of_node,"shmem" ,0 );if (!np)return false;
drivers/firmware/arm_scmi/transports/virtio.c +1 -1
@@ -375,7 +375,7 @@ static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)return vioch->max_msg; } -static bool virtio_chan_available (struct device_node *of_node,int idx) +static bool virtio_chan_available (struct fwnode_handle *fwnode,int idx) {struct scmi_vio_channel *channels, *vioch =NULL ;
Signature · 1 line
2.43.0
Re: [PATCH v3 3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
Quoted 8 lines · On Thu, 13 Aug 2026 12:32:58 +0100 Sudeep Holla <[email protected]> wrote:
Switch SCMI core plumbing from struct
device_node* to structfwnode_handle* so the core can describe SCMI instances and protocols using firmware nodes rather than OF nodes directly.This change:
- Replaces core OF property lookups with fwnode_property_*() helpers.
- Switches child enumeration tofwnode_for_each_available_child_node_scoped().
Why the scoped version? See inline for more on this. Probably just needs a comment here (or use the non _scoped variant)
Quoted 11 lines
- Plumbs fwnode through the SCMI device creation and channel setup paths.
- Updates transport ->chan_available() callbacks to take a fwnode.
- Stores per-protocol child fwnodes ininfo->active_protocolsso the core can later locate the descriptor for a given protocol ID.
- Updates mailbox/optee/smc/virtio transports to accept fwnodes and map back to OF nodes where their existing parsing remains DT-specific.DT-only transports such as mailbox, OP-TEE and SMC still parse DT properties by mapping the fwnode back to an OF node. On non-DT systems these transports report no channel available.
Quoted 5 lines
This is a mechanical step towards firmware-node neutrality and prepares the SCMI core for non-DT transports, such as an ACPI/PCC transport. DT users continue to work unchanged; no non-DT transport is enabled by this patch.
Signed-off-by Sudeep Holla <[email protected]>
A few minor things - with those cleaned up. Only the cleanup.h one really matters.
Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +0
-0
...
drivers/firmware/arm_scmi/driver.c static int scmi_probe(struct platform_device *pdev) · line 3357
Quoted 6 lines
drivers/firmware/arm_scmi/driver.c +1
-1@@ -3352,10 +3354,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) {
There are no early exits yet and I can't see any added later in the series. So the scoped bit is irrelevant. I don't mind the change on basis of hardening or similar but it needs a comment in the patch description to justify that.
Quoted 19 lines
drivers/firmware/arm_scmi/driver.c +3
-3u32 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)) {@@ -3370,8 +3372,8 @@ static int scmi_probe(struct platform_device *pdev) }/* -* Save this valid DT protocol descriptor amongst -* @active_protocols for this SCMI instance/ +* Save this valid fwnode protocol descriptor amongst +* @active_protocols for this SCMI instance. */ ret =idr_alloc (&info->active_protocols, child, prot_id, prot_id +1 ,GFP_KERNEL );
drivers/firmware/arm_scmi/driver.c static int scmi_probe(struct platform_device *pdev) · line 3387
Quoted 6 lines
drivers/firmware/arm_scmi/driver.c +1
-1@@ -3381,7 +3383,7 @@ static int scmi_probe(struct platform_device *pdev)continue ; } -of_node_get (child); +fwnode_handle_get (child);scmi_create_protocol_devices (child, info, prot_id,NULL );
Give this is handing over ownership I'd make that explicit and do
scmi_create_protcol_devices(fwnode_handle_get(child), info, prot_id, NULL);
but that is a slightly unrelated change - so I don't mind if you don't change this one.
Quoted 2 lines
drivers/firmware/arm_scmi/driver.c +0
-0}
...
Quoted 5 lines
drivers/firmware/arm_scmi/transports/smc.c +0
-0
drivers/firmware/arm_scmi/transports/smc.c static irqreturn_t smc_msg_done_isr(int irq, void *data) · line 90
Quoted 10 lines
drivers/firmware/arm_scmi/transports/smc.c +3
-3@@ -84,10 +84,15 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)return IRQ_HANDLED ; } -static bool smc_chan_available (struct device_node *of_node,int idx) +static bool smc_chan_available (struct fwnode_handle *fwnode,int idx) { - struct device_node *np __free(device_node) = -of_parse_phandle (of_node,"shmem" ,0 ); +struct device_node *of_node =to_of_node (fwnode); + struct device_node *np __free(device_node) = NULL;
See guidance in cleanup.h. Basically says constructor and destructor must be together (that was after some grumpy replies from Linus to early cleanup.h users!)
drivers/firmware/arm_scmi/transports/smc.c static irqreturn_t smc_msg_done_isr(int irq, void *data) · line 95
Quoted 5 lines
drivers/firmware/arm_scmi/transports/smc.c +5
-0+ +if (!of_node) +return false; + + np =of_parse_phandle (of_node,"shmem" ,0 );
struct device_node *np __free(device_node) = of_parse_phandle(of_node, "shmem", 0);
And don't worry about the inline declaration - this case is specifically allowed.
Quoted 2 lines
drivers/firmware/arm_scmi/transports/smc.c +0
-0if (!np)return false;
Sudeep Holla
maintainerRe: [PATCH v3 3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 13 Aug 2026 12:32:58 +0100 Sudeep Holla <[email protected]> wrote:
Switch SCMI core plumbing from struct
device_node* to structfwnode_handle* so the core can describe SCMI instances and protocols using firmware nodes rather than OF nodes directly.
Quoted 8 lines
Quoted 4 lines
This change:
- Replaces core OF property lookups with fwnode_property_*() helpers.
- Switches child enumeration tofwnode_for_each_available_child_node_scoped().Why the scoped version? See inline for more on this. Probably just needs a comment here (or use the non
_scopedvariant)
Sure
Quoted 11 lines
Quoted 11 lines
- Plumbs fwnode through the SCMI device creation and channel setup paths.
- Updates transport ->chan_available() callbacks to take a fwnode.
- Stores per-protocol child fwnodes ininfo->active_protocolsso the core can later locate the descriptor for a given protocol ID.
- Updates mailbox/optee/smc/virtio transports to accept fwnodes and map back to OF nodes where their existing parsing remains DT-specific.DT-only transports such as mailbox, OP-TEE and SMC still parse DT properties by mapping the fwnode back to an OF node. On non-DT systems these transports report no channel available.
Quoted 9 lines
Quoted 5 lines
This is a mechanical step towards firmware-node neutrality and prepares the SCMI core for non-DT transports, such as an ACPI/PCC transport. DT users continue to work unchanged; no non-DT transport is enabled by this patch.
Signed-off-by Sudeep Holla <[email protected]>A few minor things - with those cleaned up. Only the
cleanup.hone really matters.
Fixed now.
Quoted 13 lines
Reviewed-by Jonathan Cameron <[email protected]>Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +0
-0...
Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +0
-0@@ -3352,10 +3354,10 @@ static int scmi_probe(struct platform_device *pdev)scmi_enable_matching_quirks (info);
Quoted 8 lines
drivers/firmware/arm_scmi/driver.c static int scmi_probe(struct platform_device *pdev) · line 3357
Quoted 2 lines
drivers/firmware/arm_scmi/driver.c +1
-1-for_each_available_child_of_node (np, child) { +fwnode_for_each_available_child_node_scoped (dev_fwnode (dev), child) {There are no early exits yet and I can't see any added later in the series. So the scoped bit is irrelevant. I don't mind the change on basis of hardening or similar but it needs a comment in the patch description to justify that.
This is mainly to release the reference taken in fwnode_get_next_available_child_node(). It is taken explicitly via fwnode_handle_get() before scmi_create_protocol_devices() as discussed below.
Quoted 28 lines
Quoted 19 lines
drivers/firmware/arm_scmi/driver.c +3
-3u32 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)) {@@ -3370,8 +3372,8 @@ static int scmi_probe(struct platform_device *pdev) }/* -* Save this valid DT protocol descriptor amongst -* @active_protocols for this SCMI instance/ +* Save this valid fwnode protocol descriptor amongst +* @active_protocols for this SCMI instance. */ ret =idr_alloc (&info->active_protocols, child, prot_id, prot_id +1 ,GFP_KERNEL );drivers/firmware/arm_scmi/driver.c static int scmi_probe(struct platform_device *pdev) · line 3387
Quoted 6 lines
drivers/firmware/arm_scmi/driver.c +1
-1@@ -3381,7 +3383,7 @@ static int scmi_probe(struct platform_device *pdev)continue ; } -of_node_get (child); +fwnode_handle_get (child);scmi_create_protocol_devices (child, info, prot_id,NULL );Give this is handing over ownership I'd make that explicit and do
Quoted 4 lines
scmi_create_protcol_devices(fwnode_handle_get(child), info, prot_id, NULL);but that is a slightly unrelated change - so I don't mind if you don't change this one.
Agreed, I can change this if it help readability.
[...]
Quoted 9 lines
Quoted 9 lines
drivers/firmware/arm_scmi/transports/smc.c +0
-0@@ -84,10 +84,15 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)return IRQ_HANDLED ; }
Quoted 12 lines
drivers/firmware/arm_scmi/transports/smc.c static irqreturn_t smc_msg_done_isr(int irq, void *data) · line 90
Quoted 7 lines
drivers/firmware/arm_scmi/transports/smc.c +3
-3-static bool smc_chan_available (struct device_node *of_node,int idx) +static bool smc_chan_available (struct fwnode_handle *fwnode,int idx) { - struct device_node *np __free(device_node) = -of_parse_phandle (of_node,"shmem" ,0 ); +struct device_node *of_node =to_of_node (fwnode); + struct device_node *np __free(device_node) = NULL;See guidance in
cleanup.h. Basically says constructor and destructor must be together (that was after some grumpy replies from Linus to earlycleanup.husers!)
Thanks, fixed locally now.
Signature · 2 lines
Regards, Sudeep
Re: [PATCH v3 3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
Quoted 64 lines · On Wed, 2 Sep 2026 14:39:31 +0100 Sudeep Holla <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 13 Aug 2026 12:32:58 +0100 Sudeep Holla <[email protected]> wrote:
Switch SCMI core plumbing from struct
device_node* to structfwnode_handle* so the core can describe SCMI instances and protocols using firmware nodes rather than OF nodes directly.Quoted 8 lines
Quoted 4 lines
This change:
- Replaces core OF property lookups with fwnode_property_*() helpers.
- Switches child enumeration tofwnode_for_each_available_child_node_scoped().Why the scoped version? See inline for more on this. Probably just needs a comment here (or use the non
_scopedvariant)Sure
Quoted 11 lines
Quoted 11 lines
- Plumbs fwnode through the SCMI device creation and channel setup paths.
- Updates transport ->chan_available() callbacks to take a fwnode.
- Stores per-protocol child fwnodes ininfo->active_protocolsso the core can later locate the descriptor for a given protocol ID.
- Updates mailbox/optee/smc/virtio transports to accept fwnodes and map back to OF nodes where their existing parsing remains DT-specific.DT-only transports such as mailbox, OP-TEE and SMC still parse DT properties by mapping the fwnode back to an OF node. On non-DT systems these transports report no channel available.
Quoted 9 lines
Quoted 5 lines
This is a mechanical step towards firmware-node neutrality and prepares the SCMI core for non-DT transports, such as an ACPI/PCC transport. DT users continue to work unchanged; no non-DT transport is enabled by this patch.
Signed-off-by Sudeep Holla <[email protected]>A few minor things - with those cleaned up. Only the
cleanup.hone really matters.Fixed now.
Quoted 13 lines
Reviewed-by Jonathan Cameron <[email protected]>Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +0
-0...
Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +0
-0@@ -3352,10 +3354,10 @@ static int scmi_probe(struct platform_device *pdev)scmi_enable_matching_quirks (info);Quoted 8 lines
drivers/firmware/arm_scmi/driver.c static int scmi_probe(struct platform_device *pdev) · line 3357
Quoted 2 lines
drivers/firmware/arm_scmi/driver.c +1
-1-for_each_available_child_of_node (np, child) { +fwnode_for_each_available_child_node_scoped (dev_fwnode (dev), child) {There are no early exits yet and I can't see any added later in the series. So the scoped bit is irrelevant. I don't mind the change on basis of hardening or similar but it needs a comment in the patch description to justify that.
Quoted 4 lines
This is mainly to release the reference taken in
fwnode_get_next_available_child_node(). It is taken explicitly viafwnode_handle_get()beforescmi_create_protocol_devices()as discussed below.
When the loop continues to normal termination the puts are all there anyway as part of the iterators. The _scoped case just deals with early exits via break or return.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/firmware/arm_scmi/driver.c +1
-1u32 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)) {
Sudeep Holla
maintainerRe: [PATCH v3 3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core
Quoted 4 lines · Jonathan Cameron
Quoted 1 line · On Wed, 2 Sep 2026 14:39:31 +0100 Sudeep Holla <[email protected]> wrote:
On Mon, Aug 24, 2026 at 10:39:29AM -0700, Jonathan Cameron wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
There are no early exits yet and I can't see any added later in the series. So the scoped bit is irrelevant. I don't mind the change on basis of hardening or similar but it needs a comment in the patch description to justify that.
Quoted 8 lines
Quoted 4 lines
This is mainly to release the reference taken in
fwnode_get_next_available_child_node(). It is taken explicitly viafwnode_handle_get()beforescmi_create_protocol_devices()as discussed below.When the loop continues to normal termination the puts are all there anyway as part of the iterators. The
_scopedcase just deals with early exits via break or return.
You're right. For some reason I conflated the iterator-owned reference won't be released and _scoped version is needed. This loop has no early exit, so I will use the non-scoped iterator here. Thanks again.
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 4/9 firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent
In reply to Sudeep Hollascmi_debugfs_common_setup() uses the "compatible" property to populate the debugfs transport type string. ACPI-described SCMI devices do not provide that DT property, so the string remains NULL and debugfs setup falls through the allocation failure path.
Check the property lookup result and use the ACPI HID as the fallback transport type when an ACPI companion is present.
All supported DT SCMI platforms are expected to provide "compatible", so the non-ACPI fallback is not needed for normal DT operation. Keep the explicit "unknown" fallback anyway to avoid passing NULL to kstrdup() if that assumption is ever violated.
--- drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/driver.c +14 -2
@@ -16,6 +16,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cleanup.h> #include <linux/debugfs.h>
@@ -3063,6 +3064,15 @@ static void scmi_debugfs_common_cleanup(void *d)kfree (dbg->type); } +static const char *scmi_acpi_device_hid (struct acpi_device *adev) +{ +#ifdef CONFIG_ACPI +return adev ?acpi_device_hid (adev) :"unknown" ; +#else +return "unknown" ; +#endif +} +static struct scmi_debug_info *scmi_debugfs_common_setup (struct scmi_info *info) {char top_dir[16 ];
@@ -3080,8 +3090,10 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)return NULL ; } -fwnode_property_read_string (dev_fwnode (info->dev),"compatible" , - &c_ptr); +if (fwnode_property_read_string (dev_fwnode (info->dev),"compatible" , + &c_ptr)) + c_ptr =scmi_acpi_device_hid (ACPI_COMPANION (info->dev)); + dbg->type =kstrdup (c_ptr,GFP_KERNEL );if (!dbg->type) {kfree (dbg->name);
Signature · 1 line
2.43.0
Re: [PATCH v3 4/9] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent
Quoted 8 lines · On Thu, 13 Aug 2026 12:32:59 +0100 Sudeep Holla <[email protected]> wrote:
scmi_debugfs_common_setup()uses the "compatible" property to populate the debugfs transport type string. ACPI-described SCMI devices do not provide that DT property, so the string remains NULL and debugfs setup falls through the allocation failure path.Check the property lookup result and use the ACPI HID as the fallback transport type when an ACPI companion is present.
Quoted 6 lines
All supported DT SCMI platforms are expected to provide "compatible", so the non-ACPI fallback is not needed for normal DT operation. Keep the explicit "unknown" fallback anyway to avoid passing NULL to
kstrdup()if that assumption is ever violated.Signed-off-by Sudeep Holla <[email protected]>
Can drop some complexity in here and rely on the stubs in acpi.h a little more.
Quoted 17 lines
--- drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/firmware/arm_scmi/driver.c +1
-0@@ -16,6 +16,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cleanup.h> #include <linux/debugfs.h>
drivers/firmware/arm_scmi/driver.c static void scmi_debugfs_common_cleanup(void *d) · line 3069
Quoted 6 lines
drivers/firmware/arm_scmi/driver.c +3
-0@@ -3063,6 +3064,15 @@ static void scmi_debugfs_common_cleanup(void *d)kfree (dbg->type); } +static const char *scmi_acpi_device_hid (struct acpi_device *adev) +{ +#ifdef CONFIG_ACPI
Hmm. Ugly that acpi_device_id returns an empty string.
However given when !CONFIG_ACPI the stub for ACPI_COMPANION(dev) is NULL. You don't need this dance anyway.
Quoted 23 lines
drivers/firmware/arm_scmi/driver.c +10
-2+return adev ?acpi_device_hid (adev) :"unknown" ; +#else +return "unknown" ; +#endif +} +static struct scmi_debug_info *scmi_debugfs_common_setup (struct scmi_info *info) {char top_dir[16 ];@@ -3080,8 +3090,10 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)return NULL ; } -fwnode_property_read_string (dev_fwnode (info->dev),"compatible" , - &c_ptr); +if (fwnode_property_read_string (dev_fwnode (info->dev),"compatible" , + &c_ptr)) + c_ptr =scmi_acpi_device_hid (ACPI_COMPANION (info->dev)); + dbg->type =kstrdup (c_ptr,GFP_KERNEL );if (!dbg->type) {kfree (dbg->name);
Sudeep Holla
maintainerRe: [PATCH v3 4/9] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent
Quoted 39 lines · Jonathan Cameron
Quoted 8 lines · On Thu, 13 Aug 2026 12:32:59 +0100 Sudeep Holla <[email protected]> wrote:
scmi_debugfs_common_setup()uses the "compatible" property to populate the debugfs transport type string. ACPI-described SCMI devices do not provide that DT property, so the string remains NULL and debugfs setup falls through the allocation failure path.Check the property lookup result and use the ACPI HID as the fallback transport type when an ACPI companion is present.
Quoted 6 lines
All supported DT SCMI platforms are expected to provide "compatible", so the non-ACPI fallback is not needed for normal DT operation. Keep the explicit "unknown" fallback anyway to avoid passing NULL to
kstrdup()if that assumption is ever violated.Signed-off-by Sudeep Holla <[email protected]>Can drop some complexity in here and rely on the stubs in
acpi.ha little more.Quoted 20 lines
--- drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/firmware/arm_scmi/driver.c +1
-0@@ -16,6 +16,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cleanup.h> #include <linux/debugfs.h> @@ -3063,6 +3064,15 @@ static void scmi_debugfs_common_cleanup(void *d)kfree (dbg->type); }
Quoted 9 lines
drivers/firmware/arm_scmi/driver.c static void scmi_debugfs_common_cleanup(void *d) · line 3069
Quoted 3 lines
drivers/firmware/arm_scmi/driver.c +3
-0+static const char *scmi_acpi_device_hid (struct acpi_device *adev) +{ +#ifdef CONFIG_ACPI Hmm. Ugly that
acpi_device_idreturns an empty string.However given when !CONFIG_ACPI the stub for
ACPI_COMPANION(dev)is NULL. You don't need this dance anyway.
That was exactly my thoughts initially until builder bots complained. But acpi_device_hid() is defined only for CONFIG_ACPI, though I can handle it runtime, I need to define acpi_device_hid() as NULL for !CONFIG_ACPI as alternative.
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerRe: [PATCH v3 4/9] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent
Quoted 46 lines · Sudeep Holla
Quoted 45 lines · Jonathan Cameron
Quoted 8 lines · On Thu, 13 Aug 2026 12:32:59 +0100 Sudeep Holla <[email protected]> wrote:
scmi_debugfs_common_setup()uses the "compatible" property to populate the debugfs transport type string. ACPI-described SCMI devices do not provide that DT property, so the string remains NULL and debugfs setup falls through the allocation failure path.Check the property lookup result and use the ACPI HID as the fallback transport type when an ACPI companion is present.
Quoted 6 lines
All supported DT SCMI platforms are expected to provide "compatible", so the non-ACPI fallback is not needed for normal DT operation. Keep the explicit "unknown" fallback anyway to avoid passing NULL to
kstrdup()if that assumption is ever violated.Signed-off-by Sudeep Holla <[email protected]>Can drop some complexity in here and rely on the stubs in
acpi.ha little more.Quoted 17 lines
--- drivers/firmware/arm_scmi/driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)drivers/firmware/arm_scmi/driver.c +1
-0@@ -16,6 +16,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/acpi.h> #include <linux/bitmap.h> #include <linux/cleanup.h> #include <linux/debugfs.h> drivers/firmware/arm_scmi/driver.c static void scmi_debugfs_common_cleanup(void *d) · line 3069
Quoted 6 lines
drivers/firmware/arm_scmi/driver.c +3
-0@@ -3063,6 +3064,15 @@ static void scmi_debugfs_common_cleanup(void *d)kfree (dbg->type); } +static const char *scmi_acpi_device_hid (struct acpi_device *adev) +{ +#ifdef CONFIG_ACPI Hmm. Ugly that
acpi_device_idreturns an empty string.
Quoted 9 lines
Quoted 3 lines
However given when !CONFIG_ACPI the stub for
ACPI_COMPANION(dev)is NULL. You don't need this dance anyway.That was exactly my thoughts initially until builder bots complained. But
acpi_device_hid()is defined only forCONFIG_ACPI, though I can handle it runtime, I need to defineacpi_device_hid()as NULL for !CONFIG_ACPI as alternative.
Scratch that, I need to dig the build failure and understand it better. I think including acpi_bus.h caused some issue which I don't like as acpi_bus.h must be for core acpi support code. We may need to move acpi_device_hid() out of there.
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 5/9 firmware: arm_scmi: Pass protocol ID to chan_available() transport callback
In reply to Sudeep HollaExtend the SCMI transport_ops chan_available() callback to include the protocol ID (prot_id) as an argument. This allows transports to determine channel availability based on the specific protocol being used, improving flexibility in platforms that share transport channels across multiple protocols. This will be useful when ACPI PCC transport gets added.
Updated all existing users and definitions of chan_available() in SCMI core and transport drivers (mailbox, optee, etc.) accordingly.
No functional change.
--- drivers/firmware/arm_scmi/common.h | 3 ++- drivers/firmware/arm_scmi/driver.c | 2 +- drivers/firmware/arm_scmi/transports/mailbox.c | 3 ++- drivers/firmware/arm_scmi/transports/optee.c | 3 ++- drivers/firmware/arm_scmi/transports/smc.c | 3 ++- drivers/firmware/arm_scmi/transports/virtio.c | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-)
drivers/firmware/arm_scmi/common.h +2 -1
@@ -207,7 +207,8 @@ struct scmi_chan_info {* @poll_done: Callback to poll transfer status */ struct scmi_transport_ops { -bool (*chan_available)(struct fwnode_handle *fwnode,int idx); +bool (*chan_available)(struct fwnode_handle *fwnode,int prot_id, +int idx);int (*chan_setup)(struct scmi_chan_info *cinfo,struct device *dev,bool tx);int (*chan_free)(int id,void *p,void *data);
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -2768,7 +2768,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct fwnode_handle *fwnode,if (idr_find (idr, prot_id))return -EEXIST ; -if (!info->desc->ops->chan_available (fwnode, idx)) { +if (!info->desc->ops->chan_available (fwnode, prot_id, idx)) { cinfo =idr_find (idr,SCMI_PROTOCOL_BASE );if (unlikely (!cinfo))/* Possible only if platform has no Rx */ return -EINVAL ;
drivers/firmware/arm_scmi/transports/mailbox.c +2 -1
@@ -77,7 +77,8 @@ static void rx_callback(struct mbox_client *cl, void *m) core->shmem->read_header(smbox->shmem), NULL); } -static bool mailbox_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +mailbox_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {int num_mb;struct device_node *of_node =to_of_node (fwnode);
drivers/firmware/arm_scmi/transports/optee.c +2 -1
@@ -314,7 +314,8 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_treturn 0 ; } -static bool scmi_optee_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +scmi_optee_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {u32 channel_id;struct device_node *of_node =to_of_node (fwnode);
drivers/firmware/arm_scmi/transports/smc.c +2 -1
@@ -84,7 +84,8 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)return IRQ_HANDLED ; } -static bool smc_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +smc_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {struct device_node *of_node =to_of_node (fwnode); struct device_node *np __free(device_node) = NULL;
drivers/firmware/arm_scmi/transports/virtio.c +2 -1
@@ -375,7 +375,8 @@ static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)return vioch->max_msg; } -static bool virtio_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +virtio_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {struct scmi_vio_channel *channels, *vioch =NULL ;
Signature · 1 line
2.43.0
Re: [PATCH v3 5/9] firmware: arm_scmi: Pass protocol ID to chan_available() transport callback
Quoted 6 lines · On Thu, 13 Aug 2026 12:33:00 +0100 Sudeep Holla <[email protected]> wrote:
Extend the SCMI
transport_opschan_available()callback to include the protocol ID (prot_id) as an argument. This allows transports to determine channel availability based on the specific protocol being used, improving flexibility in platforms that share transport channels across multiple protocols. This will be useful when ACPI PCC transport gets added.
Quoted 6 lines
Updated all existing users and definitions of
chan_available()in SCMI core and transport drivers (mailbox, optee, etc.) accordingly.No functional change.
Signed-off-by Sudeep Holla <[email protected]>
Quoted 93 lines
--- drivers/firmware/arm_scmi/common.h | 3 ++- drivers/firmware/arm_scmi/driver.c | 2 +- drivers/firmware/arm_scmi/transports/mailbox.c | 3 ++- drivers/firmware/arm_scmi/transports/optee.c | 3 ++- drivers/firmware/arm_scmi/transports/smc.c | 3 ++- drivers/firmware/arm_scmi/transports/virtio.c | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-)drivers/firmware/arm_scmi/common.h +2
-1@@ -207,7 +207,8 @@ struct scmi_chan_info {* @poll_done: Callback to poll transfer status */ struct scmi_transport_ops { -bool (*chan_available)(struct fwnode_handle *fwnode,int idx); +bool (*chan_available)(struct fwnode_handle *fwnode,int prot_id, +int idx);int (*chan_setup)(struct scmi_chan_info *cinfo,struct device *dev,bool tx);int (*chan_free)(int id,void *p,void *data);drivers/firmware/arm_scmi/driver.c +1
-1@@ -2768,7 +2768,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct fwnode_handle *fwnode,if (idr_find (idr, prot_id))return -EEXIST ; -if (!info->desc->ops->chan_available (fwnode, idx)) { +if (!info->desc->ops->chan_available (fwnode, prot_id, idx)) { cinfo =idr_find (idr,SCMI_PROTOCOL_BASE );if (unlikely (!cinfo))/* Possible only if platform has no Rx */ return -EINVAL ;drivers/firmware/arm_scmi/transports/mailbox.c +2
-1@@ -77,7 +77,8 @@ static void rx_callback(struct mbox_client *cl, void *m) core->shmem->read_header(smbox->shmem), NULL); } -static bool mailbox_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +mailbox_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {int num_mb;struct device_node *of_node =to_of_node (fwnode);drivers/firmware/arm_scmi/transports/optee.c +2
-1@@ -314,7 +314,8 @@ static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_treturn 0 ; } -static bool scmi_optee_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +scmi_optee_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {u32 channel_id;struct device_node *of_node =to_of_node (fwnode);drivers/firmware/arm_scmi/transports/smc.c +2
-1@@ -84,7 +84,8 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)return IRQ_HANDLED ; } -static bool smc_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +smc_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {struct device_node *of_node =to_of_node (fwnode); struct device_node *np __free(device_node) = NULL;drivers/firmware/arm_scmi/transports/virtio.c +2
-1@@ -375,7 +375,8 @@ static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)return vioch->max_msg; } -static bool virtio_chan_available (struct fwnode_handle *fwnode,int idx) +static bool +virtio_chan_available (struct fwnode_handle *fwnode,int prot_id,int idx) {struct scmi_vio_channel *channels, *vioch =NULL ;
Sudeep Holla
maintainerPATCH v3 6/9 firmware: arm_scmi: Refactor protocol device creation logic
In reply to Sudeep HollaMove the protocol validation and device creation logic in scmi_probe() into a reusable scmi_device_check_create() helper.
The helper centralizes checks for the protocol ID range, implementation availability and duplicate activation before invoking scmi_create_protocol_devices(). This preserves the existing behavior while allowing the logic to be reused by the ACPI path, where protocol child fwnodes are absent.
No functional change intended.
--- drivers/firmware/arm_scmi/driver.c | 60 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-)
drivers/firmware/arm_scmi/driver.c +35 -25
@@ -3244,6 +3244,40 @@ static void scmi_enable_matching_quirks(struct scmi_info *info) rev->sub_vendor_id, rev->impl_ver); } +static void scmi_device_check_create (struct fwnode_handle *fwnode,int prot_id, +struct scmi_info *info) +{ +int ret; +struct device *dev = info->dev; +struct scmi_handle *handle = &info->handle; + +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { +dev_err (dev,"Out of range protocol %d\n" , prot_id); +return ; + } + +if (!scmi_is_protocol_implemented (handle, prot_id)) { +dev_err (dev,"SCMI protocol %d not implemented\n" , + prot_id); +return ; + } + +/* +* Save this valid fwnode protocol descriptor amongst +* @active_protocols for this SCMI instance. +*/ + ret =idr_alloc (&info->active_protocols, fwnode, + prot_id, prot_id +1 ,GFP_KERNEL ); +if (ret != prot_id) { +dev_err (dev,"SCMI protocol %d already activated. Skip\n" , + prot_id); +return ; + } + +fwnode_handle_get (fwnode); +scmi_create_protocol_devices (fwnode, info, prot_id,NULL ); +} +static int scmi_probe (struct platform_device *pdev) {int ret;
@@ -3372,31 +3406,7 @@ static int scmi_probe(struct platform_device *pdev)if (fwnode_property_read_u32 (child,"reg" , &prot_id))continue ; -if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { -dev_err (dev,"Out of range protocol %d\n" , prot_id); -continue ; - } - -if (!scmi_is_protocol_implemented (handle, prot_id)) { -dev_err (dev,"SCMI protocol %d not implemented\n" , - prot_id); -continue ; - } - -/* -* Save this valid fwnode protocol descriptor amongst -* @active_protocols for this SCMI instance. -*/ - ret =idr_alloc (&info->active_protocols, child, - prot_id, prot_id +1 ,GFP_KERNEL ); -if (ret != prot_id) { -dev_err (dev,"SCMI protocol %d already activated. Skip\n" , - prot_id); -continue ; - } - -fwnode_handle_get (child); -scmi_create_protocol_devices (child, info, prot_id,NULL ); +scmi_device_check_create (child, prot_id, info); }return 0 ;
Signature · 1 line
2.43.0
Re: [PATCH v3 6/9] firmware: arm_scmi: Refactor protocol device creation logic
Quoted 9 lines · On Thu, 13 Aug 2026 12:33:01 +0100 Sudeep Holla <[email protected]> wrote:
Move the protocol validation and device creation logic in
scmi_probe()into a reusablescmi_device_check_create()helper.The helper centralizes checks for the protocol ID range, implementation availability and duplicate activation before invoking
scmi_create_protocol_devices(). This preserves the existing behavior while allowing the logic to be reused by the ACPI path, where protocol child fwnodes are absent.
Quoted 3 lines
No functional change intended.
Signed-off-by Sudeep Holla <[email protected]>
A trivial thing and one follow on from earlier. For that just be consistent with what you choose to do for the earlier comment.
Quoted 17 lines
--- drivers/firmware/arm_scmi/driver.c | 60 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-)drivers/firmware/arm_scmi/driver.c +5
-0@@ -3244,6 +3244,40 @@ static void scmi_enable_matching_quirks(struct scmi_info *info) rev->sub_vendor_id, rev->impl_ver); } +static void scmi_device_check_create (struct fwnode_handle *fwnode,int prot_id, +struct scmi_info *info) +{ +int ret; +struct device *dev = info->dev;
drivers/firmware/arm_scmi/driver.c static void scmi_enable_matching_quirks(struct scmi_info *info) · line 3261
Quoted 10 lines
drivers/firmware/arm_scmi/driver.c +10
-0+struct scmi_handle *handle = &info->handle; + +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { +dev_err (dev,"Out of range protocol %d\n" , prot_id); +return ; + } + +if (!scmi_is_protocol_implemented (handle, prot_id)) { +dev_err (dev,"SCMI protocol %d not implemented\n" , + prot_id);
Fits on one line. I didn't check if you modify this later in the series though so if this is churn reduction, fine to leave it as it stands.
Quoted 7 lines
drivers/firmware/arm_scmi/driver.c +7
-0+return ; + } + +/* +* Save this valid fwnode protocol descriptor amongst +* @active_protocols for this SCMI instance. +*/
drivers/firmware/arm_scmi/driver.c static void scmi_enable_matching_quirks(struct scmi_info *info) · line 3278
Quoted 10 lines
drivers/firmware/arm_scmi/driver.c +10
-0+ ret =idr_alloc (&info->active_protocols, fwnode, + prot_id, prot_id +1 ,GFP_KERNEL ); +if (ret != prot_id) { +dev_err (dev,"SCMI protocol %d already activated. Skip\n" , + prot_id); +return ; + } + +fwnode_handle_get (fwnode); +scmi_create_protocol_devices (fwnode, info, prot_id,NULL );
If you take the suggest I made earlier to make the hand over of ownership slightly more obvious by using the return value of fwmonde_handle_get() then applies here too.
Quoted 1 line
drivers/firmware/arm_scmi/driver.c +1
-0+}
Sudeep Holla
maintainerRe: [PATCH v3 6/9] firmware: arm_scmi: Refactor protocol device creation logic
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Thu, 13 Aug 2026 12:33:01 +0100 Sudeep Holla <[email protected]> wrote:
Move the protocol validation and device creation logic in
scmi_probe()into a reusablescmi_device_check_create()helper.The helper centralizes checks for the protocol ID range, implementation availability and duplicate activation before invoking
scmi_create_protocol_devices(). This preserves the existing behavior while allowing the logic to be reused by the ACPI path, where protocol child fwnodes are absent.
Quoted 8 lines
Quoted 3 lines
No functional change intended.
Signed-off-by Sudeep Holla <[email protected]>A trivial thing and one follow on from earlier. For that just be consistent with what you choose to do for the earlier comment.
Reviewed-by Jonathan Cameron <[email protected]>
Thanks!
Quoted 22 lines
Quoted 22 lines
--- drivers/firmware/arm_scmi/driver.c | 60 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-)drivers/firmware/arm_scmi/driver.c +10
-0@@ -3244,6 +3244,40 @@ static void scmi_enable_matching_quirks(struct scmi_info *info) rev->sub_vendor_id, rev->impl_ver); } +static void scmi_device_check_create (struct fwnode_handle *fwnode,int prot_id, +struct scmi_info *info) +{ +int ret; +struct device *dev = info->dev; +struct scmi_handle *handle = &info->handle; + +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { +dev_err (dev,"Out of range protocol %d\n" , prot_id); +return ;
Quoted 9 lines
drivers/firmware/arm_scmi/driver.c static void scmi_enable_matching_quirks(struct scmi_info *info) · line 3261
Quoted 5 lines
drivers/firmware/arm_scmi/driver.c +5
-0+ } + +if (!scmi_is_protocol_implemented (handle, prot_id)) { +dev_err (dev,"SCMI protocol %d not implemented\n" , + prot_id);Fits on one line. I didn't check if you modify this later in the series though so if this is churn reduction, fine to leave it as it stands.
Fixed locally, must be side-effect of refactoring.
Quoted 13 lines
Quoted 13 lines
drivers/firmware/arm_scmi/driver.c +13
-0+return ; + } + +/* +* Save this valid fwnode protocol descriptor amongst +* @active_protocols for this SCMI instance. +*/ + ret =idr_alloc (&info->active_protocols, fwnode, + prot_id, prot_id +1 ,GFP_KERNEL ); +if (ret != prot_id) { +dev_err (dev,"SCMI protocol %d already activated. Skip\n" , + prot_id); +return ;
Quoted 9 lines
drivers/firmware/arm_scmi/driver.c static void scmi_enable_matching_quirks(struct scmi_info *info) · line 3278
Quoted 4 lines
drivers/firmware/arm_scmi/driver.c +4
-0+ } + +fwnode_handle_get (fwnode); +scmi_create_protocol_devices (fwnode, info, prot_id,NULL );If you take the suggest I made earlier to make the hand over of ownership slightly more obvious by using the return value of
fwmonde_handle_get()then applies here too.
I will update 3/9, it should be there by 6/9, so no change here other that the move itself.
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 7/9 firmware: arm_scmi: Add ACPI PCC transport
In reply to Sudeep HollaIntroduce a new SCMI transport that uses ACPI PCCT (PCC) subspaces via the Linux PCC mailbox layer. Parse ACPI _DSD data to map protocol associations to PCC transport UIDs. Support common and protocol-exclusive A2P channels, plus optional common or protocol-exclusive P2A channels for notifications.
Key points:
- new CONFIG_ARM_SCMI_TRANSPORT_PCC option
- integration with SCMI core via scmi_desc and transport ops
- response and notification fetch from PCC shared memory
- ACPI device matching and registration via the ACPI transport macro
This enables SCMI to be exercised over PCC on ACPI platforms.
--- drivers/firmware/arm_scmi/common.h | 11 + drivers/firmware/arm_scmi/transports/Kconfig | 13 + drivers/firmware/arm_scmi/transports/Makefile | 2 + drivers/firmware/arm_scmi/transports/pcc.c | 791 ++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 1 + 5 files changed, 818 insertions(+)
drivers/firmware/arm_scmi/common.h +11 -0
@@ -468,6 +468,17 @@ struct scmi_transport_core_operations {const struct scmi_message_operations *msg; }; +struct scmi_dsd_info { +u32 protocol_id; +const char *const property_name; +}; + +static const struct scmi_dsd_info scmi_dsd_info_list[]__maybe_unused = { + {SCMI_PROTOCOL_BASE ,"arm-arml0001-transport-pcc" }, + {SCMI_PROTOCOL_POWERCAP ,"arm-arml0001-protocol-pcap" }, + {SCMI_PROTOCOL_TELEMETRY ,"arm-arml0001-protocol-telemetry" }, +}; +/** * struct scmi_transport_handle - Transport instance handle * @supplier_get: A helper to retrieve the device descriptor, identifying the
drivers/firmware/arm_scmi/transports/Kconfig +13 -0
@@ -77,6 +77,19 @@ config ARM_SCMI_TRANSPORT_OPTEE This driver can also be built as a module. If so, the module will be called scmi_transport_optee. +config ARM_SCMI_TRANSPORT_PCC + tristate "SCMI transport based on ACPI PCC" + depends on PCC + select ARM_SCMI_HAVE_TRANSPORT + default y + help + Enable ACPI PCC mailbox based transport for SCMI. + + If you want the ARM SCMI PROTOCOL stack to include support for a + transport based on mailboxes, answer Y. + This driver can also be built as a module. If so, the module + will be called scmi_transport_pcc. + config ARM_SCMI_TRANSPORT_VIRTIO tristate "SCMI transport based on VirtIO" depends on VIRTIO
drivers/firmware/arm_scmi/transports/Makefile +2 -0
@@ -7,6 +7,8 @@ scmi_transport_mailbox-objs := mailbox.o obj-$(CONFIG_ARM_SCMI_TRANSPORT_MAILBOX) += scmi_transport_mailbox.o scmi_transport_optee-objs := optee.o obj-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += scmi_transport_optee.o +scmi_transport_pcc-objs := pcc.o +obj-$(CONFIG_ARM_SCMI_TRANSPORT_PCC) += scmi_transport_pcc.o scmi_transport_virtio-objs := virtio.o obj-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += scmi_transport_virtio.o
drivers/firmware/arm_scmi/transports/pcc.c new file +791 -0
791 lines not on this page · raw message
include/linux/scmi_protocol.h +1 -0
@@ -930,6 +930,7 @@ enum scmi_std_protocol {SCMI_PROTOCOL_VOLTAGE =0x17 ,SCMI_PROTOCOL_POWERCAP =0x18 ,SCMI_PROTOCOL_PINCTRL =0x19 , + SCMI_PROTOCOL_TELEMETRY = 0x1B, }; enum scmi_system_events {
Signature · 1 line
2.43.0
Re: [PATCH v3 7/9] firmware: arm_scmi: Add ACPI PCC transport
Quoted 12 lines · On Thu, 13 Aug 2026 12:33:02 +0100 Sudeep Holla <[email protected]> wrote:
Introduce a new SCMI transport that uses ACPI PCCT (PCC) subspaces via the Linux PCC mailbox layer. Parse ACPI
_DSDdata to map protocol associations to PCC transport UIDs. Support common and protocol-exclusive A2P channels, plus optional common or protocol-exclusive P2A channels for notifications.Key points:
- newCONFIG_ARM_SCMI_TRANSPORT_PCCoption
- integration with SCMI core viascmi_descand transport ops
- response and notification fetch from PCC shared memory
- ACPI device matching and registration via the ACPI transport macro
Quoted 3 lines
This enables SCMI to be exercised over PCC on ACPI platforms.
Signed-off-by Sudeep Holla <[email protected]>
Hi Sudeep
This is quite dense and ACPI parsing code is always 'interesting' Anyhow some comments inline
Jonathan
Quoted 13 lines
--- drivers/firmware/arm_scmi/common.h | 11 + drivers/firmware/arm_scmi/transports/Kconfig | 13 + drivers/firmware/arm_scmi/transports/Makefile | 2 + drivers/firmware/arm_scmi/transports/pcc.c | 791 ++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 1 + 5 files changed, 818 insertions(+)drivers/firmware/arm_scmi/common.h +0
-0
drivers/firmware/arm_scmi/common.h struct scmi_transport_core_operations { · line 477
Quoted 10 lines
drivers/firmware/arm_scmi/common.h +7
-0@@ -468,6 +468,17 @@ struct scmi_transport_core_operations {const struct scmi_message_operations *msg; }; +struct scmi_dsd_info { +u32 protocol_id; +const char *const property_name; +}; + +static const struct scmi_dsd_info scmi_dsd_info_list[]__maybe_unused = { + {SCMI_PROTOCOL_BASE ,"arm-arml0001-transport-pcc" },
For symmetry needs a space before }
drivers/firmware/arm_scmi/common.h struct scmi_transport_core_operations { · line 479
Quoted 2 lines
drivers/firmware/arm_scmi/common.h +2
-0+ { SCMI_PROTOCOL_POWERCAP, "arm-arml0001-protocol-pcap"}, + { SCMI_PROTOCOL_TELEMETRY, "arm-arml0001-protocol-telemetry"},
I guess it is trivial but I'd have been tempted to add the transport first then follow up with the new protocol as a separate patch.
Quoted 10 lines
drivers/firmware/arm_scmi/common.h +2
-0+}; +/** * struct scmi_transport_handle - Transport instance handle * @supplier_get: A helper to retrieve the device descriptor, identifying the drivers/firmware/arm_scmi/transports/Kconfig +0
-0
drivers/firmware/arm_scmi/transports/Kconfig config ARM_SCMI_TRANSPORT_OPTEE · line 84
Quoted 8 lines
drivers/firmware/arm_scmi/transports/Kconfig +5
-0@@ -77,6 +77,19 @@ config ARM_SCMI_TRANSPORT_OPTEE This driver can also be built as a module. If so, the module will be called scmi_transport_optee. +config ARM_SCMI_TRANSPORT_PCC + tristate "SCMI transport based on ACPI PCC" + depends on PCC + select ARM_SCMI_HAVE_TRANSPORT + default y
We almost never do default y except when papering over new symbols for things
that were always built before. Why is it appropriate here?
Quoted 12 lines
drivers/firmware/arm_scmi/transports/Kconfig +7
-0+ help + Enable ACPI PCC mailbox based transport for SCMI. + + If you want the ARM SCMI PROTOCOL stack to include support for a + transport based on mailboxes, answer Y. + This driver can also be built as a module. If so, the module + will be called scmi_transport_pcc.drivers/firmware/arm_scmi/transports/pcc.c new file +0
-0
drivers/firmware/arm_scmi/transports/pcc.c line 47
Quoted 9 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +8
-0+/* +* SCMI specification requires all parameters, message headers, return +* arguments or any protocol data to be expressed in little endian +* format only. +*/ +struct pcc_shared_mem { +struct acpi_pcct_ext_pcc_shared_memory header; +u8 msg_payload[];
Can we do __counted_by header.length?
I'm not sure if that works or not.
Quoted 1 line
+};
...
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ +static int +acpi_scmi_dsd_parse_transport_package (struct pcc_transport_map *map, +const union acpi_object *obj) +{ +const union acpi_object *elems; +u32 revision, pkg_cnt; +unsigned int common_a2p =0 , common_p2a =0 ; +int idx; +
drivers/firmware/arm_scmi/transports/pcc.c line 190
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count <2 || +acpi_scmi_pkg_u32 (obj,0 , &revision) || +acpi_scmi_pkg_u32 (obj,1 , &pkg_cnt)) +return -EINVAL ; +if (revision !=SCMI_TRANSPORT_PACKAGE_MAX_VERSION ) +return -EINVAL ; +if (obj->package.count != pkg_cnt +2 ) +return -EINVAL ; + +for (idx =0 ; idx < pkg_cnt; idx++) {
for (int idx = 0; ...
Quoted 34 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +34
-0+union acpi_object *pack = &obj->package.elements[idx +2 ]; +struct pcc_transport *p, *tmp; +u32 pcc_ss_id, uid; +u64 flags; + + elems =acpi_scmi_pkg_elements (pack,3 ); +if (!elems) { +pr_info ("Invalid transport properties pkg %d\n" , idx); +return -EINVAL ; + } +if (acpi_scmi_pkg_u32 (pack,0 , &pcc_ss_id) || +acpi_scmi_pkg_u32 (pack,1 , &uid) || +acpi_scmi_pkg_u64 (pack,2 , &flags)) +return -EINVAL ; +if (flags & ~SCMI_TRANSPORT_FLAGS_MASK ) +return -EINVAL ; + +hash_for_each_possible (map->table, tmp, hnode, uid) { +if (tmp->uid == uid) { +pr_info ("Duplicate UID %d\n" , uid); +return -EEXIST ; + } + } + + p =kzalloc (sizeof (*p),GFP_KERNEL ); +if (!p) +return -ENOMEM ; + + p->uid = uid; + p->pcc_ss_id = pcc_ss_id; + p->flags = flags; +if (p->flags &SCMI_TRANSPORT_SHARED_CHANNEL ) { + p->protocol_id =SCMI_PROTOCOL_BASE ; +if (p->flags &SCMI_TRANSPORT_P2A_CHANNEL )
drivers/firmware/arm_scmi/transports/pcc.c line 234
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ common_p2a++; + else + common_a2p++; + } + +hash_add (map->table, &p->hnode, uid); + } + +if (common_a2p !=1 || common_p2a >1 ) +return -EINVAL ;
If you are just going to fail on larger counts, why not do it earlier as you do in some of the other similar functions when a repeat is seen? If they need to be in the hash table anyway add a comment.
Quoted 4 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +4
-0+ +return 0 ; +} +
drivers/firmware/arm_scmi/transports/pcc.c line 248
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+static int +acpi_scmi_dsd_parse_protocol_subpackage (struct pcc_transport_map *map, +const union acpi_object *obj, +int prot_id) +{ +bool found, tx_found = false, rx_found = false; +u32 uid; +int idx, ret =0 ; +struct pcc_transport *p; +unsigned int pkg_cnt = obj->package.count;
Not sure if you've standardized on an ordering I can't spot for declarations. If not pick one for the whole file.
drivers/firmware/arm_scmi/transports/pcc.c line 251
Quoted 3 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +3
-0+ +if (pkg_cnt >2 ) { +pr_warn ("Only 2 channels: one Tx and one Rx needed\n" );
Not sure that's helpful. "%u channels found, only 2 needed ...
drivers/firmware/arm_scmi/transports/pcc.c line 134
Quoted 3 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +3
-0+return -EINVAL ; + } +
for (u32 idx = 0; ...
drivers/firmware/arm_scmi/transports/pcc.c line 259
Quoted 5 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +5
-0+for (idx =0 ; idx < pkg_cnt; idx++) { +union acpi_object *pack = &obj->package.elements[idx]; +u64 flags; + + if (!acpi_scmi_pkg_elements(pack, 2) ||
figure out how to avoid those magic 2s.
Quoted 26 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +26
-0+acpi_scmi_pkg_u32 (pack,0 , &uid) || + acpi_scmi_pkg_u64(pack, 1, &flags)) + return -EINVAL; +if (flags) +return -EINVAL ; + + found = false; +hash_for_each_possible (map->table, p, hnode, uid) { +if (p->uid != uid) +continue ; + + found = true; +if (p->flags &SCMI_TRANSPORT_SHARED_CHANNEL ) { +pr_info ("Invalid! %d channel is shared\n" , + p->pcc_ss_id); + ret = -EINVAL ; +break ; + } +if (p->protocol_id && p->protocol_id != prot_id) +return -EINVAL ; + +if (p->flags &SCMI_TRANSPORT_P2A_CHANNEL ) { +if (rx_found) +return -EINVAL ; + rx_found = true; + }else {
drivers/firmware/arm_scmi/transports/pcc.c line 295
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+if (tx_found) +return -EINVAL ; + tx_found = true; + } + p->protocol_id = prot_id; +break ; + } + +if (ret) +return ret;
Might as well return above. You do in some paths already.
drivers/firmware/arm_scmi/transports/pcc.c line 300
Quoted 5 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +5
-0+if (!found) +return -ENOENT ; + } + +return ret;
Can you get here with ret != 0?
return 0 probably as this is the normal exit path.
Quoted 16 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +16
-0+} + +static int +acpi_scmi_dsd_parse_protocol_package (struct pcc_transport_map *map, +const union acpi_object *obj,int prot_id) +{ +const union acpi_object *elems; +const union acpi_object *pack; +u32 revision; +int ret; + + elems =acpi_scmi_pkg_elements (obj,3 ); +if (!elems ||acpi_scmi_pkg_u32 (obj,0 , &revision)) +return -EINVAL ; + + pack = &elems[1 ];
drivers/firmware/arm_scmi/transports/pcc.c line 326
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ +if (revision !=SCMI_PROTOCOL_PACKAGE_MAX_VERSION ) +return -EINVAL ; + +if (pack->type !=ACPI_TYPE_PACKAGE ) { +pr_info ("Invalid protocol transport package\n" ); +return -EINVAL ; + } + +/* Empty protocol specific transport package allowed */
For a statement like that I'd kind of expect a spec reference.
Quoted 47 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +46
-0+if (pack->package.count !=0 ) { + ret =acpi_scmi_dsd_parse_protocol_subpackage (map, pack, prot_id); +if (ret) +return ret; + } + + pack = &elems[2 ]; +if (pack->type !=ACPI_TYPE_PACKAGE ) { +pr_info ("Invalid protocol transport association package\n" ); +return -EINVAL ; + } + +if (pack->package.count !=0 ) { +pr_info ("Non-empty association package not supported\n" ); +return -EINVAL ; + } + +return 0 ; +} + +static int acpi_scmi_parse_properties (struct pcc_transport_map *map, +const union acpi_object *properties) +{ +bool transport_found = false; +int i; + +if (properties->type !=ACPI_TYPE_PACKAGE ) +return -EINVAL ; + +for (i =0 ; i < properties->package.count; i++) { +const union acpi_object *v; +const char *name; +int prot_id, ret; + + ret =acpi_scmi_property (properties, i, &name, &v); +if (ret) +return ret; + + prot_id =acpi_scmi_lookup_protocol_id (name); +if (prot_id <0 ) +continue ; +if (prot_id !=SCMI_PROTOCOL_BASE ) +continue ; +if (v->type !=ACPI_TYPE_PACKAGE ) +return -EINVAL ; +if (transport_found)
drivers/firmware/arm_scmi/transports/pcc.c line 398
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+return -EEXIST ; + + ret =acpi_scmi_dsd_parse_transport_package (map, v); +if (ret) +return ret; + transport_found = true; + } + +if (!transport_found) +return -ENOENT ;
This double loop needs a few more comments. Why do we need to handle the base protocol completely first?
Maybe can factor it out to a helper that takes bool unique, bool base? then we just get 2 calls to that.
Quoted 23 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +22
-0+ +for (i =0 ; i < properties->package.count; i++) { +const union acpi_object *v; +const char *name; +int prot_id, ret; + + ret =acpi_scmi_property (properties, i, &name, &v); +if (ret) +return ret; + + prot_id =acpi_scmi_lookup_protocol_id (name); +if (prot_id <0 || prot_id ==SCMI_PROTOCOL_BASE ) +continue ; +if (v->type !=ACPI_TYPE_PACKAGE ) +return -EINVAL ; + + ret =acpi_scmi_dsd_parse_protocol_package (map, v, prot_id); +if (ret) +return ret; + } + +return 0 ;
drivers/firmware/arm_scmi/transports/pcc.c line 430
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+} + +static int acpi_scmi_namespace_fwnode_parse (struct fwnode_handle *fwnode, +struct pcc_transport_map *map) +{ +struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_device *adev =to_acpi_device_node (fwnode); +union acpi_object *desc; +acpi_status status; +int i, ret = -ENOENT ;
ret is always overwritten I think.
drivers/firmware/arm_scmi/transports/pcc.c line 441
Quoted 11 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +11
-0+ +if (!adev->handle) +return -EINVAL ; + + status =acpi_evaluate_object_typed (adev->handle,"_DSD" ,NULL , &buf, +ACPI_TYPE_PACKAGE ); +if (ACPI_FAILURE (status)) +return -EINVAL ; + + desc = buf.pointer; +if (desc->package.count %2 )
ret = -EINVAL; goto out_free; }
drivers/firmware/arm_scmi/transports/pcc.c line 445
Quoted 4 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +4
-0+ goto out_free_inval; + +/* Look for the device properties GUID. */ +for (i =0 ; i < desc->package.count; i +=2 ) {
for (int i = 0; i < ...
acceptable in kernel these days and keeps scope tight. Any way to justify that 2 as sizeof of something? If not maybe a define is appropriate.
(applies above as well.)
Quoted 11 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +11
-0+const union acpi_object *guid; +const union acpi_object *properties; + + guid = &desc->package.elements[i]; + properties = &desc->package.elements[i +1 ]; + +/* +* The first element must be a GUID and the second one must be +* a package. +*/ + if (guid->type != ACPI_TYPE_BUFFER ||
drivers/firmware/arm_scmi/transports/pcc.c line 466
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ guid->buffer.length !=UUID_SIZE || + properties->type != ACPI_TYPE_PACKAGE) + continue; + +if (!guid_equal ((guid_t *)guid->buffer.pointer, + &acpi_scmi_uuid)) +continue ; + + ret =acpi_scmi_parse_properties (map, properties); + goto out_free;
break maybe if this doesn't get more complex in later
patches.
drivers/firmware/arm_scmi/transports/pcc.c line 474
Quoted 8 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +8
-0+ } + +out_free: +ACPI_FREE (buf.pointer); +return ret; +out_free_inval: + ret = -EINVAL ; + goto out_free;
Two different error paths and one that folds back is not a nice to read code structure. Particularly as second one only sets a return value. Just set that at the callers.
Quoted 23 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +21
-0+} +static +struct pcc_transport_map *pcc_transport_map_get (struct fwnode_handle *fwnode) +{ +struct pcc_transport_map *map; +int ret; + + map =pcc_transport_map_find (fwnode); +if (map) +return map; + + map =kzalloc_obj (*map,GFP_KERNEL ); +if (!map) +return ERR_PTR (-ENOMEM ); + +hash_init (map->table); + ret =acpi_scmi_namespace_fwnode_parse (fwnode, map); +if (ret) + goto err_free_map; + + ret =pcc_transport_map_validate (map);
drivers/firmware/arm_scmi/transports/pcc.c line 549
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+if (ret) + goto err_free_map; + + map->fwnode =fwnode_handle_get (fwnode); +list_add_tail (&map->node, &pcc_transport_maps); + +return map; + +err_free_map: +acpi_scmi_destroy_transport_map (map);
Personally I'd prefer seeing each step being unwound only when necessary. So break it out here as as series of labels.
Quoted 19 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +19
-0+return ERR_PTR (ret); +} + +static int pcc_lookup_ss_id (struct pcc_transport_map *map,u32 prot_id,bool tx) +{ +struct pcc_transport *p; +int idx; + +hash_for_each (map->table, idx, p, hnode) { +if (p->protocol_id != prot_id) +continue ; + +if ((!tx && (p->flags &SCMI_TRANSPORT_P2A_CHANNEL )) || + (tx && !(p->flags &SCMI_TRANSPORT_P2A_CHANNEL ))) +return p->pcc_ss_id; + } + +return -ENOENT ; +}
drivers/firmware/arm_scmi/transports/pcc.c line 578
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ +static int pcc_get_ss_id (struct fwnode_handle *fwnode,u32 prot_id,bool tx) +{ +struct pcc_transport_map *map; +int ret; + +if (!fwnode) +return -EINVAL ; + +mutex_lock (&pcc_transport_maps_lock);
guard(mutex)(&pcc_transport_maps_lock);
drivers/firmware/arm_scmi/transports/pcc.c line 581
Quoted 3 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +3
-0+ map =pcc_transport_map_get (fwnode); +if (IS_ERR (map)) + ret =PTR_ERR (map);
return PTR_ERR(map) return pcc_lookup_ss_id(map, prot_id, tx);
Quoted 4 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +4
-0+else + ret =pcc_lookup_ss_id (map, prot_id, tx); +mutex_unlock (&pcc_transport_maps_lock); +
drivers/firmware/arm_scmi/transports/pcc.c line 687
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +9
-0+return ret; +} + +static int pcc_chan_free (int id,void *p,void *data) +{ +struct scmi_chan_info *cinfo = p; +struct scmi_pcc *smbox = cinfo->transport_info; + +if (smbox && !IS_ERR (smbox->pchan)) {
Maybe an early exit is neater?
if (!smbox || IS_ERR(smbox->pchan) return 0;
Quoted 11 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+pcc_mbox_free_channel (smbox->pchan); + cinfo->transport_info =NULL ; + smbox->pchan =NULL ; + smbox->cinfo =NULL ; + } + +return 0 ; +} +static void pcc_fetch_response (struct scmi_chan_info *cinfo, +struct scmi_xfer *xfer)
drivers/firmware/arm_scmi/transports/pcc.c line 729
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+{ +struct scmi_pcc *smbox = cinfo->transport_info; +struct pcc_shared_mem __iomem *shmem = smbox->pchan->shmem; +size_t len =ioread32 (&shmem->header.length); + + xfer->hdr.status =ioread32 (shmem->msg_payload); +/* Skip the length of header and status in shmem area i.e 8 bytes */ + xfer->rx.len =min_t (size_t, xfer->rx.len, len >8 ? len -8 :0 ); + +/* Take a copy to the rx buffer.. */
As below - that bit is obvious.
drivers/firmware/arm_scmi/transports/pcc.c line 730
Quoted 1 line
drivers/firmware/arm_scmi/transports/pcc.c new file +1
-0+memcpy_fromio (xfer->rx.buf, shmem->msg_payload +4 , xfer->rx.len);
So you compute the length skipping 8 but then copy 4 in. That needs an explanatory comment if correct.
drivers/firmware/arm_scmi/transports/pcc.c line 740
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+} + +static void pcc_fetch_notification (struct scmi_chan_info *cinfo,size_t max_len, +struct scmi_xfer *xfer) +{ +struct scmi_pcc *smbox = cinfo->transport_info; +struct pcc_shared_mem __iomem *shmem = smbox->pchan->shmem; +size_t len =ioread32 (&shmem->header.length); + +/* Skip only the length of header in shmem area i.e 4 bytes */
Ideally get that header size from a define rather than magic 4.
drivers/firmware/arm_scmi/transports/pcc.c line 741
Quoted 1 line
drivers/firmware/arm_scmi/transports/pcc.c new file +1
-0+ xfer->rx.len =min_t (size_t, max_len, len >4 ? len -4 :0 );
min() preferred unless we are hitting one of the weird corner cases (don't think so)
drivers/firmware/arm_scmi/transports/pcc.c
Quoted 2 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +2
-0+ +/* Take a copy to the rx buffer.. */
Kind of obvious - maybe say why if that is useful, or drop the comment.
Quoted 5 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +5
-0+memcpy_fromio (xfer->rx.buf, shmem->msg_payload, xfer->rx.len); +} + +static const struct scmi_transport_ops scmi_pcc_ops = { + .chan_available = pcc_chan_available,
drivers/firmware/arm_scmi/transports/pcc.c line 758
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+ .chan_setup = pcc_chan_setup, + .chan_free = pcc_chan_free, + .send_message = pcc_send_message, + .fetch_response = pcc_fetch_response, + .fetch_notification = pcc_fetch_notification, +}; + +static struct scmi_desc scmi_pcc_desc = { + .ops = &scmi_pcc_ops, + .max_rx_timeout_ms =30 ,/* We may increase this if required */
That's always true - so what does the comment bring us?
drivers/firmware/arm_scmi/transports/pcc.c line 759
Quoted 1 line
drivers/firmware/arm_scmi/transports/pcc.c new file +1
-0+ .max_msg = 20, /* Limited by MBOX_TX_QUEUE_LEN */
If this is relevant to this driver, why can't see see it via a suitable header? Feels to me like this is in the wrong place or needs a query interface.
drivers/firmware/arm_scmi/transports/pcc.c line 764
Quoted 5 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +5
-0+ .max_msg_size = SCMI_SHMEM_MAX_PAYLOAD_SIZE - 12, +}; + +static const struct acpi_device_id scmi_acpi_ids[] = { + {"ARML0001" ,0 },
Uwe is driving an effort to make these all named initializers.
+ Don't set anything you don't use as it makes refactors a pain. Uwe has also been deleting those throughout the kernel!
Quoted 8 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +8
-0+ { } +}; + +MODULE_DEVICE_TABLE (acpi, scmi_acpi_ids); + +DEFINE_SCMI_ACPI_TRANSPORT_DRIVER (scmi_pcc, scmi_pcc_driver, + scmi_pcc_desc, scmi_acpi_ids, core); +
drivers/firmware/arm_scmi/transports/pcc.c line 782
Quoted 10 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +10
-0+static int __init scmi_pcc_init (void ) +{ +return platform_driver_register (&scmi_pcc_driver); +} + +static void __exit scmi_pcc_exit(void) +{ +platform_driver_unregister (&scmi_pcc_driver); + +mutex_lock (&pcc_transport_maps_lock);
I'd move the locking into acpi_scmi_clear_transport_maps()
I'm not immediately understanding why, when all setup in this driver is associated with the registered driver, this bit of tear down can't be done as part of the driver remove.
Quoted 22 lines
drivers/firmware/arm_scmi/transports/pcc.c new file +9
-0+acpi_scmi_clear_transport_maps (); +mutex_unlock (&pcc_transport_maps_lock); +} +module_init (scmi_pcc_init); +module_exit (scmi_pcc_exit); + +MODULE_AUTHOR ("Sudeep Holla <[email protected]>" ); +MODULE_DESCRIPTION ("SCMI ACPI PCC Transport driver" ); +MODULE_LICENSE ("GPL" );include/linux/scmi_protocol.h +1
-0@@ -930,6 +930,7 @@ enum scmi_std_protocol {SCMI_PROTOCOL_VOLTAGE =0x17 ,SCMI_PROTOCOL_POWERCAP =0x18 ,SCMI_PROTOCOL_PINCTRL =0x19 , + SCMI_PROTOCOL_TELEMETRY = 0x1B, }; enum scmi_system_events {
Sudeep Holla
maintainerRe: [PATCH v3 7/9] firmware: arm_scmi: Add ACPI PCC transport
Quoted 15 lines · Jonathan Cameron
Quoted 12 lines · On Thu, 13 Aug 2026 12:33:02 +0100 Sudeep Holla <[email protected]> wrote:
Introduce a new SCMI transport that uses ACPI PCCT (PCC) subspaces via the Linux PCC mailbox layer. Parse ACPI
_DSDdata to map protocol associations to PCC transport UIDs. Support common and protocol-exclusive A2P channels, plus optional common or protocol-exclusive P2A channels for notifications.Key points:
- newCONFIG_ARM_SCMI_TRANSPORT_PCCoption
- integration with SCMI core viascmi_descand transport ops
- response and notification fetch from PCC shared memory
- ACPI device matching and registration via the ACPI transport macro
Quoted 8 lines
Quoted 3 lines
This enables SCMI to be exercised over PCC on ACPI platforms.
Signed-off-by Sudeep Holla <[email protected]>Hi Sudeep
This is quite dense and ACPI parsing code is always 'interesting' Anyhow some comments inline
Indeed quite dense to even parse the comments. It could be my brain which is still recovering from the flu, but I can't respond to them inline. I think I have taken most of the suggestions(saying most as I might have missed unintentionally). I might have gone overboard with some macros to eliminate random magic offsets. I will post v4 soon.
Thanks again for all the review comments. I am still debating if I need to break this into 2 patches(technically yes, motivationally not yet 😄)
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v3 8/9 firmware: arm_scmi: Initialise known ACPI protocol devices and channels
In reply to Sudeep HollaUnlike Device Tree, the ACPI SCMI namespace device does not provide child fwnodes to represent each protocol. Iterate over the non-BASE entries in scmi_dsd_info_list to initialize their protocol devices and transport channels. The BASE channel and device are handled by the common setup path.
Let the transport channel-availability and SCMI protocol implementation checks decide which of the known protocols are usable on the platform.
--- drivers/firmware/arm_scmi/driver.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/firmware/arm_scmi/driver.c +33 -4
@@ -2873,7 +2873,7 @@ scmi_txrx_setup(struct scmi_info *info, struct fwnode_handle *fwnode,*/ static int scmi_channels_setup (struct scmi_info *info) { -int ret; +int ret, idx;struct fwnode_handle *fwnode =dev_fwnode (info->dev);/* Initialize a common generic channel at first */
@@ -2898,6 +2898,20 @@ static int scmi_channels_setup(struct scmi_info *info)return ret; } +if (!is_acpi_node (fwnode)) +return 0 ; + +for (idx =0 ; idx <ARRAY_SIZE (scmi_dsd_info_list); idx++) { +int prot_id = scmi_dsd_info_list[idx].protocol_id; + +if (prot_id ==SCMI_PROTOCOL_BASE ) +continue ; + + ret =scmi_txrx_setup (info, fwnode, prot_id); +if (ret) +return ret; + } +return 0 ; }
@@ -3245,7 +3259,7 @@ static void scmi_enable_matching_quirks(struct scmi_info *info) }static void scmi_device_check_create (struct fwnode_handle *fwnode,int prot_id, -struct scmi_info *info) +struct scmi_info *info,bool report_missing) {int ret;struct device *dev = info->dev;
@@ -3257,6 +3271,9 @@ static void scmi_device_check_create(struct fwnode_handle *fwnode, int prot_id, }if (!scmi_is_protocol_implemented (handle, prot_id)) { +if (!report_missing) +return ; +dev_err (dev,"SCMI protocol %d not implemented\n" , prot_id);return ;
@@ -3280,7 +3297,7 @@ static void scmi_device_check_create(struct fwnode_handle *fwnode, int prot_id,static int scmi_probe (struct platform_device *pdev) { -int ret; +int ret, idx;char *err_str ="probe failure\n" ;struct scmi_handle *handle;const struct scmi_desc *desc;
@@ -3406,7 +3423,19 @@ static int scmi_probe(struct platform_device *pdev)if (fwnode_property_read_u32 (child,"reg" , &prot_id))continue ; -scmi_device_check_create (child, prot_id, info); +scmi_device_check_create (child, prot_id, info, true); + } + +if (!is_acpi_node (dev_fwnode (dev))) +return 0 ; + +for (idx =0 ; idx <ARRAY_SIZE (scmi_dsd_info_list); idx++) { +int prot_id = scmi_dsd_info_list[idx].protocol_id; + +if (prot_id ==SCMI_PROTOCOL_BASE ) +continue ; + +scmi_device_check_create (dev_fwnode (dev), prot_id, info, false); }return 0 ;
Signature · 1 line
2.43.0
Re: [PATCH v3 8/9] firmware: arm_scmi: Initialise known ACPI protocol devices and channels
Quoted 10 lines · On Thu, 13 Aug 2026 12:33:03 +0100 Sudeep Holla <[email protected]> wrote:
Unlike Device Tree, the ACPI SCMI namespace device does not provide child fwnodes to represent each protocol. Iterate over the non-BASE entries in
scmi_dsd_info_listto initialize their protocol devices and transport channels. The BASE channel and device are handled by the common setup path.Let the transport channel-availability and SCMI protocol implementation checks decide which of the known protocols are usable on the platform.
Signed-off-by Sudeep Holla <[email protected]>
Sudeep Holla
maintainerPATCH v3 9/9 firmware: arm_scmi: Validate PCC shared memory signature
In reply to Sudeep HollaValidate the PCC shared memory signature when setting up an SCMI PCC channel.
Reject channels whose shared memory signature does not encode PCC_SIGNATURE combined with the PCC subspace ID, so misconfigured firmware is caught before the transport starts using the shared memory region.
--- drivers/firmware/arm_scmi/transports/pcc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/firmware/arm_scmi/transports/pcc.c +10 -2
@@ -623,8 +623,11 @@ static void rx_callback(struct mbox_client *cl, void *m) }static int pcc_chan_validate_shmem (struct scmi_chan_info *cinfo, -struct scmi_pcc *smbox) +struct scmi_pcc *smbox,int ss_id) { +struct pcc_shared_mem __iomem *shmem = smbox->pchan->shmem; +u32 valid_signature = ss_id +PCC_SIGNATURE ; +if (smbox->pchan->shmem_size <SCMI_PCC_SHMEM_OVERHEAD || smbox->pchan->shmem_size -SCMI_PCC_SHMEM_OVERHEAD < cinfo->max_msg_size) {
@@ -632,6 +635,11 @@ static int pcc_chan_validate_shmem(struct scmi_chan_info *cinfo,return -ENOSPC ; } +if (ioread32 (&shmem->header.signature) != valid_signature) { +dev_err (cinfo->dev,"invalid PCC shared memory signature\n" ); +return -EINVAL ; + } +return 0 ; }
@@ -667,7 +675,7 @@ static int pcc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,return ret; } - ret =pcc_chan_validate_shmem (cinfo, smbox); + ret =pcc_chan_validate_shmem (cinfo, smbox, ss_id);if (ret) {pcc_mbox_free_channel (smbox->pchan);return ret;
Signature · 1 line
2.43.0
Re: [PATCH v3 9/9] firmware: arm_scmi: Validate PCC shared memory signature
Quoted 9 lines · On Thu, 13 Aug 2026 12:33:04 +0100 Sudeep Holla <[email protected]> wrote:
Validate the PCC shared memory signature when setting up an SCMI PCC channel.
Reject channels whose shared memory signature does not encode
PCC_SIGNATUREcombined with the PCC subspace ID, so misconfigured firmware is caught before the transport starts using the shared memory region.Signed-off-by Sudeep Holla <[email protected]>
Interesting there aren't more checks on this in the various PCC users. Question for another day perhaps.
Seems correct to me.
Quoted 43 lines
--- drivers/firmware/arm_scmi/transports/pcc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)drivers/firmware/arm_scmi/transports/pcc.c +10
-2@@ -623,8 +623,11 @@ static void rx_callback(struct mbox_client *cl, void *m) }static int pcc_chan_validate_shmem (struct scmi_chan_info *cinfo, -struct scmi_pcc *smbox) +struct scmi_pcc *smbox,int ss_id) { +struct pcc_shared_mem __iomem *shmem = smbox->pchan->shmem; +u32 valid_signature = ss_id +PCC_SIGNATURE ; +if (smbox->pchan->shmem_size <SCMI_PCC_SHMEM_OVERHEAD || smbox->pchan->shmem_size -SCMI_PCC_SHMEM_OVERHEAD < cinfo->max_msg_size) {@@ -632,6 +635,11 @@ static int pcc_chan_validate_shmem(struct scmi_chan_info *cinfo,return -ENOSPC ; } +if (ioread32 (&shmem->header.signature) != valid_signature) { +dev_err (cinfo->dev,"invalid PCC shared memory signature\n" ); +return -EINVAL ; + } +return 0 ; }@@ -667,7 +675,7 @@ static int pcc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,return ret; } - ret =pcc_chan_validate_shmem (cinfo, smbox); + ret =pcc_chan_validate_shmem (cinfo, smbox, ss_id);if (ret) {pcc_mbox_free_channel (smbox->pchan);return ret;
Sudeep Holla
maintainerRe: [PATCH v3 9/9] firmware: arm_scmi: Validate PCC shared memory signature
Quoted 6 lines · Jonathan Cameron
Quoted 3 lines · On Thu, 13 Aug 2026 12:33:04 +0100 Sudeep Holla <[email protected]> wrote:
Validate the PCC shared memory signature when setting up an SCMI PCC channel.
Quoted 9 lines
Quoted 6 lines
Reject channels whose shared memory signature does not encode
PCC_SIGNATUREcombined with the PCC subspace ID, so misconfigured firmware is caught before the transport starts using the shared memory region.Signed-off-by Sudeep Holla <[email protected]>Interesting there aren't more checks on this in the various PCC users. Question for another day perhaps.
Tried cleaning up all but some platforms like Hisilicon kunpeng complained it will break their platforms. So added a warning in the core but I want to enforce stricter check here for SCMI PCC.
Quoted 4 lines
Seems correct to me.
Reviewed-by Jonathan Cameron <[email protected]>
Thanks!
Signature · 2 lines
Regards, Sudeep
Re: [PATCH v3 9/9] firmware: arm_scmi: Validate PCC shared memory signature
Quoted 12 lines · On Wed, 2 Sep 2026 09:25:19 +0100 Sudeep Holla <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 8 lines · On Thu, 13 Aug 2026 12:33:04 +0100 Sudeep Holla <[email protected]> wrote:
Validate the PCC shared memory signature when setting up an SCMI PCC channel.
Reject channels whose shared memory signature does not encode
PCC_SIGNATUREcombined with the PCC subspace ID, so misconfigured firmware is caught before the transport starts using the shared memory region.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sudeep Holla <[email protected]>Interesting there aren't more checks on this in the various PCC users. Question for another day perhaps.
Tried cleaning up all but some platforms like Hisilicon kunpeng complained it will break their platforms. So added a warning in the core but I want to enforce stricter check here for SCMI PCC.
Fair enough. I'd be tempted to check in core and add a quirks list for those broken platforms but meh, not my problem ;)
Quoted 8 lines
Quoted 5 lines
Seems correct to me.
Reviewed-by Jonathan Cameron <[email protected]>Thanks!
Sudeep Holla
maintainerRe: [PATCH v3 9/9] firmware: arm_scmi: Validate PCC shared memory signature
Quoted 20 lines · Jonathan Cameron
Quoted 17 lines · On Wed, 2 Sep 2026 09:25:19 +0100 Sudeep Holla <[email protected]> wrote:
Quoted 15 lines · Jonathan Cameron
Quoted 9 lines · On Thu, 13 Aug 2026 12:33:04 +0100 Sudeep Holla <[email protected]> wrote:
Validate the PCC shared memory signature when setting up an SCMI PCC channel.
Reject channels whose shared memory signature does not encode
PCC_SIGNATUREcombined with the PCC subspace ID, so misconfigured firmware is caught before the transport starts using the shared memory region.Signed-off-by Sudeep Holla <[email protected]>Interesting there aren't more checks on this in the various PCC users. Question for another day perhaps.
Quoted 7 lines
Quoted 3 lines
Tried cleaning up all but some platforms like Hisilicon kunpeng complained it will break their platforms. So added a warning in the core but I want to enforce stricter check here for SCMI PCC.
Fair enough. I'd be tempted to check in core and add a quirks list for those broken platforms but meh, not my problem ;)
Yes that is a possibility. One step at a time, lets keep warning for some time and then handle broken systems as quirks. The warning is already in place.
Signature · 2 lines
Regards, Sudeep