drm/amdgpu: Remove unnecessary TLB workaround
Subsystems (3)
PATCH 1/2 drm/amdgpu: Remove unnecessary TLB workaround
This workaround is better handled in user mode in a way that doesn't require allocating extra memory and breaking userptr BOs.
The TLB bug is a performance bug, not a functional or security bug. Hence it is safe to remove this kernel part of the workaround to allow a better workaround using only virtual address alignments in user mode.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -11
@@ -1110,7 +1110,6 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(uint64_t user_addr =0 ;struct amdgpu_bo *bo;struct amdgpu_bo_param bp; -int byte_align;u32 domain, alloc_domain;u64 alloc_flags;int ret;
@@ -1165,15 +1164,6 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(if ((*mem)->aql_queue) size = size >>1 ; -/* Workaround for TLB bug on older VI chips */ - byte_align = (adev->family ==AMDGPU_FAMILY_VI && - adev->asic_type !=CHIP_FIJI && - adev->asic_type !=CHIP_POLARIS10 && - adev->asic_type !=CHIP_POLARIS11 && - adev->asic_type !=CHIP_POLARIS12 && - adev->asic_type !=CHIP_VEGAM ) ? -VI_BO_SIZE_ALIGN :1 ; - (*mem)->alloc_flags = flags;amdgpu_sync_create (&(*mem)->sync);
@@ -1189,7 +1179,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(memset (&bp,0 ,sizeof (bp)); bp.size = size; - bp.byte_align = byte_align; + bp.byte_align =1 ; bp.domain = alloc_domain; bp.flags = alloc_flags; bp.type = bo_type;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190830051443.3906-1-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: Disable page faults while reading user wptrs
These wptrs must be pinned and GPU accessible when this is called from hqd_load functions. So they should never fault. This resolves a circular lock dependency issue involving four locks including the DQM lock and mmap_sem.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +8 -0
@@ -179,10 +179,17 @@ uint64_t amdgpu_amdkfd_get_mmio_remap_phys_addr(struct kgd_dev *kgd);uint32_t amdgpu_amdkfd_get_num_gws (struct kgd_dev *kgd);uint8_t amdgpu_amdkfd_get_xgmi_hops_count (struct kgd_dev *dst,struct kgd_dev *src); +/* Read user wptr from a specified user address space with page fault +* disabled. The memory must be pinned and mapped to the hardware when +* this is called in hqd_load functions, so it should never fault in +* the first place. This resolves a circular lock dependency involving +* four locks, including the DQM lock and mmap_sem. +*/ #define read_user_wptr (mmptr, wptr, dst) \ ({ \ bool valid = false; \ if ((mmptr) && (wptr)) { \ + pagefault_disable(); \ if ((mmptr) == current->mm) { \ valid = !get_user((dst), (wptr)); \ } else if (current->mm == NULL) { \
@@ -190,6 +197,7 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s valid = !get_user ((dst), (wptr)); \unuse_mm (mmptr); \ } \ +pagefault_enable (); \ } \ valid; \ })
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190830051443.3906-2-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org
Zeng, Oak
Reviewed-by Oak ZengRE: [PATCH 2/2] drm/amdgpu: Disable page faults while reading user wptrs
Regards,
Oak
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Kuehling, Felix
Sent: Friday, August 30, 2019 1:15 AM
To: [email protected]
Subject: [PATCH 2/2] drm/amdgpu: Disable page faults while reading user wptrs
These wptrs must be pinned and GPU accessible when this is called from hqd_load functions. So they should never fault. This resolves a circular lock dependency issue involving four locks including the DQM lock and mmap_sem.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +8 -0
@@ -179,10 +179,17 @@ uint64_t amdgpu_amdkfd_get_mmio_remap_phys_addr(struct kgd_dev *kgd); uint32_t amdgpu_amdkfd_get_num_gws(struct kgd_dev *kgd); uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *src); +/* Read user wptr from a specified user address space with page fault +* disabled. The memory must be pinned and mapped to the hardware when +* this is called in hqd_load functions, so it should never fault in +* the first place. This resolves a circular lock dependency involving +* four locks, including the DQM lock and mmap_sem. +*/ #define read_user_wptr (mmptr, wptr, dst) \ ({ \ bool valid = false; \ if ((mmptr) && (wptr)) { \ + pagefault_disable(); \ if ((mmptr) == current->mm) { \ valid = !get_user((dst), (wptr)); \ } else if (current->mm == NULL) { \
@@ -190,6 +197,7 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_count(struct kgd_dev *dst, struct kgd_dev *s valid = !get_user ((dst), (wptr)); \unuse_mm (mmptr); \ } \ +pagefault_enable (); \ } \ valid; \ })
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 30.08.19 um 07:14 schrieb Kuehling, Felix:
Quoted 9 lines
This workaround is better handled in user mode in a way that doesn't require allocating extra memory and breaking userptr BOs.
The TLB bug is a performance bug, not a functional or security bug. Hence it is safe to remove this kernel part of the workaround to allow a better workaround using only virtual address alignments in user mode.
Signed-off-by Felix Kuehling <[email protected]>
Maybe the VI_BO_SIZE_ALIGN define can now be removed as well?
Apart from that this patch is Reviewed-by: Christian König <[email protected]>.
Quoted 33 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0
-10@@ -1110,7 +1110,6 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(uint64_t user_addr =0 ;struct amdgpu_bo *bo;struct amdgpu_bo_param bp; -int byte_align;u32 domain, alloc_domain;u64 alloc_flags;int ret;@@ -1165,15 +1164,6 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(if ((*mem)->aql_queue) size = size >>1 ; -/* Workaround for TLB bug on older VI chips */ - byte_align = (adev->family ==AMDGPU_FAMILY_VI && - adev->asic_type !=CHIP_FIJI && - adev->asic_type !=CHIP_POLARIS10 && - adev->asic_type !=CHIP_POLARIS11 && - adev->asic_type !=CHIP_POLARIS12 && - adev->asic_type !=CHIP_VEGAM ) ? -VI_BO_SIZE_ALIGN :1 ; - (*mem)->alloc_flags = flags;amdgpu_sync_create (&(*mem)->sync);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu( · line 1185
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1
-1@@ -1189,7 +1179,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(memset (&bp,0 ,sizeof (bp)); bp.size = size; - bp.byte_align = byte_align; + bp.byte_align =1 ; bp.domain = alloc_domain; bp.flags = alloc_flags; bp.type = bo_type;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx