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 15/16] drm/xe: Allow probe without a primary GT
Date: Fri, 20 Nov 2026 06:13:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-224544@kernel.org> (raw)
In-Reply-To: <20261120054712.377573-33-stuart.summers@intel.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] drm/xe: NULL derefs in probe when primary GT is disabled via
  configfs
- [High] drm/xe: NULL program_media call in xe_pat_init() when
  graphics_ip is NULL
- [High] drm/xe: missing xe_ggtt_init() and NULL assert deref without
  primary_gt
- [Medium] drm/xe: unguarded primary_gt in xe_pt.c/xe_svm.c and blit in
  memtest
- [Low] drm/xe: commit message inaccurately states VRAM is a graphics IP
  property
--

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

drm/xe: Allow probe without a primary GT

This commit allows probing a device when either the graphics IP or the
media IP is detected and each tile has at least one GT, removing the hard
requirement for a graphics IP and a primary GT.

> The dgpu concern the old comment raised is covered by VRAM being a
> graphics IP property, so a device without one has no VRAM to manage.

[Severity: Low]
Is this commit message description accurate?  Discrete GPU status and VRAM
configuration (desc->is_dgfx and desc->vram_flags) come from the platform
device descriptor rather than the graphics IP descriptor, so a discrete GPU
probed without a graphics IP or primary GT still allocates and probes VRAM
via xe_tile_alloc_vram() and xe_vram_probe().

> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index 998cd11802a86..db443828f1d56 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
> @@ -1059,11 +1059,11 @@ static int xe_probe_ips(struct xe_device *xe,
>  	}
>  
>  	/*
> -	 * If we couldn't detect the graphics IP, that's considered a fatal
> -	 * error and we should abort driver load.  Failing to detect media
> -	 * IP is non-fatal; we'll just proceed without enabling media support.
> +	 * Either IP on its own is enough to go on with.  Only a device where
> +	 * neither could be detected is a fatal error, since there would be
> +	 * nothing left to drive.
>  	 */
> -	if (!probed_info->graphics_ip)
> +	if (!probed_info->graphics_ip && !probed_info->media_ip)
>  		return -ENODEV;
>  
>  	return 0;

[Severity: High]
When probed_info->graphics_ip is NULL, xe->info.graphics_verx100 remains 0.
Can xe_pat_init() then call a NULL xe->pat.ops->program_media pointer when
initializing the media GT?

In xe_pat_init_early(), every non-MTL platform checks GRAPHICS_VER(xe) or
GRAPHICS_VERx100(xe), so a value of 0 falls into the
GRAPHICS_VERx100(xe) <= 1210 branch and selects xelp_pat_ops, where
program_media is NULL.  Having GRAPHICS_VERx100(xe) == 0 also causes
ggtt_probe(), xe_force_wake_init_gt(), rw_with_mcr_steering(), and
read_media_fuses() to take legacy pre-Gen12.5 paths on the media GT.

> @@ -1178,21 +1178,14 @@ static int xe_info_init(struct xe_device *xe,
>  		if (IS_ERR(tile->primary_gt))
>  			return PTR_ERR(tile->primary_gt);
>  
> -		/*
> -		 * It's not currently possible to probe a device with the
> -		 * primary GT disabled.  With some work, this may be future in
> -		 * the possible for igpu platforms (although probably not for
> -		 * dgpu's since access to the primary GT's BCS engines is
> -		 * required for VRAM management).
> -		 */
> -		if (!tile->primary_gt) {
> -			drm_err(&xe->drm, "Cannot probe device with without a primary GT\n");
> -			return -ENODEV;
> -		}
> -
>  		tile->media_gt = alloc_media_gt(tile, media_desc);
>  		if (IS_ERR(tile->media_gt))
>  			return PTR_ERR(tile->media_gt);
> +
> +		if (!tile->primary_gt && !tile->media_gt) {
> +			xe_tile_err(tile, "Cannot probe tile without any GT\n");
> +			return -ENODEV;
> +		}
>  	}

[Severity: High]
When the primary GT is disabled via configfs (gt_types_allowed=media) on a
platform that physically has a graphics IP, can probe hit NULL pointer
dereferences in get_flat_ccs_offset() and xe_migrate_prepare_vm()?

Because probed_info->graphics_ip is still detected from hardware,
xe_info_init() populates graphics_desc without checking
xe_configfs_primary_gt_allowed():

drivers/gpu/drm/xe/xe_pci.c:xe_info_init() {
	...
	if (graphics_desc) {
		...
		xe->info.has_usm = graphics_desc->has_usm;
		xe->info.has_64bit_timestamp = graphics_desc->has_64bit_timestamp;
	} else {
		xe->info.has_flat_ccs = 0;
	}
}

With tile->primary_gt set to NULL by alloc_primary_gt(), xe->info.has_flat_ccs
and xe->info.has_usm remain enabled:

1. probe_has_flat_ccs() sees xe_root_mmio_gt(xe) == NULL and returns early
   without clearing has_flat_ccs, so on discrete GPUs with Flat CCS,
   xe_vram_probe() -> tile_vram_size() passes gt = tile->primary_gt (NULL)
   to get_flat_ccs_offset(), which dereferences gt.
2. In gt_init_with_all_forcewake(), gt->usm.bb_pool is only allocated when
   xe_gt_is_main_type(gt) is true, leaving tile->media_gt->usm.bb_pool NULL.
   When xe_migrate_init() runs on tile->media_gt (now the tile's
   xe_tile_pt_gt()), xe_migrate_prepare_vm() checks xe->info.has_usm and
   dereferences xe_tile_pt_gt(tile)->usm.bb_pool->bo.

[Severity: High]
When tile->primary_gt is NULL, does probing skip xe_ggtt_init() and
dereference a NULL primary_gt in ggtt_init_ranges()?

In ggtt_init_ranges(), gt = ggtt->tile->primary_gt is passed to
xe_gt_assert(gt, full_size), which evaluates gt_to_tile(gt) ((gt)->tile)
when CONFIG_DRM_XE_DEBUG is enabled.  Later, in gt_init_with_gt_forcewake(),
xe_ggtt_init() is only called under if (xe_gt_is_main_type(gt)), so a tile
with only a media GT never initializes its GGTT scratch page or clears the
GGTT.  Similarly, xe_gt_flr_prepare() and xe_gt_reinit() still gate
xe_migrate_flr_prepare() and xe_migrate_reinit() on xe_gt_is_main_type(gt)
rather than gt == xe_tile_pt_gt(gt_to_tile(gt)).

[Severity: Medium]
Are there remaining paths after probe that assume tile->primary_gt is
non-NULL or that tile->migrate supports blitter commands?

In xe_pt.c, generate_reclaim_entry(), add_pte_to_prl(), and
xe_pt_stage_unbind_entry() pass tile->primary_gt to xe_gt_stats_incr() and
xe_page_reclaim_list_abort(), which dereference gt->stats (when
CONFIG_DEBUG_FS is enabled) and gt_to_xe(gt)->drm on platforms with
has_page_reclaim_hw_assist.  In xe_svm.c,
xe_svm_range_notifier_event_begin() and xe_svm_invalidate() guard
tile->media_gt before updating TLB invalidation stats, but pass
tile->primary_gt unconditionally.  Also, in xe_vram.c, xe_vram_memtest()
calls xe_migrate_clear() without checking xe_migrate_can_blit(tile->migrate),
emitting blitter clear commands onto the media GT's migration queue.

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

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

Thread overview: 22+ 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
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  6:13   ` sashiko-bot [this message]
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-224544@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