public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Yadav, Sanjay Kumar" <sanjay.kumar.yadav@intel.com>
To: "Gurram, Pravalika" <pravalika.gurram@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Cc: "Auld, Matthew" <matthew.auld@intel.com>
Subject: Re: [PATCH] lib/intel_pat: Handle platforms without compressed PAT index
Date: Tue, 3 Mar 2026 16:00:54 +0530	[thread overview]
Message-ID: <cc6fb449-b15d-4f56-b2c2-4ac7f391b7af@intel.com> (raw)
In-Reply-To: <BL1PR11MB552518C35C193641C8AC3DB9847FA@BL1PR11MB5525.namprd11.prod.outlook.com>


On 03-03-2026 15:20, Gurram, Pravalika wrote:
>
>> -----Original Message-----
>> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of Sanjay
>> Yadav
>> Sent: Wednesday, 18 February, 2026 04:06 PM
>> To: igt-dev@lists.freedesktop.org
>> Cc: Auld, Matthew <matthew.auld@intel.com>
>> Subject: [PATCH] lib/intel_pat: Handle platforms without compressed PAT
>> index
>>
>> Previously intel_get_pat_idx_uc_comp() would silently return zero on
>> platforms where no compressed PAT index exists (e.g. CRI), since uc_comp was
>> zero-initialized by default. This could lead to incorrect behavior when callers
>> assume the returned index is valid.
>>
>> Fix this by:
>> - Adding XE_PAT_IDX_INVALID sentinel to detect unsupported platforms
>> - Initializing uc_comp to XE_PAT_IDX_INVALID in intel_get_pat_idx();
>>    only platforms with CCS (graphics_ver 20/30) override it to a valid
>>    index
>> - Adding igt_assert_f() in intel_get_pat_idx_uc_comp() to fail with
>>    a clear error instead of returning an invalid index
>>
>> Also update the bo-comp-disable-bind test to distinguish between "CCS is
>> disabled" and "CCS does not exist" using HAS_FLATCCS(). On platforms
>> without CCS, the compressed PAT bind check is skipped since there is no valid
>> compressed PAT index to test with.
>>
>> Suggested-by: Matthew Auld <matthew.auld@intel.com>
>> Signed-off-by: Sanjay Yadav <sanjay.kumar.yadav@intel.com>
>> ---
>>   lib/intel_pat.c      |  5 +++++
>>   lib/intel_pat.h      |  1 +
>>   tests/intel/xe_pat.c | 30 ++++++++++++++++++++++--------
>>   3 files changed, 28 insertions(+), 8 deletions(-)
>>
>> diff --git a/lib/intel_pat.c b/lib/intel_pat.c index 9815efc18..d30bee453
>> 100644
>> --- a/lib/intel_pat.c
>> +++ b/lib/intel_pat.c
>> @@ -98,6 +98,8 @@ static void intel_get_pat_idx(int fd, struct
>> intel_pat_cache *pat)  {
>>   	uint16_t dev_id = intel_get_drm_devid(fd);
>>
>> +	pat->uc_comp = XE_PAT_IDX_INVALID;
>> +
>>   	if (intel_graphics_ver(dev_id) == IP_VER(35, 11)) {
>>   		pat->uc = 3;
>>   		pat->wb = 2;
>> @@ -155,8 +157,11 @@ uint8_t intel_get_pat_idx_uc_comp(int fd)
>>   	uint16_t dev_id = intel_get_drm_devid(fd);
>>
>>   	igt_assert(intel_gen(dev_id) >= 20);
>> +	igt_assert(HAS_FLATCCS(dev_id));
>>
>>   	intel_get_pat_idx(fd, &pat);
>> +	igt_assert_f(pat.uc_comp != XE_PAT_IDX_INVALID,
>> +		     "No compressed PAT index available on this platform\n");
>>   	return pat.uc_comp;
>>   }
>>
>> diff --git a/lib/intel_pat.h b/lib/intel_pat.h index e9ade2e2e..e5dd8a0af
>> 100644
>> --- a/lib/intel_pat.h
>> +++ b/lib/intel_pat.h
>> @@ -10,6 +10,7 @@
>>   #include <stdint.h>
>>
>>   #define DEFAULT_PAT_INDEX ((uint8_t)-1) /* igt-core can pick 1way or better
>> */
>> +#define XE_PAT_IDX_INVALID ((uint8_t)-2) /* no such PAT index on this
>> +platform */
>>   #define XE_PAT_MAX_ENTRIES 32
>>
>>   struct xe_pat_entry {
>> diff --git a/tests/intel/xe_pat.c b/tests/intel/xe_pat.c index
>> 21547c84e..052b7b699 100644
>> --- a/tests/intel/xe_pat.c
>> +++ b/tests/intel/xe_pat.c
>> @@ -844,15 +844,18 @@ static bool has_no_compression_hint(int fd)
>>    * Test category: functionality test
>>    * Description: Validates that binding a BO created with
>>    * the NO_COMPRESSION flag using a compressed PAT index fails
>> - * with -EINVAL on Xe2+ platforms.
>> + * with -EINVAL on Xe2+ platforms. On platforms where CCS
>> + * does not exist, the test verifies uncompressed access works.
>>    */
>>
>>   static void bo_comp_disable_bind(int fd)  {
>>   	size_t size = xe_get_default_alignment(fd);
>> -	uint8_t comp_pat_index, uncomp_pat_index;
>> -	bool supported;
>> +	uint16_t dev_id = intel_get_drm_devid(fd);
>> +	bool has_flatccs = HAS_FLATCCS(dev_id);
>> +	uint8_t uncomp_pat_index;
>>   	uint32_t vm, bo;
>> +	bool supported;
>>   	int ret;
>>
>>   	supported = has_no_compression_hint(fd); @@ -868,14 +871,25
>> @@ static void bo_comp_disable_bind(int fd)
>>   	igt_assert_eq(ret, 0);
>>   	vm = xe_vm_create(fd, 0, 0);
>>
>> -	comp_pat_index = intel_get_pat_idx_uc_comp(fd);
>>   	uncomp_pat_index = intel_get_pat_idx_uc(fd);
>>
>> -	igt_assert_eq(__xe_vm_bind(fd, vm, 0, bo, 0, 0x100000,
>> -				   size, 0, 0, NULL, 0,
>> -				   0, comp_pat_index, 0),
>> -		      -EINVAL);
>> +	/*
>> +	 * On platforms with CCS, binding a NO_COMPRESSION BO with a
>> +	 * compressed PAT index must fail. On platforms without CCS,
>> +	 * there is no valid compressed PAT index, so skip this check.
>> +	 */
>> +	if (has_flatccs) {
>> +		uint8_t comp_pat_index = intel_get_pat_idx_uc_comp(fd);
>> +
>> +		igt_assert_eq(__xe_vm_bind(fd, vm, 0, bo, 0, 0x100000,
>> +					   size, 0, 0, NULL, 0,
>> +					   0, comp_pat_index, 0),
>> +			      -EINVAL);
>> +	} else {
>> +		igt_debug("Platform has no CCS, skipping compressed PAT
>> bind check\n");
>> +	}
> Does this test needs to be skipped here? If yes you need to use igt_skip
> And handle the resource cleanup
No. The test still has a valid positive path on platforms without CCS: 
it verifies that binding with the uncompressed
PAT index succeeds. Only the compressed-path assertion is not applicable 
when HAS_FLATCCS(dev_id) is false, so I kept
the test running and added a debug log to make that explicit. Skipping 
the test with igt_skip would drop that coverage.

>> +	/* Uncompressed bind must always succeed */
>>   	igt_assert_eq(__xe_vm_bind(fd, vm, 0, bo, 0, 0x100000,
>>   				   size, 0, 0, NULL, 0,
>>   				   0, uncomp_pat_index, 0),
>> --
>> 2.52.0

  reply	other threads:[~2026-03-03 10:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 10:36 [PATCH] lib/intel_pat: Handle platforms without compressed PAT index Sanjay Yadav
2026-02-18 11:58 ` ✓ i915.CI.BAT: success for " Patchwork
2026-02-18 12:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-18 12:37 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-18 14:14 ` ✗ i915.CI.Full: " Patchwork
2026-03-03  9:50 ` [PATCH] " Gurram, Pravalika
2026-03-03 10:30   ` Yadav, Sanjay Kumar [this message]
2026-03-03 11:23     ` Gurram, Pravalika
2026-03-03 11:34       ` Yadav, Sanjay Kumar

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=cc6fb449-b15d-4f56-b2c2-4ac7f391b7af@intel.com \
    --to=sanjay.kumar.yadav@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=pravalika.gurram@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