Skip to content

Commit c919577

Browse files
committed
Merge tag 'perf-urgent-2026-04-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "Four Intel uncore PMU driver fixes by Zide Chen" * tag 'perf-urgent-2026-04-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel/uncore: Remove extra double quote mark perf/x86/intel/uncore: Fix die ID init and look up bugs perf/x86/intel/uncore: Skip discovery table for offline dies perf/x86/intel/uncore: Fix iounmap() leak on global_init failure
2 parents 8648ac8 + 16bcbe6 commit c919577

3 files changed

Lines changed: 42 additions & 37 deletions

File tree

arch/x86/events/intel/uncore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ int uncore_die_to_segment(int die)
6767
return bus ? pci_domain_nr(bus) : -EINVAL;
6868
}
6969

70+
/* Note: This API can only be used when NUMA information is available. */
7071
int uncore_device_to_die(struct pci_dev *dev)
7172
{
7273
int node = pcibus_to_node(dev->bus);

arch/x86/events/intel/uncore_discovery.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ static int __parse_discovery_table(struct uncore_discovery_domain *domain,
264264
struct uncore_unit_discovery unit;
265265
void __iomem *io_addr;
266266
unsigned long size;
267+
int ret = 0;
267268
int i;
268269

269270
size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
@@ -273,21 +274,23 @@ static int __parse_discovery_table(struct uncore_discovery_domain *domain,
273274

274275
/* Read Global Discovery State */
275276
memcpy_fromio(&global, io_addr, sizeof(struct uncore_global_discovery));
277+
iounmap(io_addr);
278+
276279
if (uncore_discovery_invalid_unit(global)) {
277280
pr_info("Invalid Global Discovery State: 0x%llx 0x%llx 0x%llx\n",
278281
global.table1, global.ctl, global.table3);
279-
iounmap(io_addr);
280282
return -EINVAL;
281283
}
282-
iounmap(io_addr);
283284

284285
size = (1 + global.max_units) * global.stride * 8;
285286
io_addr = ioremap(addr, size);
286287
if (!io_addr)
287288
return -ENOMEM;
288289

289-
if (domain->global_init && domain->global_init(global.ctl))
290-
return -ENODEV;
290+
if (domain->global_init && domain->global_init(global.ctl)) {
291+
ret = -ENODEV;
292+
goto out;
293+
}
291294

292295
/* Parsing Unit Discovery State */
293296
for (i = 0; i < global.max_units; i++) {
@@ -307,8 +310,10 @@ static int __parse_discovery_table(struct uncore_discovery_domain *domain,
307310
}
308311

309312
*parsed = true;
313+
314+
out:
310315
iounmap(io_addr);
311-
return 0;
316+
return ret;
312317
}
313318

314319
static int parse_discovery_table(struct uncore_discovery_domain *domain,
@@ -366,7 +371,7 @@ static bool uncore_discovery_pci(struct uncore_discovery_domain *domain)
366371
(val & UNCORE_DISCOVERY_DVSEC2_BIR_MASK) * UNCORE_DISCOVERY_BIR_STEP;
367372

368373
die = get_device_die_id(dev);
369-
if (die < 0)
374+
if ((die < 0) || (die >= uncore_max_dies()))
370375
continue;
371376

372377
parse_discovery_table(domain, dev, die, bar_offset, &parsed);

arch/x86/events/intel/uncore_snbep.c

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,7 @@ static int snbep_pci2phy_map_init(int devid, int nodeid_loc, int idmap_loc, bool
14591459
}
14601460

14611461
map->pbus_to_dieid[bus] = die_id = uncore_device_to_die(ubox_dev);
1462-
14631462
raw_spin_unlock(&pci2phy_map_lock);
1464-
1465-
if (WARN_ON_ONCE(die_id == -1)) {
1466-
err = -EINVAL;
1467-
break;
1468-
}
14691463
}
14701464
}
14711465

@@ -6420,7 +6414,7 @@ static void spr_update_device_location(int type_id)
64206414

64216415
while ((dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, dev)) != NULL) {
64226416

6423-
die = uncore_device_to_die(dev);
6417+
die = uncore_pcibus_to_dieid(dev->bus);
64246418
if (die < 0)
64256419
continue;
64266420

@@ -6444,6 +6438,11 @@ static void spr_update_device_location(int type_id)
64446438

64456439
int spr_uncore_pci_init(void)
64466440
{
6441+
int ret = snbep_pci2phy_map_init(0x3250, SKX_CPUNODEID, SKX_GIDNIDMAP, true);
6442+
6443+
if (ret)
6444+
return ret;
6445+
64476446
/*
64486447
* The discovery table of UPI on some SPR variant is broken,
64496448
* which impacts the detection of both UPI and M3UPI uncore PMON.
@@ -6935,34 +6934,34 @@ static struct freerunning_counters dmr_iio_freerunning[] = {
69356934

69366935
static struct uncore_event_desc dmr_uncore_iio_freerunning_events[] = {
69376936
/* ITC Free Running Data BW counter for inbound traffic */
6938-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port0, 0x10, "3.814697266e-6"),
6939-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port1, 0x11, "3.814697266e-6"),
6940-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port2, 0x12, "3.814697266e-6"),
6941-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port3, 0x13, "3.814697266e-6"),
6942-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port4, 0x14, "3.814697266e-6"),
6943-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port5, 0x15, "3.814697266e-6"),
6944-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port6, 0x16, "3.814697266e-6"),
6945-
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port7, 0x17, "3.814697266e-6"),
6937+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port0, 0x10, 3.814697266e-6),
6938+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port1, 0x11, 3.814697266e-6),
6939+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port2, 0x12, 3.814697266e-6),
6940+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port3, 0x13, 3.814697266e-6),
6941+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port4, 0x14, 3.814697266e-6),
6942+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port5, 0x15, 3.814697266e-6),
6943+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port6, 0x16, 3.814697266e-6),
6944+
INTEL_UNCORE_FR_EVENT_DESC(inb_data_port7, 0x17, 3.814697266e-6),
69466945

