From: Raag Jadav <raag.jadav@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org, rodrigo.vivi@intel.com,
thomas.hellstrom@linux.intel.com, riana.tauro@intel.com,
michal.wajdeczko@intel.com, matthew.d.roper@intel.com,
michal.winiarski@intel.com, matthew.auld@intel.com,
maarten@lankhorst.se
Subject: Re: [PATCH v2 8/9] drm/xe/migrate: Introduce xe_migrate_reinit()
Date: Tue, 3 Mar 2026 06:29:31 +0100 [thread overview]
Message-ID: <aaZxu7P_XWd-i_wx@black.igk.intel.com> (raw)
In-Reply-To: <aaJ5SSnzTBvYE514@black.igk.intel.com>
On Sat, Feb 28, 2026 at 06:12:45AM +0100, Raag Jadav wrote:
> On Fri, Feb 27, 2026 at 10:32:19AM -0800, Matthew Brost wrote:
> > On Fri, Feb 27, 2026 at 10:30:48PM +0530, Raag Jadav wrote:
> > > In preparation of usecases which require re-initializing migrate context
> > > after PCIe FLR, introduce xe_migrate_reinit() helper. Migrate exec queue
> > > and pt_bo already exist in migrate structure but since their contents live
> > > on VRAM, they are lost on PCIe FLR and need re-initialization.
> > >
> > > Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> > > ---
> > > v2: Re-initialize migrate context (Matthew Brost)
> > > ---
> > > drivers/gpu/drm/xe/xe_gt.c | 10 +++++
> > > drivers/gpu/drm/xe/xe_migrate.c | 65 +++++++++++++++++++++++++--------
> > > drivers/gpu/drm/xe/xe_migrate.h | 1 +
> > > 3 files changed, 61 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> > > index ff4a4e769fb1..ab34312830e3 100644
> > > --- a/drivers/gpu/drm/xe/xe_gt.c
> > > +++ b/drivers/gpu/drm/xe/xe_gt.c
> > > @@ -966,6 +966,16 @@ void xe_gt_flr_prepare(struct xe_gt *gt)
> > > */
> > > int xe_gt_flr_done(struct xe_gt *gt)
> > > {
> > > + int err;
> > > +
> > > + if (xe_gt_is_main_type(gt)) {
> > > + struct xe_tile *tile = gt_to_tile(gt);
> > > +
> > > + err = xe_migrate_reinit(tile->migrate);
> >
> > I think there is work ahead for future platforms where multiple tiles
> > point to the same migrate object, so we’ll need to keep an eye on that.
> > Perhaps calling xe_migrate_reinit twice is harmless too.
> >
> > Anyways the patch looks correct.
> >
> > Reviewed-by: Matthew Brost <matthew.brost@intel.com>
>
> Thank you.
Similar to LRC this looks like a candidate for independent refactor.
I'll retain the tag and send it out separately.
Raag
> > > + if (err)
> > > + return err;
> > > + }
> > > +
> > > return xe_uc_flr_done(>->uc);
> > > }
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> > > index 333af7b57ae9..f4a2ad3ce601 100644
> > > --- a/drivers/gpu/drm/xe/xe_migrate.c
> > > +++ b/drivers/gpu/drm/xe/xe_migrate.c
> > > @@ -184,19 +184,11 @@ static void xe_migrate_program_identity(struct xe_device *xe, struct xe_vm *vm,
> > > xe_assert(xe, pos == vram_limit);
> > > }
> > >
> > > -static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
> > > - struct xe_vm *vm, struct drm_exec *exec)
> > > +static int xe_migrate_pt_bo_alloc(struct xe_tile *tile, struct xe_migrate *m,
> > > + struct xe_vm *vm, struct drm_exec *exec)
> > > {
> > > - struct xe_device *xe = tile_to_xe(tile);
> > > - u16 pat_index = xe->pat.idx[XE_CACHE_WB];
> > > - u8 id = tile->id;
> > > - u32 num_entries = NUM_PT_SLOTS, num_level = vm->pt_root[id]->level;
> > > -#define VRAM_IDENTITY_MAP_COUNT 2
> > > - u32 num_setup = num_level + VRAM_IDENTITY_MAP_COUNT;
> > > -#undef VRAM_IDENTITY_MAP_COUNT
> > > - u32 map_ofs, level, i;
> > > struct xe_bo *bo, *batch = tile->mem.kernel_bb_pool->bo;
> > > - u64 entry, pt29_ofs;
> > > + u32 num_entries = NUM_PT_SLOTS;
> > >
> > > /* Can't bump NUM_PT_SLOTS too high */
> > > BUILD_BUG_ON(NUM_PT_SLOTS > SZ_2M/XE_PAGE_SIZE);
> > > @@ -216,6 +208,24 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
> > > if (IS_ERR(bo))
> > > return PTR_ERR(bo);
> > >
> > > + m->pt_bo = bo;
> > > + return 0;
> > > +}
> > > +
> > > +static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
> > > + struct xe_vm *vm, u32 *ofs)
> > > +{
> > > + struct xe_device *xe = tile_to_xe(tile);
> > > + u16 pat_index = xe->pat.idx[XE_CACHE_WB];
> > > + u8 id = tile->id;
> > > + u32 num_entries = NUM_PT_SLOTS, num_level = vm->pt_root[id]->level;
> > > +#define VRAM_IDENTITY_MAP_COUNT 2
> > > + u32 num_setup = num_level + VRAM_IDENTITY_MAP_COUNT;
> > > +#undef VRAM_IDENTITY_MAP_COUNT
> > > + u32 map_ofs, level, i;
> > > + struct xe_bo *bo = m->pt_bo, *batch = tile->mem.kernel_bb_pool->bo;
> > > + u64 entry, pt29_ofs;
> > > +
> > > /* PT30 & PT31 reserved for 2M identity map */
> > > pt29_ofs = xe_bo_size(bo) - 3 * XE_PAGE_SIZE;
> > > entry = vm->pt_ops->pde_encode_bo(bo, pt29_ofs);
> > > @@ -338,6 +348,12 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
> > > }
> > > }
> > >
> > > + if (ofs)
> > > + *ofs = map_ofs;
> > > +}
> > > +
> > > +static void xe_migrate_suballoc_manager_init(struct xe_migrate *m, u32 map_ofs)
> > > +{
> > > /*
> > > * Example layout created above, with root level = 3:
> > > * [PT0...PT7]: kernel PT's for copy/clear; 64 or 4KiB PTE's
> > > @@ -363,9 +379,6 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
> > > drm_suballoc_manager_init(&m->vm_update_sa,
> > > (size_t)(map_ofs / XE_PAGE_SIZE - NUM_KERNEL_PDE) *
> > > NUM_VMUSA_UNIT_PER_PAGE, 0);
> > > -
> > > - m->pt_bo = bo;
> > > - return 0;
> > > }
> > >
> > > /*
> > > @@ -416,12 +429,22 @@ static int xe_migrate_lock_prepare_vm(struct xe_tile *tile, struct xe_migrate *m
> > > struct xe_device *xe = tile_to_xe(tile);
> > > struct xe_validation_ctx ctx;
> > > struct drm_exec exec;
> > > + u32 map_ofs;
> > > int err = 0;
> > >
> > > xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
> > > err = xe_vm_drm_exec_lock(vm, &exec);
> > > + if (err)
> > > + return err;
> > > +
> > > drm_exec_retry_on_contention(&exec);
> > > - err = xe_migrate_prepare_vm(tile, m, vm, &exec);
> > > +
> > > + err = xe_migrate_pt_bo_alloc(tile, m, vm, &exec);
> > > + if (err)
> > > + return err;
> > > +
> > > + xe_migrate_prepare_vm(tile, m, vm, &map_ofs);
> > > + xe_migrate_suballoc_manager_init(m, map_ofs);
> > > drm_exec_retry_on_contention(&exec);
> > > xe_validation_retry_on_oom(&ctx, &err);
> > > }
> > > @@ -429,6 +452,18 @@ static int xe_migrate_lock_prepare_vm(struct xe_tile *tile, struct xe_migrate *m
> > > return err;
> > > }
> > >
> > > +/**
> > > + * xe_migrate_reinit() - Re-initialize a migrate context
> > > + * @m: The migration context
> > > + *
> > > + * Returns: 0 on success, negative error code otherwise.
> > > + */
> > > +int xe_migrate_reinit(struct xe_migrate *m)
> > > +{
> > > + xe_migrate_prepare_vm(m->tile, m, m->q->vm, NULL);
> > > + return xe_exec_queue_reinit(m->q);
> > > +}
> > > +
> > > /**
> > > * xe_migrate_init() - Initialize a migrate context
> > > * @m: The migration context
> > > diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
> > > index 1522afb37dcf..fffbcab8b2e3 100644
> > > --- a/drivers/gpu/drm/xe/xe_migrate.h
> > > +++ b/drivers/gpu/drm/xe/xe_migrate.h
> > > @@ -112,6 +112,7 @@ struct xe_migrate_pt_update {
> > >
> > > struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile);
> > > int xe_migrate_init(struct xe_migrate *m);
> > > +int xe_migrate_reinit(struct xe_migrate *m);
> > >
> > > struct dma_fence *xe_migrate_to_vram(struct xe_migrate *m,
> > > unsigned long npages,
> > > --
> > > 2.43.0
> > >
next prev parent reply other threads:[~2026-03-03 5:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 17:00 [PATCH v2 0/9] Introduce Xe PCIe FLR Raag Jadav
2026-02-27 17:00 ` [PATCH v2 1/9] drm/xe/uc_fw: Allow re-initializing firmware Raag Jadav
2026-02-27 17:00 ` [PATCH v2 2/9] drm/xe/gt: Introduce FLR helpers Raag Jadav
2026-02-27 17:00 ` [PATCH v2 3/9] drm/xe/irq: Introduce xe_irq_disable() Raag Jadav
2026-02-27 17:00 ` [PATCH v2 4/9] drm/xe: Introduce xe_device_assert_lmem_ready() Raag Jadav
2026-02-27 17:00 ` [PATCH v2 5/9] drm/xe/bo_evict: Introduce xe_bo_restore_map() Raag Jadav
2026-02-27 17:00 ` [PATCH v2 6/9] drm/xe/lrc: Introduce xe_lrc_reinit() Raag Jadav
2026-02-27 18:06 ` Matthew Brost
2026-02-28 5:11 ` Raag Jadav
2026-02-27 17:00 ` [PATCH v2 7/9] drm/xe/exec_queue: Introduce xe_exec_queue_reinit() Raag Jadav
2026-02-27 17:00 ` [PATCH v2 8/9] drm/xe/migrate: Introduce xe_migrate_reinit() Raag Jadav
2026-02-27 18:32 ` Matthew Brost
2026-02-28 5:12 ` Raag Jadav
2026-03-03 5:29 ` Raag Jadav [this message]
2026-02-27 17:00 ` [PATCH v2 9/9] drm/xe/pci: Introduce PCIe FLR Raag Jadav
2026-02-27 17:49 ` Vivi, Rodrigo
2026-02-28 5:24 ` Raag Jadav
2026-03-02 16:58 ` Rodrigo Vivi
2026-03-02 19:37 ` Laguna, Lukasz
2026-02-27 17:50 ` [PATCH v2 0/9] Introduce Xe " Vivi, Rodrigo
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=aaZxu7P_XWd-i_wx@black.igk.intel.com \
--to=raag.jadav@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten@lankhorst.se \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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