When working with CPU-wide scenarios and the HW enacts an N:1 source/sink topology the sink is shared between source and needs to use double buffering. As such introduce a new function to easily determine if a sink is shared by multiple source.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 25 ++++++++++++++++++++ 2 files changed, 26 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index e0684d06e9ee..5d7213561e94 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -146,6 +146,7 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val,
void coresight_disable_path(struct list_head *path); int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); +int coresight_sink_is_shared(struct list_head *path); struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_enabled_sink(bool reset); struct coresight_device *coresight_get_sink_by_id(u32 id); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 19ba121d7451..d74b2f621885 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -483,6 +483,31 @@ int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data) goto out; }
+int coresight_sink_is_shared(struct list_head *path) +{ + enum coresight_dev_type type; + enum coresight_dev_subtype_link subtype; + struct coresight_node *nd; + struct coresight_device *csdev; + + if (!path) + return -EINVAL; + + /* Go through each of the entries in the path */ + list_for_each_entry(nd, path, link) { + csdev = nd->csdev; + type = csdev->type; + subtype = csdev->subtype.link_subtype; + + /* If we find a funnel the sink is shared */ + if (type == CORESIGHT_DEV_TYPE_LINK && + subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) + return 1; + } + + return 0; +} + struct coresight_device *coresight_get_sink(struct list_head *path) { struct coresight_device *csdev;