Compare
70db8dea2aac43dd4f9a7ec2365d8c950efaa07d..cf1f186e08dadb5abc4410d10fe3ada7ebf801ae
perf/x86/intel/uncore: Fix DMR CXL CM invert filter
The DMR CXL CM PMU places its invert filter at config bit 21 and its
9-bit threshold at bits 23-31. However, dmr_uncore_cxlcm uses
GENERIC_PMON_RAW_EVENT_MASK, which covers the threshold through the
generic bit 23 invert field and bits 24-31 threshold field, but does not
include the relocated invert bit. As a result, uncore_pmu_event_init()
silently clears bit 21 and inv=1 programs the same configuration as
inv=0.
Add bit 21 to a DMR CXL CM-specific event mask so the requested invert
filter reaches hardware.
Fixes: 6daf2c35b835 ("perf/x86/intel/uncore: Add IMH PMON support for Diamond Rapids")
Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Zide Chen <zide.chen@intel.com>
Link: https://patch.msgid.link/20261008051953.6293-2-weiguixiong@bytedance.com
Guixiong Wei <weiguixiong@bytedance.com> · 2026-10-08 05:19 UTC · committed by Peter Zijlstra
4 files changed,
+14
−91
- arch/x86/events/intel/uncore_snbep.c
- drivers/gpu/drm/i915/display/intel_cx0_phy.c
- drivers/gpu/drm/i915/display/intel_dmc.c
- drivers/gpu/drm/i915/display/intel_dmc_regs.h
modified arch/x86/events/intel/uncore_snbep.c
| @@ -474,6 +474,9 @@ | |||
| 474 | 474 | /* DMR */ | |
| 475 | 475 | #define DMR_IMH1_HIOP_MMIO_BASE 0x1ffff6ae7000 | |
| 476 | 476 | #define DMR_HIOP_MMIO_SIZE 0x8000 | |
| 477 | + | #define DMR_CXLCM_PMON_CTL_INVERT BIT(21) | |
| 478 | + | #define DMR_CXLCM_PMON_RAW_EVENT_MASK (GENERIC_PMON_RAW_EVENT_MASK | \ | |
| 479 | + | DMR_CXLCM_PMON_CTL_INVERT) | |
| 477 | 480 | #define DMR_CXLCM_EVENT_MASK_EXT 0xf | |
| 478 | 481 | #define DMR_HAMVF_EVENT_MASK_EXT 0xffffffff | |
| 479 | 482 | #define DMR_PCIE4_EVENT_MASK_EXT 0xffffff | |
| @@ -6696,7 +6699,7 @@ static struct event_constraint dmr_uncore_cxlcm_constraints[] = { | |||
| 6696 | 6699 | ||
| 6697 | 6700 | static struct intel_uncore_type dmr_uncore_cxlcm = { | |
| 6698 | 6701 | .name = "cxlcm", | |
| 6699 | - | .event_mask = GENERIC_PMON_RAW_EVENT_MASK, | |
| 6702 | + | .event_mask = DMR_CXLCM_PMON_RAW_EVENT_MASK, | |
| 6700 | 6703 | .event_mask_ext = DMR_CXLCM_EVENT_MASK_EXT, | |
| 6701 | 6704 | .constraints = dmr_uncore_cxlcm_constraints, | |
| 6702 | 6705 | .format_group = &dmr_cxlcm_uncore_format_group, | |
modified drivers/gpu/drm/i915/display/intel_cx0_phy.c
| @@ -2342,14 +2342,12 @@ static void intel_c10pll_dump_hw_state(struct drm_printer *p, | |||
| 2342 | 2342 | static bool is_arrowlake_s_by_host_bridge(void) | |
| 2343 | 2343 | { | |
| 2344 | 2344 | struct pci_dev *pdev = NULL; | |
| 2345 | - | while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev))) { | |
| 2346 | - | if (IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(pdev->device)) { | |
| 2347 | - | pci_dev_put(pdev); | |
| 2348 | - | return true; | |
| 2349 | - | } | |
| 2350 | - | } | |
| 2345 | + | u16 host_bridge_pci_dev_id; | |
| 2351 | 2346 | ||
| 2352 | - | return false; | |
| 2347 | + | while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev))) | |
| 2348 | + | host_bridge_pci_dev_id = pdev->device; | |
| 2349 | + | ||
| 2350 | + | return pdev && IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(host_bridge_pci_dev_id); | |
| 2353 | 2351 | } | |
| 2354 | 2352 | ||
| 2355 | 2353 | static u16 intel_c20_hdmi_tmds_tx_cgf_1(struct intel_display *display) | |
modified drivers/gpu/drm/i915/display/intel_dmc.c
| @@ -1023,55 +1023,6 @@ static void dmc_set_fw_offset(struct intel_dmc *dmc, | |||
| 1023 | 1023 | } | |
| 1024 | 1024 | } | |
| 1025 | 1025 | ||
| 1026 | - | /* | |
| 1027 | - | * Check if the load address is within the valid range for the given DMC ID. | |
| 1028 | - | */ | |
| 1029 | - | static bool dmc_load_addr_sanity_check(struct intel_dmc *dmc, | |
| 1030 | - | u32 start_addr, u32 payload_size, | |
| 1031 | - | int header_ver, enum intel_dmc_id dmc_id) | |
| 1032 | - | { | |
| 1033 | - | u32 start_range, end_range, end_addr; | |
| 1034 | - | ||
| 1035 | - | if (header_ver != 3) | |
| 1036 | - | return true; | |
| 1037 | - | ||
| 1038 | - | switch (dmc_id) { | |
| 1039 | - | case DMC_FW_MAIN: | |
| 1040 | - | start_range = DMC_MAIN_PROGRAM_BASE_START; | |
| 1041 | - | end_range = DMC_MAIN_PROGRAM_BASE_END; | |
| 1042 | - | break; | |
| 1043 | - | case DMC_FW_PIPEA: | |
| 1044 | - | start_range = DMC_PIPEA_PROGRAM_BASE_START; | |
| 1045 | - | end_range = DMC_PIPEA_PROGRAM_BASE_END; | |
| 1046 | - | break; | |
| 1047 | - | case DMC_FW_PIPEB: | |
| 1048 | - | start_range = DMC_PIPEB_PROGRAM_BASE_START; | |
| 1049 | - | end_range = DMC_PIPEB_PROGRAM_BASE_END; | |
| 1050 | - | break; | |
| 1051 | - | case DMC_FW_PIPEC: | |
| 1052 | - | start_range = DMC_PIPEC_PROGRAM_BASE_START; | |
| 1053 | - | end_range = DMC_PIPEC_PROGRAM_BASE_END; | |
| 1054 | - | break; | |
| 1055 | - | case DMC_FW_PIPED: | |
| 1056 | - | start_range = DMC_PIPED_PROGRAM_BASE_START; | |
| 1057 | - | end_range = DMC_PIPED_PROGRAM_BASE_END; | |
| 1058 | - | break; | |
| 1059 | - | default: | |
| 1060 | - | MISSING_CASE(dmc_id); | |
| 1061 | - | return false; | |
| 1062 | - | } | |
| 1063 | - | ||
| 1064 | - | if (payload_size == 0) | |
| 1065 | - | end_addr = start_addr; | |
| 1066 | - | else if (check_add_overflow(start_addr, payload_size - 1, &end_addr)) | |
| 1067 | - | return false; | |
| 1068 | - | ||
| 1069 | - | if (start_addr < start_range || end_addr > end_range) | |
| 1070 | - | return false; | |
| 1071 | - | ||
| 1072 | - | return true; | |
| 1073 | - | } | |
| 1074 | - | ||
| 1075 | 1026 | static bool dmc_mmio_addr_sanity_check(struct intel_dmc *dmc, | |
| 1076 | 1027 | const u32 *mmioaddr, u32 mmio_count, | |
| 1077 | 1028 | int header_ver, enum intel_dmc_id dmc_id) | |
| @@ -1169,7 +1120,7 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc, | |||
| 1169 | 1120 | } | |
| 1170 | 1121 | ||
| 1171 | 1122 | /* Cache the dmc header info. */ | |
| 1172 | - | if (!mmio_count || mmio_count > mmio_count_max) { | |
| 1123 | + | if (mmio_count > mmio_count_max) { | |
| 1173 | 1124 | drm_err(display->drm, "DMC firmware has wrong mmio count %u\n", mmio_count); | |
| 1174 | 1125 | return 0; | |
| 1175 | 1126 | } | |
| @@ -1215,21 +1166,13 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc, | |||
| 1215 | 1166 | disable_dmc_evt(display, dmc_id, dmc_info->mmioaddr[i], | |
| 1216 | 1167 | dmc_info->mmiodata[i]) ? " (disabling)" : ""); | |
| 1217 | 1168 | } | |
| 1169 | + | dmc_info->mmio_count = mmio_count; | |
| 1170 | + | dmc_info->start_mmioaddr = start_mmioaddr; | |
| 1218 | 1171 | ||
| 1219 | 1172 | rem_size -= header_len_bytes; | |
| 1220 | 1173 | ||
| 1221 | 1174 | /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */ | |
| 1222 | - | if (check_mul_overflow(dmc_header->fw_size, 4u, &payload_size)) { | |
| 1223 | - | drm_err(display->drm, "DMC fw_size too large (%u dwords)\n", | |
| 1224 | - | dmc_header->fw_size); | |
| 1225 | - | return 0; | |
| 1226 | - | } | |
| 1227 | - | ||
| 1228 | - | if (!payload_size) { | |
| 1229 | - | drm_err(display->drm, "DMC firmware has empty payload\n"); | |
| 1230 | - | return 0; | |
| 1231 | - | } | |
| 1232 | - | ||
| 1175 | + | payload_size = dmc_header->fw_size * 4; | |
| 1233 | 1176 | if (rem_size < payload_size) | |
| 1234 | 1177 | goto error_truncated; | |
| 1235 | 1178 | ||
| @@ -1237,21 +1180,12 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc, | |||
| 1237 | 1180 | drm_err(display->drm, "DMC FW too big (%u bytes)\n", payload_size); | |
| 1238 | 1181 | return 0; | |
| 1239 | 1182 | } | |
| 1240 | - | ||
| 1241 | - | if (!dmc_load_addr_sanity_check(dmc, start_mmioaddr, payload_size, | |
| 1242 | - | dmc_header->header_ver, dmc_id)) { | |
| 1243 | - | drm_err(display->drm, "DMC %d: firmware has wrong load address\n", dmc_id); | |
| 1244 | - | return 0; | |
| 1245 | - | } | |
| 1183 | + | dmc_info->dmc_fw_size = dmc_header->fw_size; | |
| 1246 | 1184 | ||
| 1247 | 1185 | dmc_info->payload = kmalloc(payload_size, GFP_KERNEL); | |
| 1248 | 1186 | if (!dmc_info->payload) | |
| 1249 | 1187 | return 0; | |
| 1250 | 1188 | ||
| 1251 | - | dmc_info->mmio_count = mmio_count; | |
| 1252 | - | dmc_info->start_mmioaddr = start_mmioaddr; | |
| 1253 | - | dmc_info->dmc_fw_size = dmc_header->fw_size; | |
| 1254 | - | ||
| 1255 | 1189 | payload = (u8 *)(dmc_header) + header_len_bytes; | |
| 1256 | 1190 | memcpy(dmc_info->payload, payload, payload_size); | |
| 1257 | 1191 | ||
modified drivers/gpu/drm/i915/display/intel_dmc_regs.h
| @@ -521,18 +521,6 @@ enum pipedmc_event_id { | |||
| 521 | 521 | #define TGL_PIPE_MMIO_END(dmc_id) _PICK_EVEN(((dmc_id) - 1), _TGL_PIPEA_MMIO_END,\ | |
| 522 | 522 | _TGL_PIPEB_MMIO_END) | |
| 523 | 523 | ||
| 524 | - | /* For DMC header version v3*/ | |
| 525 | - | #define DMC_MAIN_PROGRAM_BASE_START 0x80000 | |
| 526 | - | #define DMC_MAIN_PROGRAM_BASE_END 0x86fff | |
| 527 | - | #define DMC_PIPEA_PROGRAM_BASE_START 0x90000 | |
| 528 | - | #define DMC_PIPEA_PROGRAM_BASE_END 0x96fff | |
| 529 | - | #define DMC_PIPEB_PROGRAM_BASE_START 0x98000 | |
| 530 | - | #define DMC_PIPEB_PROGRAM_BASE_END 0x9efff | |
| 531 | - | #define DMC_PIPEC_PROGRAM_BASE_START 0x52000 | |
| 532 | - | #define DMC_PIPEC_PROGRAM_BASE_END 0x53fff | |
| 533 | - | #define DMC_PIPED_PROGRAM_BASE_START 0x59000 | |
| 534 | - | #define DMC_PIPED_PROGRAM_BASE_END 0x5afff | |
| 535 | - | ||
| 536 | 524 | #define SKL_DMC_DC3_DC5_COUNT _MMIO(0x80030) | |
| 537 | 525 | #define SKL_DMC_DC5_DC6_COUNT _MMIO(0x8002C) | |
| 538 | 526 | #define BXT_DMC_DC3_DC5_COUNT _MMIO(0x80038) | |