Skip to contentSkip to conversation

drm/amdgpu: Fix CSA buffer alloc failed on Vega

PATCH In review Rex Zhu 2 participants 3 messages Nov 12, 2018 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix CSA buffer alloc failed on Vega

Alloc_pte failed when the VA address located in
the higher arrange of 256T.

so reserve the csa buffer under 128T as a work around.

[  122.979425] amdgpu 0000:03:00.0: va above limit (0xFFFFFFFFFFF1F >= 0x1000000000)
[  122.987080] BUG: unable to handle kernel paging request at ffff880e1a79fff8
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
index fea4555..e2f325b 100644
@@ -36,9 +36,9 @@ uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev, uint32_t id)
 {
 	uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
 
-	addr -= AMDGPU_VA_RESERVED_SIZE * id;
+	addr = min(addr, AMDGPU_GMC_HOLE_START);
 
-	addr = amdgpu_gmc_sign_extend(addr);
+	addr -= (uint64_t)AMDGPU_VA_RESERVED_SIZE * id;
 
 	return addr;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 338a091..ea6a12a 100644
@@ -711,7 +711,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 
 		dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
 		dev_info.virtual_address_max =
-			min(vm_size, AMDGPU_GMC_HOLE_START);
+			min(vm_size, AMDGPU_GMC_HOLE_START - adev->vm_manager.reserved_vm_size);
 
 		if (vm_size > AMDGPU_GMC_HOLE_START) {
 			dev_info.high_va_offset = AMDGPU_GMC_HOLE_END;
Signature · 6 lines
1.9.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): 1542018800-998-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 12.11.18 um 11:33 schrieb Rex Zhu:

Quoted 9 lines

Alloc_pte failed when the VA address located in
the higher arrange of 256T.

so reserve the csa buffer under 128T as a work around.

[  122.979425] amdgpu 0000:03:00.0: va above limit (0xFFFFFFFFFFF1F >= 0x1000000000)
[  122.987080] BUG: unable to handle kernel paging request at ffff880e1a79fff8

Well NAK, userspace wants to use the full address space below 128T for SVM.

The problem is rather that you incorrectly use amdgpu_csa_vaddr(). See the code in amdgpu_driver_open_kms() how to do it correctly:

Quoted 6 lines

                uint64_t csa_addr = amdgpu_csa_vaddr(adev) & AMDGPU_GMC_HOLE_MASK;

                r = amdgpu_map_static_csa(adev, &fpriv->vm, adev->virt.csa_obj, &fpriv->csa_va, csa_addr, AMDGPU_CSA_SIZE);
                if (r)
                        goto error_vm;

Christian.

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
index fea4555..e2f325b 100644
@@ -36,9 +36,9 @@ uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev, uint32_t id)
  {
  	uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
 
-	addr -= AMDGPU_VA_RESERVED_SIZE * id;
+	addr = min(addr, AMDGPU_GMC_HOLE_START);
 
-	addr = amdgpu_gmc_sign_extend(addr);
+	addr -= (uint64_t)AMDGPU_VA_RESERVED_SIZE * id;
 
  	return addr;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
index 338a091..ea6a12a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 717

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -711,7 +711,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 
  		dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
  		dev_info.virtual_address_max =
-			min(vm_size, AMDGPU_GMC_HOLE_START);
+			min(vm_size, AMDGPU_GMC_HOLE_START - adev->vm_manager.reserved_vm_size);
 
  		if (vm_size > AMDGPU_GMC_HOLE_START) {
  			dev_info.high_va_offset = AMDGPU_GMC_HOLE_END;

_______________________________________________
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): e7909a29-fddd-9c65-d748-49f51e72afa9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

Got it .

Thanks.

Best Regards

Rex

________________________________
From: Christian König <[email protected]>
Sent: Monday, November 12, 2018 6:42 PM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix CSA buffer alloc failed on Vega

Am 12.11.18 um 11:33 schrieb Rex Zhu:

Quoted 9 lines

Alloc_pte failed when the VA address located in
the higher arrange of 256T.

so reserve the csa buffer under 128T as a work around.

[  122.979425] amdgpu 0000:03:00.0: va above limit (0xFFFFFFFFFFF1F >= 0x1000000000)
[  122.987080] BUG: unable to handle kernel paging request at ffff880e1a79fff8

Well NAK, userspace wants to use the full address space below 128T for SVM.

The problem is rather that you incorrectly use amdgpu_csa_vaddr(). See the code in amdgpu_driver_open_kms() how to do it correctly:

Quoted 8 lines

uint64_t csa_addr = amdgpu_csa_vaddr(adev) &
AMDGPU_GMC_HOLE_MASK;

                r = amdgpu_map_static_csa(adev, &fpriv->vm,
adev->virt.csa_obj,
&fpriv->csa_va, csa_addr, AMDGPU_CSA_SIZE);
                if (r)
                        goto error_vm;

Christian.

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
index fea4555..e2f325b 100644
@@ -36,9 +36,9 @@ uint64_t amdgpu_csa_vaddr(struct amdgpu_device *adev, uint32_t id)
  {
       uint64_t addr = adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT;
 
-     addr -= AMDGPU_VA_RESERVED_SIZE * id;
+     addr = min(addr, AMDGPU_GMC_HOLE_START);
 
-     addr = amdgpu_gmc_sign_extend(addr);
+     addr -= (uint64_t)AMDGPU_VA_RESERVED_SIZE * id;
 
       return addr;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
index 338a091..ea6a12a 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 717

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
@@ -711,7 +711,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
 
               dev_info.virtual_address_offset = AMDGPU_VA_RESERVED_SIZE;
               dev_info.virtual_address_max =
-                     min(vm_size, AMDGPU_GMC_HOLE_START);
+                     min(vm_size, AMDGPU_GMC_HOLE_START - adev->vm_manager.reserved_vm_size);
 
               if (vm_size > AMDGPU_GMC_HOLE_START) {
                       dev_info.high_va_offset = AMDGPU_GMC_HOLE_END;

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