Skip to content

Commit fc5382d

Browse files
Linu Cheriangregkh
authored andcommitted
coresight: Make sysfs functional on topologies with per core sink
[ Upstream commit 6d57825 ] 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: Linu Cherian <lcherian@marvell.com> [Fixed indentation problem and removed obsolete comment] Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20200916191737.4001561-15-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1737a0b commit fc5382d

2 files changed

Lines changed: 29 additions & 36 deletions

File tree

drivers/hwtracing/coresight/coresight-priv.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val,
148148
void coresight_disable_path(struct list_head *path);
149149
int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
150150
struct coresight_device *coresight_get_sink(struct list_head *path);
151-
struct coresight_device *coresight_get_enabled_sink(bool reset);
151+
struct coresight_device *
152+
coresight_get_enabled_sink(struct coresight_device *source);
152153
struct coresight_device *coresight_get_sink_by_id(u32 id);
153154
struct coresight_device *
154155
coresight_find_default_sink(struct coresight_device *csdev);

drivers/hwtracing/coresight/coresight.c

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -540,50 +540,46 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
540540
return csdev;
541541
}
542542

543-
static int coresight_enabled_sink(struct device *dev, const void *data)
543+
static struct coresight_device *
544+
coresight_find_enabled_sink(struct coresight_device *csdev)
544545
{
545-
const bool *reset = data;
546-
struct coresight_device *csdev = to_coresight_device(dev);
546+
int i;
547+
struct coresight_device *sink;
547548

548549
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
549550
csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
550-
csdev->activated) {
551-
/*
552-
* Now that we have a handle on the sink for this session,
553-
* disable the sysFS "enable_sink" flag so that possible
554-
* concurrent perf session that wish to use another sink don't
555-
* trip on it. Doing so has no ramification for the current
556-
* session.
557-
*/
558-
if (*reset)
559-
csdev->activated = false;
551+
csdev->activated)
552+
return csdev;
560553

561-
return 1;
554+
/*
555+
* Recursively explore each port found on this element.
556+
*/
557+
for (i = 0; i < csdev->pdata->nr_outport; i++) {
558+
struct coresight_device *child_dev;
559+
560+
child_dev = csdev->pdata->conns[i].child_dev;
561+
if (child_dev)
562+
sink = coresight_find_enabled_sink(child_dev);
563+
if (sink)
564+
return sink;
562565
}
563566

564-
return 0;
567+
return NULL;
565568
}
566569

567570
/**
568-
* coresight_get_enabled_sink - returns the first enabled sink found on the bus
569-
* @deactivate: Whether the 'enable_sink' flag should be reset
570-
*
571-
* When operated from perf the deactivate parameter should be set to 'true'.
572-
* That way the "enabled_sink" flag of the sink that was selected can be reset,
573-
* allowing for other concurrent perf sessions to choose a different sink.
571+
* coresight_get_enabled_sink - returns the first enabled sink using
572+
* connection based search starting from the source reference
574573
*
575-
* When operated from sysFS users have full control and as such the deactivate
576-
* parameter should be set to 'false', hence mandating users to explicitly
577-
* clear the flag.
574+
* @source: Coresight source device reference
578575
*/
579-
struct coresight_device *coresight_get_enabled_sink(bool deactivate)
576+
struct coresight_device *
577+
coresight_get_enabled_sink(struct coresight_device *source)
580578
{
581-
struct device *dev = NULL;
582-
583-
dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
584-
coresight_enabled_sink);
579+
if (!source)
580+
return NULL;
585581

586-
return dev ? to_coresight_device(dev) : NULL;
582+
return coresight_find_enabled_sink(source);
587583
}
588584

589585
static int coresight_sink_by_id(struct device *dev, const void *data)
@@ -988,11 +984,7 @@ int coresight_enable(struct coresight_device *csdev)
988984
goto out;
989985
}
990986

991-
/*
992-
* Search for a valid sink for this session but don't reset the
993-
* "enable_sink" flag in sysFS. Users get to do that explicitly.
994-
*/
995-
sink = coresight_get_enabled_sink(false);
987+
sink = coresight_get_enabled_sink(csdev);
996988
if (!sink) {
997989
ret = -EINVAL;
998990
goto out;

0 commit comments

Comments
 (0)