Skip to contentSkip to conversation

drm/amdgpu: Fix huge page updates with CPU

PATCH In review Felix Kuehling 2 participants 2 messages Aug 18, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix huge page updates with CPU

Correctly detect system memory mappings when using CPU and don't use huge pages for them.

Avoid incorrectly translating a physical page table GPU address when splitting a huge page while mapping system memory.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +15 -1
index 02c64d28..2015bbf 100644
@@ -1276,7 +1276,7 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,
 	/* In the case of a mixed PT the PDE must point to it*/
 	if (p->adev->asic_type < CHIP_VEGA10 ||
 	    nptes != AMDGPU_VM_PTE_COUNT(p->adev) ||
-	    p->func == amdgpu_vm_do_copy_ptes ||
+	    p->src ||
 	    !(flags & AMDGPU_PTE_VALID)) {
 
 		dst = amdgpu_bo_gpu_offset(entry->bo);
@@ -1293,9 +1293,23 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,
 	entry->addr = (dst | flags);
 
 	if (use_cpu_update) {
+		/* In case a huge page is replaced with a system
+		 * memory mapping, p->pages_addr != NULL and
+		 * amdgpu_vm_cpu_set_ptes would try to translate dst
+		 * through amdgpu_vm_map_gart. But dst is already a
+		 * GPU address (of the page table). Disable
+		 * amdgpu_vm_map_gart temporarily.
+		 */
+		dma_addr_t *tmp;
+
+		tmp = p->pages_addr;
+		p->pages_addr = NULL;
+
 		pd_addr = (unsigned long)amdgpu_bo_kptr(parent->bo);
 		pde = pd_addr + (entry - parent->entries) * 8;
 		amdgpu_vm_cpu_set_ptes(p, pde, dst, 1, 0, flags);
+
+		p->pages_addr = tmp;
 	} else {
 		if (parent->bo->shadow) {
 			pd_addr = amdgpu_bo_gpu_offset(parent->bo->shadow);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1503069506-10766-1-git-send-email-Felix.Kuehling-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 18.08.2017 um 17:18 schrieb Felix Kuehling:

Quoted 7 lines

Correctly detect system memory mappings when using CPU and don't use huge pages for them.

Avoid incorrectly translating a physical page table GPU address when splitting a huge page while mapping system memory.

Quoted 31 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11 -1
index 02c64d28..2015bbf 100644
@@ -1276,7 +1276,7 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,
  	/* In the case of a mixed PT the PDE must point to it*/
  	if (p->adev->asic_type < CHIP_VEGA10 ||
  	    nptes != AMDGPU_VM_PTE_COUNT(p->adev) ||
-	    p->func == amdgpu_vm_do_copy_ptes ||
+	    p->src ||
  	    !(flags & AMDGPU_PTE_VALID)) {
 
  		dst = amdgpu_bo_gpu_offset(entry->bo);
@@ -1293,9 +1293,23 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p,
  	entry->addr = (dst | flags);
 
  	if (use_cpu_update) {
+		/* In case a huge page is replaced with a system
+		 * memory mapping, p->pages_addr != NULL and
+		 * amdgpu_vm_cpu_set_ptes would try to translate dst
+		 * through amdgpu_vm_map_gart. But dst is already a
+		 * GPU address (of the page table). Disable
+		 * amdgpu_vm_map_gart temporarily.
+		 */
+		dma_addr_t *tmp;
+
+		tmp = p->pages_addr;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, · line 1315

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -0
+		p->pages_addr = NULL;
+
  		pd_addr = (unsigned long)amdgpu_bo_kptr(parent->bo);
  		pde = pd_addr + (entry - parent->entries) * 8;
  		amdgpu_vm_cpu_set_ptes(p, pde, dst, 1, 0, flags);
+
+		p->pages_addr = tmp;
  	} else {
  		if (parent->bo->shadow) {
  			pd_addr = amdgpu_bo_gpu_offset(parent->bo->shadow);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx