Skip to content

Commit 6532783

Browse files
Alexander AntonovPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Clear attr_update properly
Current clear_attr_update procedure in pmu_set_mapping() sets attr_update field in NULL that is not correct because intel_uncore_type pmu types can contain several groups in attr_update field. For example, SPR platform already has uncore_alias_group to update and then UPI topology group will be added in next patches. Fix current behavior and clear attr_update group related to mapping only. Fixes: bb42b3d ("perf/x86/intel/uncore: Expose an Uncore unit to IIO PMON mapping") 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> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20221117122833.3103580-4-alexander.antonov@linux.intel.com
1 parent cee4eeb commit 6532783

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

arch/x86/events/intel/uncore_snbep.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3872,6 +3872,21 @@ static const struct attribute_group *skx_iio_attr_update[] = {
38723872
NULL,
38733873
};
38743874

3875+
static void pmu_clear_mapping_attr(const struct attribute_group **groups,
3876+
struct attribute_group *ag)
3877+
{
3878+
int i;
3879+
3880+
for (i = 0; groups[i]; i++) {
3881+
if (groups[i] == ag) {
3882+
for (i++; groups[i]; i++)
3883+
groups[i - 1] = groups[i];
3884+
groups[i - 1] = NULL;
3885+
break;
3886+
}
3887+
}
3888+
}
3889+
38753890
static int
38763891
pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag,
38773892
ssize_t (*show)(struct device*, struct device_attribute*, char*),
@@ -3926,7 +3941,7 @@ pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag,
39263941
clear_topology:
39273942
pmu_free_topology(type);
39283943
clear_attr_update:
3929-
type->attr_update = NULL;
3944+
pmu_clear_mapping_attr(type->attr_update, ag);
39303945
return ret;
39313946
}
39323947

0 commit comments

Comments
 (0)