Skip to content

Commit b575fc0

Browse files
ZideChen0Peter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Add domain global init callback
In the Intel uncore self-describing mechanism, the Global Control Register freeze_all bit is SoC-wide and propagates to all uncore PMUs. On Diamond Rapids, this bit is set at power-on, unlike some prior platforms. Add a global_init callback to unfreeze all PMON units. Signed-off-by: Zide Chen <zide.chen@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Link: https://patch.msgid.link/20251231224233.113839-7-zide.chen@intel.com
1 parent 66e2075 commit b575fc0

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

arch/x86/events/intel/uncore.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,21 @@ static int __init uncore_mmio_init(void)
16971697
return ret;
16981698
}
16991699

1700+
static int uncore_mmio_global_init(u64 ctl)
1701+
{
1702+
void __iomem *io_addr;
1703+
1704+
io_addr = ioremap(ctl, sizeof(ctl));
1705+
if (!io_addr)
1706+
return -ENOMEM;
1707+
1708+
/* Clear freeze bit (0) to enable all counters. */
1709+
writel(0, io_addr);
1710+
1711+
iounmap(io_addr);
1712+
return 0;
1713+
}
1714+
17001715
static const struct uncore_plat_init nhm_uncore_init __initconst = {
17011716
.cpu_init = nhm_uncore_cpu_init,
17021717
};
@@ -1839,6 +1854,7 @@ static const struct uncore_plat_init dmr_uncore_init __initconst = {
18391854
.domain[0].units_ignore = dmr_uncore_imh_units_ignore,
18401855
.domain[1].discovery_base = CBB_UNCORE_DISCOVERY_MSR,
18411856
.domain[1].units_ignore = dmr_uncore_cbb_units_ignore,
1857+
.domain[1].global_init = uncore_mmio_global_init,
18421858
};
18431859

18441860
static const struct uncore_plat_init generic_uncore_init __initconst = {

arch/x86/events/intel/uncore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct uncore_discovery_domain {
5151
/* MSR address or PCI device used as the discovery base */
5252
u32 discovery_base;
5353
bool base_is_pci;
54+
int (*global_init)(u64 ctl);
55+
5456
/* The units in the discovery table should be ignored. */
5557
int *units_ignore;
5658
};

arch/x86/events/intel/uncore_discovery.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ static int __parse_discovery_table(struct uncore_discovery_domain *domain,
286286
if (!io_addr)
287287
return -ENOMEM;
288288

289+
if (domain->global_init && domain->global_init(global.ctl))
290+
return -ENODEV;
291+
289292
/* Parsing Unit Discovery State */
290293
for (i = 0; i < global.max_units; i++) {
291294
memcpy_fromio(&unit, io_addr + (i + 1) * (global.stride * 8),

0 commit comments

Comments
 (0)