Skip to content

Commit 07813e2

Browse files
Alexander AntonovPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Generalize get_topology() for SKX PMUs
Factor out a generic code from skx_iio_get_topology() to skx_pmu_get_topology() to avoid code duplication. This code will be used by get_topology() procedure for SKX UPI PMUs in the further patch. Signed-off-by: Alexander Antonov <alexander.antonov@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Link: https://lore.kernel.org/r/20221117122833.3103580-6-alexander.antonov@linux.intel.com
1 parent efe0627 commit 07813e2

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

arch/x86/events/intel/uncore_snbep.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,32 +3837,50 @@ static void pmu_free_topology(struct intel_uncore_type *type)
38373837
}
38383838
}
38393839

3840-
static int skx_iio_get_topology(struct intel_uncore_type *type)
3840+
static int skx_pmu_get_topology(struct intel_uncore_type *type,
3841+
int (*topology_cb)(struct intel_uncore_type*, int, int, u64))
38413842
{
38423843
int die, ret = -EPERM;
3843-
u64 configuration;
3844-
int idx;
3844+
u64 cpu_bus_msr;
38453845

38463846
for (die = 0; die < uncore_max_dies(); die++) {
3847-
ret = skx_msr_cpu_bus_read(die_to_cpu(die), &configuration);
3847+
ret = skx_msr_cpu_bus_read(die_to_cpu(die), &cpu_bus_msr);
38483848
if (ret)
38493849
break;
38503850

38513851
ret = uncore_die_to_segment(die);
38523852
if (ret < 0)
38533853
break;
38543854

3855-
for (idx = 0; idx < type->num_boxes; idx++) {
3856-
type->topology[die][idx].pmu_idx = idx;
3857-
type->topology[die][idx].iio->segment = ret;
3858-
type->topology[die][idx].iio->pci_bus_no =
3859-
(configuration >> (idx * BUS_NUM_STRIDE)) & 0xff;
3860-
}
3855+
ret = topology_cb(type, ret, die, cpu_bus_msr);
3856+
if (ret)
3857+
break;
38613858
}
38623859

38633860
return ret;
38643861
}
38653862

3863+
static int skx_iio_topology_cb(struct intel_uncore_type *type, int segment,
3864+
int die, u64 cpu_bus_msr)
3865+
{
3866+
int idx;
3867+
struct intel_uncore_topology *t;
3868+
3869+
for (idx = 0; idx < type->num_boxes; idx++) {
3870+
t = &type->topology[die][idx];
3871+
t->pmu_idx = idx;
3872+
t->iio->segment = segment;
3873+
t->iio->pci_bus_no = (cpu_bus_msr >> (idx * BUS_NUM_STRIDE)) & 0xff;
3874+
}
3875+
3876+
return 0;
3877+
}
3878+
3879+
static int skx_iio_get_topology(struct intel_uncore_type *type)
3880+
{
3881+
return skx_pmu_get_topology(type, skx_iio_topology_cb);
3882+
}
3883+
38663884
static struct attribute_group skx_iio_mapping_group = {
38673885
.is_visible = skx_iio_mapping_visible,
38683886
};

0 commit comments

Comments
 (0)