69476946
/* ITC Free Running BW IN counters */
6948-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port0, 0x20, "3.814697266e-6"),
6949-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port1, 0x21, "3.814697266e-6"),
6950-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port2, 0x22, "3.814697266e-6"),
6951-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port3, 0x23, "3.814697266e-6"),
6952-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port4, 0x24, "3.814697266e-6"),
6953-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port5, 0x25, "3.814697266e-6"),
6954-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port6, 0x26, "3.814697266e-6"),
6955-
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port7, 0x27, "3.814697266e-6"),
6947+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port0, 0x20, 3.814697266e-6),
6948+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port1, 0x21, 3.814697266e-6),
6949+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port2, 0x22, 3.814697266e-6),
6950+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port3, 0x23, 3.814697266e-6),
6951+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port4, 0x24, 3.814697266e-6),
6952+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port5, 0x25, 3.814697266e-6),
6953+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port6, 0x26, 3.814697266e-6),
6954+
INTEL_UNCORE_FR_EVENT_DESC(bw_in_port7, 0x27, 3.814697266e-6),
69566955

69576956
/* ITC Free Running BW OUT counters */
6958-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port0, 0x30, "3.814697266e-6"),
6959-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port1, 0x31, "3.814697266e-6"),
6960-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port2, 0x32, "3.814697266e-6"),
6961-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port3, 0x33, "3.814697266e-6"),
6962-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port4, 0x34, "3.814697266e-6"),
6963-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port5, 0x35, "3.814697266e-6"),
6964-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port6, 0x36, "3.814697266e-6"),
6965-
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port7, 0x37, "3.814697266e-6"),
6957+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port0, 0x30, 3.814697266e-6),
6958+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port1, 0x31, 3.814697266e-6),
6959+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port2, 0x32, 3.814697266e-6),
6960+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port3, 0x33, 3.814697266e-6),
6961+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port4, 0x34, 3.814697266e-6),
6962+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port5, 0x35, 3.814697266e-6),
6963+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port6, 0x36, 3.814697266e-6),
6964+
INTEL_UNCORE_FR_EVENT_DESC(bw_out_port7, 0x37, 3.814697266e-6),
69666965

69676966
/* Free Running Clock Counter */
69686967
INTEL_UNCORE_EVENT_DESC(clockticks, "event=0xff,umask=0x40"),

0 commit comments

Comments
 (0)