From 619acf4f75599763beef666e31fb86d60b3c49c2 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Wed, 5 Feb 2020 01:55:39 -0600 Subject: [PATCH] Update pointer info to include IPC memory. IPC memory was previously returned as HSA_POINTER_ALLOCATED and had garbage in the node_id field. Due to ROCR_VISIBLE_DEVICES we need to be able to distinguish between imported memory and regular memory because imported memory may not be owned by an agent that is visible in the process. Differentiating these flags allows the users to expect null agent for the owning agent. Fixes Change-Id: Ide3489cec1ee2072dc9697fa5cb71ddb17999d14 [ROCm/ROCR-Runtime commit: 6957202df89780311ec495e12ba25a80adbba90e] --- projects/rocr-runtime/include/hsakmttypes.h | 3 ++- projects/rocr-runtime/src/fmm.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/projects/rocr-runtime/include/hsakmttypes.h b/projects/rocr-runtime/include/hsakmttypes.h index ab55047739..ae5e4fdbad 100644 --- a/projects/rocr-runtime/include/hsakmttypes.h +++ b/projects/rocr-runtime/include/hsakmttypes.h @@ -1262,7 +1262,8 @@ typedef enum _HSA_POINTER_TYPE { HSA_POINTER_UNKNOWN = 0, HSA_POINTER_ALLOCATED = 1, // Allocated with hsaKmtAllocMemory (except scratch) HSA_POINTER_REGISTERED_USER = 2, // Registered user pointer - HSA_POINTER_REGISTERED_GRAPHICS = 3 // Registered graphics buffer + HSA_POINTER_REGISTERED_GRAPHICS = 3, // Registered graphics buffer + HSA_POINTER_REGISTERED_SHARED = 4 // Registered shared buffer (IPC) // (hsaKmtRegisterGraphicsToNodes) } HSA_POINTER_TYPE; diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index e2c45b5324..4442876e43 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -3276,6 +3276,7 @@ HSAKMT_STATUS fmm_register_shared_memory(const HsaSharedMemoryHandle *SharedMemo err = HSAKMT_STATUS_ERROR; goto err_free_obj; } + obj->node_id = gpu_mem[gpu_mem_id].node_id; map_fd = importArgs.mmap_offset >= (1ULL<<40) ? kfd_fd : gpu_mem[gpu_mem_id].drm_render_fd; ret = mmap(reservedMem, (SizeInPages << PAGE_SHIFT), @@ -3496,7 +3497,9 @@ HSAKMT_STATUS fmm_get_mem_info(const void *address, HsaPointerInfo *info) } /* Successful vm_find_object returns with the aperture locked */ - if (vm_obj->metadata) + if (vm_obj->is_imported_kfd_bo) + info->Type = HSA_POINTER_REGISTERED_SHARED; + else if (vm_obj->metadata) info->Type = HSA_POINTER_REGISTERED_GRAPHICS; else if (vm_obj->userptr) info->Type = HSA_POINTER_REGISTERED_USER;