Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stuart Summers" <stuart.summers@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 11/16] drm/xe: Run page table updates on the media GT when there is no primary
Date: Fri, 20 Nov 2026 06:10:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-224538@kernel.org> (raw)
In-Reply-To: <20261120054712.377573-29-stuart.summers@intel.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/xe: xe_gt_flr_prepare() and xe_gt_reinit() skip
  media-only tile migration
- [Medium] drm/xe: NULL dereference of usm.bb_pool in
  xe_migrate_prepare_vm()
- [Medium] drm/xe: silent no-op blit copy and clear on media-only tiles
  in xe_migrate
--

commit e4d0026f61d092e34250b892e47f82036445a7f5
Author: Stuart Summers <stuart.summers@intel.com>

drm/xe: Run page table updates on the media GT when there is no primary

This commit introduces xe_tile_pt_gt() and xe_tile_pt_class() so that tile
migration and bind exec queues fall back to the media GT and a video
decode engine when a tile has no primary GT.

> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index fe71cb011d3a0..327e4985d8586 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c

[ ... ]

> @@ -657,10 +658,12 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt)
>  		}
>  	}
>  
> -	if (xe_gt_is_main_type(gt)) {
> -		struct xe_tile *tile = gt_to_tile(gt);
> -
> -		err = xe_migrate_init(tile->migrate);
> +	/*
> +	 * Normally the migration context runs on the primary GT, but a tile
> +	 * with no graphics IP has only its media GT to run it on.
> +	 */
> +	if (gt == xe_tile_pt_gt(gt_to_tile(gt))) {
> +		err = xe_migrate_init(gt_to_tile(gt)->migrate);
>  		if (err)
>  			return err;
>  	}

[Severity: Medium]
Should xe_gt_flr_prepare() and xe_gt_reinit() also check
gt == xe_tile_pt_gt(gt_to_tile(gt)) instead of xe_gt_is_main_type(gt)?

On a tile with no primary GT, xe_migrate_init() now sets up tile->migrate
on the media GT, where xe_gt_is_main_type(gt) is false.  Across a PCIe
FLR, xe_uc_flr_prepare() tears down the media GT's GuC queues (including
tile->migrate->q), while xe_gt_flr_prepare() and xe_gt_reinit() skip
xe_migrate_flr_prepare() and xe_migrate_reinit(), leaving the migration VM
page tables and queue uninitialized after resume.

> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index d7a8d8ecffe63..8fc3e5d500a2b 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c

[ ... ]

