Arm SCMI updates for v6.15

Couple of updates around the flexibility in SCMI device names and
 addition of name, protocol id attributes and modalias for SCMI
 devices in the sysfs.
 
 Currently, in the scmi_protocol_device_request() function, SCMI device
 names ust be unique across all protocols. However, this constraint is
 being relaxed, allowing devices in different protocols to share the
 same name. The change aims to provide more flexibility in naming devices
 across various protocols.
 
 Two attributes: name and protocol ID is being added to the SCMI device
 in the sysfs along with the support for the modalias. These attributes
 aim to enhance device identification and management.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEunHlEgbzHrJD3ZPhAEG6vDF+4pgFAmfFoCcACgkQAEG6vDF+
 4piYkRAAhUsFR41gMzxKnsf1oIO3kV+6ZU8azQiHRldJEvKo8uP29XhDUYRaQau4
 4ubh/4ZFR+ZMzvrVufHWklwC177bjstL075YuNF+q7U0SQ7iF1n8Fmma8JoJd/EC
 Tz23aW/lTuZKAFu+//YvoNnVUJZx3EB/hddcfvlQxODlwArldwblG+ftrYmGB0Cv
 lp5smQO1I4HnVyP3ptwIKVol5RpFnpXXflTpsCNovgfptPOGDL+HTILf4RqsWifC
 TxLfdgi4ciF1K3Yb9jZByBhud30JnjK/xQQTQ3I6+n66Cm29DSPTtHF5wzYalBcs
 ZfNiSgy8PS60WH13eGaTHYvq26BUmKu2kyi2JpdBM9DneRb16fNuv4amYrKPfbeE
 bYrU9Uey491zKjBnjUu1JxFvMuNzVolvztax4CAp6SbbkI22XF1OZcxt4ydVDgzQ
 fykc2gNr/uO/unLWnzsOYRlE/DalYsPpsuK7uNIIXPMe9JCOtOs1JOD6Pj68kNyV
 Gh+uCJc/eRXPg/eBchBetq9TTV+DFfMP1Rh11up0a8mrmquL/UnORORMurK922px
 mS6kmewHBDccwC4V4FTbaHmNivaKHhJRRNaBEV+pTkxFits2ehjfsAsxIva144Gc
 NLxP+Kbux5uMa/UsvXUSY+fktueh8SnmkJkUO3txixayHY3cXxs=
 =DMuT
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEiK/NIGsWEZVxh/FrYKtH/8kJUicFAmfJyuoACgkQYKtH/8kJ
 UidiXQ//Qms9GfMxzJYxiJ8HCQOlvetuQJNs2u3Rhr1pWkCFxHq4sKdYpSRcwN+I
 MkgR4sfiMzXjqKzWl2MxJuwduZmCyo7RaHi+iyH3l/Xpwlofv+WrJkUSsTutQB+V
 fMwMNv8yK4Lb1Abm8JH70b0UIyXBpDmYMfkDftbj0jDV+wH+JOMaJwkVtQFA0LI+
 XFIDUGV49FvZowZW1AjChdA5xtl63af9EtkEE0e6X/MFmUhg2DaX2Me1+tEchuRB
 LBKB49TS1v0ACT/O6u5ZBK7Mg1H4bisHMs7PpZHokU1P3FTNJqpZEESG4mE9fOG+
 5WXcvnsdL1jZjl3Mwr5szHBBlOAb8QRuQOld7I9jqSvfNrCl6jR+UQErl4UUTkJa
 xmwPpjl+5bzgbzVrGXNrTxiL4m/fi9HKxJiuPMny1tA3kIqHXjQPA1eXv6sUWQt0
 dquCzvx5lAtHQ/m8XJ2v0ahRkWHeMyUiR1+89Zbl10gdrzDv9BfNRIvsYpiw3xRr
 4WEK8XBZuCBaJus3lOt72mnPJxfNGMJk1CWp0V44jHZwBxAPJHARSEpop0azIYFK
 5tKUeB/2EB5Ryh13ufdc9uXz60lf6cb2MbcfRm9IPpzQxmZ4csM2aZ5yrt3C/Y81
 /NS24mV6aiATl9p1o71u8d9JZbeaWk7ogSExgrPQgChmLIE9eYQ=
 =cVvD
 -----END PGP SIGNATURE-----

Merge tag 'scmi-updates-6.15' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/drivers

Arm SCMI updates for v6.15

