Skip to contentSkip to conversation

drm/amdgpu: soc15 enable (v3)

bug report Dan Carpenter 3 participants 5 messages Apr 3, 2017 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello Ken Wang,

The patch 220ab9bd1ccf: "drm/amdgpu: soc15 enable (v3)" from Mar 6, 2017, leads to the following static checker warning:

	drivers/gpu/drm/amd/amdgpu/soc15.c:110 soc15_pcie_rreg()
	error: potentially dereferencing uninitialized 'nbio_pcie_id'.

drivers/gpu/drm/amd/amdgpu/soc15.c
101 static u32 soc15_pcie_rreg(struct amdgpu_device *adev, u32 reg) 102 {

   103          unsigned long flags, address, data;
   104          u32 r;
   105          struct nbio_pcie_index_data *nbio_pcie_id;

106
107 if (adev->asic_type == CHIP_VEGA10)
108 nbio_pcie_id = &nbio_v6_1_pcie_index_data;

There should be an else statement to this probably?

   109  
   110          address = nbio_pcie_id->index_offset;
   111          data = nbio_pcie_id->data_offset;
   112  
   113          spin_lock_irqsave(&adev->pcie_idx_lock, flags);
   114          WREG32(address, reg);
   115          (void)RREG32(address);
   116          r = RREG32(data);
   117          spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
   118          return r;
   119  }
   120  

See also:

drivers/gpu/drm/amd/amdgpu/soc15.c:110 soc15_pcie_rreg() error: potentially dereferencing uninitialized 'nbio_pcie_id'. drivers/gpu/drm/amd/amdgpu/soc15.c:129 soc15_pcie_wreg() error: potentially dereferencing uninitialized 'nbio_pcie_id'. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:1736 amdgpu_sriov_reinit_early() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3033 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3036 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3043 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:357 sdma_v4_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:359 sdma_v4_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vega10_smumgr.c:425 vega10_smu_init() error: uninitialized symbol 'handle'. drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/vega10_hwmgr.c:2860 vega10_apply_state_adjust_rules() error: uninitialized symbol 'stable_pstate_sclk_dpm_percentage'.

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

#1 lore raw
Quoted 18 lines · Dan Carpenter

Hello Ken Wang,

The patch 220ab9bd1ccf: "drm/amdgpu: soc15 enable (v3)" from Mar 6, 2017, leads to the following static checker warning:

drivers/gpu/drm/amd/amdgpu/soc15.c:110 soc15_pcie_rreg()
error: potentially dereferencing uninitialized 'nbio_pcie_id'.

drivers/gpu/drm/amd/amdgpu/soc15.c
101 static u32 soc15_pcie_rreg(struct amdgpu_device *adev, u32 reg)

   102  {
   103          unsigned long flags, address, data;
   104          u32 r;
   105          struct nbio_pcie_index_data *nbio_pcie_id;
   106
   107          if (adev->asic_type == CHIP_VEGA10)
   108                  nbio_pcie_id = &nbio_v6_1_pcie_index_data;
Quoted 1 line

There should be an else statement to this probably?

Currently vega10 is the only soc15 gpu so there is else case yet.

Alex

Quoted 27 lines
   109
   110          address = nbio_pcie_id->index_offset;
   111          data = nbio_pcie_id->data_offset;
   112
   113          spin_lock_irqsave(&adev->pcie_idx_lock, flags);
   114          WREG32(address, reg);
   115          (void)RREG32(address);
   116          r = RREG32(data);
   117          spin_unlock_irqrestore(&adev->pcie_idx_lock, flags);
   118          return r;
   119  }
   120

See also:

drivers/gpu/drm/amd/amdgpu/soc15.c:110 soc15_pcie_rreg() error: potentially dereferencing uninitialized 'nbio_pcie_id'. drivers/gpu/drm/amd/amdgpu/soc15.c:129 soc15_pcie_wreg() error: potentially dereferencing uninitialized 'nbio_pcie_id'. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:1736 amdgpu_sriov_reinit_early() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3033 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3036 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:3043 gfx_v9_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:357 sdma_v4_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:359 sdma_v4_0_ring_emit_hdp_flush() error: potentially dereferencing uninitialized 'nbio_hf_reg'. drivers/gpu/drm/amd/amdgpu/../powerplay/smumgr/vega10_smumgr.c:425 vega10_smu_init() error: uninitialized symbol 'handle'. drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/vega10_hwmgr.c:2860 vega10_apply_state_adjust_rules() error: uninitialized symbol 'stable_pstate_sclk_dpm_percentage'.

Quoted 6 lines

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

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

#3 lore raw
In reply to a message not in the archive
Quoted 19 lines · Alex Deucher
Quoted 18 lines · Dan Carpenter

Hello Ken Wang,

The patch 220ab9bd1ccf: "drm/amdgpu: soc15 enable (v3)" from Mar 6, 2017, leads to the following static checker warning:

drivers/gpu/drm/amd/amdgpu/soc15.c:110 soc15_pcie_rreg()
error: potentially dereferencing uninitialized 'nbio_pcie_id'.

drivers/gpu/drm/amd/amdgpu/soc15.c
101 static u32 soc15_pcie_rreg(struct amdgpu_device *adev, u32 reg)

   102  {
   103          unsigned long flags, address, data;
   104          u32 r;
   105          struct nbio_pcie_index_data *nbio_pcie_id;
   106
   107          if (adev->asic_type == CHIP_VEGA10)
   108                  nbio_pcie_id = &nbio_v6_1_pcie_index_data;
Quoted 4 lines
Quoted 1 line

There should be an else statement to this probably?

Currently vega10 is the only soc15 gpu so there is else case yet.

Yeah. I figured. But it's annoying to have half implemented code and static checker warnings.

regards,
dan carpenter

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

#5 lore raw
Quoted 8 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Dan Carpenter
Sent: Monday, April 03, 2017 3:35 PM
To: Alex Deucher
Cc: Wang, Ken; amd-gfx list
Subject: Re: [bug report] drm/amdgpu: soc15 enable (v3)

Quoted 6 lines

If we added an:

		else
			BUG();

that would silence the warning.

We can do that.

Alex

Quoted 8 lines

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

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