diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index 6b3926aa75..9e9b0a05e7 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -922,6 +922,13 @@ static void __fmm_release(void *address, if (object->device_ids_array_size > 0) free(object->device_ids_array); + if (address >= dgpu_shared_aperture_base && + address <= dgpu_shared_aperture_limit) { + /* Remove any CPU mapping, but keep the address range reserved */ + mmap(address, object->size, PROT_NONE, + MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED, -1, 0); + } + args.handle = object->handle; kmtIoctl(kfd_fd, AMDKFD_IOC_FREE_MEMORY_OF_GPU, &args); @@ -971,14 +978,6 @@ void fmm_release(void *address, uint64_t MemorySizeInBytes) } } - if (found && - address >= dgpu_shared_aperture_base && - address <= dgpu_shared_aperture_limit) { - /* Remove any CPU mapping, but keep the address range reserved */ - mmap(address, MemorySizeInBytes, PROT_NONE, - MAP_ANONYMOUS | MAP_NORESERVE | MAP_PRIVATE | MAP_FIXED, -1, 0); - } - /* * If memory address isn't inside of any defined aperture - it refers * to the system memory