perf/x86/uncore: Use u64 to replace unsigned for the uncore offsets array
authorKan Liang <kan.liang@linux.intel.com>
Fri, 17 Nov 2023 16:39:36 +0000 (08:39 -0800)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 24 Nov 2023 19:25:01 +0000 (20:25 +0100)
commitb560e0cd882b11921c84307efe139f1247434c5e
tree81cd5e73aa7dfb48892c141042aa22468b814242
parentcf35791476fcb3230b98a42241a56242d60ebdd3
perf/x86/uncore: Use u64 to replace unsigned for the uncore offsets array

The current perf doesn't save the complete address of an uncore unit.
The complete address of each unit is calculated by the base address +
offset. The type of the base address is u64, while the type of offset is
unsigned.
In the old platforms (without the discovery table method), the base
address and offset are hard coded in the driver. Perf can always use the
lowest address as the base address. Everything works well.

In the new platforms (starting from SPR), the discovery table provides
a complete address for all uncore units. To follow the current
framework/codes, when parsing the discovery table, the complete address
of the first box is stored as a base address. The offset of the
following units is calculated by the complete address of the unit minus
the base address (the address of the first unit). On GNR, the latter
units may have a lower address compared to the first unit. So the offset
is a negative value. The upper 32 bits are lost when casting a negative
u64 to an unsigned type.

Use u64 to replace unsigned for the uncore offsets array to correct the
above case. There is no functional change.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Ammy Yi <ammy.yi@intel.com>
Link: https://lore.kernel.org/r/20231117163939.2468007-2-kan.liang@linux.intel.com
arch/x86/events/intel/uncore.h
arch/x86/events/intel/uncore_discovery.c
arch/x86/events/intel/uncore_discovery.h
arch/x86/events/intel/uncore_nhmex.c
arch/x86/events/intel/uncore_snbep.c