Skip to content

Commit bcb48dd

Browse files
committed
Merge tag 'perf-core-2025-07-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 performance events updates from Ingo Molnar: "Intel uncore driver enhancements (Kan Liang): - Support MSR portal for discovery tables - Support customized MMIO map size - Add Panther Lake support - Add IMC freerunning support for Panther Lake" * tag 'perf-core-2025-07-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel/uncore: Add iMC freerunning for Panther Lake perf/x86/intel/uncore: Add Panther Lake support perf/x86/intel/uncore: Support customized MMIO map size perf/x86/intel/uncore: Support MSR portal for discovery tables
2 parents bf76f23 + 829f5a6 commit bcb48dd

File tree

6 files changed

+166
-22
lines changed

6 files changed

+166
-22
lines changed

arch/x86/events/intel/uncore.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,12 @@ static const struct intel_uncore_init_fun lnl_uncore_init __initconst = {
18071807
.mmio_init = lnl_uncore_mmio_init,
18081808
};
18091809

1810+
static const struct intel_uncore_init_fun ptl_uncore_init __initconst = {
1811+
.cpu_init = ptl_uncore_cpu_init,
1812+
.mmio_init = ptl_uncore_mmio_init,
1813+
.use_discovery = true,
1814+
};
1815+
18101816
static const struct intel_uncore_init_fun icx_uncore_init __initconst = {
18111817
.cpu_init = icx_uncore_cpu_init,
18121818
.pci_init = icx_uncore_pci_init,
@@ -1888,6 +1894,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
18881894
X86_MATCH_VFM(INTEL_ARROWLAKE_U, &mtl_uncore_init),
18891895
X86_MATCH_VFM(INTEL_ARROWLAKE_H, &mtl_uncore_init),
18901896
X86_MATCH_VFM(INTEL_LUNARLAKE_M, &lnl_uncore_init),
1897+
X86_MATCH_VFM(INTEL_PANTHERLAKE_L, &ptl_uncore_init),
18911898
X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, &spr_uncore_init),
18921899
X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, &spr_uncore_init),
18931900
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, &gnr_uncore_init),

arch/x86/events/intel/uncore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,12 @@ void tgl_uncore_cpu_init(void);
612612
void adl_uncore_cpu_init(void);
613613
void lnl_uncore_cpu_init(void);
614614
void mtl_uncore_cpu_init(void);
615+
void ptl_uncore_cpu_init(void);
615616
void tgl_uncore_mmio_init(void);
616617
void tgl_l_uncore_mmio_init(void);
617618
void adl_uncore_mmio_init(void);
618619
void lnl_uncore_mmio_init(void);
620+
void ptl_uncore_mmio_init(void);
619621
int snb_pci2phy_map_init(int devid);
620622

621623
/* uncore_snbep.c */

arch/x86/events/intel/uncore_discovery.c

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,32 +274,15 @@ uncore_ignore_unit(struct uncore_unit_discovery *unit, int *ignore)
274274
return false;
275275
}
276276

277-
static int parse_discovery_table(struct pci_dev *dev, int die,
278-
u32 bar_offset, bool *parsed,
279-
int *ignore)
277+
static int __parse_discovery_table(resource_size_t addr, int die,
278+
bool *parsed, int *ignore)
280279
{
281280
struct uncore_global_discovery global;
282281
struct uncore_unit_discovery unit;
283282
void __iomem *io_addr;
284-
resource_size_t addr;
285283
unsigned long size;
286-
u32 val;
287284
int i;
288285

289-
pci_read_config_dword(dev, bar_offset, &val);
290-
291-
if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
292-
return -EINVAL;
293-
294-
addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
295-
#ifdef CONFIG_PHYS_ADDR_T_64BIT
296-
if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
297-
u32 val2;
298-
299-
pci_read_config_dword(dev, bar_offset + 4, &val2);
300-
addr |= ((resource_size_t)val2) << 32;
301-
}
302-
#endif
303286
size = UNCORE_DISCOVERY_GLOBAL_MAP_SIZE;
304287
io_addr = ioremap(addr, size);
305288
if (!io_addr)
@@ -342,7 +325,32 @@ static int parse_discovery_table(struct pci_dev *dev, int die,
342325
return 0;
343326
}
344327

