Re: [PATCH v3 11/25] drm/xe: Store level in struct xe_vm_pgtable_update

Summers, Stuart
2026-03-03T23:44:14Z

On Fri, 2026-02-27 at 17:34 -0800, Matthew Brost wrote:
> The level was previously extracted from struct xe_pt inside
> xe_vm_pgtable_update during CPU binds, which always occurred during
> the
> bind IOCTL. With CPU binds now supported in bind jobs, struct xe_pt
> may
> no longer be valid in memory at that point. To address this, store
> the
> level directly in struct xe_vm_pgtable_update.
>
> Signed-off-by: Matthew Brost <matthew.brost@intel.com>

Reviewed-by: Stuart Summers <stuart.summers@intel.com>

> ---
>  drivers/gpu/drm/xe/xe_pt.c       | 3 ++-
>  drivers/gpu/drm/xe/xe_pt_types.h | 8 +++++++-
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> index 6b56e62a35c1..0a90d1460a8b 100644
> --- a/drivers/gpu/drm/xe/xe_pt.c
> +++ b/drivers/gpu/drm/xe/xe_pt.c
> @@ -381,6 +381,7 @@ xe_pt_new_shared(struct xe_walk_update *wupd,
> struct xe_pt *parent,
>         entry->flags = 0;
>         entry->qwords = 0;
>         entry->pt_bo->update_index = -1;
> +       entry->level = parent->level;
>
>         if (alloc_entries) {
>                 entry->pt_entries = kmalloc_objs(*entry->pt_entries,
> XE_PDES);
> @@ -1830,7 +1831,7 @@ xe_migrate_clear_pgtable_callback(struct xe_vm
> *vm, struct xe_tile *tile,
>                                   u32 qword_ofs, u32 num_qwords,
>                                   const struct xe_vm_pgtable_update
> *update)
>  {
> -       u64 empty = __xe_pt_empty_pte(tile, vm, update->pt->level);
> +       u64 empty = __xe_pt_empty_pte(tile, vm, update->level);
>         int i;
>
>         if (map && map->is_iomem)
> diff --git a/drivers/gpu/drm/xe/xe_pt_types.h
> b/drivers/gpu/drm/xe/xe_pt_types.h
> index 92d50573ed1d..aa1d7c0e8669 100644
> --- a/drivers/gpu/drm/xe/xe_pt_types.h
> +++ b/drivers/gpu/drm/xe/xe_pt_types.h
> @@ -65,12 +65,18 @@ struct xe_vm_pgtable_update {
>         /** @qwords: number of PTE's to write */
>         u32 qwords;
>
> -       /** @pt: opaque pointer useful for the caller of
> xe_migrate_update_pgtables */
> +       /**
> +        * @pt: opaque pointer useful for PT building in the bind
> IOCTL. Only
> +        * safe to touch during the bind IOCTL (i.e., not in bind
> jobs).
> +        */
>         struct xe_pt *pt;
>
>         /** @pt_entries: Newly added pagetable entries */
>         struct xe_pt_entry *pt_entries;
>
> +       /** @level: level of update */
> +       unsigned int level;
> +
>         /** @flags: Target flags */
>         u32 flags;
>  };