Commit 75c86dc7 authored by Cristian Marussi's avatar Cristian Marussi Committed by Sudeep Holla

firmware: arm_scmi: Add internal platform/channel identifiers

Add a couple of unique identifiers to channel and platform instance
descriptors in order to emit more descriptive message dump traces.
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Tested-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20230118121426.492864-8-cristian.marussi@arm.comSigned-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 936a2b91
...@@ -157,6 +157,8 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id); ...@@ -157,6 +157,8 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
/** /**
* struct scmi_chan_info - Structure representing a SCMI channel information * struct scmi_chan_info - Structure representing a SCMI channel information
* *
* @id: An identifier for this channel: this matches the protocol number
* used to initialize this channel
* @dev: Reference to device in the SCMI hierarchy corresponding to this * @dev: Reference to device in the SCMI hierarchy corresponding to this
* channel * channel
* @rx_timeout_ms: The configured RX timeout in milliseconds. * @rx_timeout_ms: The configured RX timeout in milliseconds.
...@@ -168,6 +170,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id); ...@@ -168,6 +170,7 @@ void scmi_protocol_release(const struct scmi_handle *handle, u8 protocol_id);
* @transport_info: Transport layer related information * @transport_info: Transport layer related information
*/ */
struct scmi_chan_info { struct scmi_chan_info {
int id;
struct device *dev; struct device *dev;
unsigned int rx_timeout_ms; unsigned int rx_timeout_ms;
struct scmi_handle *handle; struct scmi_handle *handle;
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/scmi.h> #include <trace/events/scmi.h>
static DEFINE_IDA(scmi_id);
static DEFINE_IDR(scmi_protocols); static DEFINE_IDR(scmi_protocols);
static DEFINE_SPINLOCK(protocol_lock); static DEFINE_SPINLOCK(protocol_lock);
...@@ -98,6 +100,7 @@ struct scmi_protocol_instance { ...@@ -98,6 +100,7 @@ struct scmi_protocol_instance {
/** /**
* struct scmi_info - Structure representing a SCMI instance * struct scmi_info - Structure representing a SCMI instance
* *
* @id: A sequence number starting from zero identifying this instance
* @dev: Device pointer * @dev: Device pointer
* @desc: SoC description for this instance * @desc: SoC description for this instance
* @version: SCMI revision information containing protocol version, * @version: SCMI revision information containing protocol version,
...@@ -131,6 +134,7 @@ struct scmi_protocol_instance { ...@@ -131,6 +134,7 @@ struct scmi_protocol_instance {
* @devreq_mtx: A mutex to serialize device creation for this SCMI instance * @devreq_mtx: A mutex to serialize device creation for this SCMI instance
*/ */
struct scmi_info { struct scmi_info {
int id;
struct device *dev; struct device *dev;
const struct scmi_desc *desc; const struct scmi_desc *desc;
struct scmi_revision_info version; struct scmi_revision_info version;
...@@ -2270,6 +2274,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node, ...@@ -2270,6 +2274,7 @@ static int scmi_chan_setup(struct scmi_info *info, struct device_node *of_node,
} }
of_node_get(of_node); of_node_get(of_node);
cinfo->id = prot_id;
cinfo->dev = &tdev->dev; cinfo->dev = &tdev->dev;
ret = info->desc->ops->chan_setup(cinfo, info->dev, tx); ret = info->desc->ops->chan_setup(cinfo, info->dev, tx);
if (ret) { if (ret) {
...@@ -2486,6 +2491,10 @@ static int scmi_probe(struct platform_device *pdev) ...@@ -2486,6 +2491,10 @@ static int scmi_probe(struct platform_device *pdev)
if (!info) if (!info)
return -ENOMEM; return -ENOMEM;
info->id = ida_alloc_min(&scmi_id, 0, GFP_KERNEL);
if (info->id < 0)
return info->id;
info->dev = dev; info->dev = dev;
info->desc = desc; info->desc = desc;
info->bus_nb.notifier_call = scmi_bus_notifier; info->bus_nb.notifier_call = scmi_bus_notifier;
...@@ -2518,13 +2527,13 @@ static int scmi_probe(struct platform_device *pdev) ...@@ -2518,13 +2527,13 @@ static int scmi_probe(struct platform_device *pdev)
if (desc->ops->link_supplier) { if (desc->ops->link_supplier) {
ret = desc->ops->link_supplier(dev); ret = desc->ops->link_supplier(dev);
if (ret) if (ret)
return ret; goto clear_ida;
} }
/* Setup all channels described in the DT at first */ /* Setup all channels described in the DT at first */
ret = scmi_channels_setup(info); ret = scmi_channels_setup(info);
if (ret) if (ret)
return ret; goto clear_ida;
ret = bus_register_notifier(&scmi_bus_type, &info->bus_nb); ret = bus_register_notifier(&scmi_bus_type, &info->bus_nb);
if (ret) if (ret)
...@@ -2604,6 +2613,8 @@ static int scmi_probe(struct platform_device *pdev) ...@@ -2604,6 +2613,8 @@ static int scmi_probe(struct platform_device *pdev)
bus_unregister_notifier(&scmi_bus_type, &info->bus_nb); bus_unregister_notifier(&scmi_bus_type, &info->bus_nb);
clear_txrx_setup: clear_txrx_setup:
scmi_cleanup_txrx_channels(info); scmi_cleanup_txrx_channels(info);
clear_ida:
ida_free(&scmi_id, info->id);
return ret; return ret;
} }
...@@ -2637,6 +2648,8 @@ static int scmi_remove(struct platform_device *pdev) ...@@ -2637,6 +2648,8 @@ static int scmi_remove(struct platform_device *pdev)
/* Safe to free channels since no more users */ /* Safe to free channels since no more users */
scmi_cleanup_txrx_channels(info); scmi_cleanup_txrx_channels(info);
ida_free(&scmi_id, info->id);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment