diff mbox series

[v2] drm/radeon: don't evict if not initialized

Message ID 20210321151907.367586-1-ztong0001@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/radeon: don't evict if not initialized | expand

Commit Message

Tong Zhang March 21, 2021, 3:19 p.m. UTC
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]

Suggested-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
v2: coding style fix

 drivers/gpu/drm/radeon/radeon_object.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christian König March 22, 2021, 7:40 a.m. UTC | #1
Am 21.03.21 um 16:19 schrieb Tong Zhang:
> 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]
>
> Suggested-by: Christian König <christian.koenig@amd.com>
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
> v2: coding style fix
>
>   drivers/gpu/drm/radeon/radeon_object.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 9b81786782de..499ce55e34cc 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -384,6 +384,8 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
>   	}
>   #endif
>   	man = ttm_manager_type(bdev, TTM_PL_VRAM);
> +	if (!man)
> +		return 0;
>   	return ttm_resource_manager_evict_all(bdev, man);
>   }
>
Alex Deucher March 23, 2021, 2:45 p.m. UTC | #2
Applied.  Thanks!

Alex

On Mon, Mar 22, 2021 at 3:40 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 21.03.21 um 16:19 schrieb Tong Zhang:
> > 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]
> >
> > Suggested-by: Christian König <christian.koenig@amd.com>
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > v2: coding style fix
> >
> >   drivers/gpu/drm/radeon/radeon_object.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> > index 9b81786782de..499ce55e34cc 100644
> > --- a/drivers/gpu/drm/radeon/radeon_object.c
> > +++ b/drivers/gpu/drm/radeon/radeon_object.c
> > @@ -384,6 +384,8 @@ int radeon_bo_evict_vram(struct radeon_device *rdev)
> >       }
> >   #endif
> >       man = ttm_manager_type(bdev, TTM_PL_VRAM);
> > +     if (!man)
> > +             return 0;
> >       return ttm_resource_manager_evict_all(bdev, man);
> >   }
> >
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 9b81786782de..499ce55e34cc 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -384,6 +384,8 @@  int radeon_bo_evict_vram(struct radeon_device *rdev)
 	}
 #endif
 	man = ttm_manager_type(bdev, TTM_PL_VRAM);
+	if (!man)
+		return 0;
 	return ttm_resource_manager_evict_all(bdev, man);
 }