Skip to content

Commit 642dfc9

Browse files
mbrost05rodrigovivi
authored andcommitted
drm/xe: Take ref to VM in delayed snapshot
Kernel BO's don't take a ref to the VM, we need the VM for the delayed snapshot, so take a ref to the VM in delayed snapshot. v2: - Check for lrc_bo before taking a VM ref (CI) - Check lrc_bo->vm before taking / dropping a VM ref (CI) - Drop VM in xe_lrc_snapshot_free v5: - Fix commit message wording (Johnathan) Fixes: 4705863 ("drm/xe: Move lrc snapshot capturing to xe_lrc.c") Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240801154118.2547543-2-matthew.brost@intel.com (cherry picked from commit c3bc97d) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent ac3191c commit 642dfc9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/gpu/drm/xe/xe_lrc.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,9 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
16341634
if (!snapshot)
16351635
return NULL;
16361636

1637+
if (lrc->bo && lrc->bo->vm)
1638+
xe_vm_get(lrc->bo->vm);
1639+
16371640
snapshot->context_desc = xe_lrc_ggtt_addr(lrc);
16381641
snapshot->indirect_context_desc = xe_lrc_indirect_ring_ggtt_addr(lrc);
16391642
snapshot->head = xe_lrc_ring_head(lrc);
@@ -1653,12 +1656,14 @@ struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
16531656
void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)
16541657
{
16551658
struct xe_bo *bo;
1659+
struct xe_vm *vm;
16561660
struct iosys_map src;
16571661

16581662
if (!snapshot)
16591663
return;
16601664

16611665
bo = snapshot->lrc_bo;
1666+
vm = bo->vm;
16621667
snapshot->lrc_bo = NULL;
16631668

16641669
snapshot->lrc_snapshot = kvmalloc(snapshot->lrc_size, GFP_KERNEL);
@@ -1678,6 +1683,8 @@ void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot)
16781683
xe_bo_unlock(bo);
16791684
put_bo:
16801685
xe_bo_put(bo);
1686+
if (vm)
1687+
xe_vm_put(vm);
16811688
}
16821689

16831690
void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p)
@@ -1727,8 +1734,14 @@ void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot)
17271734
return;
17281735

17291736
kvfree(snapshot->lrc_snapshot);
1730-
if (snapshot->lrc_bo)
1737+
if (snapshot->lrc_bo) {
1738+
struct xe_vm *vm;
1739+
1740+
vm = snapshot->lrc_bo->vm;
17311741
xe_bo_put(snapshot->lrc_bo);
1742+
if (vm)
1743+
xe_vm_put(vm);
1744+
}
17321745
kfree(snapshot);
17331746
}
17341747

0 commit comments

Comments
 (0)