> @@ -485,7 +486,7 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
>  		if (xe->info.has_usm) {
>  			xe_tile_assert(tile, xe_bo_size(batch) == SZ_1M);
>  
> -			batch = tile->primary_gt->usm.bb_pool->bo;
> +			batch = xe_tile_pt_gt(tile)->usm.bb_pool->bo;
>  			m->usm_batch_base_ofs = m->batch_base_ofs + SZ_1M;
>  			xe_tile_assert(tile, xe_bo_size(batch) == SZ_512K);
>  
> @@ -506,7 +507,7 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
>  		m->batch_base_ofs = xe_migrate_vram_ofs(xe, batch_addr, false);
>  
>  		if (xe->info.has_usm) {
> -			batch = tile->primary_gt->usm.bb_pool->bo;
> +			batch = xe_tile_pt_gt(tile)->usm.bb_pool->bo;
>  			batch_addr = xe_bo_addr(batch, 0, XE_PAGE_SIZE);
>  			m->usm_batch_base_ofs = xe_migrate_vram_ofs(xe, batch_addr, false);
>  		}

[Severity: Medium]
Can xe_tile_pt_gt(tile)->usm.bb_pool be NULL here when tile->primary_gt is
NULL and xe->info.has_usm is set (for example, with gt_types_allowed=media
in configfs on an Xe2+ platform)?

gt_init_with_all_forcewake() only allocates gt->usm.bb_pool when
xe_gt_is_main_type(gt) is true, so tile->media_gt->usm.bb_pool is NULL and
xe_migrate_prepare_vm() dereferences a NULL pointer.  Even if bb_pool were
allocated on xe_tile_pt_gt(tile), media GTs have no copy engines, so
gt->usm.paging_hwe0 is also NULL and the xe->info.has_usm paths in
xe_migrate_init() and xe_exec_queue_create_bind() will fail with -EINVAL
instead of falling back to xe_tile_pt_class(tile).

[ ... ]

> @@ -1276,7 +1277,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  					   bool copy_only_ccs,
>  					   bool is_vram_resolve)
>  {
> -	struct xe_gt *gt = m->tile->primary_gt;
> +	struct xe_gt *gt = xe_tile_pt_gt(m->tile);
>  	struct xe_device *xe = gt_to_xe(gt);
>  	struct dma_fence *fence = NULL;
>  	u64 size = xe_bo_size(src_bo);

[ ... ]

> @@ -1992,7 +1993,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  	bool clear_vram = is_devmem(bo, dst);
>  	bool clear_bo_data = XE_MIGRATE_CLEAR_FLAG_BO_DATA & clear_flags;
>  	bool clear_ccs = XE_MIGRATE_CLEAR_FLAG_CCS_DATA & clear_flags;
> -	struct xe_gt *gt = m->tile->primary_gt;
> +	struct xe_gt *gt = xe_tile_pt_gt(m->tile);
>  	struct xe_device *xe = gt_to_xe(gt);
>  	bool clear_only_system_ccs = false;
>  	struct dma_fence *fence = NULL;
> @@ -2357,7 +2358,7 @@ static struct dma_fence *xe_migrate_vram(struct xe_migrate *m,
>  					 struct dma_fence *deps,
>  					 const enum xe_migrate_copy_dir dir)
>  {
> -	struct xe_gt *gt = m->tile->primary_gt;
> +	struct xe_gt *gt = xe_tile_pt_gt(m->tile);
>  	struct xe_device *xe = gt_to_xe(gt);
>  	bool use_usm_batch = xe->info.has_usm;
>  	struct dma_fence *fence = NULL;

[Severity: Medium]
When m->q is created on XE_ENGINE_CLASS_VIDEO_DECODE, do these blit copy
and clear paths silently succeed without copying or clearing memory?

A migration job puts the PTE updates in job->ptrs[0].batch_addr and the
blitter commands in job->ptrs[1].batch_addr, but the video decode ring
ops only emit job->ptrs[0]:

drivers/gpu/drm/xe/xe_ring_ops.c:emit_job_gen12_video() {
	for (i = 0; i < job->q->width; ++i)
		__emit_job_gen12_video(job, job->q->lrc[i],
				       job->ptrs[i].batch_addr,
				       &job->ptrs[i].head,
				       xe_sched_job_lrc_seqno(job));
}

With q->width == 1, the engine executes only the PTE batch and signals the
job fence without running the copy or clear batch.  Later in the series,
commit "drm/xe: Fall back to CPU copies when the tile cannot blit" adds
xe_migrate_can_blit() checks to TTM moves, but other callers remain
unguarded: xe_ttm_access_memory() still calls xe_migrate_access_memory()
-> xe_migrate_vram() when len >= SZ_16K (silently dropping ptrace or
/proc/<pid>/mem reads and writes on VRAM BOs), and xe_vram_memtest() calls
xe_migrate_clear() and fails probe with -EIO when CONFIG_DRM_XE_DEBUG_MEM
is enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120054712.377573-18-stuart.summers@intel.com?part=11

  reply	other threads:[~2026-11-20  6:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  5:47 [PATCH 00/16] Work around media 52-bit limitation on CRI Stuart Summers
2026-11-20  5:47 ` [PATCH 01/16] drm/xe/sysctrl: Use preallocated mailbox staging buffers Stuart Summers
2026-11-20  5:52   ` sashiko-bot
2026-11-20  5:47 ` [PATCH 02/16] drm/xe: Process device OOB workarounds during early info init Stuart Summers
2026-11-20  5:47 ` [PATCH 03/16] drm/xe/sysctrl: Restore the SoC remapper on every runtime resume Stuart Summers
2026-11-20  5:47 ` [PATCH 04/16] drm/xe: Add enable_media module parameter Stuart Summers
2026-11-20  5:47 ` [PATCH 05/16] drm/xe: Detect each GMD_ID IP in a loop Stuart Summers
2026-11-20  5:47 ` [PATCH 06/16] drm/xe: Tolerate a missing graphics IP in xe_info_init() Stuart Summers
2026-11-20  5:47 ` [PATCH 07/16] drm/xe: Verify IP presence against GU_CNTL Stuart Summers
2026-11-20  5:47 ` [PATCH 08/16] drm/xe: Guard per-tile primary GT accesses Stuart Summers
2026-11-20  5:47 ` [PATCH 09/16] drm/xe: Stop assuming the root tile has a primary GT Stuart Summers
2026-11-20  5:47 ` [PATCH 10/16] drm/xe: Do not claim flat CCS without a graphics IP Stuart Summers
2026-11-20  5:47 ` [PATCH 11/16] drm/xe: Run page table updates on the media GT when there is no primary Stuart Summers
2026-11-20  6:10   ` sashiko-bot [this message]
2026-11-20  5:47 ` [PATCH 12/16] drm/xe: Document that gt_types_allowed=media now probes Stuart Summers
2026-11-20  5:47 ` [PATCH 13/16] drm/xe: Fall back to CPU copies when the tile cannot blit Stuart Summers
2026-11-20  6:09   ` sashiko-bot
2026-11-20  5:47 ` [PATCH 14/16] drm/xe: Require a fully visible VRAM BAR without a primary GT Stuart Summers
2026-11-20  5:47 ` [PATCH 15/16] drm/xe: Allow probe " Stuart Summers
2026-11-20  5:47 ` [PATCH 16/16] drm/xe: Work around media 52-bit limitation on CRI Stuart Summers
2026-11-20  6:11   ` sashiko-bot

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=sashiko-outbox-224538@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=stuart.summers@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