From fb429237acbb4452269592a239606cd719f94d3a Mon Sep 17 00:00:00 2001 From: tiancyin Date: Mon, 24 Feb 2025 09:13:28 +0800 Subject: [PATCH] wsl/hsakmt: fix incorrect addr info of hsaKmtQueryPointerInfo rocr runtime will take care of the block offset(ref Runtime::IPCCreate), just returning the block base is enough in suballocator case. Reviewed-by: Flora Cui Signed-off-by: tiancyin --- memory.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/memory.cpp b/memory.cpp index dfc5a1f2f1..2b65def00b 100644 --- a/memory.cpp +++ b/memory.cpp @@ -844,26 +844,18 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtQueryPointerInfo(const void *Pointer, return HSAKMT_STATUS_INVALID_PARAMETER; pr_debug("pointer %p\n", Pointer); - void *ptr = const_cast(Pointer); memset(PointerInfo, 0, sizeof(HsaPointerInfo)); - void* block_base = nullptr; - { - std::lock_guard gard(*fragment_allocator_lock_); - block_base = fragment_allocator_.block_base(ptr); - if (block_base != nullptr) - ptr = block_base; - } Allocation allocation_info; bool found = false; { std::lock_guard gard(*allocation_map_lock_); - auto it = allocation_map_.upper_bound(ptr); + auto it = allocation_map_.upper_bound(Pointer); if (it != allocation_map_.begin()) { --it; - if (ptr >= it->first && - (ptr < reinterpret_cast(it->first) + it->second.size_requested)) { + if (Pointer >= it->first && + (Pointer < reinterpret_cast(it->first) + it->second.size_requested)) { allocation_info = it->second; found = true; } @@ -888,13 +880,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtQueryPointerInfo(const void *Pointer, PointerInfo->MemFlags.Value = allocation_info.mem_flags_value; PointerInfo->CPUAddress = allocation_info.cpu_addr; PointerInfo->GPUAddress = allocation_info.gpu_addr; - if (block_base != nullptr) { - uint64_t offset = reinterpret_cast(Pointer) - - reinterpret_cast(block_base); - PointerInfo->CPUAddress = reinterpret_cast( - reinterpret_cast(PointerInfo->CPUAddress) + offset); - PointerInfo->GPUAddress += offset; - } PointerInfo->UserData = allocation_info.user_data; return HSAKMT_STATUS_SUCCESS;