From 573a9810cf8913fedabf97396bb8fef1ad0f4944 Mon Sep 17 00:00:00 2001 From: Matthew Brost Date: Fri, 25 Sep 2026 13:15:13 -0700 Subject: [PATCH] drm/xe: Store level in struct xe_vm_pgtable_update 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 Reviewed-by: Stuart Summers Reviewed-by: Himal Prasad Ghimiray Reviewed-by: Maarten Lankhorst Link: https://patch.msgid.link/20260925201526.1355279-12-matthew.brost@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 c004ce449b69..a483158f94d4 100644 --- a/drivers/gpu/drm/xe/xe_pt.c +++ b/drivers/gpu/drm/xe/xe_pt.c @@ -380,6 +380,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); @@ -2025,7 +2026,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 39c5b89ce9b7..ccab6613385f 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; };