On Thu, Dec 03, 2026 at 12:18:43AM +0000, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] drm/xe: page range mismatch in xe_bo_defrag_iova_copy() with > CCS extra_pages
Valid and will be fixed in eariler patch. Matt > -- > > commit d43bc6ca2ee8e9ea06f7417aee36a16ea7bf5ca3 > Author: Matthew Brost <[email protected]> > > drm/xe: Finalize defrag-IOVA moves with post-copy job > > This commit wires up IOVA defragmentation moves using a packed temporary > copy mapping and a post-copy dependency job to transfer the IOVA > reservation and relink changed pages. > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index 9f216a7d115ea..65ab974c56acc 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > [ ... ] > > @@ -1191,6 +1308,157 @@ static void xe_tt_iova_transfer(struct xe_device > > *xe, > > old_tt->use_iova = false; > > } > > > > +/* > > + * xe_bo_defrag_iova_copy - Run an IOVA defrag move with a packed copy > > mapping. > > + * > > + * Only the changed (non-borrowed) pages of @new_tt are DMA mapped, packed > > + * contiguously into the front of its reservation, the GPU copy blits them > > from > > + * the old tt at natural offsets, and a post-copy finalize job adopts the > > old > > + * tt's full reservation and relinks the changed runs. Returns the finalize > > + * job's finished fence (the fence the move waits on), or an ERR_PTR on > > failure > > + * with all partial state unwound. > > + */ > > +static struct dma_fence * > > +xe_bo_defrag_iova_copy(struct xe_device *xe, struct xe_migrate *migrate, > > + struct xe_bo *bo, struct ttm_resource *old_mem, > > + struct ttm_resource *new_mem, struct ttm_tt *old_tt, > > + bool handle_system_ccs) > > +{ > > + struct ttm_tt *new_tt = bo->ttm.ttm; > > + struct xe_ttm_tt *new_xe_tt = container_of(new_tt, struct xe_ttm_tt, > > ttm); > > + struct xe_ttm_tt *old_xe_tt = container_of(old_tt, struct xe_ttm_tt, > > ttm); > > + struct drm_sched_entity *entity = > > + xe_dep_scheduler_entity(xe->mem.defrag.iova_sched); > > + struct xe_iova_defrag_job *job; > > + struct dma_fence *copy_fence; > > + struct dma_fence *fence; > > + struct xe_tt_iova_copy copy; > > + int err; > > + > > + xe_assert(xe, new_xe_tt->iova_eligible && !new_xe_tt->use_iova); > > + xe_assert(xe, old_xe_tt->use_iova && old_xe_tt->iova_linked); > > + > > + err = xe_tt_iova_copy_init(new_tt, old_tt, ©); > > + if (err) > > + return ERR_PTR(err); > > + > > + /* > > + * TTM fails a defrag move that (re)allocates no chunk, so at least one > > + * page always differs from the old tt. > > + */ > > + if (XE_WARN_ON(!copy.nr_changed)) { > > + err = -EINVAL; > > + goto err_copy; > > + } > > + > > + err = xe_tt_map_iova_copy(xe, new_tt, ©); > > + if (err) > > + goto err_copy; > > + > > + copy_fence = xe_migrate_copy_defrag_iova(migrate, bo, old_mem, new_mem, > > + old_tt, copy.nr_changed, > > + handle_system_ccs); > > [Severity: Medium] > Can xe_bo_defrag_iova_copy() hit XE_WARN_ON(!fence) in __xe_migrate_copy() > when a defrag slice only upgrades Flat-CCS extra_pages? > > On integrated platforms with Flat-CCS, xe_ttm_tt_create() appends CCS > extra_pages to tt->num_pages, and ttm_pool_alloc() upgrades and tracks > TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED across the full tt->num_pages array. > When a defrag pass borrows all data pages in [0, xe_bo_size(bo)) from > old_tt and only reallocates a chunk in those trailing extra_pages (for > example, on the final defrag slice of a >= 1 GB compressible BO where > extra_pages >= 512), xe_tt_iova_copy_init() walks new_tt->num_pages and > sets copy.nr_changed > 0. > > However, xe_migrate_copy_defrag_iova() -> __xe_migrate_copy() only > iterates over size = xe_bo_size(src_bo). Because all pages in that range > were borrowed, xe_migrate_leading_borrowed_pages() skips the entire > buffer without emitting a job, hitting XE_WARN_ON(!fence) and returning > -EINVAL. TTM then restores old_tt with > TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED still set, leaving the BO at the head > of xe->mem.defrag.list to warn and abort the defrag worker on every retry. > > -- > Sashiko AI review ยท > https://sashiko.dev/#/patchset/[email protected]?part=33
