Skip to content

drm/xe/pat: Type cleanup and invalid index hardening

Xin Wang intel-xe 5 versions – Applied

Status from this message: Applied to drm-xe-next. Thanks for the patches and reviews.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 2 repliesApplied
  2. v43 patches 0 repliesSuperseded
  3. v33 patches 3 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v23 patches0 repliesSuperseded
v12 patches4 repliesSuperseded

Changes in v5 from the cover letter

- 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.

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/3drm/xe: Standardize pat_index to u16 typedrivers/gpu/drm/xe/xe_device_types.h drivers/gpu/drm/xe/xe_vm.c+2 -20 replies
2/3drm/xe/pat: Default XE_CACHE_NONE_COMPRESSION to invaliddrivers/gpu/drm/xe/xe_pat.c+1 -00 replies
3/3drm/xe/pat: Introduce xe_cache_pat_idx() macro helperdrivers/gpu/drm/xe/display/xe_fb_pin.c drivers/gpu/drm/xe/tests/xe_migrate.c drivers/gpu/drm/xe/xe_ggtt.c +4 more+33 -200 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchMatthew Auld
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/3] drm/xe/pat: Type cleanup and invalid index hardening

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.

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(-)
Signature · 1 line
2.43.0