drm/amdkfd: CRIU export dmabuf handles for GTT BOs
Subsystems (3)
PATCH 1/1 drm/amdkfd: CRIU export dmabuf handles for GTT BOs
Export dmabuf handles for GTT BOs so that their contents can be accessed using SDMA during checkpoint/restore.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +8 -4
@@ -1759,7 +1759,8 @@ static int criu_checkpoint_bos(struct kfd_process *p, goto exit; } } -if (bo_bucket->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) { +if (bo_bucket->alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT )) { ret = criu_get_prime_handle(&dumper_bo->tbo.base, bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? DRM_RDWR : 0,
@@ -1812,7 +1813,8 @@ static int criu_checkpoint_bos(struct kfd_process *p, exit:while (ret && bo_index--) { -if (bo_buckets[bo_index].alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) +if (bo_buckets[bo_index].alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT ))close_fd (bo_buckets[bo_index].dmabuf_fd); }
@@ -2211,7 +2213,8 @@ static int criu_restore_bo(struct kfd_process *p,pr_debug ("map memory was successful for the BO\n" );/* create the dmabuf object and export the bo */ -if (bo_bucket->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) { +if (bo_bucket->alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT )) { ret =criu_get_prime_handle (&kgd_mem->bo->tbo.base,DRM_RDWR , &bo_bucket->dmabuf_fd);if (ret)
@@ -2281,7 +2284,8 @@ static int criu_restore_bos(struct kfd_process *p, exit:while (ret && i--) { -if (bo_buckets[i].alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) +if (bo_buckets[i].alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT ))close_fd (bo_buckets[i].dmabuf_fd); }kvfree (bo_buckets);
Signature · 1 line
2.17.1
Felix Kuehling
maintainerAm 2022-03-08 um 14:11 schrieb David Yat Sin:
Quoted 2 lines
Export dmabuf handles for GTT BOs so that their contents can be accessed using SDMA during checkpoint/restore.
This deserves a minor version bump. The plugin should depend on that bumped version when it starts using dmabuf handles for GTT BOs.
Regards,
Felix
Quoted 50 lines
Signed-off-by David Yat Sin <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +8
-4@@ -1759,7 +1759,8 @@ static int criu_checkpoint_bos(struct kfd_process *p, goto exit; } } -if (bo_bucket->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) { +if (bo_bucket->alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT )) { ret = criu_get_prime_handle(&dumper_bo->tbo.base, bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? DRM_RDWR : 0,@@ -1812,7 +1813,8 @@ static int criu_checkpoint_bos(struct kfd_process *p, exit:while (ret && bo_index--) { -if (bo_buckets[bo_index].alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) +if (bo_buckets[bo_index].alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT ))close_fd (bo_buckets[bo_index].dmabuf_fd); }@@ -2211,7 +2213,8 @@ static int criu_restore_bo(struct kfd_process *p,pr_debug ("map memory was successful for the BO\n" );/* create the dmabuf object and export the bo */ -if (bo_bucket->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) { +if (bo_bucket->alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT )) { ret =criu_get_prime_handle (&kgd_mem->bo->tbo.base,DRM_RDWR , &bo_bucket->dmabuf_fd);if (ret)@@ -2281,7 +2284,8 @@ static int criu_restore_bos(struct kfd_process *p, exit:while (ret && i--) { -if (bo_buckets[i].alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) +if (bo_buckets[i].alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT ))close_fd (bo_buckets[i].dmabuf_fd); }kvfree (bo_buckets);
[AMD Official Use Only]
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Yat Sin
Sent: Tuesday, March 8, 2022 2:12 PM
To: [email protected]; [email protected]
Cc: Kuehling, Felix <[email protected]>; Yat Sin, David <[email protected]>
Subject: [PATCH] drm/amdkfd: CRIU export dmabuf handles for GTT BOs
Export dmabuf handles for GTT BOs so that their contents can be accessed using SDMA during checkpoint/restore.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +3 -1
@@ -1759,7 +1759,8 @@ static int criu_checkpoint_bos(struct kfd_process *p, goto exit; } } -if (bo_bucket->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_VRAM ) { +if (bo_bucket->alloc_flags + & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM |KFD_IOC_ALLOC_MEM_FLAGS_GTT )) +{ ret = criu_get_prime_handle(&dumper_bo->tbo.base, bo_bucket->alloc_flags &
KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ? DRM_RDWR : 0, @@ -1812,7 +1813,8 @@ static int criu_checkpoint_bos(struct kfd_process *p,
exit:
while (ret && bo_index--) {
- if (bo_buckets[bo_index].alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM)
+ if (bo_buckets[bo_index].alloc_flags
+ & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT))
close_fd(bo_buckets[bo_index].dmabuf_fd);
}
@@ -2211,7 +2213,8 @@ static int criu_restore_bo(struct kfd_process *p,
pr_debug("map memory was successful for the BO\n");
/* create the dmabuf object and export the bo */
- if (bo_bucket->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM) {
+ if (bo_bucket->alloc_flags
+ & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT)) {
ret = criu_get_prime_handle(&kgd_mem->bo->tbo.base, DRM_RDWR,
&bo_bucket->dmabuf_fd);
if (ret)
@@ -2281,7 +2284,8 @@ static int criu_restore_bos(struct kfd_process *p,
exit:
while (ret && i--) {
- if (bo_buckets[i].alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM)
+ if (bo_buckets[i].alloc_flags
+ & (KFD_IOC_ALLOC_MEM_FLAGS_VRAM | KFD_IOC_ALLOC_MEM_FLAGS_GTT))
close_fd(bo_buckets[i].dmabuf_fd);
}
kvfree(bo_buckets);
--
2.17.1