[PATCH 05/12] perf/x86/intel/uncore: Drop spr_uncore_mmio_ops for generic MMIO

From: Zide Chen

Date: Fri Dec 04 2026 - 22:34:43 EST


Under the discovery PMON architecture, programmable counters count as
long as the box is unfrozen via the box control register and a valid
event encoding is programmed.

However, fixed counters have no event select or unit mask fields, and
require the enable bit (GENERIC_PMON_CTL_EN, bit 22) to be set to
start counting.

Move fixed counter handling into intel_generic_uncore_mmio_enable_event(),
making spr_uncore_mmio_enable_event() and spr_uncore_mmio_ops redundant.
Because GENERIC_PMON_CTL_EN is the same bit (bit 22) as SNBEP_PMON_CTL_EN,
IMC types behave exactly as before. Drop spr_uncore_mmio_ops and let IMC
types inherit generic MMIO ops from discovery.

No functional change intended.

Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
---
arch/x86/events/intel/uncore_discovery.c | 5 +++++
arch/x86/events/intel/uncore_discovery.h | 1 +
arch/x86/events/intel/uncore_snbep.c | 28 +-----------------------
3 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/arch/x86/events/intel/uncore_discovery.c b/arch/x86/events/intel/uncore_discovery.c
index 75fd3e52c540..979d3da466e3 100644
--- a/arch/x86/events/intel/uncore_discovery.c
+++ b/arch/x86/events/intel/uncore_discovery.c
@@ -703,6 +703,11 @@ void intel_generic_uncore_mmio_enable_event(struct intel_uncore_box *box,
if (!box->io_addr)
return;

+ if (uncore_pmc_fixed(hwc->idx)) {
+ writel(GENERIC_PMON_CTL_EN, box->io_addr + hwc->config_base);
+ return;
+ }
+
writel(hwc->config, box->io_addr + hwc->config_base);
}

diff --git a/arch/x86/events/intel/uncore_discovery.h b/arch/x86/events/intel/uncore_discovery.h
index 142e1b56cfc2..58746f9868a7 100644
--- a/arch/x86/events/intel/uncore_discovery.h
+++ b/arch/x86/events/intel/uncore_discovery.h
@@ -50,6 +50,7 @@
#define GENERIC_PMON_CTL_EV_SEL_MASK 0x000000ff
#define GENERIC_PMON_CTL_UMASK_MASK 0x0000ff00
#define GENERIC_PMON_CTL_EDGE_DET (1 << 18)
+#define GENERIC_PMON_CTL_EN (1 << 22)
#define GENERIC_PMON_CTL_INVERT (1 << 23)
#define GENERIC_PMON_CTL_TRESH_MASK 0xff000000
#define GENERIC_PMON_RAW_EVENT_MASK (GENERIC_PMON_CTL_EV_SEL_MASK | \
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index e73c028c9415..9e164beb32c5 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -5915,30 +5915,6 @@ static struct intel_uncore_type spr_uncore_pcu = {
.attr_update = uncore_alias_groups,
};

-static void spr_uncore_mmio_enable_event(struct intel_uncore_box *box,
- struct perf_event *event)
-{
- struct hw_perf_event *hwc = &event->hw;
-
- if (!box->io_addr)
- return;
-
- if (uncore_pmc_fixed(hwc->idx))
- writel(SNBEP_PMON_CTL_EN, box->io_addr + hwc->config_base);
- else
- writel(hwc->config, box->io_addr + hwc->config_base);
-}
-
-static struct intel_uncore_ops spr_uncore_mmio_ops = {
- .init_box = intel_generic_uncore_mmio_init_box,
- .exit_box = uncore_mmio_exit_box,
- .disable_box = intel_generic_uncore_mmio_disable_box,
- .enable_box = intel_generic_uncore_mmio_enable_box,
- .disable_event = intel_generic_uncore_mmio_disable_event,
- .enable_event = spr_uncore_mmio_enable_event,
- .read_counter = uncore_mmio_read_counter,
-};
-
static struct uncore_event_desc spr_uncore_imc_events[] = {
INTEL_UNCORE_EVENT_DESC(clockticks, "event=0x01,umask=0x00"),
INTEL_UNCORE_EVENT_DESC(cas_count_read, "event=0x05,umask=0xcf"),
@@ -5951,8 +5927,7 @@ static struct uncore_event_desc spr_uncore_imc_events[] = {
};

#define SPR_UNCORE_MMIO_COMMON_FORMAT() \
- SPR_UNCORE_COMMON_FORMAT(), \
- .ops = &spr_uncore_mmio_ops
+ SPR_UNCORE_COMMON_FORMAT()

static struct intel_uncore_type spr_uncore_imc = {
SPR_UNCORE_MMIO_COMMON_FORMAT(),
@@ -6639,7 +6614,6 @@ static struct intel_uncore_type dmr_uncore_imc = {
.fixed_ctr_bits = 48,
.fixed_ctr = DMR_IMC_PMON_FIXED_CTR,
.fixed_ctl = DMR_IMC_PMON_FIXED_CTL,
- .ops = &spr_uncore_mmio_ops,
.format_group = &dmr_imc_uncore_format_group,
.attr_update = uncore_alias_groups,
};
--
2.56.1