Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <nitin.r.gote@intel.com>, <matthew.d.roper@intel.com>,
	Tejas Upadhyay <tejas.upadhyay@intel.com>
Subject: Re: [PATCH V2] drm/xe/nvl-p: Add Wa_14028564128
Date: Fri, 20 Nov 2026 20:58:03 -0300	[thread overview]
Message-ID: <877bi7qcms.fsf@intel.com> (raw)
In-Reply-To: <20261119075242.3292552-2-tejas.upadhyay@intel.com>

Tejas Upadhyay <tejas.upadhyay@intel.com> writes:

> Wa_14028564128 applies to 35.10
>
> V2:
> - Add missing pat indexes to no_promote as asked by WA
>
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_pat.c        | 39 ++++++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_pat.h        | 14 +++++++++++
>  drivers/gpu/drm/xe/xe_vm.c         |  6 +++--
>  drivers/gpu/drm/xe/xe_vm_madvise.c | 11 ++++++---
>  drivers/gpu/drm/xe/xe_wa_oob.rules |  1 +
>  5 files changed, 66 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pat.c b/drivers/gpu/drm/xe/xe_pat.c
> index 5938fef22579..24caed262642 100644
> --- a/drivers/gpu/drm/xe/xe_pat.c
> +++ b/drivers/gpu/drm/xe/xe_pat.c
> @@ -337,6 +337,18 @@ bool xe_pat_wa_14026539277_reserved(struct xe_device *xe, u16 pat_index)
>  		}
>  	}
>  
> +	/*
> +	 * Wa_14028564128 remaps every PAT index that is statically 2-way
> +	 * coherent (indices 2, 7, 23, 27 and 31 in this table) to a safe
> +	 * no-promote/UC/1-way value, so none of them are subject to this
> +	 * restriction once that WA is enabled.
> +	 */
> +	for_each_gt(gt, xe, id) {
> +		if (XE_GT_WA(gt, 14028564128) &&
> +		    xe_pat_index_get_coh_mode(xe, pat_index) == XE_COH_2WAY)
> +			return false;
> +	}
> +
>  	/*
>  	 * Disallow 2-way coherency for any L3 cache policy because
>  	 * XE_L3_POLICY_UC could still be promoted to a cached policy
> @@ -345,6 +357,21 @@ bool xe_pat_wa_14026539277_reserved(struct xe_device *xe, u16 pat_index)
>  	return has_wa && xe_pat_index_get_coh_mode(xe, pat_index) == XE_COH_2WAY;
>  }
>  
> +bool xe_pat_wa_14028564128_safe_userptr_index(struct xe_device *xe, u16 pat_index)
> +{
> +	struct xe_gt *gt;
> +	u8 id;
> +
> +	if (pat_index != 2)
> +		return false;
> +
> +	for_each_gt(gt, xe, id)
> +		if (XE_GT_WA(gt, 14028564128))
> +			return true;
> +
> +	return false;
> +}

Is this change really related to the workaround?  If it is just a happy
coincidence that fulfills some requirement associated to userptr usage, I
think we could make it a separate patch and add some rationale in the
commit message.

> +
>  static u32 wa_14026539277_fixup_pat_value(struct xe_gt *gt, u32 value)
>  {
>  	if (XE_GT_WA(gt, 14026539277)) {
> @@ -358,6 +385,15 @@ static u32 wa_14026539277_fixup_pat_value(struct xe_gt *gt, u32 value)
>  	return value;
>  }
>  
> +static u32 wa_14028564128_fixup_pat_value(struct xe_gt *gt, u32 orig_value, u32 value)
> +{
> +	if (XE_GT_WA(gt, 14028564128) &&
> +	    REG_FIELD_GET(XE2_COH_MODE, orig_value) == XE_COH_2WAY)
> +		value |= XE2_NO_PROMOTE;

This is just setting the XE2_NO_PROMOTE flag and is not setting the
other required ones.  Is this is implemented this way because of
Wa_14026539277?

Because Wa_14026539277 applies only to A* steppings, we would wind up
with the wrong PAT bits on B* steppings.

Note that Wa_14028564128 must be applied to all steppings of graphics
version 35.10.

I propose we make this function set all the required bits and ensure
that wa_14028564128_fixup_pat_value() is always called before
wa_14026539277_fixup_pat_value() (and with a comment noting the ordering
dependency), because the modifications done by Wa_14028564128 are a
superset of the ones done by Wa_14026539277.

> +
> +	return value;
> +}
> +
>  static const struct xe_pat_table_entry *gt_pta_entry(struct xe_gt *gt)
>  {
>  	struct xe_device *xe = gt_to_xe(gt);
> @@ -420,6 +456,8 @@ static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry ta
>  		struct xe_reg_mcr reg_mcr = XE_REG_MCR(_PAT_INDEX(i));
>  		u32 pat = wa_14026539277_fixup_pat_value(gt, table[i].value);
>  
> +		pat = wa_14028564128_fixup_pat_value(gt, table[i].value, pat);
> +
>  		xe_gt_mcr_multicast_write(gt, reg_mcr, pat);
>  	}
>  
> @@ -810,6 +848,7 @@ int xe_pat_dump_sw_config(struct xe_gt *gt, struct drm_printer *p)
>  		u32 pat = xe->pat.table[i].value;
>  
>  		pat = wa_14026539277_fixup_pat_value(gt, pat);
> +		pat = wa_14028564128_fixup_pat_value(gt, xe->pat.table[i].value, pat);
>  
>  		if (GRAPHICS_VER(xe) >= 20) {
>  			bool rsvd = !xe->pat.table[i].valid ||
> diff --git a/drivers/gpu/drm/xe/xe_pat.h b/drivers/gpu/drm/xe/xe_pat.h
> index 2ac6ddc66587..247dc0faa095 100644
> --- a/drivers/gpu/drm/xe/xe_pat.h
> +++ b/drivers/gpu/drm/xe/xe_pat.h
> @@ -105,6 +105,20 @@ u16 xe_pat_index_get_l3_policy(struct xe_device *xe, u16 pat_index);
>   */
>  bool xe_pat_wa_14026539277_reserved(struct xe_device *xe, u16 pat_index);
>  
> +/**
> + * xe_pat_wa_14028564128_safe_userptr_index - Is this PAT index safe for
> + * misaligned host-pointer userptr/SVM binds due to Wa_14028564128?
> + * @xe: xe device
> + * @pat_index: The pat_index to query
> + *
> + * Wa_14028564128 reprograms PAT index 2 to the no-promote/UC/1-way policy
> + * required for misaligned host pointers; once that WA is enabled, index 2
> + * should be accepted anywhere PAT 19 or a 2-way coherent index already is.
> + *
> + * Return: a boolean indicating whether the PAT index is safe to use.
> + */
> +bool xe_pat_wa_14028564128_safe_userptr_index(struct xe_device *xe, u16 pat_index);
> +
>  #define xe_cache_pat_idx(xe, cache_mode) ({					\
>  	const struct xe_device *__xedev = (xe);					\
>  	enum xe_cache_level __mode = (cache_mode);				\
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index dd855876f571..80ccaa44720c 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -3888,7 +3888,8 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,
>  		    XE_IOCTL_DBG(xe, xe_device_is_l2_flush_optimized(xe) &&
>  				 (op == DRM_XE_VM_BIND_OP_MAP_USERPTR ||
>  				  is_cpu_addr_mirror) &&
> -				 (pat_index != 19 && coh_mode != XE_COH_2WAY)) ||
> +				 (pat_index != 19 && coh_mode != XE_COH_2WAY &&
> +				  !xe_pat_wa_14028564128_safe_userptr_index(xe, pat_index))) ||
>  		    XE_IOCTL_DBG(xe, comp_en &&
>  				 op == DRM_XE_VM_BIND_OP_MAP_USERPTR) ||
>  		    XE_IOCTL_DBG(xe, op == DRM_XE_VM_BIND_OP_MAP_USERPTR &&
> @@ -4033,7 +4034,8 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,
>  		return -EINVAL;
>  
>  	if (XE_IOCTL_DBG(xe, bo->ttm.base.import_attach && xe_device_is_l2_flush_optimized(xe) &&
> -			 (pat_index != 19 && coh_mode != XE_COH_2WAY)))
> +			 (pat_index != 19 && coh_mode != XE_COH_2WAY &&
> +			  !xe_pat_wa_14028564128_safe_userptr_index(xe, pat_index))))
>  		return -EINVAL;
>  
>  	/* If a BO is protected it can only be mapped if the key is still valid */
> diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c
> index 31245c6c96d4..80dedeaae579 100644
> --- a/drivers/gpu/drm/xe/xe_vm_madvise.c
> +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c
> @@ -594,6 +594,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  	};
>  	struct xe_madvise_details details;
>  	u16 pat_index, coh_mode;
> +	bool safe_pat;
>  	struct xe_vm *vm;
>  	struct drm_exec exec;
>  	int err, attr_type;
> @@ -653,9 +654,11 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  	if (args->type == DRM_XE_MEM_RANGE_ATTR_PAT) {
>  		pat_index = array_index_nospec(args->pat_index.val, xe->pat.n_entries);
>  		coh_mode = xe_pat_index_get_coh_mode(xe, pat_index);
> +		safe_pat = xe_pat_wa_14028564128_safe_userptr_index(xe, pat_index);
>  		if (XE_IOCTL_DBG(xe, madvise_range.has_svm_userptr_vmas &&
>  				 xe_device_is_l2_flush_optimized(xe) &&
> -				 (pat_index != 19 && coh_mode != XE_COH_2WAY))) {
> +				 (pat_index != 19 && coh_mode != XE_COH_2WAY &&
> +				  !safe_pat))) {
>  			err = -EINVAL;
>  			goto free_vmas;
>  		}
> @@ -685,10 +688,12 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
>  					continue;
>  
>  				if (args->type == DRM_XE_MEM_RANGE_ATTR_PAT) {
> +					bool invalid_pat = pat_index != 19 &&
> +						coh_mode != XE_COH_2WAY && !safe_pat;
> +
>  					if (XE_IOCTL_DBG(xe, bo->ttm.base.import_attach &&
>  							 xe_device_is_l2_flush_optimized(xe) &&
> -							 (pat_index != 19 &&
> -							  coh_mode != XE_COH_2WAY))) {
> +							 invalid_pat)) {
>  						err = -EINVAL;
>  						goto err_fini;
>  					}
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 03b713f55dfb..6a48b2c716ea 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -74,6 +74,7 @@
>  16029897822	MEDIA_VERSION(3500)
>  		GRAPHICS_VERSION(3510)
>  14026539277	GRAPHICS_VERSION(3510), GRAPHICS_STEP(A0, B0)
> +14028564128	GRAPHICS_VERSION(3510), GRAPHICS_STEP(A0, B0)

This is a temporary workaround for graphics version 35.10, meaning that
we should drop GRAPHICS_STEP(A0, B0) here.

--
Gustavo Sousa

>  14027054324	GRAPHICS_VERSION(3511)
>  14025941587	GRAPHICS_VERSION_RANGE(2001, 3511)
>  		MEDIA_VERSION_RANGE(1301, 3503)
> -- 
> 2.52.0

      parent reply	other threads:[~2026-11-20 23:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  7:52 [PATCH V2] drm/xe/nvl-p: Add Wa_14028564128 Tejas Upadhyay
2026-11-19  8:08 ` sashiko-bot
2026-11-19  9:48 ` ✓ CI.KUnit: success for drm/xe/nvl-p: Add Wa_14028564128 (rev2) Patchwork
2026-11-19 10:47 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-20 15:30 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-20 23:58 ` Gustavo Sousa [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=877bi7qcms.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=nitin.r.gote@intel.com \
    --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