From: Matthew Auld <matthew.auld@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>,
Tejas Upadhyay <tejas.upadhyay@intel.com>
Subject: [PATCH v2 3/3] drm/xe/pat: always check is_valid() when querying an index
Date: Thu, 15 Oct 2026 16:45:57 +0100 [thread overview]
Message-ID: <20261015154553.483229-8-matthew.auld@intel.com> (raw)
In-Reply-To: <20261015154553.483229-5-matthew.auld@intel.com>
Make the bevaviour consistent. If trying to extract comp or l3 on an
unknown index, just treat as a programmer error, like we already do for
coh_mode (implicit).
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
---
drivers/gpu/drm/xe/xe_pat.c | 6 +++---
drivers/gpu/drm/xe/xe_pat.h | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_pat.c b/drivers/gpu/drm/xe/xe_pat.c
index d239693b803b..1189d7255c12 100644
--- a/drivers/gpu/drm/xe/xe_pat.c
+++ b/drivers/gpu/drm/xe/xe_pat.c
@@ -303,7 +303,7 @@ bool xe_pat_index_is_valid(struct xe_device *xe, u16 pat_index)
u16 xe_pat_index_get_coh_mode(struct xe_device *xe, u16 pat_index)
{
- WARN_ON(pat_index >= xe->pat.n_entries);
+ WARN_ON(!xe_pat_index_is_valid(xe, pat_index));
WARN_ON(!xe->pat.table[pat_index].coh_mode ||
xe->pat.table[pat_index].coh_mode > XE_COH_2WAY);
return xe->pat.table[pat_index].coh_mode;
@@ -311,13 +311,13 @@ u16 xe_pat_index_get_coh_mode(struct xe_device *xe, u16 pat_index)
bool xe_pat_index_get_comp_en(struct xe_device *xe, u16 pat_index)
{
- WARN_ON(pat_index >= xe->pat.n_entries);
+ WARN_ON(!xe_pat_index_is_valid(xe, pat_index));
return !!(xe->pat.table[pat_index].value & XE2_COMP_EN);
}
u16 xe_pat_index_get_l3_policy(struct xe_device *xe, u16 pat_index)
{
- WARN_ON(pat_index >= xe->pat.n_entries);
+ WARN_ON(!xe_pat_index_is_valid(xe, pat_index));
return REG_FIELD_GET(XE2_L3_POLICY, xe->pat.table[pat_index].value);
}
diff --git a/drivers/gpu/drm/xe/xe_pat.h b/drivers/gpu/drm/xe/xe_pat.h
index f6b0fac2000a..de4d57ef9a4e 100644
--- a/drivers/gpu/drm/xe/xe_pat.h
+++ b/drivers/gpu/drm/xe/xe_pat.h
@@ -75,7 +75,7 @@ u16 xe_pat_index_get_coh_mode(struct xe_device *xe, u16 pat_index);
/**
* xe_pat_index_get_comp_en - Extract the compression enable flag for
- * the given pat_index.
+ * the given pat_index. Index must be valid for the hw.
* @xe: xe device
* @pat_index: The pat_index to query
*
@@ -88,6 +88,7 @@ bool xe_pat_index_get_comp_en(struct xe_device *xe, u16 pat_index);
#define XE_L3_POLICY_UC 3 /* Uncached */
/**
* xe_pat_index_get_l3_policy - Extract the L3 policy for the given pat_index.
+ * Index must be valid for the hw.
* @xe: xe device
* @pat_index: The pat_index to query
*/
--
2.56.0
next prev parent reply other threads:[~2026-10-15 15:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 15:45 [PATCH v2 0/3] Improve hw reserved PAT checking Matthew Auld
2026-10-15 15:45 ` [PATCH v2 1/3] drm/xe/pat: initialise pat.valid everywhere Matthew Auld
2026-10-15 15:45 ` [PATCH v2 2/3] drm/xe: revamp hw reserved PAT index checking Matthew Auld
2026-10-15 16:01 ` sashiko-bot
2026-10-15 15:45 ` Matthew Auld [this message]
2026-10-15 16:12 ` [PATCH v2 3/3] drm/xe/pat: always check is_valid() when querying an index sashiko-bot
2026-10-15 15:54 ` ✓ CI.KUnit: success for Improve hw reserved PAT checking (rev2) Patchwork
2026-10-15 20:15 ` ✓ Xe.CI.BAT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261015154553.483229-8-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=alan.previn.teres.alexis@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=tejas.upadhyay@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.