Commit f471fac7 authored by Alexander Antonov's avatar Alexander Antonov Committed by Peter Zijlstra

perf/x86/intel/uncore: Generalize I/O stacks to PMON mapping procedure

Currently I/O stacks to IIO PMON mapping is available on Skylake servers
only and need to make code more general to easily enable further platforms.
So, introduce get_topology() callback in struct intel_uncore_type which
allows to move common code to separate function and make mapping procedure
more general.
Signed-off-by: default avatarAlexander Antonov <alexander.antonov@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Link: https://lkml.kernel.org/r/20210426131614.16205-2-alexander.antonov@linux.intel.com
parent 440e9067
...@@ -92,6 +92,7 @@ struct intel_uncore_type { ...@@ -92,6 +92,7 @@ struct intel_uncore_type {
/* /*
* Optional callbacks for managing mapping of Uncore units to PMONs * Optional callbacks for managing mapping of Uncore units to PMONs
*/ */
int (*get_topology)(struct intel_uncore_type *type);
int (*set_mapping)(struct intel_uncore_type *type); int (*set_mapping)(struct intel_uncore_type *type);
void (*cleanup_mapping)(struct intel_uncore_type *type); void (*cleanup_mapping)(struct intel_uncore_type *type);
}; };
......
...@@ -3680,12 +3680,19 @@ static inline u8 skx_iio_stack(struct intel_uncore_pmu *pmu, int die) ...@@ -3680,12 +3680,19 @@ static inline u8 skx_iio_stack(struct intel_uncore_pmu *pmu, int die)
} }
static umode_t static umode_t
skx_iio_mapping_visible(struct kobject *kobj, struct attribute *attr, int die) pmu_iio_mapping_visible(struct kobject *kobj, struct attribute *attr,
int die, int zero_bus_pmu)
{ {
struct intel_uncore_pmu *pmu = dev_to_uncore_pmu(kobj_to_dev(kobj)); struct intel_uncore_pmu *pmu = dev_to_uncore_pmu(kobj_to_dev(kobj));
/* Root bus 0x00 is valid only for die 0 AND pmu_idx = 0. */ return (!skx_iio_stack(pmu, die) && pmu->pmu_idx != zero_bus_pmu) ? 0 : attr->mode;
return (!skx_iio_stack(pmu, die) && pmu->pmu_idx) ? 0 : attr->mode; }
static umode_t
skx_iio_mapping_visible(struct kobject *kobj, struct attribute *attr, int die)
{
/* Root bus 0x00 is valid only for pmu_idx = 0. */
return pmu_iio_mapping_visible(kobj, attr, die, 0);
} }
static ssize_t skx_iio_mapping_show(struct device *dev, static ssize_t skx_iio_mapping_show(struct device *dev,
...@@ -3770,7 +3777,8 @@ static const struct attribute_group *skx_iio_attr_update[] = { ...@@ -3770,7 +3777,8 @@ static const struct attribute_group *skx_iio_attr_update[] = {
NULL, NULL,
}; };
static int skx_iio_set_mapping(struct intel_uncore_type *type) static int
pmu_iio_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag)
{ {
char buf[64]; char buf[64];
int ret; int ret;
...@@ -3778,7 +3786,7 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) ...@@ -3778,7 +3786,7 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
struct attribute **attrs = NULL; struct attribute **attrs = NULL;
struct dev_ext_attribute *eas = NULL; struct dev_ext_attribute *eas = NULL;
ret = skx_iio_get_topology(type); ret = type->get_topology(type);
if (ret < 0) if (ret < 0)
goto clear_attr_update; goto clear_attr_update;
...@@ -3805,7 +3813,7 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) ...@@ -3805,7 +3813,7 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
eas[die].var = (void *)die; eas[die].var = (void *)die;
attrs[die] = &eas[die].attr.attr; attrs[die] = &eas[die].attr.attr;
} }
skx_iio_mapping_group.attrs = attrs; ag->attrs = attrs;
return 0; return 0;
err: err:
...@@ -3819,6 +3827,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type) ...@@ -3819,6 +3827,11 @@ static int skx_iio_set_mapping(struct intel_uncore_type *type)
return ret; return ret;
} }
static int skx_iio_set_mapping(struct intel_uncore_type *type)
{
return pmu_iio_set_mapping(type, &skx_iio_mapping_group);
}
static void skx_iio_cleanup_mapping(struct intel_uncore_type *type) static void skx_iio_cleanup_mapping(struct intel_uncore_type *type)
{ {
struct attribute **attr = skx_iio_mapping_group.attrs; struct attribute **attr = skx_iio_mapping_group.attrs;
...@@ -3849,6 +3862,7 @@ static struct intel_uncore_type skx_uncore_iio = { ...@@ -3849,6 +3862,7 @@ static struct intel_uncore_type skx_uncore_iio = {
.ops = &skx_uncore_iio_ops, .ops = &skx_uncore_iio_ops,
.format_group = &skx_uncore_iio_format_group, .format_group = &skx_uncore_iio_format_group,
.attr_update = skx_iio_attr_update, .attr_update = skx_iio_attr_update,
.get_topology = skx_iio_get_topology,
.set_mapping = skx_iio_set_mapping, .set_mapping = skx_iio_set_mapping,
.cleanup_mapping = skx_iio_cleanup_mapping, .cleanup_mapping = skx_iio_cleanup_mapping,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment