[PATCH 04/12] perf/x86/intel/uncore: Fix DMR MMIO counter control stride
From: Zide Chen
Date: Fri Dec 04 2026 - 22:34:39 EST
Unlike Sapphire Rapids and Granite Rapids, where MMIO counter control
registers are a mix of 32-bit (4-byte stride, e.g. IMC) and 64-bit
(8-byte stride, e.g. CXL) layouts, all Diamond Rapids MMIO uncore units
use 64-bit counter control registers spaced 8 bytes apart.
Because DMR MMIO types do not set ctl_offs8, uncore_pci_event_ctl()
addresses counter control registers with a 4-byte stride instead of 8.
As a result, counter 1's configuration is written to the upper 32 bits
of counter 0's control register, leaving counter 1 unprogrammed and
corrupting counter 0.
Rather than defining dozens of static intel_uncore_type structures
solely to set .ctl_offs8 = 1, introduce uncore_types_set_ctl_offs8()
to set the flag across an uncore type array.
Fixes: 6daf2c35b835 ("perf/x86/intel/uncore: Add IMH PMON support for Diamond Rapids")
Fixes: 66e2075426f3 ("perf/x86/intel/uncore: Add CBB PMON support for Diamond Rapids")
Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
---
arch/x86/events/intel/uncore_snbep.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index e0be7a35baec..e73c028c9415 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -6991,6 +6991,15 @@ int dmr_uncore_pci_init(void)
return 0;
}
+static void uncore_types_set_ctl_offs8(struct intel_uncore_type **types)
+{
+ if (!types)
+ return;
+
+ for (; *types; types++)
+ (*types)->ctl_offs8 = 1;
+}
+
void dmr_uncore_mmio_init(void)
{
uncore_mmio_uncores = uncore_get_uncores(UNCORE_ACCESS_MMIO,
@@ -6999,6 +7008,8 @@ void dmr_uncore_mmio_init(void)
UNCORE_DMR_NUM_UNCORE_TYPES,
dmr_uncores);
+ uncore_types_set_ctl_offs8(uncore_mmio_uncores);
+
dmr_uncore_iio_free_running.num_boxes =
uncore_type_max_boxes(uncore_mmio_uncores, UNCORE_DMR_ITC);
}
--
2.56.1