firmware: arm_scmi: Refactoring and enablement of ACPI PCC transport
Sudeep Holla
maintainerv5 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 v5:
- Make DT child-node enumeration and ACPI known-protocol enumeration mutually exclusive, preventing duplicate protocol device and channel initialization when an incorrect ACPI SCMI device has child nodes. (Reported by sashiko)
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- Fixed generated platform-device fwnode ownership using the platform-device OF/fwnode helpers.
- Dropped the PCC transport’s default y and clarified its Kconfig help.
- Treated ACPI package integers as 64-bit values and validated PCCT indices before narrowing.
- Reworked PCC parsing with named package indices.
- Made cached PCC transport maps device-managed and protected map cleanup with scoped locking.
- Replaced hard-coded framing and queue limits with symbolic constants.
- Simplified fwnode iteration and made cleanup-helper acquisition and release visibly colocated.
- Link to v3: https://patch.msgid.link/[email protected]
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 generated device fwnode with platform helpers
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 transport chan_available()
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 | 39 +- drivers/firmware/arm_scmi/driver.c | 222 ++++--- drivers/firmware/arm_scmi/transports/Kconfig | 12 + 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 | 875 +++++++++++++++++++++++++ drivers/firmware/arm_scmi/transports/smc.c | 10 +- drivers/firmware/arm_scmi/transports/virtio.c | 3 +- include/linux/scmi_protocol.h | 1 + 11 files changed, 1099 insertions(+), 116 deletions(-)
---
base-commit: fd73f4a6659897191fa0d40695fe370925dd3780
change-id: 20251017-acpi_scmi_pcc-e44e1233eae3
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v5 1/9 firmware: arm_scmi: Set generated device fwnode with platform helpers
The SCMI transport probe helper creates a platform device for the SCMI core. device_set_of_node_from_dev() propagates the supplier's OF node, but leaves generated devices for non-DT transports without a firmware node.
Use platform_device_set_of_node_from_dev() for devicetree suppliers so the shared OF node is referenced and marked as reused. For all other suppliers, use platform_device_set_fwnode() so ACPI and other firmware nodes are propagated with a reference that platform_device_release() can balance.
--- drivers/firmware/arm_scmi/common.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/arm_scmi/common.h +4 -1
@@ -649,7 +649,10 @@ static int __tag##_probe(struct platform_device *pdev) \ goto err_mem; \ } \ \ -device_set_of_node_from_dev (&spdev->dev, dev); \ +if (dev_of_node (dev)) \ +platform_device_set_of_node_from_dev (spdev, dev); \ +else \ +platform_device_set_fwnode (spdev,dev_fwnode (dev)); \ \ strans.supplier = supplier; \memcpy (&strans.desc, &(__desc),sizeof (strans.desc)); \
Signature · 1 line
2.43.0
Sudeep Holla
maintainerPATCH v5 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; \
@@ -681,11 +683,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
Sudeep Holla
maintainerPATCH v5 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.
- 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 | 113 +++++++++++++------------ drivers/firmware/arm_scmi/transports/mailbox.c | 6 +- drivers/firmware/arm_scmi/transports/optee.c | 6 +- drivers/firmware/arm_scmi/transports/smc.c | 9 +- drivers/firmware/arm_scmi/transports/virtio.c | 2 +- 7 files changed, 99 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 +58 -55
301 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 +7 -2
@@ -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 *of_node =to_of_node (fwnode); + +if (!of_node) +return false; + struct device_node *np __free(device_node) = -of_parse_phandle (of_node,"shmem" ,0 ); +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
Sudeep Holla
maintainerPATCH v5 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
Sudeep Holla
maintainerPATCH v5 5/9 firmware: arm_scmi: Pass protocol ID to transport chan_available()
In reply to Sudeep HollaPass the protocol ID to the transport chan_available() callback so a transport can distinguish channels associated with different protocols when they share the same firmware node. This is required by the ACPI PCC transport to resolve protocol-exclusive PCC subspaces.
Update all transport implementations for the new callback signature. Existing transports ignore the protocol ID, so there is 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);
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
Sudeep Holla
maintainerPATCH v5 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 | 59 ++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 25 deletions(-)
drivers/firmware/arm_scmi/driver.c +34 -25
@@ -3244,6 +3244,39 @@ 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 ; + } + +scmi_create_protocol_devices (fwnode_handle_get (fwnode), info, prot_id, +NULL ); +} +static int scmi_probe (struct platform_device *pdev) {int ret;
@@ -3373,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 ; - } - -scmi_create_protocol_devices (fwnode_handle_get (child), info, - prot_id,NULL ); +scmi_device_check_create (child, prot_id, info); }return 0 ;
Signature · 1 line
2.43.0
Sudeep Holla
maintainerPATCH v5 7/9 firmware: arm_scmi: Add ACPI PCC transport
In reply to Sudeep HollaAdd an SCMI transport for ACPI-described systems using PCCT PCC subspaces through the Linux PCC mailbox layer.
Parse the SCMI Device Properties _DSD packages defined by Arm document 111115A v1.0, sections 2.2.1.1, 2.2.2.1 and 2.2.3. Map transport UIDs to PCC subspaces for common and protocol-exclusive A2P and P2A channels, validate the mappings, and cache them for channel setup.
Support the Powercap and System Telemetry protocol properties and add the System Telemetry protocol ID. Implement PCC channel management, message framing, shared-memory bounds validation, and response and notification delivery.
Add the corresponding Kconfig, module and ARML0001 ACPI matching plumbing.
--- drivers/firmware/arm_scmi/common.h | 11 + drivers/firmware/arm_scmi/transports/Kconfig | 12 + drivers/firmware/arm_scmi/transports/Makefile | 2 + drivers/firmware/arm_scmi/transports/pcc.c | 867 ++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 1 + 5 files changed, 893 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 +12 -0
@@ -77,6 +77,18 @@ 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 + help + This enables the ACPI PCC mailbox based transport for SCMI. + + If you want the ARM SCMI PROTOCOL stack to include support for a + transport based on ACPI PCC 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 +867 -0
867 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
Sudeep Holla
maintainerRe: [PATCH v5 7/9] firmware: arm_scmi: Add ACPI PCC transport
Quoted 48 lines · Sudeep Holla
Quoted 34 lines
Add an SCMI transport for ACPI-described systems using PCCT PCC subspaces through the Linux PCC mailbox layer.
Parse the SCMI Device Properties
_DSDpackages defined by Arm document 111115A v1.0, sections 2.2.1.1, 2.2.2.1 and 2.2.3. Map transport UIDs to PCC subspaces for common and protocol-exclusive A2P and P2A channels, validate the mappings, and cache them for channel setup.Support the Powercap and System Telemetry protocol properties and add the System Telemetry protocol ID. Implement PCC channel management, message framing, shared-memory bounds validation, and response and notification delivery.
Add the corresponding
Kconfig, module and ARML0001 ACPI matching plumbing.Signed-off-by Sudeep Holla <[email protected]>--- drivers/firmware/arm_scmi/common.h | 11 + drivers/firmware/arm_scmi/transports/Kconfig | 12 + drivers/firmware/arm_scmi/transports/Makefile | 2 + drivers/firmware/arm_scmi/transports/pcc.c | 867 ++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 1 + 5 files changed, 893 insertions(+)drivers/firmware/arm_scmi/common.h +1
-0@@ -468,6 +468,17 @@ struct scmi_transport_core_operations {const struct scmi_message_operations *msg; }; +struct scmi_dsd_info {drivers/firmware/arm_scmi/common.h struct scmi_transport_core_operations { · line 481
Quoted 10 lines
drivers/firmware/arm_scmi/common.h +10
-0+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" }, +}; +[Below is copied from [email protected] review comments Severity: High]
Quoted 6 lines
Since
scmi_dsd_info_listis defined as a static const array in a header file, won't this cause the array to be duplicated in the .rodata section of every translation unit that includescommon.h?Could this array be defined in a .c file and exported via extern to prevent unnecessary binary bloat?
Although the header gives each translation unit its own definition, unused instances are discarded by the compiler. The table is referenced only by the SCMI core and PCC transport, which are separate modules. Moving it to a C file would require exporting the table and its size between those modules. Given that each emitted table is only 48 bytes, I prefer to avoid that additional interface and keep the local copies.
Signature · 2 lines
Regards, Sudeep
Sudeep Holla
maintainerPATCH v5 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 | 66 +++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 19 deletions(-)
drivers/firmware/arm_scmi/driver.c +47 -19
@@ -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 */
@@ -2881,21 +2881,34 @@ static int scmi_channels_setup(struct scmi_info *info)if (ret)return ret; -fwnode_for_each_available_child_node_scoped (fwnode, child) { -u32 prot_id; +if (!is_acpi_node (fwnode)) { +fwnode_for_each_available_child_node_scoped (fwnode, child) { +u32 prot_id; + +if (fwnode_property_read_u32 (child,"reg" , &prot_id)) +continue ; -if (fwnode_property_read_u32 (child,"reg" , &prot_id)) -continue ; +if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { +dev_err (info->dev, +"Out of range protocol %d\n" , prot_id); +continue ; + } -if (!FIELD_FIT (MSG_PROTOCOL_ID_MASK , prot_id)) { -dev_err (info->dev, -"Out of range protocol %d\n" , prot_id); -continue ; + ret =scmi_txrx_setup (info, child, prot_id); +if (ret) +return ret; } + }else { +for (idx =0 ; idx <ARRAY_SIZE (scmi_dsd_info_list); idx++) { +int prot_id = scmi_dsd_info_list[idx].protocol_id; - ret =scmi_txrx_setup (info, child, prot_id); -if (ret) -return ret; +if (prot_id ==SCMI_PROTOCOL_BASE ) +continue ; + + ret =scmi_txrx_setup (info, fwnode, prot_id); +if (ret) +return ret; + } }return 0 ;
@@ -3245,7 +3258,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 +3270,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 ; }
@@ -3279,7 +3295,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;
@@ -3400,13 +3416,25 @@ static int scmi_probe(struct platform_device *pdev)scmi_enable_matching_quirks (info); -fwnode_for_each_available_child_node (dev_fwnode (dev), child) { -u32 prot_id; +if (!is_acpi_node (dev_fwnode (dev))) { +fwnode_for_each_available_child_node (dev_fwnode (dev), child) { +u32 prot_id; -if (fwnode_property_read_u32 (child,"reg" , &prot_id)) -continue ; +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); + } + }else { +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
Sudeep Holla
maintainerPATCH v5 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
@@ -698,8 +698,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) {
@@ -707,6 +710,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 ; }
@@ -742,7 +750,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
Quoted 5 lines · Sudeep Holla
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.
Quoted 8 lines
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.
[...]
Applied to sudeep.holla/linux (for-next/scmi/updates), thanks!
[1/9] firmware: arm_scmi: Set generated device fwnode with platform helpers
https://git.kernel.org/sudeep.holla/c/146af926951d [2/9] firmware: arm_scmi: Extend transport driver macro to support ACPI https://git.kernel.org/sudeep.holla/c/8bac2642a97a [3/9] firmware: arm_scmi: Convert OF-only paths to generic fwnode in SCMI core https://git.kernel.org/sudeep.holla/c/16276ab69678 [4/9] firmware: arm_scmi: Fall back to ACPI HID when "compatible" is absent https://git.kernel.org/sudeep.holla/c/17b3cdaa7ab4 [5/9] firmware: arm_scmi: Pass protocol ID to transport chan_available() https://git.kernel.org/sudeep.holla/c/f35ee1a26795 [6/9] firmware: arm_scmi: Refactor protocol device creation logic https://git.kernel.org/sudeep.holla/c/48339595cbd3 [7/9] firmware: arm_scmi: Add ACPI PCC transport https://git.kernel.org/sudeep.holla/c/b42e73fa118f [8/9] firmware: arm_scmi: Initialise known ACPI protocol devices and channels https://git.kernel.org/sudeep.holla/c/4f5f291a5704 [9/9] firmware: arm_scmi: Validate PCC shared memory signature https://git.kernel.org/sudeep.holla/c/60a89ec8d8f5
Signature · 2 lines
Regards, Sudeep