Hi Mike,
On Thu, Aug 27, 2020 at 03:34:09PM +0100, Mike Leach wrote:
Loaded coresight configurations are registered in the cs_etm\cs_config sub directory. This extends the etm-perf code to handle these registrations, and the cs_syscfg driver to perform the registration on load.
Signed-off-by: Mike Leach mike.leach@linaro.org
.../hwtracing/coresight/coresight-etm-perf.c | 89 ++++++++++++++----- .../hwtracing/coresight/coresight-etm-perf.h | 6 ++ .../hwtracing/coresight/coresight-syscfg.c | 7 ++ .../hwtracing/coresight/coresight-syscfg.h | 2 + 4 files changed, 83 insertions(+), 21 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 2d619b764738..d2a42a7305fe 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -20,6 +20,8 @@ #include "coresight-etm-perf.h" #include "coresight-priv.h" +#include "coresight-config.h" +#include "coresight-syscfg.h" static struct pmu etm_pmu; static bool etm_perf_up; @@ -34,6 +36,8 @@ PMU_FORMAT_ATTR(timestamp, "config:" __stringify(ETM_OPT_TS)); PMU_FORMAT_ATTR(retstack, "config:" __stringify(ETM_OPT_RETSTK)); /* Sink ID - same for all ETMs */ PMU_FORMAT_ATTR(sinkid, "config2:0-31"); +/* preset - if sink ID is used as a configuration selector */ +PMU_FORMAT_ATTR(preset, "config2:32-35");
More brain gymnastics on this... I think it would make sense to keep bitfields for sink and configuration distinct so that users can specify a sink and a configuration to use at the same time:
PMU_FORMAT_ATTR(preset, "config1:0-3"); PMU_FORMAT_ATTR(sinkid, "config2:0-31"); PMU_FORMAT_ATTR(configid, "config2:32-63");
We (still) have room and it is just a matter of time before someone wants to do that.
More comments to come...
Thanks, Mathieu
static struct attribute *etm_config_formats_attr[] = { &format_attr_cycacc.attr, @@ -41,6 +45,7 @@ static struct attribute *etm_config_formats_attr[] = { &format_attr_timestamp.attr, &format_attr_retstack.attr, &format_attr_sinkid.attr,
- &format_attr_preset.attr, NULL,
}; @@ -58,9 +63,20 @@ static const struct attribute_group etm_pmu_sinks_group = { .attrs = etm_config_sinks_attr, }; +static struct attribute *etm_config_cscfg_attr[] = {
- NULL,
+};
+static const struct attribute_group etm_pmu_cscfg_group = {
- .name = "cs_config",
- .attrs = etm_config_cscfg_attr,
+};
static const struct attribute_group *etm_pmu_attr_groups[] = { &etm_pmu_format_group, &etm_pmu_sinks_group,
- &etm_pmu_cscfg_group, NULL,
}; @@ -529,21 +545,17 @@ static ssize_t etm_perf_sink_name_show(struct device *dev, return scnprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)(ea->var)); } -int etm_perf_add_symlink_sink(struct coresight_device *csdev) +int etm_perf_add_symlink_group(struct device *dev,
struct dev_ext_attribute **ext_attr,
const char *name,
const char *group_name)
{
- int ret;
- struct dev_ext_attribute *ea; unsigned long hash;
- const char *name;
- int ret; struct device *pmu_dev = etm_pmu.dev;
- struct device *dev = &csdev->dev;
- struct dev_ext_attribute *ea;
- if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
return -EINVAL;
- if (csdev->ea != NULL)
return -EINVAL;
- *ext_attr = NULL;
if (!etm_perf_up) return -EPROBE_DEFER; @@ -552,7 +564,6 @@ int etm_perf_add_symlink_sink(struct coresight_device *csdev) if (!ea) return -ENOMEM;
- name = dev_name(dev); /* See function coresight_get_sink_by_id() to know where this is used */ hash = hashlen_hash(hashlen_string(NULL, name));
@@ -566,31 +577,67 @@ int etm_perf_add_symlink_sink(struct coresight_device *csdev) ea->var = (unsigned long *)hash; ret = sysfs_add_file_to_group(&pmu_dev->kobj,
&ea->attr.attr, "sinks");
if (!ret)&ea->attr.attr, group_name);
csdev->ea = ea;
return ret;*ext_attr = ea;
} -void etm_perf_del_symlink_sink(struct coresight_device *csdev) +int etm_perf_add_symlink_sink(struct coresight_device *csdev) +{
- const char *name;
- struct device *dev = &csdev->dev;
- if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
return -EINVAL;
- if (csdev->ea != NULL)
return -EINVAL;
- name = dev_name(dev);
- return etm_perf_add_symlink_group(dev, &csdev->ea, name, "sinks");
+}
+void etm_perf_del_symlink_group(struct dev_ext_attribute *ea, const char *group_name) { struct device *pmu_dev = etm_pmu.dev;
- struct dev_ext_attribute *ea = csdev->ea;
- sysfs_remove_file_from_group(&pmu_dev->kobj,
&ea->attr.attr, group_name);
+}
+void etm_perf_del_symlink_sink(struct coresight_device *csdev) +{ if (csdev->type != CORESIGHT_DEV_TYPE_SINK && csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) return;
- if (!ea)
- if (!csdev->ea) return;
- sysfs_remove_file_from_group(&pmu_dev->kobj,
&ea->attr.attr, "sinks");
- etm_perf_del_symlink_group(csdev->ea, "sinks"); csdev->ea = NULL;
} +int etm_perf_add_symlink_cscfg(struct device *dev, struct cs_cfg_config *cs_cfg) +{
- if (cs_cfg->ea != NULL)
return -EINVAL;
- return etm_perf_add_symlink_group(dev, &cs_cfg->ea,
cs_cfg->desc->name, "cs_config");
+}
+void etm_perf_del_symlink_cscfg(struct cs_cfg_config *cs_cfg) +{
- if (!cs_cfg->ea)
return;
- etm_perf_del_symlink_group(cs_cfg->ea, "cs_config");
- cs_cfg->ea = NULL;
+}
int __init etm_perf_init(void) { int ret; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h index 29d90dfeba31..a718d0778bcf 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -11,6 +11,7 @@ #include "coresight-priv.h" struct coresight_device; +struct cs_cfg_config; /*
- In both ETMv3 and v4 the maximum number of address comparator implentable
@@ -69,6 +70,8 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle) return data->snk_config; return NULL; } +int etm_perf_add_symlink_cscfg(struct device *dev, struct cs_cfg_config *cs_cfg); +void etm_perf_del_symlink_cscfg(struct cs_cfg_config *cs_cfg); #else static inline int etm_perf_symlink(struct coresight_device *csdev, bool link) { return -EINVAL; } @@ -79,6 +82,9 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle) { return NULL; } +int etm_perf_add_symlink_cscfg(struct device *dev, struct cs_cfg_config *cs_cfg) +{ return -EINVAL; } +void etm_perf_del_symlink_cscfg(struct cs_cfg_config *cs_cfg) {} #endif /* CONFIG_CORESIGHT */ diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c index 479dc81993c2..8f6a50fe86dd 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -7,6 +7,7 @@ #include <linux/platform_device.h> #include "coresight-config.h" +#include "coresight-etm-perf.h" #include "coresight-syscfg.h" @@ -103,6 +104,7 @@ static int cscfg_add_dev_cfg(struct coresight_device *csdev, if (!dev_cfg) return -ENOMEM; dev_cfg->desc = cfg->desc;
}dev_cfg->id_hash = (unsigned long)cfg->ea->var; } dev_cfg->feats[dev_cfg->nr_feat++] = feat;
@@ -231,6 +233,11 @@ static int cscfg_load_config(struct cs_cfg_config_desc *cfg_desc) return -ENOMEM; cfg->desc = cfg_desc;
- /* add config name to perf event directory */
- err = etm_perf_add_symlink_cscfg(to_device_cscfg(), cfg);
- if (err)
return err;
- /* add config to any matching registered device */ err = cscfg_add_cfg_to_devs(cfg); if (err)
diff --git a/drivers/hwtracing/coresight/coresight-syscfg.h b/drivers/hwtracing/coresight/coresight-syscfg.h index 8ba800cc2e42..30dc12a7ecaa 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.h +++ b/drivers/hwtracing/coresight/coresight-syscfg.h @@ -48,10 +48,12 @@ struct cscfg_featlist_item {
- @desc: Descriptor for the configuration.
- @item: List entry.
*/
- @ea: Attribute for perf selection.
struct cs_cfg_config { const struct cs_cfg_config_desc *desc; struct list_head item;
- struct dev_ext_attribute *ea;
}; /** -- 2.17.1