drm/amdgpu: fix some uninitialized variables
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix some uninitialized variables
Fix some variables not initialized before use.
Scan them out using Synopsys tools.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 3 ++- 6 files changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1 -1
@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +5 -0
@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg =VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }
drivers/gpu/drm/amd/amdgpu/atom.c +1 -0
@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2 -1
@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2 -1
@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2 -1
@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }
Signature · 1 line
2.25.1
Quoted 4 lines · Jesse Zhang
Fix some variables not initialized before use.
Scan them out using Synopsys tools.
Quoted 8 lines
Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 3 ++-
Please split out the SDMA changes into a separate patch.
More comments below on the other hunks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 12 lines
6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;
Can you elaborate on what the issue is here? Presumably it's warning about size being passed as a parameter in the function?
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 420
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +5
-0new_state.fw_based =VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg =VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }
This should be a separate patch as well.
Quoted 57 lines
drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-2@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; } --2.25.1
[AMD Official Use Only - General]
Hi Alex,
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, April 24, 2024 9:46 AM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix some uninitialized variables
Quoted 4 lines · Jesse Zhang
Fix some variables not initialized before use.
Scan them out using Synopsys tools.
Quoted 8 lines
Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c| 3 ++-drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c| 3 ++-
Please split out the SDMA changes into a separate patch.
More comments below on the other hunks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 13 lines
6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;
Can you elaborate on what the issue is here? Presumably it's warning about size being passed as a parameter in the function?
[Zhang, Jesse(Jie)] Using uninitialized value *size when calling amdgpu_vce_cs_reloc for case 0x03000001. Because uint32_t *size = &tmp;
I'm not sure if other commands initialize the size before running case 0x03000001.Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 419
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg = +VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }
This should be a separate patch as well.
Thanks for your reminder, Alex, I will.
Quoted 61 lines
drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-2@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; } --2.25.1
Quoted 45 lines · Jesse(Jie)
[AMD Official Use Only - General]
Hi Alex,
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, April 24, 2024 9:46 AM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix some uninitialized variablesQuoted 4 lines · Jesse Zhang
Fix some variables not initialized before use.
Scan them out using Synopsys tools.Quoted 8 lines
Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c| 3 ++-drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c| 3 ++-Please split out the SDMA changes into a separate patch.
More comments below on the other hunks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 13 lines
6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;Can you elaborate on what the issue is here? Presumably it's warning about size being passed as a parameter in the function?
Quoted 2 lines
[Zhang, Jesse(Jie)] Using uninitialized value *size when calling amdgpu_vce_cs_reloc for case 0x03000001. Because uint32_t *size = &tmp;
I'm not sure if other commands initialize the size before running case 0x03000001.Yeah, I don't really see a cleaner way to handle this. Maybe Leo has a better idea?
Alex
Quoted 89 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 419
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg = +VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }This should be a separate patch as well.
Thanks for your reminder, Alex, I will.Quoted 61 lines
drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-2@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; } --2.25.1
Fix Leo's address.
Quoted 144 lines · Alex Deucher
Quoted 45 lines · Jesse(Jie)
[AMD Official Use Only - General]
Hi Alex,
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, April 24, 2024 9:46 AM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix some uninitialized variablesQuoted 4 lines · Jesse Zhang
Fix some variables not initialized before use.
Scan them out using Synopsys tools.Quoted 8 lines
Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c| 3 ++-drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c| 3 ++-Please split out the SDMA changes into a separate patch.
More comments below on the other hunks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 13 lines
6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;Can you elaborate on what the issue is here? Presumably it's warning about size being passed as a parameter in the function?
Quoted 2 lines
[Zhang, Jesse(Jie)] Using uninitialized value *size when calling amdgpu_vce_cs_reloc for case 0x03000001. Because uint32_t *size = &tmp; I'm not sure if other commands initialize the size before running case 0x03000001.Yeah, I don't really see a cleaner way to handle this. Maybe Leo has a better idea?
Alex
Quoted 89 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 419
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg = +VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }This should be a separate patch as well.
Thanks for your reminder, Alex, I will.Quoted 61 lines
drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-2@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; } --2.25.1
Christian König
maintainerAm 24.04.24 um 04:04 schrieb Zhang, Jesse(Jie):
Quoted 41 lines
[AMD Official Use Only - General]
Hi Alex,
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, April 24, 2024 9:46 AM
To: Zhang, Jesse(Jie) <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: fix some uninitialized variablesQuoted 11 lines · Jesse Zhang
Fix some variables not initialized before use.
Scan them out using Synopsys tools.Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++-
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c| 3 ++-drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c| 3 ++-Please split out the SDMA changes into a separate patch.
More comments below on the other hunks.
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 13 lines
6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;Can you elaborate on what the issue is here? Presumably it's warning about size being passed as a parameter in the function?
Quoted 2 lines
[Zhang, Jesse(Jie)] Using uninitialized value *size when calling amdgpu_vce_cs_reloc for case 0x03000001. Because uint32_t *size = &tmp;
I'm not sure if other commands initialize the size before running case 0x03000001.Ah! Yeah, that handling is actually correct. The size might be uninitialized in this function when the command stream isn't valid.
We could instead set size to NULL and check that everywhere, but that would probably be overkill.
Well we could silence the warning by setting tmp to zero, but that actually doesn't improve anything.
Regards,
Christian.
Quoted 88 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +0
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c static void amdgpu_vcn_idle_work_handler(struct work_struct *work) · line 419
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +6
-0VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg = +VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }This should be a separate patch as well.
Thanks for your reminder, Alex, I will.Quoted 61 lines
drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-2@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; } --2.25.1
Christian König
maintainerAm 24.04.24 um 03:19 schrieb Jesse Zhang:
Quoted 18 lines
Fix some variables not initialized before use.
Scan them out using Synopsys tools.Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/atom.c | 1 + drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 3 ++- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 3 ++- 6 files changed, 13 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, · line 745
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +1
-1@@ -742,7 +742,7 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p,uint32_t destroyed =0 ;uint32_t created =0 ;uint32_t allocated =0 ; -uint32_t tmp, handle =0 ; +uint32_t tmp =0 , handle =0 ;
As far as I can see that isn't correct. tmp isn't used before it is written.
Is the tool maybe broken?
Regards,
Christian.
Quoted 73 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +0
-0uint32_t *size = &tmp;unsigned int idx;int i, r =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +5
-0@@ -410,6 +410,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)else new_state.fw_based =VCN_DPG_STATE__UNPAUSE ; +if (amdgpu_fence_count_emitted (adev->jpeg.inst->ring_dec)) + new_state.jpeg =VCN_DPG_STATE__PAUSE ; +else + new_state.jpeg =VCN_DPG_STATE__UNPAUSE ; + adev->vcn.pause_dpg_mode (adev, j, &new_state); }drivers/gpu/drm/amd/amdgpu/atom.c +1
-0@@ -1243,6 +1243,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, ectx.ps_size = params_size; ectx.abort = false; ectx.last_jump =0 ; + ectx.last_jump_jiffies =0 ;if (ws) { ectx.ws =kcalloc (4 , ws,GFP_KERNEL ); ectx.ws_size = ws;drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +2
-1@@ -999,7 +999,8 @@ static int sdma_v5_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +2
-1@@ -839,7 +839,8 @@ static int sdma_v5_2_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,20 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +2
-1@@ -861,7 +861,8 @@ static int sdma_v6_0_ring_test_ring(struct amdgpu_ring *ring) r =amdgpu_ring_alloc (ring,5 );if (r) {DRM_ERROR ("amdgpu: dma failed to lock ring %d (%d).\n" , ring->idx, r); -amdgpu_device_wb_free (adev, index); +if (!ring->is_mes_queue) +amdgpu_device_wb_free (adev, index);return r; }