From: Matthew Brost <matthew.brost@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2] drm/xe/pt: check no-DMA huge-pte cases before DMA segment test
Date: Mon, 27 Jul 2026 20:28:16 -0700 [thread overview]
Message-ID: <amgh0E2u/wcy/Xm9@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20260727061342.562020-2-himal.prasad.ghimiray@intel.com>
On Mon, Jul 27, 2026 at 11:43:43AM +0530, Himal Prasad Ghimiray wrote:
> On a non-range clear, curs.size is never set, so the segment test
> (next - va_curs_start > curs->size) returns false for every level > 0
> before the clear_pt short-circuit is reached. The clear then descends to
> level 0 instead of forming a huge zero-leaf, wasting page tables and
> risking -ENOMEM on unbind.
>
> Move the null-VMA, purged-BO and clear_pt short-circuits above the
> curs->size test. The bind path always sets curs.size, so it is unaffected.
>
> v2
> - Also set curs.size on the clear path so the cursor stays meaningful
> during the walk. clear_pt is only reached with range == NULL, so assert
> that invariant. (Matthew Brost)
>
> Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> Fixes: 5b658b7e89c3 ("drm/xe: Clear scratch page on vm_bind")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> drivers/gpu/drm/xe/xe_pt.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> index 598c6b2571e7..0e9d669620b9 100644
> --- a/drivers/gpu/drm/xe/xe_pt.c
> +++ b/drivers/gpu/drm/xe/xe_pt.c
> @@ -443,10 +443,6 @@ static bool xe_pt_hugepte_possible(u64 addr, u64 next, unsigned int level,
> if (!xe_pt_covers(addr, next, level, &xe_walk->base))
> return false;
>
> - /* Does the DMA segment cover the whole pte? */
> - if (next - xe_walk->va_curs_start > xe_walk->curs->size)
> - return false;
> -
> /* null VMA's and purged BO's do not have dma addresses */
> if (xe_vma_is_null(xe_walk->vma) || (bo && xe_bo_is_purged(bo)))
> return true;
> @@ -455,6 +451,10 @@ static bool xe_pt_hugepte_possible(u64 addr, u64 next, unsigned int level,
> if (xe_walk->clear_pt)
> return true;
>
> + /* Does the DMA segment cover the whole pte? */
> + if (next - xe_walk->va_curs_start > xe_walk->curs->size)
> + return false;
> +
> /* Is the DMA address huge PTE size aligned? */
> size = next - addr;
> dma = addr - xe_walk->va_curs_start + xe_res_dma(xe_walk->curs);
> @@ -775,8 +775,11 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma,
> }
>
> xe_walk.needs_64K = (vm->flags & XE_VM_FLAG_64K);
> - if (clear_pt)
> + if (clear_pt) {
> + xe_assert(xe, !range);
> + curs.size = xe_vma_size(vma);
> goto walk_pt;
> + }
>
> if (vma->gpuva.flags & XE_VMA_ATOMIC_PTE_BIT) {
> xe_walk.default_vram_pte = xe_atomic_for_vram(vm, vma) ? XE_USM_PPGTT_PTE_AE : 0;
> --
> 2.43.0
>
next parent reply other threads:[~2026-07-28 3:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260727061342.562020-2-himal.prasad.ghimiray@intel.com>
2026-07-28 3:28 ` Matthew Brost [this message]
2026-07-28 5:59 [PATCH v2] drm/xe/pt: check no-DMA huge-pte cases before DMA segment test Himal Prasad Ghimiray
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=amgh0E2u/wcy/Xm9@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-bot@kernel.org \
/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