public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] drm/xe/pat: Type cleanup and invalid index hardening
@ 2026-04-16  4:55 Xin Wang
  2026-04-16  4:55 ` [PATCH v5 1/3] drm/xe: Standardize pat_index to u16 type Xin Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Xin Wang @ 2026-04-16  4:55 UTC (permalink / raw)
  To: intel-xe; +Cc: Xin Wang, Matthew Auld

Small follow-up series to harden the PAT subsystem:

Patch 1 fixes two remaining spots where pat_index was typed as u32/int
instead of u16, aligning with the rest of the driver.

Patch 2 defaults XE_CACHE_NONE_COMPRESSION to XE_PAT_INVALID_IDX (like
WB_COMPRESSION already does).

Patch 3 introduces xe_cache_pat_idx(), a macro helper that validates
cache_mode bounds and checks for XE_PAT_INVALID_IDX before returning the
PAT index. All 20 pat.idx[] read sites across the driver are converted.

Suggested-by: Matthew Auld <matthew.auld@intel.com>

v5:
- Patch 3: Use `struct xe_device *__xedev = (xe);` instead of `__xe` in
  the `xe_cache_pat_idx` macro to avoid shadowing/conflict with `__xe`
  used inside `xe_assert()` which caused a runtime pointer access error.

v4:
- Adopted a strictly decoupled approach for the `xe_cache_pat_idx()` macro
  helper. Dropped any new header dependencies (e.g. `xe_device_types.h`
  or `xe_pt_types.h`) from `xe_pat.h`, relying cleanly on the compilation
  contexts where the macro is expanded. Forward declarations are kept
  untouched.

v3:
- Rebased on latest drm-tip

v2:
- Dropped xe_assert() guards from xe_migrate that were added in v1 patch 2;
  the new helper in patch 3 now provides the same coverage uniformly across
  all call sites (Matthew Auld)
- New patch 3: xe_cache_pat_idx() helper with xe_assert() for every
  pat.idx[] read access, including bounds check on cache_mode


Xin Wang (3):
  drm/xe: Standardize pat_index to u16 type
  drm/xe/pat: Default XE_CACHE_NONE_COMPRESSION to invalid
  drm/xe/pat: Introduce xe_cache_pat_idx() macro helper

 drivers/gpu/drm/xe/display/xe_fb_pin.c | 11 ++++++-----
 drivers/gpu/drm/xe/tests/xe_migrate.c  |  3 ++-
 drivers/gpu/drm/xe/xe_device_types.h   |  2 +-
 drivers/gpu/drm/xe/xe_ggtt.c           |  7 ++++---
 drivers/gpu/drm/xe/xe_migrate.c        | 15 ++++++++-------
 drivers/gpu/drm/xe/xe_pat.c            |  1 +
 drivers/gpu/drm/xe/xe_pat.h            |  8 ++++++++
 drivers/gpu/drm/xe/xe_pt.c             |  3 ++-
 drivers/gpu/drm/xe/xe_vm.c             |  8 ++++----
 9 files changed, 36 insertions(+), 22 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-04-21 17:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16  4:55 [PATCH v5 0/3] drm/xe/pat: Type cleanup and invalid index hardening Xin Wang
2026-04-16  4:55 ` [PATCH v5 1/3] drm/xe: Standardize pat_index to u16 type Xin Wang
2026-04-16  4:55 ` [PATCH v5 2/3] drm/xe/pat: Default XE_CACHE_NONE_COMPRESSION to invalid Xin Wang
2026-04-16  4:55 ` [PATCH v5 3/3] drm/xe/pat: Introduce xe_cache_pat_idx() macro helper Xin Wang
2026-04-16  5:22 ` ✓ CI.KUnit: success for drm/xe/pat: Type cleanup and invalid index hardening Patchwork
2026-04-16  6:26 ` ✓ Xe.CI.BAT: " Patchwork
2026-04-16  9:29 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-04-17  1:57   ` Wang, X
2026-04-21 17:21     ` Matt Roper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox