From: Matthew Auld <matthew.auld@intel.com>
To: "Upadhyay, Tejas" <tejas.upadhyay@intel.com>,
"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Cc: "Teres Alexis, Alan Previn" <alan.previn.teres.alexis@intel.com>
Subject: Re: [PATCH v2 3/3] drm/xe/pat: always check is_valid() when querying an index
Date: Thu, 22 Oct 2026 11:39:10 +0100 [thread overview]
Message-ID: <1d3b59b9-fe5a-427d-af24-6777e45f4849@intel.com> (raw)
In-Reply-To: <DS0PR11MB87185E444C2C6085230F750681652@DS0PR11MB8718.namprd11.prod.outlook.com>
On 22/10/2026 08:02, Upadhyay, Tejas wrote:
>
>
>> -----Original Message-----
>> From: Auld, Matthew <matthew.auld@intel.com>
>> Sent: 15 October 2026 21:16
>> To: intel-xe@lists.freedesktop.org
>> Cc: Teres Alexis, Alan Previn <alan.previn.teres.alexis@intel.com>; Upadhyay,
>> Tejas <tejas.upadhyay@intel.com>
>> Subject: [PATCH v2 3/3] drm/xe/pat: always check is_valid() when querying an
>> index
>>
>> 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));
>
> Multiple WARN_ON!
> Should we change API:
> bool xe_pat_index_is_valid(struct xe_device *xe, u16 pat_index)
> {
> if (WARN_ON(pat_index >= xe->pat.n_entries))
> return false;
> return xe->pat.table[pat_index].valid;
> }
Yeah, good point.
>
> Tejas
>
>> 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-22 10:39 UTC|newest]
Thread overview: 11+ 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 ` [PATCH v2 3/3] drm/xe/pat: always check is_valid() when querying an index Matthew Auld
2026-10-15 16:12 ` sashiko-bot
2026-10-22 7:02 ` Upadhyay, Tejas
2026-10-22 10:39 ` Matthew Auld [this message]
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
2026-10-16 3:42 ` ✗ Xe.CI.FULL: failure " 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=1d3b59b9-fe5a-427d-af24-6777e45f4849@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox