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>
Bu işleme şunda yer alıyor:
cadolphe-amd
2025-11-25 18:05:25 -05:00
işlemeyi yapan: GitHub
ebeveyn daf8596ce9
işleme cce94f6ee0
2 değiştirilmiş dosya ile 10 ekleme ve 5 silme
+6 -4
Dosyayı Görüntüle
@@ -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 =
+4 -1
Dosyayı Görüntüle
@@ -239,7 +239,10 @@ address VmHeap::Alloc(size_t size) {
size_t offset = 0;
auto hb = AllocBlock(size + block_alignment_);
if (hb != nullptr) {
offset = ((hb->Offset() & ~kChunkSize) == 0) ? hb->Offset() + block_alignment_ : hb->Offset();
// Add 256-byte offset if virtual address matches chunk address to avoid map conflicts
offset = ((hb->Offset() & (kChunkSize - 1)) == 0)
? hb->Offset() + block_alignment_
: hb->Offset();
ptr = base_address_ + offset;
} else {
return nullptr;