Skip to content

Commit b560e0c

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
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
1 parent cf35791 commit b560e0c

5 files changed

Lines changed: 11 additions & 10 deletions

File tree

arch/x86/events/intel/uncore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ struct intel_uncore_type {
7272
unsigned single_fixed:1;
7373
unsigned pair_ctr_ctl:1;
7474
union {
75-
unsigned *msr_offsets;
76-
unsigned *pci_offsets;
77-
unsigned *mmio_offsets;
75+
u64 *msr_offsets;
76+
u64 *pci_offsets;
77+
u64 *mmio_offsets;
7878
};
7979
unsigned *box_ids;
8080
struct event_constraint unconstrainted;

arch/x86/events/intel/uncore_discovery.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
125125
int die, bool parsed)
126126
{
127127
struct intel_uncore_discovery_type *type;
128-
unsigned int *box_offset, *ids;
128+
unsigned int *ids;
129+
u64 *box_offset;
129130
int i;
130131

131132
if (!unit->ctl || !unit->ctl_offset || !unit->ctr_offset) {
@@ -153,7 +154,7 @@ uncore_insert_box_info(struct uncore_unit_discovery *unit,
153154
if (!type)
154155
return;
155156

156-
box_offset = kcalloc(type->num_boxes + 1, sizeof(unsigned int), GFP_KERNEL);
157+
box_offset = kcalloc(type->num_boxes + 1, sizeof(u64), GFP_KERNEL);
157158
if (!box_offset)
158159
return;
159160

arch/x86/events/intel/uncore_discovery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct intel_uncore_discovery_type {
125125
u8 ctr_offset; /* Counter 0 offset */
126126
u16 num_boxes; /* number of boxes for the uncore block */
127127
unsigned int *ids; /* Box IDs */
128-
unsigned int *box_offset; /* Box offset */
128+
u64 *box_offset; /* Box offset */
129129
};
130130

131131
bool intel_uncore_has_discovery_tables(int *ignore);

arch/x86/events/intel/uncore_nhmex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static const struct attribute_group nhmex_uncore_cbox_format_group = {
306306
};
307307

308308
/* msr offset for each instance of cbox */
309-
static unsigned nhmex_cbox_msr_offsets[] = {
309+
static u64 nhmex_cbox_msr_offsets[] = {
310310
0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x240, 0x2c0,
311311
};
312312

arch/x86/events/intel/uncore_snbep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,7 +5278,7 @@ void snr_uncore_mmio_init(void)
52785278

52795279
/* ICX uncore support */
52805280

5281-
static unsigned icx_cha_msr_offsets[] = {
5281+
static u64 icx_cha_msr_offsets[] = {
52825282
0x2a0, 0x2ae, 0x2bc, 0x2ca, 0x2d8, 0x2e6, 0x2f4, 0x302, 0x310,
52835283
0x31e, 0x32c, 0x33a, 0x348, 0x356, 0x364, 0x372, 0x380, 0x38e,
52845284
0x3aa, 0x3b8, 0x3c6, 0x3d4, 0x3e2, 0x3f0, 0x3fe, 0x40c, 0x41a,
@@ -5326,7 +5326,7 @@ static struct intel_uncore_type icx_uncore_chabox = {
53265326
.format_group = &snr_uncore_chabox_format_group,
53275327
};
53285328

5329-
static unsigned icx_msr_offsets[] = {
5329+
static u64 icx_msr_offsets[] = {
53305330
0x0, 0x20, 0x40, 0x90, 0xb0, 0xd0,
53315331
};
53325332

@@ -6184,7 +6184,7 @@ static struct intel_uncore_type *spr_uncores[UNCORE_SPR_NUM_UNCORE_TYPES] = {
61846184
*/
61856185
#define SPR_UNCORE_UPI_NUM_BOXES 4
61866186

6187-
static unsigned int spr_upi_pci_offsets[SPR_UNCORE_UPI_NUM_BOXES] = {
6187+
static u64 spr_upi_pci_offsets[SPR_UNCORE_UPI_NUM_BOXES] = {
61886188
0, 0x8000, 0x10000, 0x18000
61896189
};
61906190

0 commit comments

Comments
 (0)