Couple of updates around the flexibility in SCMI device names and
addition of name, protocol id attributes and modalias for SCMI
devices in the sysfs.

Currently, in the scmi_protocol_device_request() function, SCMI device
names ust be unique across all protocols. However, this constraint is
being relaxed, allowing devices in different protocols to share the
same name. The change aims to provide more flexibility in naming devices
across various protocols.

Two attributes: name and protocol ID is being added to the SCMI device
in the sysfs along with the support for the modalias. These attributes
aim to enhance device identification and management.

* tag 'scmi-updates-6.15' of https://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_scmi: Emit modalias for SCMI devices
  firmware: arm_scmi: Add name and protocol id attributes
  firmware: arm_scmi: Relax duplicate name constraint across protocol ids

Link: https://lore.kernel.org/r/20250304105915.432967-1-sudeep.holla@arm.com
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2025-03-06 17:18:49 +01:00
commit 698a56d1fe

View File

@ -17,6 +17,8 @@
#include "common.h"
#define SCMI_UEVENT_MODALIAS_FMT "%s:%02x:%s"
BLOCKING_NOTIFIER_HEAD(scmi_requested_devices_nh);
EXPORT_SYMBOL_GPL(scmi_requested_devices_nh);
@ -42,7 +44,7 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0);
* This helper let an SCMI driver request specific devices identified by the
* @id_table to be created for each active SCMI instance.
*
* The requested device name MUST NOT be already existent for any protocol;
* The requested device name MUST NOT be already existent for this protocol;
* at first the freshly requested @id_table is annotated in the IDR table
* @scmi_requested_devices and then the requested device is advertised to any
* registered party via the @scmi_requested_devices_nh notification chain.
@ -52,7 +54,6 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0);
static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
{
int ret = 0;
unsigned int id = 0;
struct list_head *head, *phead = NULL;
struct scmi_requested_dev *rdev;
@ -67,19 +68,13 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
}
/*
* Search for the matching protocol rdev list and then search
* of any existent equally named device...fails if any duplicate found.
* Find the matching protocol rdev list and then search of any
* existent equally named device...fails if any duplicate found.
*/
mutex_lock(&scmi_requested_devices_mtx);
idr_for_each_entry(&scmi_requested_devices, head, id) {
if (!phead) {
/* A list found registered in the IDR is never empty */
rdev = list_first_entry(head, struct scmi_requested_dev,
node);
if (rdev->id_table->protocol_id ==
id_table->protocol_id)
phead = head;
}
phead = idr_find(&scmi_requested_devices, id_table->protocol_id);
if (phead) {
head = phead;
list_for_each_entry(rdev, head, node) {
if (!strcmp(rdev->id_table->name, id_table->name)) {
pr_err("Ignoring duplicate request [%d] %s\n",
@ -283,11 +278,59 @@ static void scmi_dev_remove(struct device *dev)
scmi_drv->remove(scmi_dev);
}
static int scmi_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct scmi_device *scmi_dev = to_scmi_dev(dev);
return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT,
dev_name(&scmi_dev->dev), scmi_dev->protocol_id,
scmi_dev->name);
}
static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct scmi_device *scmi_dev = to_scmi_dev(dev);
return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT,
dev_name(&scmi_dev->dev), scmi_dev->protocol_id,
scmi_dev->name);
}
static DEVICE_ATTR_RO(modalias);
static ssize_t protocol_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct scmi_device *scmi_dev = to_scmi_dev(dev);
return sprintf(buf, "0x%02x\n", scmi_dev->protocol_id);
}
static DEVICE_ATTR_RO(protocol_id);
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scmi_device *scmi_dev = to_scmi_dev(dev);
return sprintf(buf, "%s\n", scmi_dev->name);
}
static DEVICE_ATTR_RO(name);
static struct attribute *scmi_device_attributes_attrs[] = {
&dev_attr_protocol_id.attr,
&dev_attr_name.attr,
&dev_attr_modalias.attr,
NULL,
};
ATTRIBUTE_GROUPS(scmi_device_attributes);
const struct bus_type scmi_bus_type = {
.name = "scmi_protocol",
.match = scmi_dev_match,
.probe = scmi_dev_probe,
.remove = scmi_dev_remove,
.uevent = scmi_device_uevent,
.dev_groups = scmi_device_attributes_groups,
};
EXPORT_SYMBOL_GPL(scmi_bus_type);