[PATCH v2 6/9] drm/xe: Add xe_migrate_job_lock/unlock helpers
Matthew Brost
matthew.brost at intel.com
Wed Jul 16 01:11:19 UTC 2025
On Tue, Jul 15, 2025 at 04:48:00PM -0600, Summers, Stuart wrote:
> On Wed, 2025-07-02 at 16:42 -0700, Matthew Brost wrote:
> > Add xe_migrate_job_lock/unlock helpers is used ensure ordering when
> > issuing GT TLB invalidation jobs.
> >
> > v2:
> > - Fix multi-line comments (checkpatch)
> >
> > Signed-off-by: Matthew Brost <matthew.brost at intel.com>
>
> IMO this could be squashed with the patch after since there aren't any
> users in this patch. But the code itself looks ok to me.
>
Sure, I'll squash into the following patch.
Matt
> > ---
> > drivers/gpu/drm/xe/xe_migrate.c | 36
> > +++++++++++++++++++++++++++++++++
> > drivers/gpu/drm/xe/xe_migrate.h | 4 ++++
> > 2 files changed, 40 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_migrate.c
> > b/drivers/gpu/drm/xe/xe_migrate.c
> > index b5f85162b9ed..1f57adcbb535 100644
> > --- a/drivers/gpu/drm/xe/xe_migrate.c
> > +++ b/drivers/gpu/drm/xe/xe_migrate.c
> > @@ -1917,6 +1917,42 @@ int xe_migrate_access_memory(struct xe_migrate
> > *m, struct xe_bo *bo,
> > return IS_ERR(fence) ? PTR_ERR(fence) : 0;
> > }
> >
> > +/**
> > + * xe_migrate_job_lock() - Lock migrate job lock
> > + * @m: The migration context.
> > + * @q: Queue associated with the operation which requires a lock
> > + *
> > + * Lock the migrate job lock if the queue is a migration queue,
> > otherwise
> > + * assert the VM's dma-resv is held (user queue's have own locking).
> > + */
> > +void xe_migrate_job_lock(struct xe_migrate *m, struct xe_exec_queue
> > *q)
> > +{
> > + bool is_migrate = q == m->q;
>
> Maybe not worth it, but we're doing these same calculations in
> xe_migrate.c. Should we just add a helper?
>
> Either way for the above 2, the code looks ok to me:
> Reviewed-by: Stuart Summers <stuart.summers at intel.com>
>
> Thanks,
> Stuart
>
> > +
> > + if (is_migrate)
> > + mutex_lock(&m->job_mutex);
> > + else
> > + xe_vm_assert_held(q->vm); /* User queues VM's
> > should be locked */
> > +}
> > +
> > +/**
> > + * xe_migrate_job_unlock() - Unlock migrate job lock
> > + * @m: The migration context.
> > + * @q: Queue associated with the operation which requires a lock
> > + *
> > + * Unlock the migrate job lock if the queue is a migration queue,
> > otherwise
> > + * assert the VM's dma-resv is held (user queue's have own locking).
> > + */
> > +void xe_migrate_job_unlock(struct xe_migrate *m, struct
> > xe_exec_queue *q)
> > +{
> > + bool is_migrate = q == m->q;
> > +
> > + if (is_migrate)
> > + mutex_unlock(&m->job_mutex);
> > + else
> > + xe_vm_assert_held(q->vm); /* User queues VM's
> > should be locked */
> > +}
> > +
> > #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> > #include "tests/xe_migrate.c"
> > #endif
> > diff --git a/drivers/gpu/drm/xe/xe_migrate.h
> > b/drivers/gpu/drm/xe/xe_migrate.h
> > index fb9839c1bae0..e9d83d320f8c 100644
> > --- a/drivers/gpu/drm/xe/xe_migrate.h
> > +++ b/drivers/gpu/drm/xe/xe_migrate.h
> > @@ -134,4 +134,8 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
> > void xe_migrate_wait(struct xe_migrate *m);
> >
> > struct xe_exec_queue *xe_tile_migrate_exec_queue(struct xe_tile
> > *tile);
> > +
> > +void xe_migrate_job_lock(struct xe_migrate *m, struct xe_exec_queue
> > *q);
> > +void xe_migrate_job_unlock(struct xe_migrate *m, struct
> > xe_exec_queue *q);
> > +
> > #endif
>
More information about the Intel-xe
mailing list