SWDEV-557412 - Incorporate proper chunk offset when remapping virtual memory (#1848)

* SWDEV-557412 - Incorporate proper offset when remapping virtual memory

* Fix condition to check if VMHeap allocation address matches a chunk address

* Move offset calculation outside if/else block

---------

Co-authored-by: JeniferC99 <150404595+JeniferC99@users.noreply.github.com>
This commit is contained in:
cadolphe-amd
2025-11-25 18:05:25 -05:00
committed by GitHub
parent daf8596ce9
commit cce94f6ee0
2 changed files with 10 additions and 5 deletions
@@ -2325,12 +2325,14 @@ void VirtualGPU::submitVirtualMap(amd::VirtualMapCommand& vcmd) {
vaddr_sub_obj = phys_mem_obj->getContext().devices()[0]->CreateVirtualBuffer(
phys_mem_obj->getContext(), const_cast<void*>(vcmd.ptr()), vcmd.size(),
phys_mem_obj->getUserData().deviceId, phys_mem_obj->getUserData().locationType, kParent);
// Calculate the offset from the original pointer.
vaddr_offset = (reinterpret_cast<address>(vaddr_sub_obj->getSvmPtr()) -
reinterpret_cast<address>(vaddr_base_obj->getSvmPtr()));
} else {
vaddr_sub_obj = amd::MemObjMap::FindMemObj(vcmd.ptr());
}
// Calculate the offset from the original pointer.
vaddr_offset = (reinterpret_cast<address>(vaddr_sub_obj->getSvmPtr()) -
reinterpret_cast<address>(vaddr_base_obj->getSvmPtr()));
// The imem() in the backend is shared between base and sub/view object.
pal::Memory* vaddr_pal_mem = dev().getGpuMemory(vaddr_base_obj);
Pal::IGpuMemory* phymem_igpu_mem =