Re: [PATCH v3 02/25] drm/xe: Add xe_migrate_update_pgtables_cpu_execute helper

Francois Dugast
2026-03-05T14:39:59Z

On Fri, Feb 27, 2026 at 05:34:38PM -0800, Matthew Brost wrote:
> Add the xe_migrate_update_pgtables_cpu_execute helper, which performs
> the CPU-side page-table update. This will support implementing CPU
> binds, as the submission backend can call this helper once a bind job’s
> dependencies are resolved. While here, add assertions to provide basic
> sanity checks on tht function arguments.

s/tht/the/

Reviewed-by: Francois Dugast <francois.dugast@intel.com>

>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_migrate.c | 58 ++++++++++++++++++++-------------
> 1 file changed, 35 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index f7e3a044bd78..69e6e3135ec6 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -1715,6 +1715,38 @@ struct migrate_test_params {
> container_of(_priv, struct migrate_test_params, base)
> #endif
>
> +static void
> +xe_migrate_update_pgtables_cpu_execute(struct xe_vm *vm, struct xe_tile *tile,
> + const struct xe_migrate_pt_update_ops *ops,
> + struct xe_vm_pgtable_update_op *pt_op,
> + int num_ops)
> +{
> + u32 j, i;
> +
> + for (j = 0; j < num_ops; ++j, ++pt_op) {
> + for (i = 0; i < pt_op->num_entries; i++) {
> + const struct xe_vm_pgtable_update *update =
> + &pt_op->entries[i];
> +
> + xe_tile_assert(tile, update);
> + xe_tile_assert(tile, update->pt_bo);
> + xe_tile_assert(tile, !iosys_map_is_null(&update->pt_bo->vmap));
> +
> + if (pt_op->bind)
> + ops->populate(tile, &update->pt_bo->vmap,
> + NULL, update->ofs, update->qwords,
> + update);
> + else
> + ops->clear(vm, tile, &update->pt_bo->vmap,
> + NULL, update->ofs, update->qwords,
> + update);
> + }
> + }
> +
> + trace_xe_vm_cpu_bind(vm);
> + xe_device_wmb(vm->xe);
> +}
> +
> static struct dma_fence *
> xe_migrate_update_pgtables_cpu(struct xe_migrate *m,
> struct xe_migrate_pt_update *pt_update)
> @@ -1727,7 +1759,6 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m,
> struct xe_vm_pgtable_update_ops *pt_update_ops =
> &pt_update->vops->pt_update_ops[pt_update->tile_id];
> int err;
> - u32 i, j;
>
> if (XE_TEST_ONLY(test && test->force_gpu))
> return ERR_PTR(-ETIME);
> @@ -1739,28 +1770,9 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m,
> return ERR_PTR(err);
> }
>
> - for (i = 0; i < pt_update_ops->num_ops; ++i) {
> - const struct xe_vm_pgtable_update_op *pt_op =
> - &pt_update_ops->ops[i];
> -
> - for (j = 0; j < pt_op->num_entries; j++) {
> - const struct xe_vm_pgtable_update *update =
> - &pt_op->entries[j];
> -
> - if (pt_op->bind)
> - ops->populate(m->tile,
> - &update->pt_bo->vmap, NULL,
> - update->ofs, update->qwords,
> - update);
> - else
> - ops->clear(vm, m->tile,
> - &update->pt_bo->vmap, NULL,
> - update->ofs, update->qwords, update);
> - }
> - }
> -
> - trace_xe_vm_cpu_bind(vm);
> - xe_device_wmb(vm->xe);
> + xe_migrate_update_pgtables_cpu_execute(vm, m->tile, ops,
> + pt_update_ops->ops,
> + pt_update_ops->num_ops);
>
> return dma_fence_get_stub();
> }
> --
> 2.34.1
>