Skip to content

Commit b853040

Browse files
author
CKI KWF Bot
committed
Merge: perf/x86/intel/uncore: Add support for Panther Lake
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7453 JIRA: https://issues.redhat.com/browse/RHEL-47442 JIRA: https://issues.redhat.com/browse/RHEL-47456 This MR adds PTL support, but also adjusts discovery table mechanism to match its needs. Signed-off-by: Michael Petlan <mpetlan@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: ashelat <ashelat@redhat.com> Approved-by: jbrnak <jbrnak@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 2c141fa + 58e1ca3 commit b853040

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
@@ -1821,6 +1821,12 @@ static const struct intel_uncore_init_fun lnl_uncore_init __initconst = {
18211821
.mmio_init = lnl_uncore_mmio_init,
18221822
};
18231823

1824+
static const struct intel_uncore_init_fun ptl_uncore_init __initconst = {
1825+
.cpu_init = ptl_uncore_cpu_init,
1826+
.mmio_init = ptl_uncore_mmio_init,
1827+
.use_discovery = true,
1828+
};
1829+
18241830
static const struct intel_uncore_init_fun icx_uncore_init __initconst = {
18251831
.cpu_init = icx_uncore_cpu_init,
18261832
.pci_init = icx_uncore_pci_init,
@@ -1902,6 +1908,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {
19021908
X86_MATCH_VFM(INTEL_ARROWLAKE_U, &mtl_uncore_init),
19031909
X86_MATCH_VFM(INTEL_ARROWLAKE_H, &mtl_uncore_init),
19041910
X86_MATCH_VFM(INTEL_LUNARLAKE_M, &lnl_uncore_init),
1911+
X86_MATCH_VFM(INTEL_PANTHERLAKE_L, &ptl_uncore_init),
19051912
X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, &spr_uncore_init),
19061913
X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, &spr_uncore_init),
19071914
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
@@ -613,10 +613,12 @@ void tgl_uncore_cpu_init(void);
613613
void adl_uncore_cpu_init(void);
614614
void lnl_uncore_cpu_init(void);
615615
void mtl_uncore_cpu_init(void);
616+
void ptl_uncore_cpu_init(void);
616617
void tgl_uncore_mmio_init(void);
617618
void tgl_l_uncore_mmio_init(void);
618619
void adl_uncore_mmio_init(void);
619620
void lnl_uncore_mmio_init(void);
621+
void ptl_uncore_mmio_init(void);
620622
int snb_pci2phy_map_init(int devid);
621623

622624
/* uncore_snbep.c */

arch/x86/events/intel/uncore_discovery.c

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

276-
static int parse_discovery_table(struct pci_dev *dev, int die,
277-
u32 bar_offset, bool *parsed,
278-
int *ignore)
276+
static int __parse_discovery_table(resource_size_t addr, int die,
277+
bool *parsed, int *ignore)
279278
{
280279
struct uncore_global_discovery global;
281280
struct uncore_unit_discovery unit;
282281
void __iomem *io_addr;
283-
resource_size_t addr;
284282
unsigned long size;
285-
u32 val;
286283
int i;
287284

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

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

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

605652
addr = unit->addr;
606-
box->io_addr = ioremap(addr, UNCORE_GENERIC_MMIO_SIZE);
653+
box->io_addr = ioremap(addr, type->mmio_map_size);
607654
if (!box->io_addr) {
608655
pr_warn("Uncore type %d box %d: ioremap error for 0x%llx.\n",
609656
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
@@ -1854,3 +1854,82 @@ void lnl_uncore_mmio_init(void)
18541854
}
18551855

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

6500-
static struct intel_uncore_type **
6502+
struct intel_uncore_type **
65016503
uncore_get_uncores(enum uncore_access_type type_id, int num_extra,
65026504
struct intel_uncore_type **extra, int max_num_types,
65036505
struct intel_uncore_type **uncores)

0 commit comments

Comments
 (0)