Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Varun Gupta <varun.gupta@intel.com>, <intel-xe@lists.freedesktop.org>
Cc: matthew.d.roper@intel.com, tilak.tirumalesh.tangudu@intel.com,
	tejas.upadhyay@intel.com,
	"Piotr Piórkowski" <piotr.piorkowski@intel.com>
Subject: Re: [PATCH 1/2] drm/xe/xe3p_lpg: Implement Wa_14028597154
Date: Wed, 25 Nov 2026 18:19:33 -0300	[thread overview]
Message-ID: <878q2ga9sq.fsf@intel.com> (raw)
In-Reply-To: <20261124130657.800225-5-varun.gupta@intel.com>

Varun Gupta <varun.gupta@intel.com> writes:

> On graphics version 35.10, when multi-queue is enabled, CS can compute a
> wrong address for the semaphore token it writes on a queue switch: the
> intended GGTT address shifted right by 10 bits. Those writes land in the
> low 4MB of GGTT, below the WOPCM-sized range the driver allocates from
> and never maps, causing GGTT faults and CAT errors.
>
> Since the tokens are also lost/overwritten by other aspects of the bug,
> there is no need to preserve these writes, only to make them harmless.
> Back the low-4MB PTEs reachable from [ggtt->start, ggtt->start +
> ggtt->size) plus one trailing spill page with a dedicated device-managed
> dummy page on native and PF, and restore these low-4MB PTEs on suspend,
> FLR, and D3cold resume since they are not covered by pinned BO restore.
> The existing GGTT scratch page is left untouched (it is not allocated on
> multi-queue GTs), so stale translations in the allocatable range keep
> faulting.
>
> SR-IOV VF support is deferred to a follow-up once PF/VF ABI negotiation
> is in place.
>
> Signed-off-by: Varun Gupta <varun.gupta@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_device.c     |  3 +
>  drivers/gpu/drm/xe/xe_ggtt.c       | 90 +++++++++++++++++++++++++++++-
>  drivers/gpu/drm/xe/xe_ggtt.h       |  1 +
>  drivers/gpu/drm/xe/xe_pm.c         |  3 +
>  drivers/gpu/drm/xe/xe_wa_oob.rules |  1 +
>  5 files changed, 96 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index eafc66d686e2..b02610d2cfe1 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -1510,6 +1510,9 @@ int xe_device_resume(struct xe_device *xe, bool flr)
>  			return err;
>  	}
>  
> +	for_each_tile(tile, xe, id)
> +		xe_ggtt_resume(tile->mem.ggtt);
> +
>  	xe_i2c_pm_resume(xe, true);
>  
>  	xe_sysctrl_pm_resume(xe);
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 86fc3d186fc8..eca9c085ddb9 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -130,6 +130,8 @@ struct xe_ggtt {
>  	unsigned int flags;
>  	/** @scratch: Internal object allocation used as a scratch page */
>  	struct xe_bo *scratch;
> +	/** @low_4m_pte: PTE backing GGTT [4K, 4M), 0 if unused */
> +	u64 low_4m_pte;
>  	/** @lock: Mutex lock to protect GGTT data */
>  	struct mutex lock;
>  	/**
> @@ -250,13 +252,27 @@ u64 xe_ggtt_size(struct xe_ggtt *ggtt)
>  	return ggtt->size;
>  }
>  
> -static void xe_ggtt_set_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte)
> +static void __xe_ggtt_set_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte)
>  {
>  	xe_tile_assert(ggtt->tile, !(addr & XE_PTE_MASK));
> +
> +	writeq(pte, &ggtt->gsm[addr >> XE_PTE_SHIFT]);
> +}
> +
> +static void xe_ggtt_set_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte)
> +{
>  	xe_tile_assert(ggtt->tile, addr >= ggtt->start);
>  	xe_tile_assert(ggtt->tile, addr < ggtt->start + ggtt->full_size);
>  
> -	writeq(pte, &ggtt->gsm[addr >> XE_PTE_SHIFT]);
> +	__xe_ggtt_set_pte(ggtt, addr, pte);
> +}
> +
> +static void ggtt_set_low_4m_pte(struct xe_ggtt *ggtt, u64 addr, u64 pte)
> +{
> +	xe_tile_assert(ggtt->tile, addr >= XE_PAGE_SIZE && addr < SZ_4M);
> +	xe_tile_assert(ggtt->tile, addr < ggtt->start);
> +
> +	__xe_ggtt_set_pte(ggtt, addr, pte);
>  }
>  
>  static void xe_ggtt_set_pte_and_flush(struct xe_ggtt *ggtt, u64 addr, u64 pte)
> @@ -552,6 +568,71 @@ ALLOW_ERROR_INJECTION(xe_ggtt_init_early, ERRNO); /* See xe_pci_probe() */
>  static void xe_ggtt_invalidate(struct xe_ggtt *ggtt);
>  static void xe_ggtt_invalidate_engine(struct xe_ggtt *ggtt);
>  
> +static void ggtt_restore_low_4m_locked(struct xe_ggtt *ggtt)
> +{
> +	u64 low_start = max_t(u64, ALIGN_DOWN(ggtt->start, SZ_4M) >> 10,
> +			      XE_PAGE_SIZE);
> +	u64 low_end = min_t(u64, (ALIGN(ggtt->start + ggtt->size, SZ_4M) >> 10) +
> +			    XE_PAGE_SIZE, SZ_4M);
> +	u64 addr;
> +
> +	lockdep_assert_held(&ggtt->lock);
> +
> +	if (!ggtt->low_4m_pte)
> +		return;
> +
> +	for (addr = low_start; addr < low_end; addr += XE_PAGE_SIZE)
> +		ggtt_set_low_4m_pte(ggtt, addr, ggtt->low_4m_pte);
> +}
> +
> +/*
> + * Wa_14028597154: multi-queue CS may write semaphore tokens to (addr >> 10),
> + * i.e. into the low 4MB of GGTT, below the range we allocate from.
> + */
> +static int ggtt_map_low_4m_wa(struct xe_ggtt *ggtt)
> +{
> +	struct xe_tile *tile = ggtt->tile;
> +	struct xe_device *xe = tile_to_xe(tile);
> +	u16 pat_index = xe_cache_pat_idx(xe, XE_CACHE_WB);
> +	struct xe_bo *bo;
> +	u64 pte;
> +
> +	/*
> +	 * TODO: SR-IOV VF support for Wa_14028597154 requires PF/VF ABI
> +	 * negotiation so PF can assign the VF's low-4MB PTEs and VF can map
> +	 * its own dummy page.

Do we really need this negotiation? I would assume that the SRIOV
implementation for this would be making sure that pf_provision_vf_ggtt()
does what is instructed by the workaround:

  (1) Ensure the start and size of the PF GGTT node allocated for the VF
      is 4MiB aligned.

  (2) Ensure that xe_ggtt_assign() also assign the respective PTEs in
      the low 4MiB range to the VF.

In addition to that, we would also need to ensure that LRC allocation
follows the recommendations from the workaround.

Thoughts?

Cc: Piotr

> +	 */
> +	if (IS_SRIOV_VF(xe))
> +		return 0;
> +
> +	if (!tile->primary_gt || !XE_GT_WA(tile->primary_gt, 14028597154) ||
> +	    !xe_gt_has_multi_queue(tile->primary_gt))
> +		return 0;
> +
> +	bo = xe_managed_bo_create_pin_map(xe, tile, XE_PAGE_SIZE, XE_BO_FLAG_SYSTEM);
> +	if (IS_ERR(bo))
> +		return PTR_ERR(bo);
> +
> +	pte = xe_bo_addr(bo, 0, XE_PAGE_SIZE) |
> +	      ggtt->pt_ops->pte_encode_flags(bo, pat_index);
> +
> +	guard(mutex)(&ggtt->lock);
> +	ggtt->low_4m_pte = pte;
> +	ggtt_restore_low_4m_locked(ggtt);

I think it is better to use scoped_guard() here.

--
Gustavo Sousa

> +
> +	return 0;
> +}
> +
> +/**
> + * xe_ggtt_resume - Restore GGTT entries not covered by pinned BO restore
> + * @ggtt: the &xe_ggtt to restore
> + */
> +void xe_ggtt_resume(struct xe_ggtt *ggtt)
> +{
> +	guard(mutex)(&ggtt->lock);
> +	ggtt_restore_low_4m_locked(ggtt);
> +}
> +
>  static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
>  {
>  	struct drm_mm_node *hole;
> @@ -668,6 +749,11 @@ int xe_ggtt_init(struct xe_ggtt *ggtt)
>  			      xe_bo_size(ggtt->scratch));
>  	}
>  
> +	err = ggtt_map_low_4m_wa(ggtt);
> +	if (err)
> +		goto err;
> +
> +	/* Also invalidates GGTT TLBs for the low 4MB entries above */
>  	xe_ggtt_initial_clear(ggtt);
>  
>  	return devm_add_action_or_reset(xe->drm.dev, ggtt_fini, ggtt);
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 59b2f0287019..78e68c2ca3ad 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -17,6 +17,7 @@ struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
>  int xe_ggtt_init_early(struct xe_ggtt *ggtt);
>  int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size);
>  int xe_ggtt_init(struct xe_ggtt *ggtt);
> +void xe_ggtt_resume(struct xe_ggtt *ggtt);
>  
>  void xe_ggtt_shift_nodes(struct xe_ggtt *ggtt, u64 new_base);
>  u64 xe_ggtt_start(struct xe_ggtt *ggtt);
> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> index f73f68bd449b..6a20a6648253 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -650,6 +650,9 @@ int xe_pm_runtime_resume(struct xe_device *xe)
>  		err = xe_bo_restore_early(xe);
>  		if (err)
>  			goto out;
> +
> +		for_each_tile(tile, xe, id)
> +			xe_ggtt_resume(tile->mem.ggtt);
>  	}
>  
>  	xe_i2c_pm_resume(xe, xe->d3cold.allowed);
> diff --git a/drivers/gpu/drm/xe/xe_wa_oob.rules b/drivers/gpu/drm/xe/xe_wa_oob.rules
> index 03b713f55dfb..6bae09c0b3ff 100644
> --- a/drivers/gpu/drm/xe/xe_wa_oob.rules
> +++ b/drivers/gpu/drm/xe/xe_wa_oob.rules
> @@ -81,3 +81,4 @@
>  14028709524	GRAPHICS_VERSION(3510)
>  14028250015	GRAPHICS_VERSION(3510)
>  16031259911	GRAPHICS_VERSION_RANGE(3510, 3511)
> +14028597154	GRAPHICS_VERSION(3510), GRAPHICS_STEP(B0, FOREVER)
> -- 
> 2.43.0

  reply	other threads:[~2026-11-25 21:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 13:06 [PATCH 0/2] drm/xe/xe3p_lpg: Implement Wa_14028597154 Varun Gupta
2026-11-24 13:06 ` [PATCH 1/2] " Varun Gupta
2026-11-25 21:19   ` Gustavo Sousa [this message]
2026-11-24 13:07 ` [PATCH 2/2] drm/xe/guc: Enable the KLV for Wa_14028597154 Varun Gupta
2026-11-24 13:35 ` ✗ CI.KUnit: failure for drm/xe/xe3p_lpg: Implement Wa_14028597154 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=878q2ga9sq.fsf@intel.com \
    --to=gustavo.sousa@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=piotr.piorkowski@intel.com \
    --cc=tejas.upadhyay@intel.com \
    --cc=tilak.tirumalesh.tangudu@intel.com \
    --cc=varun.gupta@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