On Wed, Dec 02, 2026 at 11:52:57PM +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Medium] drm/xe: WARN_ON and -EINVAL in __xe_migrate_copy() on
>   extra_pages-only defrag
> - [Low] drm/xe: commit message claims stub fence on no-op copy in
>   __xe_migrate_copy()
> --
> 
> commit ce7de21d385e57fce79126c867241da7e3be2512
> Author: Matthew Brost <[email protected]>
> 
> drm/xe: Skip self-copies for borrowed pages on defrag moves
> 
> This commit skips GPU data blits on the defragmentation data pass for
> pages that the new ttm_tt borrowed directly from the old ttm_tt.
> 
> > When an entire L0 chunk turns out to be borrowed, skip it outright: no
> > batch buffer is allocated and no GPU commands are issued, the cursors are
> > just advanced past the chunk. If every chunk of the move is borrowed the
> > copy is a complete no-op, so hand back a signaled stub fence.
> 
> [Severity: Low]
> This isn't a bug, but the commit message still says a signaled stub fence
> is returned when every chunk is borrowed, whereas v5 changed
> __xe_migrate_copy() to warn on !fence and return ERR_PTR(-EINVAL).
> 

Will fix.

> > diff --git a/drivers/gpu/drm/xe/xe_migrate.c 
> > b/drivers/gpu/drm/xe/xe_migrate.c
> > index 71192fbd722d6..5b40405aaba90 100644
> > --- a/drivers/gpu/drm/xe/xe_migrate.c
> > +++ b/drivers/gpu/drm/xe/xe_migrate.c
> 
> [ ... ]
> 
> > @@ -1442,9 +1513,30 @@ static struct dma_fence *__xe_migrate_copy(struct 
> > xe_migrate *m,
> >                     xe_assert(xe, IS_ALIGNED(ccs_it.start, PAGE_SIZE));
> >             }
> >  
> > -           /* Add copy commands size here */
> > +           /*
> > +            * Add copy commands size here. On the defrag data pass the blit
> > +            * is split into one command per run of non-borrowed pages, so
> > +            * size for the number of runs actually needed.
> > +            */
> > +           if (skip_borrowed)
> > +                   ndata_blits = emit_copy_chunks(gt, NULL, 0, 0, src_L0,
> > +                                                  src_tt, dst_tt, 
> > start_page);
> > +
> > +           /*
> > +            * If every page in this chunk was borrowed there is nothing to
> > +            * copy: don't build a batch or issue any GPU commands, just
> > +            * advance the cursors past the chunk. The non-vram tt cursors
> > +            * would otherwise be advanced by emit_pte().
> > +            */
> > +           if (skip_borrowed && !ndata_blits) {
> > +                   xe_res_next(&src_it, src_L0);
> > +                   xe_res_next(&dst_it, src_L0);
> > +                   size -= src_L0;
> > +                   continue;
> > +           }
> 
> [ ... ]
> 
> > @@ -1529,6 +1624,15 @@ static struct dma_fence *__xe_migrate_copy(struct 
> > xe_migrate *m,
> >             return ERR_PTR(err);
> >     }
> >  
> > +   /*
> > +    * A defrag move always (re)allocates at least one chunk (TTM fails a
> > +    * zero-progress defrag move), so at least one page differs and a job
> > +    * carrying the resv dependencies is always emitted. A signaled stub
> > +    * here would let the old tt be torn down under in-flight GPU work.
> > +    */
> > +   if (XE_WARN_ON(!fence))
> > +           return ERR_PTR(-EINVAL);
> > +
> >     return fence;
> >  }
> 
> [Severity: Medium]
> Can __xe_migrate_copy() hit XE_WARN_ON(!fence) and fail the move with
> -EINVAL when a defrag pass only reallocates pages in the trailing CCS
> extra_pages region?
> 

Ugh, this looks possible with a BO over 1G. I think we will have extract
a singleton from the dma-resv bookkeep slot here if !fence.

Matt

> When xe_bo_needs_ccs_pages(bo) is true, xe_ttm_tt_create() appends
> extra_pages beyond xe_bo_size(bo) >> PAGE_SHIFT to tt->num_pages, and the
> TTM pool allocator defragments across the full [0, tt->num_pages) array.
> If all data chunks in [0, xe_bo_size(bo)) are already at beneficial order
> (either initially or after earlier budget-limited defrag passes) and only
> a beneficial-order chunk in the trailing extra_pages region is upgraded,
> TTM's defrag allocation succeeds while borrowing every data page.
> Because __xe_migrate_copy() only iterates over size = xe_bo_size(src_bo),
> emit_copy_chunks() returns 0 for every pass and the loop finishes with
> fence == NULL, triggering the warning and leaving the BO on the defrag
> list to fail again on subsequent passes.
> 
> -- 
> Sashiko AI review ยท 
> https://sashiko.dev/#/patchset/[email protected]?part=17

Reply via email to