]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/xe/reg_sr: Do sanity check for MCR vs non-MCR
authorGustavo Sousa <gustavo.sousa@intel.com>
Thu, 14 May 2026 21:44:50 +0000 (18:44 -0300)
committerGustavo Sousa <gustavo.sousa@intel.com>
Fri, 15 May 2026 21:05:14 +0000 (18:05 -0300)
commit058da4a2b164e477b02ca0562f01a9eb9e621cdd
tree826467967b5e2a97aa38bdadaf086e4fb34a0899
parentcdf8489533f4dd9639fd0c266dd2ec8f7a543e34
drm/xe/reg_sr: Do sanity check for MCR vs non-MCR

The type struct xe_reg_mcr exists to ensure that the correct API is used
when handling MCR registers.  However, for the register save/restore
functionality, the RTP processing always cast the register to a struct
xe_reg and then apply_one_mmio() selects the MMIO API based on the "mcr"
field of the register instance.

This allows the developer to commit mistakes like passing a MCR register
for an RTP action for a GT where the respective register is not MCR; and
vice-versa.

To capture such scenarios, do a sanity check in xe_reg_sr_add() that,
upon an inconsistency:

- "fixes" the register type by favoring what we have in our MCR range
  tables instead of what the developer selected for the save/restore
  entry;
- raises a notice-level message to inform about the inconsistency.

Note: As a collateral of this change, we need to include MCR
initialization in xe_wa_test.c, otherwise a bunch of test cases end up
failing because xe_gt_mcr_check_reg() will always return false, meaning
that will incorrectly say that a MCR register is not MCR.

v2:
  - Downgrade messages to notice level so as not to block CI execution
    when inconsistencies are found. (Matt)
  - Add missing EXPORT_SYMBOL_IF_KUNIT() calls. (Gustavo)

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://patch.msgid.link/20260514-rtp-mcr-check-v3-7-30dd47855fee@intel.com
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
drivers/gpu/drm/xe/tests/xe_rtp_test.c
drivers/gpu/drm/xe/tests/xe_wa_test.c
drivers/gpu/drm/xe/xe_gt.c
drivers/gpu/drm/xe/xe_gt_mcr.c
drivers/gpu/drm/xe/xe_gt_mcr.h
drivers/gpu/drm/xe/xe_reg_sr.c