mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
amdgpu_ttm_io_mem_reserve gave every contiguous VRAM resource a premapped address, aper_base_kaddr plus its offset, although aper_base_kaddr maps only the visible window (256 MiB of BAR0 on the R9700). A kernel BO made without AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, as amdgpu_amdkfd_alloc_kernel_mem makes them, is placed top-down at the end of VRAM, and its kmap pointed far past the BAR0 mapping. The dext treats an address outside the aperture as process memory, so the first CPU store went to whatever was mapped there, or faulted and killed the driver process. The VRAM MQD of the grid-penalty experiment (build 258.3) was such a BO. patches/linux/amdgpu-ttm-visible-kmap.patch gives the premapped address only when amdgpu_res_cpu_visible holds. Otherwise TTM ioremaps the bus range; rt_ioremap now says loudly that the range is outside every BAR and refuses it, and the kmap fails with an error the caller reports. CPU-visible VRAM (amdgpu_bo_create_kernel, CPU_ACCESS_REQUIRED) maps exactly as before and is reached through the aperture's kernel accesses. visible_kmap_check, in the CS selftest (BAR of 64 MiB, 256 MiB of VRAM): a contiguous BO without CPU_ACCESS_REQUIRED validated past the window has no kernel mapping; a CPU_ACCESS_REQUIRED BO maps at aper_base_kaddr plus its offset, inside the window. Without the patch the first kmap returns aper_base_kaddr + 254 MiB and the check fails.