drm/amdgpu: Fix xGMI access P2P mapping failure on GFXIP 9.4.3
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Fix xGMI access P2P mapping failure on GFXIP 9.4.3
From: Rajneesh Bhardwaj <[email protected]>
On GFXIP 9.4.3, we dont need to rely on xGMI hive info to determine P2P access.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -813,7 +813,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,* if peer device has large BAR. In contrast, access over xGMI is * allowed for both small and large BAR configurations of peer device */ -if ((adev != bo_adev) && +if ((adev != bo_adev && !adev->gmc.is_app_apu) && ((mem->domain ==AMDGPU_GEM_DOMAIN_VRAM ) || (mem->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_DOORBELL ) || (mem->alloc_flags &KFD_IOC_ALLOC_MEM_FLAGS_MMIO_REMAP ))) {
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 1/1 drm/amdkfd: Remove skiping userptr buffer mapping when mmu notifier marks it as invalid
From: Xiaogang Chen <[email protected]>
mmu notifier does not always hold mm->sem during call back. That causes a race condition between kfd userprt buffer mapping and mmu notifier which leds to gpu shadder or SDMA access userptr buffer before it has been mapped to gpu VM. Always map userptr buffer to avoid that though it may make some userprt buffers mapped two times.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -10
@@ -1942,16 +1942,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(*/ mutex_lock (&mem->process_info->lock); -/* Lock notifier lock. If we find an invalid userptr BO, we can be -* sure that the MMU notifier is no longer running -* concurrently and the queues are actually stopped -*/ -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) { -mutex_lock (&mem->process_info->notifier_lock); - is_invalid_userptr = !!mem->invalid; -mutex_unlock (&mem->process_info->notifier_lock); - } -mutex_lock (&mem->lock); domain = mem->domain;
Signature · 1 line
2.40.1
Felix Kuehling
maintainerRe: [PATCH] drm/amdkfd: Remove skiping userptr buffer mapping when mmu notifier marks it as invalid
Am 2023-05-09 um 18:17 schrieb Alex Deucher:
Quoted 8 lines
From: Xiaogang Chen <[email protected]>
mmu notifier does not always hold
mm->semduring call back. That causes a race condition between kfd userprt buffer mapping and mmu notifier which leds to gpu shadder or SDMA access userptr buffer before it has been mapped to gpu VM. Always map userptr buffer to avoid that though it may make some userprt buffers mapped two times.
Quoted 4 lines
Suggested-by Felix Kuehling <[email protected]>Signed-off-by Xiaogang Chen <[email protected]>Reviewed-by Felix Kuehling <[email protected]>Signed-off-by Alex Deucher <[email protected]>
This patch is no longer needed and should not be applied. It was originally applied to amd-staging-drm-next as patch fcf00f8d29f2fc6bf00531a1447be28b99073cc3 in November 2022. This fixed a race condition due to incorrect assumptions about the mmap lock and MMU notifiers. This hunk was added back by my later patch f95f51a4c335 ("drm/amdgpu: Add notifier lock for KFD userptrs") in December, using our own notifier lock that doesn't suffer from those races.
Regards,
Felix
Quoted 25 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 ---------- 1 file changed, 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-10@@ -1942,16 +1942,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(*/ mutex_lock (&mem->process_info->lock); -/* Lock notifier lock. If we find an invalid userptr BO, we can be -* sure that the MMU notifier is no longer running -* concurrently and the queues are actually stopped -*/ -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) { -mutex_lock (&mem->process_info->notifier_lock); - is_invalid_userptr = !!mem->invalid; -mutex_unlock (&mem->process_info->notifier_lock); - } -mutex_lock (&mem->lock); domain = mem->domain;
Re: [PATCH] drm/amdkfd: Remove skiping userptr buffer mapping when mmu notifier marks it as invalid
Quoted 15 lines · Felix Kuehling
Am 2023-05-09 um 18:17 schrieb Alex Deucher:
Quoted 8 lines
From: Xiaogang Chen <[email protected]>
mmu notifier does not always hold
mm->semduring call back. That causes a race condition between kfd userprt buffer mapping and mmu notifier which leds to gpu shadder or SDMA access userptr buffer before it has been mapped to gpu VM. Always map userptr buffer to avoid that though it may make some userprt buffers mapped two times.Quoted 4 lines
Suggested-by Felix Kuehling <[email protected]>Signed-off-by Xiaogang Chen <[email protected]>Reviewed-by Felix Kuehling <[email protected]>Signed-off-by Alex Deucher <[email protected]>
Quoted 8 lines
This patch is no longer needed and should not be applied. It was originally applied to amd-staging-drm-next as patch
fcf00f8d29f2fc6bf00531a1447be28b99073cc3in November 2022. This fixed a race condition due to incorrect assumptions about the mmap lock and MMU notifiers. This hunk was added back by my later patchf95f51a4c335("drm/amdgpu: Add notifier lock for KFD userptrs") in December, using our own notifier lock that doesn't suffer from those races.
Thanks. Dropped.
Alex
Quoted 29 lines
Regards,
FelixQuoted 25 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 ---------- 1 file changed, 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-10@@ -1942,16 +1942,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(*/ mutex_lock (&mem->process_info->lock); -/* Lock notifier lock. If we find an invalid userptr BO, we can be -* sure that the MMU notifier is no longer running -* concurrently and the queues are actually stopped -*/ -if (amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) { -mutex_lock (&mem->process_info->notifier_lock); - is_invalid_userptr = !!mem->invalid; -mutex_unlock (&mem->process_info->notifier_lock); - } -mutex_lock (&mem->lock); domain = mem->domain;
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu: Fix unmapping of aperture
In reply to Alex DeucherFrom: Lijo Lazar <[email protected]>
When aperture size is zero, there is no mapping done.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++++--- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4120,7 +4120,7 @@ static void amdgpu_device_unmap_mmio(struct amdgpu_device *adev) adev->mman.aper_base_kaddr =NULL ;/* Memory manager related */ -if (!adev->gmc.xgmi.connected_to_cpu) { +if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) {arch_phys_wc_del (adev->gmc.vram_mtrr);arch_io_free_memtype_wc (adev->gmc.aper_base, adev->gmc.aper_size); }
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -2
@@ -1080,8 +1080,7 @@ void amdgpu_bo_fini(struct amdgpu_device *adev)amdgpu_ttm_fini (adev);if (drm_dev_enter (adev_to_drm (adev), &idx)) { - -if (!adev->gmc.xgmi.connected_to_cpu) { +if (!adev->gmc.xgmi.connected_to_cpu && !adev->gmc.is_app_apu) {arch_phys_wc_del (adev->gmc.vram_mtrr);arch_io_free_memtype_wc (adev->gmc.aper_base, adev->gmc.aper_size); }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -3
@@ -1848,12 +1848,13 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) adev->mman.aper_base_kaddr =ioremap_cache (adev->gmc.aper_base, adev->gmc.visible_vram_size); - else if (!adev->gmc.is_app_apu) + else if (adev->gmc.is_app_apu) + DRM_DEBUG_DRIVER( + "No need to ioremap when real vram size is 0\n"); + else#endif adev->mman.aper_base_kaddr =ioremap_wc (adev->gmc.aper_base, adev->gmc.visible_vram_size); - else - DRM_DEBUG_DRIVER("No need to ioremap when real vram size is 0\n");#endif /*
Signature · 1 line
2.40.1