Skip to contentSkip to conversation

firmware: arm: scmi: Skip ACPI protocols absent from _DSD

PATCH New Sudeep Holla 1 participant 1 message Nov 25 System control & power/management interface (SCPI/SCMI) Message Protocol drivers

lore
Share & tools
lore

Sudeep Holla

author maintainer
#0 lore raw

PATCH 1/1 firmware: arm: scmi: Skip ACPI protocols absent from _DSD

ACPI PCC setup iterates the list of known protocols even when firmware omits a protocol's _DSD property. The missing dedicated channel is then treated as a reason to reuse the BASE channel, allowing an undescribed protocol device to be created.

Record successfully parsed protocol properties in the PCC map and add a transport callback that reports their presence independently of dedicated channel availability. Skip absent protocols during channel setup and device creation, while retaining BASE-channel fallback for listed protocols without an exclusive channel.

Fixes 4f5f291a5704 ("firmware: arm_scmi: Initialise known ACPI protocol devices and channels")
---
 drivers/firmware/arm/scmi/common.h         |  3 +++
 drivers/firmware/arm/scmi/driver.c         |  6 ++++++
 drivers/firmware/arm/scmi/transports/pcc.c | 18 ++++++++++++++++++
 3 files changed, 27 insertions(+)
drivers/firmware/arm/scmi/common.h +3 -0
index af5b025ee072..3b1386f289cb 100644
@@ -193,6 +193,8 @@ struct scmi_chan_info {
 /**
  * struct scmi_transport_ops - Structure representing a SCMI transport ops
  *
+ * @protocol_available: Optional callback to check if firmware describes a
+ *                      protocol, independently of dedicated channel presence
  * @chan_available: Callback to check if channel is available or not
  * @chan_setup: Callback to allocate and setup a channel
  * @chan_free: Callback to free a channel
@@ -207,6 +209,7 @@ struct scmi_chan_info {
  * @poll_done: Callback to poll transfer status
  */
 struct scmi_transport_ops {
+	bool (*protocol_available)(struct fwnode_handle *fwnode, int prot_id);
 	bool (*chan_available)(struct fwnode_handle *fwnode, int prot_id,
 			       int idx);
 	int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
drivers/firmware/arm/scmi/driver.c +6 -0
index b753a02f1358..a971f0a74929 100644
@@ -2932,6 +2932,9 @@ static int scmi_channels_setup(struct scmi_info *info)
 
 			if (prot_id == SCMI_PROTOCOL_BASE)
 				continue;
+			if (info->desc->ops->protocol_available &&
+			    !info->desc->ops->protocol_available(fwnode, prot_id))
+				continue;
 
 			ret = scmi_txrx_setup(info, fwnode, prot_id);
 			if (ret)
@@ -3455,6 +3458,9 @@ static int scmi_probe(struct platform_device *pdev)
 
 			if (prot_id == SCMI_PROTOCOL_BASE)
 				continue;
+			if (info->desc->ops->protocol_available &&
+			    !info->desc->ops->protocol_available(dev_fwnode(dev), prot_id))
+				continue;
 
 			scmi_device_check_create(dev_fwnode(dev), prot_id,
 						 info, false);
drivers/firmware/arm/scmi/transports/pcc.c +18 -0
index 16bf3e3efcfc..47c6c48ede59 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/bitmap.h>
 #include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/err.h>
@@ -119,6 +120,7 @@ struct pcc_transport_map {
 	struct fwnode_handle *fwnode;
 	struct device *dev;
 	struct list_head node;
+	DECLARE_BITMAP(protocols, U8_MAX + 1);
 	DECLARE_HASHTABLE(table, ilog2(MAX_PCC_SUBSPACES / 8));
 };
 
@@ -447,6 +449,7 @@ static int acpi_scmi_parse_properties(struct pcc_transport_map *map,
 		if (ret)
 			return ret;
 		transport_found = true;
+		set_bit(SCMI_PROTOCOL_BASE, map->protocols);
 	}
 
 	if (!transport_found)
@@ -470,6 +473,7 @@ static int acpi_scmi_parse_properties(struct pcc_transport_map *map,
 		ret = acpi_scmi_dsd_parse_protocol_package(map, v, prot_id);
 		if (ret)
 			return ret;
+		set_bit(prot_id, map->protocols);
 	}
 
 	return 0;
@@ -672,6 +676,19 @@ pcc_chan_available(struct fwnode_handle *fwnode, int prot_id, int idx)
 	return pcc_get_ss_id(fwnode, prot_id, !idx, NULL) >= 0;
 }
 
+static bool pcc_protocol_available(struct fwnode_handle *fwnode, int prot_id)
+{
+	struct pcc_transport_map *map;
+
+	if (prot_id < 0 || prot_id > U8_MAX)
+		return false;
+
+	guard(mutex)(&pcc_transport_maps_lock);
+	map = pcc_transport_map_find(fwnode);
+
+	return map && test_bit(prot_id, map->protocols);
+}
+
 static void tx_prepare(struct mbox_client *cl, void *m)
 {
 	struct scmi_pcc *smbox = client_to_scmi_pcc(cl);
@@ -839,6 +856,7 @@ static void pcc_fetch_notification(struct scmi_chan_info *cinfo, size_t max_len,
 }
 
 static const struct scmi_transport_ops scmi_pcc_ops = {
+	.protocol_available = pcc_protocol_available,
 	.chan_available = pcc_chan_available,
 	.chan_setup = pcc_chan_setup,
 	.chan_free = pcc_chan_free,

base-commit: 99e55aac0f9cf3bbd9e1f839849997b877fd36f7

Signature · 1 line
2.43.0