On Wed, Dec 02, 2026 at 11:55:44PM +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] drm/xe: loss of FlatCCS extra TT pages on DGFX defrag in
>   xe_bo_move()
> --
> 
> commit fb1ace888ac8c6157078a250c431da6e90c2457a
> Author: Matthew Brost <[email protected]>
> 
> drm/xe: Handle defrag moves in xe_bo_move()
> 
> This commit updates xe_bo_move() to handle defragmentation moves by
> copying data from the BO's stashed defrag_old_tt to the newly allocated
> backing via xe_migrate_copy_defrag().
> 
> > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> > index 98c0b32e95439..4c735ec8754ea 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.c
> > +++ b/drivers/gpu/drm/xe/xe_bo.c
> > @@ -1291,6 +1291,7 @@ static int xe_bo_move(struct ttm_buffer_object 
> > *ttm_bo, bool evict,
> >     bool move_lacks_source;
> >     bool tt_has_data;
> >     bool needs_clear;
> > +   bool has_defrag_old_tt = !!ttm_bo->defrag_old_tt;
> >     bool handle_system_ccs = (!IS_DGFX(xe) && xe_bo_needs_ccs_pages(bo) &&
> >                               ttm && ttm_tt_is_populated(ttm)) ? true : 
> > false;
> >     int ret = 0;
> 
> [ ... ]
> 
> > @@ -1463,6 +1474,12 @@ static int xe_bo_move(struct ttm_buffer_object 
> > *ttm_bo, bool evict,
> >  
> >             fence = xe_migrate_clear(migrate, bo, new_mem, flags,
> >                                      ctx->interruptible);
> > +   } else if (has_defrag_old_tt) {
> > +           struct xe_ttm_tt *old_xe_tt =
> > +                   container_of(ttm_bo->defrag_old_tt, struct xe_ttm_tt, 
> > ttm);
> > +
> > +           fence = xe_migrate_copy_defrag(migrate, bo, old_mem, new_mem,
> > +                                          old_xe_tt->sg, 
> > handle_system_ccs);
> >     } else {
> >             fence = xe_migrate_copy(migrate, bo, bo, old_mem, new_mem,
> >                                     handle_system_ccs, ctx->interruptible);
> 
> [Severity: High]
> Does this lose the saved FlatCCS pages when defragmenting an evicted
> VRAM BO on DG2?
> 
> On discrete GPUs with FlatCCS and GRAPHICS_VER(xe) < 20 (DG2), a
> compressible VRAM-only BO evicted to XE_PL_TT stores its saved FlatCCS
> state in extra TT pages starting at xe_bo_ccs_pages_start(bo), and
> xe_bo_needs_defrag() admits that evicted BO for defragmentation when

We shouldn't be defraging VRAM-only BOs which are evicted, this is real
issue and a one line fix in patch 14. Will fix.

Matt

> ttm_tt_is_beneficial_order_failed(tt) is set.  During the defrag move,
> handle_system_ccs is false because IS_DGFX(xe) is true, and
> xe_migrate_copy_defrag() only copies [0, xe_bo_size(bo)), leaving any
> newly reallocated 2 MB chunk overlapping the trailing extra CCS pages in
> bo->ttm uninitialized.  When the BO is later validated back to VRAM,
> corrupted FlatCCS metadata is restored.
> 
> -- 
> Sashiko AI review ยท 
> https://sashiko.dev/#/patchset/[email protected]?part=16

Reply via email to