Skip to contentSkip to conversation

drm/radeon: don't evict if not initialized

PATCH Superseded Tong Zhang 2 participants 3 messages Mar 20, 2021 – Mar 21, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tong Zhang

author
#0 lore raw

PATCH 1/1 drm/radeon: don't evict if not initialized

TTM_PL_VRAM may not initialized at all when calling radeon_bo_evict_vram(). We need to check before doing eviction.

[    2.160837] BUG: kernel NULL pointer dereference, address: 0000000000000020
[    2.161212] #PF: supervisor read access in kernel mode
[    2.161490] #PF: error_code(0x0000) - not-present page
[    2.161767] PGD 0 P4D 0
[    2.163088] RIP: 0010:ttm_resource_manager_evict_all+0x70/0x1c0 [ttm]
[    2.168506] Call Trace:
[    2.168641]  radeon_bo_evict_vram+0x1c/0x20 [radeon]
[    2.168936]  radeon_device_fini+0x28/0xf9 [radeon]
[    2.169224]  radeon_driver_unload_kms+0x44/0xa0 [radeon]
[    2.169534]  radeon_driver_load_kms+0x174/0x210 [radeon]
[    2.169843]  drm_dev_register+0xd9/0x1c0 [drm]
[    2.170104]  radeon_pci_probe+0x117/0x1a0 [radeon]
---
 drivers/gpu/drm/radeon/radeon_object.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -1
index 9b81786782de..04e9a8118b0e 100644
@@ -384,7 +384,9 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
 	}
 #endif
 	man = ttm_manager_type(bdev, TTM_PL_VRAM);
-	return ttm_resource_manager_evict_all(bdev, man);
+	if (man)
+		return ttm_resource_manager_evict_all(bdev, man);
+	return 0;
 }
 
 void radeon_bo_force_delete(struct radeon_device *rdev)
Signature · 6 lines
2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#1 lore raw

Am 20.03.21 um 21:10 schrieb Tong Zhang:

Quoted 26 lines

TTM_PL_VRAM may not initialized at all when calling radeon_bo_evict_vram(). We need to check before doing eviction.

[    2.160837] BUG: kernel NULL pointer dereference, address: 0000000000000020
[    2.161212] #PF: supervisor read access in kernel mode
[    2.161490] #PF: error_code(0x0000) - not-present page
[    2.161767] PGD 0 P4D 0
[    2.163088] RIP: 0010:ttm_resource_manager_evict_all+0x70/0x1c0 [ttm]
[    2.168506] Call Trace:
[    2.168641]  radeon_bo_evict_vram+0x1c/0x20 [radeon]
[    2.168936]  radeon_device_fini+0x28/0xf9 [radeon]
[    2.169224]  radeon_driver_unload_kms+0x44/0xa0 [radeon]
[    2.169534]  radeon_driver_load_kms+0x174/0x210 [radeon]
[    2.169843]  drm_dev_register+0xd9/0x1c0 [drm]
[    2.170104]  radeon_pci_probe+0x117/0x1a0 [radeon]
---
  drivers/gpu/drm/radeon/radeon_object.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_object.c +0 -0
index 9b81786782de..04e9a8118b0e 100644

drivers/gpu/drm/radeon/radeon_object.c int radeon_bo_evict_vram(struct radeon_device *rdev) · line 389

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_object.c +3 -1
@@ -384,7 +384,9 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
  	}
  #endif
  	man = ttm_manager_type(bdev, TTM_PL_VRAM);
-	return ttm_resource_manager_evict_all(bdev, man);
+	if (man)
+		return ttm_resource_manager_evict_all(bdev, man);
+	return 0;

You should probably code this the other way around, e.g.

If (!man)
    return 0;
...

Apart from that looks good to me.

Christian.

drivers/gpu/drm/radeon/radeon_object.c int radeon_bo_evict_vram(struct radeon_device *rdev) · line 392

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_object.c +0 -0
  }
 
  void radeon_bo_force_delete(struct radeon_device *rdev)

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

author
#2 lore raw

Thanks,
Fixed as suggested and sent as v2.
- Tong

Quoted 40 lines · Christian König

Am 20.03.21 um 21:10 schrieb Tong Zhang:

Quoted 26 lines

TTM_PL_VRAM may not initialized at all when calling radeon_bo_evict_vram(). We need to check before doing eviction.

[    2.160837] BUG: kernel NULL pointer dereference, address: 0000000000000020
[    2.161212] #PF: supervisor read access in kernel mode
[    2.161490] #PF: error_code(0x0000) - not-present page
[    2.161767] PGD 0 P4D 0
[    2.163088] RIP: 0010:ttm_resource_manager_evict_all+0x70/0x1c0 [ttm]
[    2.168506] Call Trace:
[    2.168641]  radeon_bo_evict_vram+0x1c/0x20 [radeon]
[    2.168936]  radeon_device_fini+0x28/0xf9 [radeon]
[    2.169224]  radeon_driver_unload_kms+0x44/0xa0 [radeon]
[    2.169534]  radeon_driver_load_kms+0x174/0x210 [radeon]
[    2.169843]  drm_dev_register+0xd9/0x1c0 [drm]
[    2.170104]  radeon_pci_probe+0x117/0x1a0 [radeon]
---
  drivers/gpu/drm/radeon/radeon_object.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_object.c +0 -0
index 9b81786782de..04e9a8118b0e 100644

drivers/gpu/drm/radeon/radeon_object.c int radeon_bo_evict_vram(struct radeon_device *rdev) · line 389

Quoted 7 lines
drivers/gpu/drm/radeon/radeon_object.c +3 -1
@@ -384,7 +384,9 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
      }
  #endif
      man = ttm_manager_type(bdev, TTM_PL_VRAM);
-     return ttm_resource_manager_evict_all(bdev, man);
+     if (man)
+             return ttm_resource_manager_evict_all(bdev, man);
+     return 0;

You should probably code this the other way around, e.g.

Quoted 12 lines

If (!man)

     return 0;

...

Apart from that looks good to me.

Christian.

Quoted 3 lines
drivers/gpu/drm/radeon/radeon_object.c +0 -0
  }
 
  void radeon_bo_force_delete(struct radeon_device *rdev)

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