Skip to content

Commit 73274ab

Browse files
mikel-armbbgregkh
authored andcommitted
coresight: cti: Add in sysfs links to other coresight devices
Adds in sysfs links for connections where the connected device is another coresight device. This allows examination of the coresight topology. Non-coresight connections remain just as a reference name. Signed-off-by: Mike Leach <mike.leach@linaro.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Link: https://lore.kernel.org/r/20200518180242.7916-6-mathieu.poirier@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8a7365c commit 73274ab

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

drivers/hwtracing/coresight/coresight-cti.c

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,34 @@ int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
442442
return err;
443443
}
444444

445+
static bool cti_add_sysfs_link(struct cti_drvdata *drvdata,
446+
struct cti_trig_con *tc)
447+
{
448+
struct coresight_sysfs_link link_info;
449+
int link_err = 0;
450+
451+
link_info.orig = drvdata->csdev;
452+
link_info.orig_name = tc->con_dev_name;
453+
link_info.target = tc->con_dev;
454+
link_info.target_name = dev_name(&drvdata->csdev->dev);
455+
456+
link_err = coresight_add_sysfs_link(&link_info);
457+
if (link_err)
458+
dev_warn(&drvdata->csdev->dev,
459+
"Failed to set CTI sysfs link %s<=>%s\n",
460+
link_info.orig_name, link_info.target_name);
461+
return !link_err;
462+
}
463+
464+
static void cti_remove_sysfs_link(struct cti_trig_con *tc)
465+
{
466+
struct coresight_sysfs_link link_info;
467+
468+
link_info.orig_name = tc->con_dev_name;
469+
link_info.target = tc->con_dev;
470+
coresight_remove_sysfs_link(&link_info);
471+
}
472+
445473
/*
446474
* Look for a matching connection device name in the list of connections.
447475
* If found then swap in the csdev name, set trig con association pointer
@@ -452,14 +480,21 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
452480
struct coresight_device *csdev)
453481
{
454482
struct cti_trig_con *tc;
483+
struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata,
484+
ctidev);
455485

456486
list_for_each_entry(tc, &ctidev->trig_cons, node) {
457487
if (tc->con_dev_name) {
458488
if (!strcmp(node_name, tc->con_dev_name)) {
459489
/* match: so swap in csdev name & dev */
460490
tc->con_dev_name = dev_name(&csdev->dev);
461491
tc->con_dev = csdev;
462-
return true;
492+
/* try to set sysfs link */
493+
if (cti_add_sysfs_link(drvdata, tc))
494+
return true;
495+
/* link failed - remove CTI reference */
496+
tc->con_dev = NULL;
497+
break;
463498
}
464499
}
465500
}
@@ -522,6 +557,7 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev)
522557
ctidev = &ctidrv->ctidev;
523558
list_for_each_entry(tc, &ctidev->trig_cons, node) {
524559
if (tc->con_dev == csdev->ect_dev) {
560+
cti_remove_sysfs_link(tc);
525561
tc->con_dev = NULL;
526562
break;
527563
}
@@ -543,10 +579,16 @@ static void cti_update_conn_xrefs(struct cti_drvdata *drvdata)
543579
struct cti_device *ctidev = &drvdata->ctidev;
544580

545581
list_for_each_entry(tc, &ctidev->trig_cons, node) {
546-
if (tc->con_dev)
547-
/* set tc->con_dev->ect_dev */
548-
coresight_set_assoc_ectdev_mutex(tc->con_dev,
582+
if (tc->con_dev) {
583+
/* if we can set the sysfs link */
584+
if (cti_add_sysfs_link(drvdata, tc))
585+
/* set the CTI/csdev association */
586+
coresight_set_assoc_ectdev_mutex(tc->con_dev,
549587
drvdata->csdev);
588+
else
589+
/* otherwise remove reference from CTI */
590+
tc->con_dev = NULL;
591+
}
550592
}
551593
}
552594

@@ -559,6 +601,8 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
559601
if (tc->con_dev) {
560602
coresight_set_assoc_ectdev_mutex(tc->con_dev,
561603
NULL);
604+
cti_remove_sysfs_link(tc);
605+
tc->con_dev = NULL;
562606
}
563607
}
564608
}

0 commit comments

Comments
 (0)