From: Hans de Goede <johannes.goede@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>,
Cristian Marussi <cristian.marussi@arm.com>,
Sudeep Holla <sudeep.holla@kernel.org>
Cc: Hans de Goede <johannes.goede@oss.qualcomm.com>,
Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>,
Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
Frank.Li@kernel.org, arm-scmi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, imx@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: [PATCH v5 3/3] firmware: arm_scmi: Always create devices for standard protocols
Date: Wed, 2 Sep 2026 20:08:44 +0200 [thread overview]
Message-ID: <20260902180844.41230-4-johannes.goede@oss.qualcomm.com> (raw)
In-Reply-To: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com>
Protocol driver module auto-loading requires the devices to already be
created for udev to get the necessary uevents based on which udev loads
modules. But SCMI devices are only created after their { protocol, name }
device-id has been added to the requested-devices list which is done from
scmi_driver_register().
This creates a circular dependency where device creation is waiting for
the driver to register and loading the module with the driver is waiting
for the device to be created.
Add a list of standard protocol device-ids and always create devices for
these without relying on these being added to the requested-devices list.
This removes the circular dependency, fixing module auto-loading.
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
Changes in v5:
- This is a new patch in v5 replacing "Pre-register protocol, name tupples
for standard protocol". Pre-registering requires
scmi_protocol_device_request() to allow duplicate device-ids, but then if
the first driver of two with duplicate devce-ids gets unloaded device
creation for the second driver will fail. Allowing duplicates causes all
kinds of problems, so this new approach avoids this.
---
drivers/firmware/arm_scmi/bus.c | 48 +++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 6f667e4ffeed..10d15da76f19 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -505,6 +505,34 @@ _scmi_device_create(struct device_node *np, struct device *parent,
return sdev;
}
+/* Standard protocols table */
+static const struct scmi_device_id scmi_std_id_table[] = {
+ { SCMI_PROTOCOL_POWER, "genpd" },
+ { SCMI_PROTOCOL_SYSTEM, "syspower" },
+ { SCMI_PROTOCOL_PERF, "perf" },
+ { SCMI_PROTOCOL_PERF, "cpufreq" },
+ { SCMI_PROTOCOL_CLOCK, "clocks" },
+ { SCMI_PROTOCOL_SENSOR, "hwmon" },
+ { SCMI_PROTOCOL_SENSOR, "iiodev" },
+ { SCMI_PROTOCOL_RESET, "reset" },
+ { SCMI_PROTOCOL_VOLTAGE, "regulator" },
+ { SCMI_PROTOCOL_POWERCAP, "powercap" },
+ { SCMI_PROTOCOL_PINCTRL, "pinctrl" },
+ { SCMI_PROTOCOL_PINCTRL, "pinctrl-imx" },
+ { },
+};
+
+static bool scmi_device_id_in_std_id_table(const struct scmi_device_id *id)
+{
+ for (int i = 0; scmi_std_id_table[i].name[0]; i++) {
+ if (scmi_std_id_table[i].protocol_id == id->protocol_id &&
+ !strcmp(scmi_std_id_table[i].name, id->name))
+ return true;
+ }
+
+ return false;
+}
+
/**
* scmi_device_create - A method to create one or more SCMI devices
*
@@ -534,11 +562,25 @@ struct scmi_device *scmi_device_create(struct device_node *np,
{
struct list_head *phead;
struct scmi_requested_dev *rdev;
- struct scmi_device *scmi_dev = NULL;
+ struct scmi_device *sdev, *scmi_dev = NULL;
if (name)
return _scmi_device_create(np, parent, protocol, name);
+ /*
+ * Always create devices for standard protocols, even if the device-ids
+ * have not been registered into scmi_requested_devices yet. This allows
+ * auto-loading of SCMI protocol driver modules for standard protocols.
+ */
+ for (int i = 0; scmi_std_id_table[i].name[0]; i++) {
+ if (scmi_std_id_table[i].protocol_id != protocol)
+ continue;
+
+ sdev = _scmi_device_create(np, parent, protocol, scmi_std_id_table[i].name);
+ if (sdev)
+ scmi_dev = sdev;
+ }
+
mutex_lock(&scmi_requested_devices_mtx);
phead = idr_find(&scmi_requested_devices, protocol);
/* Nothing to do. */
@@ -549,7 +591,9 @@ struct scmi_device *scmi_device_create(struct device_node *np,
/* Walk the list of requested devices for protocol and create them */
list_for_each_entry(rdev, phead, node) {
- struct scmi_device *sdev;
+ /* Standard proto matches already have their dev created above */
+ if (scmi_device_id_in_std_id_table(rdev->id_table))
+ continue;
sdev = _scmi_device_create(np, parent,
rdev->id_table->protocol_id,
--
2.55.0
prev parent reply other threads:[~2026-09-02 18:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 18:08 [PATCH v5 0/3] firmware: arm_scmi: fix module auto-loading Hans de Goede
2026-09-02 18:08 ` [PATCH v5 1/3] module: add SCMI device table alias support Hans de Goede
2026-09-02 18:08 ` [PATCH v5 2/3] firmware: arm_scmi: Fix scmi_protocol_table_register() error handling Hans de Goede
2026-09-02 18:08 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902180844.41230-4-johannes.goede@oss.qualcomm.com \
--to=johannes.goede@oss.qualcomm.com \
--cc=Frank.Li@kernel.org \
--cc=andersson@kernel.org \
--cc=arm-scmi@vger.kernel.org \
--cc=bjorn.andersson@oss.qualcomm.com \
--cc=cristian.marussi@arm.com \
--cc=daniel.lezcano@oss.qualcomm.com \
--cc=imx@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudeep.holla@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox