diff mbox series

[v2,2/4] firmware: arm_scmi: Add machine_allowlist and machine_blocklist

Message ID 20250120-scmi-fwdevlink-v2-2-3af2fa37dbac@nxp.com (mailing list archive)
State New
Headers show
Series scmi: Bypass set fwnode and introduce allow/block list to address devlink issue | expand

Commit Message

Peng Fan (OSS) Jan. 20, 2025, 7:13 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

There are two cases:
pinctrl-scmi.c and pinctrl-imx-scmi.c, both use SCMI_PROTOCOL_PINCTRL.
If both drivers are built in, and the scmi device with name "pinctrl-imx"
is created earlier, and the fwnode device points to the scmi device,
non-i.MX platforms will never have the pinctrl supplier ready.

Vendor A use 0x80 for feature X, Vendor B use 0x80 for feature Y.
With both drivers built in, two scmi devices will be created, and both
drivers will be probed. On A's patform, feature Y probe may fail, vice
verus.

Introduce machine_allowlist and machine_blocklist to allow or block
the creation of scmi devices to address above issues.

machine_blocklist is non-vendor protocols, but vendor has its own
implementation. Saying need to block pinctrl-scmi.c on i.MX95.
machine_allowlist is for vendor protocols. Saying vendor A drivers only
allow vendor A machine, vendor B machines only allow vendor B machine.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/firmware/arm_scmi/bus.c | 14 ++++++++++++++
 include/linux/scmi_protocol.h   |  3 +++
 2 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 7850eb7710f499888d32aebf5d99df63db8bfa26..76a5d946de7a8e16f5d940abc4f542aac5bb2b92 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -55,6 +55,20 @@  static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
 	unsigned int id = 0;
 	struct list_head *head, *phead = NULL;
 	struct scmi_requested_dev *rdev;
+	const char * const *allowlist = id_table->machine_allowlist;
+	const char * const *blocklist = id_table->machine_blocklist;
+
+	if (blocklist && of_machine_compatible_match(blocklist)) {
+		pr_debug("block SCMI device (%s) for protocol %x\n",
+			 id_table->name, id_table->protocol_id);
+		return 0;
+	}
+
+	if (allowlist && !of_machine_compatible_match(allowlist)) {
+		pr_debug("block SCMI device (%s) for protocol %x\n",
+			 id_table->name, id_table->protocol_id);
+		return 0;
+	}
 
 	pr_debug("Requesting SCMI device (%s) for protocol %x\n",
 		 id_table->name, id_table->protocol_id);
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 688466a0e816247d24704f7ba109667a14226b67..e1b822d3522ff25168f895a4b1ed4c4e9a35bfff 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -950,6 +950,9 @@  struct scmi_device {
 struct scmi_device_id {
 	u8 protocol_id;
 	const char *name;
+	/* Optional */
+	const char * const *machine_blocklist;
+	const char * const *machine_allowlist;
 };
 
 struct scmi_driver {