All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Auld" <matthew.auld@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/xe: only evict CCS buffers from TT on iGPU
Date: Fri, 06 Nov 2026 10:50:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-201230@kernel.org> (raw)
In-Reply-To: <20261106-s4-opti-v1-1-5edaea2c6d31@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/xe: missing ttm_bo_unmap_virtual() before xe_ttm_bo_purge()
  in eviction
--

commit 0a382553920cfe97389f0ff2b7a78f7419640c3e
Author: Matthew Auld <matthew.auld@intel.com>

drm/xe: only evict CCS buffers from TT on iGPU

This commit changes xe_bo_evict_all_user() on iGPU platforms with Flat CCS
to walk the XE_PL_TT LRU and only evict or purge buffers with initialized
CCS state rather than evicting all buffers in TT.

> diff --git a/drivers/gpu/drm/xe/xe_bo_evict.c b/drivers/gpu/drm/xe/xe_bo_evict.c
> index 7661fca7f278f..1f95769c4a562 100644
> --- a/drivers/gpu/drm/xe/xe_bo_evict.c
> +++ b/drivers/gpu/drm/xe/xe_bo_evict.c
[ ... ]
> @@ -104,8 +106,46 @@ void xe_bo_notifier_unprepare_all_pinned(struct xe_device *xe)
>  				    xe_bo_notifier_unprepare_pinned);
>  }
>  
> +static int xe_bo_evict_all_ccs(struct ttm_resource_manager *man)
> +{
> +	struct ttm_operation_ctx ctx = {
> +		.interruptible = false,
> +		.no_wait_gpu = false,
> +	};
> +	struct ttm_lru_walk_arg arg = {
> +		.ctx = &ctx,
> +		.sleeping_lock = true,
> +	};
> +	struct ttm_bo_lru_cursor cursor;
> +	struct ttm_buffer_object *ttm_bo;
> +	int ret = 0;
> +
> +	ttm_bo_lru_for_each_reserved_guarded(&cursor, man, &arg, ttm_bo) {
> +		struct xe_bo *bo;
> +
> +		if (!xe_bo_is_xe_bo(ttm_bo) || ttm_bo->deleted)
> +			continue;
> +
> +		bo = ttm_to_xe_bo(ttm_bo);
> +		if (xe_bo_is_pinned(bo) || !xe_bo_needs_ccs_pages(bo) ||
> +		    !bo->ccs_cleared)
> +			continue;
> +
> +		if (xe_bo_madv_is_dontneed(bo))
> +			ret = xe_ttm_bo_purge(ttm_bo, &ctx);

[Severity: High]
Does calling xe_ttm_bo_purge() directly without ttm_bo_unmap_virtual()
leave userspace CPU mmap PTEs pointing to freed backing pages?

When a CPU-faulted BO is marked DONTNEED via xe_vm_madvise_ioctl(),
PTE invalidation is deferred until the BO is moved or purged.  Previously,
ttm_resource_manager_evict_all() went through ttm_bo_handle_move_mem(),
which calls ttm_bo_unmap_virtual() before invoking xe_bo_move() ->
xe_ttm_bo_purge().

Calling xe_ttm_bo_purge() directly here runs xe_bo_move_notify() (which
only unmaps kernel vmaps) and then calls ttm_bo_validate() with an empty
placement, which goes straight to ttm_bo_pipeline_gutting() and frees the
pages back to the TTM page pool without unmapping userspace CPU PTEs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-s4-opti-v1-0-5edaea2c6d31@intel.com?part=1

  reply	other threads:[~2026-11-06 10:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 10:16 [PATCH 0/2] Optimise suspend handling for CCS igpu platforms Matthew Auld
2026-11-06 10:16 ` [PATCH 1/2] drm/xe: only evict CCS buffers from TT on iGPU Matthew Auld
2026-11-06 10:50   ` sashiko-bot [this message]
2026-11-06 11:34     ` Matthew Auld
2026-11-06 15:07   ` Thomas Hellström
2026-11-06 10:16 ` [PATCH 2/2] drm/xe/pm: skip BO eviction on iGPU for non-hibernation sleep Matthew Auld
2026-11-06 10:31   ` sashiko-bot
2026-11-06 10:32   ` Thomas Hellström
2026-11-06 11:02     ` Matthew Auld
2026-11-06 13:16       ` Matthew Auld
2026-11-06 15:11   ` Thomas Hellström
2026-11-06 17:07   ` Ville Syrjälä
2026-11-09  9:31     ` Matthew Auld
2026-11-06 11:06 ` ✓ CI.KUnit: success for Optimise suspend handling for CCS igpu platforms Patchwork
2026-11-06 11:40 ` ✓ Xe.CI.BAT: " 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=sashiko-outbox-201230@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.