Commit 65327833 authored by Alexander Antonov's avatar Alexander Antonov Committed by Peter Zijlstra
Browse files

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: bb42b3d3 ("perf/x86/intel/uncore: Expose an Uncore unit to IIO PMON mapping")
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>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221117122833.3103580-4-alexander.antonov@linux.intel.com
parent cee4eebd
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -3872,6 +3872,21 @@ static const struct attribute_group *skx_iio_attr_update[] = {
	NULL,
};

static void pmu_clear_mapping_attr(const struct attribute_group **groups,
				   struct attribute_group *ag)
{
	int i;

	for (i = 0; groups[i]; i++) {
		if (groups[i] == ag) {
			for (i++; groups[i]; i++)
				groups[i - 1] = groups[i];
			groups[i - 1] = NULL;
			break;
		}
	}
}

static int
pmu_set_mapping(struct intel_uncore_type *type, struct attribute_group *ag,
		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,
clear_topology:
	pmu_free_topology(type);
clear_attr_update:
	type->attr_update = NULL;
	pmu_clear_mapping_attr(type->attr_update, ag);
	return ret;
}