public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Wang, X" <x.wang@intel.com>
To: <himanshu.girotra@intel.com>, <igt-dev@lists.freedesktop.org>
Cc: <matthew.d.roper@intel.com>, <francois.dugast@intel.com>,
	<matthew.auld@intel.com>
Subject: Re: [PATCH i-g-t] lib/intel_pat: add hardcoded PAT fallback for older kernels
Date: Tue, 31 Mar 2026 17:10:49 -0700	[thread overview]
Message-ID: <55c9788a-1db5-4a8b-afa1-e7850c600fd8@intel.com> (raw)
In-Reply-To: <20260327052212.27431-1-himanshu.girotra@intel.com>


On 3/26/2026 22:22, himanshu.girotra@intel.com wrote:
> From: Himanshu Girotra <himanshu.girotra@intel.com>
>
> When IGT runs on kernels that lack the gt0/pat_sw_config debugfs entry
> (commit "drm/xe: expose PAT software config to debugfs"), the PAT cache
> is NULL and intel_get_pat_idx() hits a fatal assertion.  This breaks
> basic tests like xe_exec_basic on stock distro kernels (e.g. Ubuntu
> 25.10).
>
> Add xe_pat_fallback() with hardcoded PAT indices matching the kernel's
> xe_pat_init_early() for platforms up to Crescent Island (xe3p XPC).
> When the debugfs is unavailable, the fallback provides correct values
> instead of crashing.  Newer platforms (xe3p LPG and beyond) are not
> covered because their kernel support arrived after the debugfs entry
> was already in place.
>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Matt Roper <matthew.d.roper@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Signed-off-by: Himanshu Girotra <himanshu.girotra@intel.com>
> ---
>   lib/intel_pat.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 72 insertions(+), 4 deletions(-)
>
> diff --git a/lib/intel_pat.c b/lib/intel_pat.c
> index b202a6241..71633b314 100644
> --- a/lib/intel_pat.c
> +++ b/lib/intel_pat.c
> @@ -97,6 +97,62 @@ int32_t xe_get_pat_sw_config(int drm_fd, struct intel_pat_cache *xe_pat_cache)
>   	return parsed;
>   }
>   
> +/*
> + * Hardcoded PAT indices for Xe platforms, used as a fallback when the
> + * kernel doesn't expose gt0/pat_sw_config in debugfs.
> + *
> + * Covers platforms up to Crescent Island (xe3p XPC) that have Xe driver
> + * support in current stable kernels.  Anything newer must run a kernel
> + * that provides the pat_sw_config debugfs entry.
> + *
> + * TODO: drop this fallback once stable kernels ship with pat_sw_config.
> + */
> +static bool xe_pat_fallback(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)) {
> +		/* Xe3p XPC (GFX ver 35.11): no WT, no compression */
> +		pat->uc = 3;
> +		pat->wt = 3;   /* No WT on XPC; use UC */
> +		pat->wb = 2;
> +		pat->max_index = 31;
> +	} else if (intel_get_device_info(dev_id)->graphics_ver == 30 ||
> +		   intel_get_device_info(dev_id)->graphics_ver == 20) {
> +		/* Xe2 / Xe3: GFX ver 20 / 30 */
> +		pat->uc = 3;
> +		pat->wt = 15;
> +		pat->wb = 2;
> +		pat->uc_comp = 12;
> +		pat->max_index = 31;
> +
> +		/* Wa_16023588340: CLOS3 entries at end of table are unusable */
> +		if (intel_graphics_ver(dev_id) == IP_VER(20, 1))
> +			pat->max_index -= 4;
> +	} else if (IS_METEORLAKE(dev_id)) {
> +		pat->uc = 2;
> +		pat->wt = 1;
> +		pat->wb = 3;
> +		pat->max_index = 3;
> +	} else if (IS_PONTEVECCHIO(dev_id)) {
> +		pat->uc = 0;
> +		pat->wt = 2;
> +		pat->wb = 3;
> +		pat->max_index = 7;
> +	} else if (IS_DG2(dev_id) || intel_graphics_ver(dev_id) <= IP_VER(12, 10)) {
> +		pat->uc = 3;
> +		pat->wt = 2;
> +		pat->wb = 0;
> +		pat->max_index = 3;
> +	} else {
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
Since we've already hardcoded some things, essentially repeating
parameters from the KMD, why don't we just copy the complete PAT
table as well? This way, all tests for xe_pat's dependencies on
the complete PAT table will pass smoothly.
>   static void intel_get_pat_idx(int fd, struct intel_pat_cache *pat)
>   {
>   	uint16_t dev_id;
> @@ -105,14 +161,26 @@ static void intel_get_pat_idx(int fd, struct intel_pat_cache *pat)
>   	 * For Xe, use the PAT cache stored in struct xe_device.
>   	 * xe_device_get() populates the cache while still root; forked
>   	 * children that inherit the xe_device can use it post-drop_root().
> +	 *
> +	 * Fall back to hardcoded values when the kernel lacks the
> +	 * pat_sw_config debugfs. Platforms newer than Crescent Island
> +	 * must have the debugfs available.
>   	 */
>   	if (is_xe_device(fd)) {
>   		struct xe_device *xe_dev = xe_device_get(fd);
>   
> -		igt_assert_f(xe_dev->pat_cache,
> -			     "PAT sw_config not available -- "
> -			     "debugfs not accessible (missing root or not mounted?)\n");
> -		*pat = *xe_dev->pat_cache;
> +		if (xe_dev->pat_cache) {
> +			*pat = *xe_dev->pat_cache;
> +		} else if (xe_pat_fallback(fd, pat)) {
> +			igt_info("PAT sw_config debugfs not available, "
> +				 "using hardcoded fallback\n");
> +		} else {
> +			igt_assert_f(false,
> +				     "PAT sw_config not available and no "
> +				     "hardcoded fallback for this platform -- "
> +				     "kernel with 'drm/xe: expose PAT software "
> +				     "config to debugfs' required\n");
> +		}
>   		return;
>   	}
>   

      parent reply	other threads:[~2026-04-01  0:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27  5:22 [PATCH i-g-t] lib/intel_pat: add hardcoded PAT fallback for older kernels himanshu.girotra
2026-03-27  6:28 ` ✓ i915.CI.BAT: success for " Patchwork
2026-03-27  6:32 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-27 10:35 ` [PATCH i-g-t] " Matthew Auld
2026-03-27 22:07 ` ✓ Xe.CI.FULL: success for " Patchwork
2026-03-28  7:31 ` ✗ i915.CI.Full: failure " Patchwork
2026-03-31 22:56 ` [PATCH i-g-t] " Dixit, Ashutosh
2026-03-31 23:06   ` Dixit, Ashutosh
2026-04-01  0:10 ` Wang, X [this message]

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=55c9788a-1db5-4a8b-afa1-e7850c600fd8@intel.com \
    --to=x.wang@intel.com \
    --cc=francois.dugast@intel.com \
    --cc=himanshu.girotra@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.d.roper@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