drm/amdgpu: skip force complete fences when ring is uninitialized
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: skip force complete fences when ring is uninitialized
uvd ring in uvd_v7_0_sw_init only initializes ring in bare metal case, so when executing amdgpu_uvd_resume to restore fence seq in SRIOV, a null pointer dereference will occur. This patch correct this.
Fixes 043f2271e2d0 ("drm/amdgpu: mark force completed fences with -ECANCELED")
BUG: kernel NULL pointer dereference, address: 0000000000000000 Oops: 0000 [#1] PREEMPT SMP PTI RIP: 0010:amdgpu_fence_driver_set_error+0x3f/0xc0 [amdgpu] Call Trace: <TASK> amdgpu_fence_driver_force_completion+0x18/0x50 [amdgpu] amdgpu_uvd_resume+0x1b2/0x380 [amdgpu] ? amdgpu_ring_init+0x73c/0x820 [amdgpu] uvd_v7_0_sw_init+0x358/0x450 [amdgpu] amdgpu_device_init.cold+0x198c/0x1fdf [amdgpu] ? pci_bus_read_config_byte+0x40/0x80 ? pci_read_config_byte+0x27/0x50 amdgpu_driver_load_kms+0x1a/0x160 [amdgpu] amdgpu_pci_probe+0x186/0x3c0 [amdgpu]
Signed-off-by Bob Zhou <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +2 -1
@@ -506,7 +506,8 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) }memset_io (ptr,0 , size);/* to restore uvd fence seq */ -amdgpu_fence_driver_force_completion (&adev->uvd.inst[i].ring); +if (adev->uvd.inst[i].ring.fence_drv.irq_src) +amdgpu_fence_driver_force_completion (&adev->uvd.inst[i].ring); } }return 0 ;
Signature · 1 line
2.34.1
Christian König
maintainerAm 31.05.23 um 11:34 schrieb Bob Zhou:
Quoted 3 lines
uvd ring in
uvd_v7_0_sw_initonly initializes ring in bare metal case, so when executingamdgpu_uvd_resumeto restore fence seq in SRIOV, a null pointer dereference will occur. This patch correct this.
Mhm, taking a higher level look at this why isn't the ring initialized when the VCPU BO is allocated?
Adding Leo as well since that looks more like a design issue to me.
Regards,
Christian.
Quoted 37 lines
Fixes 043f2271e2d0 ("drm/amdgpu: mark force completed fences with -ECANCELED")BUG: kernel NULL pointer dereference, address: 0000000000000000 Oops: 0000 [#1] PREEMPT SMP PTI RIP: 0010:amdgpu_fence_driver_set_error+0x3f/0xc0 [amdgpu] Call Trace: <TASK> amdgpu_fence_driver_force_completion+0x18/0x50 [amdgpu] amdgpu_uvd_resume+0x1b2/0x380 [amdgpu] ? amdgpu_ring_init+0x73c/0x820 [amdgpu] uvd_v7_0_sw_init+0x358/0x450 [amdgpu] amdgpu_device_init.cold+0x198c/0x1fdf [amdgpu] ? pci_bus_read_config_byte+0x40/0x80 ? pci_read_config_byte+0x27/0x50 amdgpu_driver_load_kms+0x1a/0x160 [amdgpu] amdgpu_pci_probe+0x186/0x3c0 [amdgpu]Signed-off-by Bob Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +2
-1@@ -506,7 +506,8 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) }memset_io (ptr,0 , size);/* to restore uvd fence seq */ -amdgpu_fence_driver_force_completion (&adev->uvd.inst[i].ring); +if (adev->uvd.inst[i].ring.fence_drv.irq_src) +amdgpu_fence_driver_force_completion (&adev->uvd.inst[i].ring); } }return 0 ;