345-
bool intel_uncore_has_discovery_tables(int *ignore)
328+
static int parse_discovery_table(struct pci_dev *dev, int die,
329+
u32 bar_offset, bool *parsed,
330+
int *ignore)
331+
{
332+
resource_size_t addr;
333+
u32 val;
334+
335+
pci_read_config_dword(dev, bar_offset, &val);
336+
337+
if (val & ~PCI_BASE_ADDRESS_MEM_MASK & ~PCI_BASE_ADDRESS_MEM_TYPE_64)
338+
return -EINVAL;
339+
340+
addr = (resource_size_t)(val & PCI_BASE_ADDRESS_MEM_MASK);
341+
#ifdef CONFIG_PHYS_ADDR_T_64BIT
342+
if ((val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
343+
u32 val2;
344+
345+
pci_read_config_dword(dev, bar_offset + 4, &val2);
346+
addr |= ((resource_size_t)val2) << 32;
347+
}
348+
#endif
349+
350+
return __parse_discovery_table(addr, die, parsed, ignore);
351+
}
352+
353+
static bool intel_uncore_has_discovery_tables_pci(int *ignore)
346354
{
347355
u32 device, val, entry_id, bar_offset;
348356
int die, dvsec = 0, ret = true;
@@ -391,6 +399,45 @@ bool intel_uncore_has_discovery_tables(int *ignore)
391399
return ret;
392400
}
393401

402+
static bool intel_uncore_has_discovery_tables_msr(int *ignore)
403+
{
404+
unsigned long *die_mask;
405+
bool parsed = false;
406+
int cpu, die;
407+
u64 base;
408+
409+
die_mask = kcalloc(BITS_TO_LONGS(uncore_max_dies()),
410+
sizeof(unsigned long), GFP_KERNEL);
411+
if (!die_mask)
412+
return false;
413+
414+
cpus_read_lock();
415+
for_each_online_cpu(cpu) {
416+
die = topology_logical_die_id(cpu);
417+
if (__test_and_set_bit(die, die_mask))
418+
continue;
419+
420+
if (rdmsrq_safe_on_cpu(cpu, UNCORE_DISCOVERY_MSR, &base))
421+
continue;
422+
423+
if (!base)
424+
continue;
425+
426+
__parse_discovery_table(base, die, &parsed, ignore);
427+
}
428+
429+
cpus_read_unlock();
430+
431+
kfree(die_mask);
432+
return parsed;
433+
}
434+
435+
bool intel_uncore_has_discovery_tables(int *ignore)
436+
{
437+
return intel_uncore_has_discovery_tables_msr(ignore) ||
438+
intel_uncore_has_discovery_tables_pci(ignore);
439+
}
440+
394441
void intel_uncore_clear_discovery_tables(void)
395442
{
396443
struct intel_uncore_discovery_type *type, *next;
@@ -604,7 +651,7 @@ void intel_generic_uncore_mmio_init_box(struct intel_uncore_box *box)
604651
}
605652

606653
addr = unit->addr;
607-
box->io_addr = ioremap(addr, UNCORE_GENERIC_MMIO_SIZE);
654+
box->io_addr = ioremap(addr, type->mmio_map_size);
608655
if (!box->io_addr) {
609656
pr_warn("Uncore type %d box %d: ioremap error for 0x%llx.\n",
610657
type->type_id, unit->id, (unsigned long long)addr);

arch/x86/events/intel/uncore_discovery.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22

3+
/* Store the full address of the global discovery table */
4+
#define UNCORE_DISCOVERY_MSR 0x201e
5+
36
/* Generic device ID of a discovery table device */
47
#define UNCORE_DISCOVERY_TABLE_DEVICE 0x09a7
58
/* Capability ID for a discovery table device */
@@ -168,3 +171,7 @@ bool intel_generic_uncore_assign_hw_event(struct perf_event *event,
168171
struct intel_uncore_box *box);
169172
void uncore_find_add_unit(struct intel_uncore_discovery_unit *node,
170173
struct rb_root *root, u16 *num_units);
174+
struct intel_uncore_type **
175+
uncore_get_uncores(enum uncore_access_type type_id, int num_extra,
176+
struct intel_uncore_type **extra, int max_num_types,
177+
struct intel_uncore_type **uncores);

arch/x86/events/intel/uncore_snb.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,3 +1855,82 @@ void lnl_uncore_mmio_init(void)
18551855
}
18561856

18571857
/* end of Lunar Lake MMIO uncore support */
1858+
1859+
/* Panther Lake uncore support */
1860+
1861+
#define UNCORE_PTL_MAX_NUM_UNCORE_TYPES 42
1862+
#define UNCORE_PTL_TYPE_IMC 6
1863+
#define UNCORE_PTL_TYPE_SNCU 34
1864+
#define UNCORE_PTL_TYPE_HBO 41
1865+
1866+
#define PTL_UNCORE_GLOBAL_CTL_OFFSET 0x380
1867+
1868+
static struct intel_uncore_type ptl_uncore_imc = {
1869+
.name = "imc",
1870+
.mmio_map_size = 0xf00,
1871+
};
1872+
1873+
static void ptl_uncore_sncu_init_box(struct intel_uncore_box *box)
1874+
{
1875+
intel_generic_uncore_mmio_init_box(box);
1876+
1877+
/* Clear the global freeze bit */
1878+
if (box->io_addr)
1879+
writel(0, box->io_addr + PTL_UNCORE_GLOBAL_CTL_OFFSET);
1880+
}
1881+
1882+
static struct intel_uncore_ops ptl_uncore_sncu_ops = {
1883+
.init_box = ptl_uncore_sncu_init_box,
1884+
.exit_box = uncore_mmio_exit_box,
1885+
.disable_box = intel_generic_uncore_mmio_disable_box,
1886+
.enable_box = intel_generic_uncore_mmio_enable_box,
1887+
.disable_event = intel_generic_uncore_mmio_disable_event,
1888+
.enable_event = intel_generic_uncore_mmio_enable_event,
1889+
.read_counter = uncore_mmio_read_counter,
1890+
};
1891+
1892+
static struct intel_uncore_type ptl_uncore_sncu = {
1893+
.name = "sncu",
1894+
.ops = &ptl_uncore_sncu_ops,
1895+
.mmio_map_size = 0xf00,
1896+
};
1897+
1898+
static struct intel_uncore_type ptl_uncore_hbo = {
1899+
.name = "hbo",
1900+
.mmio_map_size = 0xf00,
1901+
};
1902+
1903+
static struct intel_uncore_type *ptl_uncores[UNCORE_PTL_MAX_NUM_UNCORE_TYPES] = {
1904+
[UNCORE_PTL_TYPE_IMC] = &ptl_uncore_imc,
1905+
[UNCORE_PTL_TYPE_SNCU] = &ptl_uncore_sncu,
1906+
[UNCORE_PTL_TYPE_HBO] = &ptl_uncore_hbo,
1907+
};
1908+
1909+
#define UNCORE_PTL_MMIO_EXTRA_UNCORES 1
1910+
1911+
static struct intel_uncore_type *ptl_mmio_extra_uncores[UNCORE_PTL_MMIO_EXTRA_UNCORES] = {
1912+
&adl_uncore_imc_free_running,
1913+
};
1914+
1915+
void ptl_uncore_mmio_init(void)
1916+
{
1917+
uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO,
1918+
UNCORE_PTL_MMIO_EXTRA_UNCORES,
1919+
ptl_mmio_extra_uncores,
1920+
UNCORE_PTL_MAX_NUM_UNCORE_TYPES,
1921+
ptl_uncores);
1922+
}
1923+
1924+
static struct intel_uncore_type *ptl_msr_uncores[] = {
1925+
&mtl_uncore_cbox,
1926+
NULL
1927+
};
1928+
1929+
void ptl_uncore_cpu_init(void)
1930+
{
1931+
mtl_uncore_cbox.num_boxes = 6;
1932+
mtl_uncore_cbox.ops = &lnl_uncore_msr_ops;
1933+
uncore_msr_uncores = ptl_msr_uncores;
1934+
}
1935+
1936+
/* end of Panther Lake uncore support */

arch/x86/events/intel/uncore_snbep.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6409,9 +6409,11 @@ static void uncore_type_customized_copy(struct intel_uncore_type *to_type,
64096409
to_type->get_topology = from_type->get_topology;
64106410
if (from_type->cleanup_mapping)
64116411
to_type->cleanup_mapping = from_type->cleanup_mapping;
6412+
if (from_type->mmio_map_size)
6413+
to_type->mmio_map_size = from_type->mmio_map_size;
64126414
}
64136415

6414-
static struct intel_uncore_type **
6416+
struct intel_uncore_type **
64156417
uncore_get_uncores(enum uncore_access_type type_id, int num_extra,
64166418
struct intel_uncore_type **extra, int max_num_types,
64176419
struct intel_uncore_type **uncores)

0 commit comments

Comments
 (0)