提交 6d578258 编写于 作者: L Linu Cherian 提交者: Greg Kroah-Hartman

coresight: Make sysfs functional on topologies with per core sink

Coresight driver assumes sink is common across all the ETMs,
and tries to build a path between ETM and the first enabled
sink found using bus based search. This breaks sysFS usage
on implementations that has multiple per core sinks in
enabled state.

To fix this, coresight_get_enabled_sink API is updated to
do a connection based search starting from the given source,
instead of bus based search.
With sink selection using sysfs depecrated for perf interface,
provision for reset is removed as well in this API.
Signed-off-by: NLinu Cherian <lcherian@marvell.com>
[Fixed indentation problem and removed obsolete comment]
Signed-off-by: NMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200916191737.4001561-15-mathieu.poirier@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 bb1860ef
...@@ -148,7 +148,8 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val, ...@@ -148,7 +148,8 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val,
void coresight_disable_path(struct list_head *path); void coresight_disable_path(struct list_head *path);
int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
struct coresight_device *coresight_get_sink(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_enabled_sink(struct coresight_device *source);
struct coresight_device *coresight_get_sink_by_id(u32 id); struct coresight_device *coresight_get_sink_by_id(u32 id);
struct coresight_device * struct coresight_device *
coresight_find_default_sink(struct coresight_device *csdev); coresight_find_default_sink(struct coresight_device *csdev);
......
...@@ -540,50 +540,46 @@ struct coresight_device *coresight_get_sink(struct list_head *path) ...@@ -540,50 +540,46 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
return csdev; return csdev;
} }
static int coresight_enabled_sink(struct device *dev, const void *data) static struct coresight_device *
coresight_find_enabled_sink(struct coresight_device *csdev)
{ {
const bool *reset = data; int i;
struct coresight_device *csdev = to_coresight_device(dev); struct coresight_device *sink;
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
csdev->activated) { csdev->activated)
/* return csdev;
* Now that we have a handle on the sink for this session,
* disable the sysFS "enable_sink" flag so that possible
* concurrent perf session that wish to use another sink don't
* trip on it. Doing so has no ramification for the current
* session.
*/
if (*reset)
csdev->activated = false;
return 1; /*
* Recursively explore each port found on this element.
*/
for (i = 0; i < csdev->pdata->nr_outport; i++) {
struct coresight_device *child_dev;
child_dev = csdev->pdata->conns[i].child_dev;
if (child_dev)
sink = coresight_find_enabled_sink(child_dev);
if (sink)
return sink;
} }
return 0; return NULL;
} }
/** /**
* coresight_get_enabled_sink - returns the first enabled sink found on the bus * coresight_get_enabled_sink - returns the first enabled sink using
* @deactivate: Whether the 'enable_sink' flag should be reset * connection based search starting from the source reference
*
* When operated from perf the deactivate parameter should be set to 'true'.
* That way the "enabled_sink" flag of the sink that was selected can be reset,
* allowing for other concurrent perf sessions to choose a different sink.
* *
* When operated from sysFS users have full control and as such the deactivate * @source: Coresight source device reference
* parameter should be set to 'false', hence mandating users to explicitly
* clear the flag.
*/ */
struct coresight_device *coresight_get_enabled_sink(bool deactivate) struct coresight_device *
coresight_get_enabled_sink(struct coresight_device *source)
{ {
struct device *dev = NULL; if (!source)
return NULL;
dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
coresight_enabled_sink);
return dev ? to_coresight_device(dev) : NULL; return coresight_find_enabled_sink(source);
} }
static int coresight_sink_by_id(struct device *dev, const void *data) static int coresight_sink_by_id(struct device *dev, const void *data)
...@@ -988,11 +984,7 @@ int coresight_enable(struct coresight_device *csdev) ...@@ -988,11 +984,7 @@ int coresight_enable(struct coresight_device *csdev)
goto out; goto out;
} }
/* sink = coresight_get_enabled_sink(csdev);
* Search for a valid sink for this session but don't reset the
* "enable_sink" flag in sysFS. Users get to do that explicitly.
*/
sink = coresight_get_enabled_sink(false);
if (!sink) { if (!sink) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册