Re: [PATCH] drm/amd/amdgpu: Use “__packed“ instead of "pragma pack()"
Hi Su, kernel test robot noticed the following build warnings: [auto build test WARNING on drm-misc/drm-misc-next] [also build test WARNING on linus/master v6.4-rc7 next-20230620] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Su-Hui/drm-amd-amdgpu-Use-__packed-instead-of-pragma-pack/20230620-165739 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230620085543.576733-1-suhui%40nfschina.com patch subject: [PATCH] drm/amd/amdgpu: Use “__packed“ instead of "pragma pack()" config: openrisc-randconfig-s051-20230620 (https://download.01.org/0day-ci/archive/20230621/202306210140.tawpw0sg-...@intel.com/config) compiler: or1k-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230621/202306210140.tawpw0sg-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202306210140.tawpw0sg-...@intel.com/ sparse warnings: (new ones prefixed by >>) drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression >> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: incorrect >> type in initializer (different address spaces) @@ expected unsigned int >> [noderef] __user *__pu_addr @@ got unsigned int [usertype] * @@ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: expected unsigned int [noderef] __user *__pu_addr drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: got unsigned int [usertype] * drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:485:29: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int [noderef] __user *__pu_addr @@ got unsigned int [usertype] * @@ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: expected unsigned int [noderef] __user *__pu_addr drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: got unsigned int [usertype] * drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:500:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int [noderef] __user *__pu_addr @@ got unsigned int [usertype] * @@ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: expected unsigned int [noderef] __user *__pu_addr drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: got unsigned int [usertype] * drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: sparse: cast removes address space '__user' of expression drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c:546:21: sparse: sparse: cast removes address space
Re: [PATCH] drm/amd/amdgpu: Use “__packed“ instead of "pragma pack()"
When there was a #pragma then Sparse just turned off. The Sparse warnings are places where people forgot to put the __user in their casts or didn't annotate endianness correctly. It's not a "bug" to forget to annotate endianness or user pointers. That's how we used to do it prior to 2003. But these days it feels strange and dangerous to see these sorts of warnings. Smatch also disabled some uninitialized variable checks. These are mostly false positives where we have a loop: int r; while (something) { r = frob(); } return r; Smatch complains that we don't necessarily enter the loop. I think I'm going to disable this type of "enter the loop" warning when you don't have the cross function database available. That will silence these for the kbuild bot. regards, dan carpenter Hi Su, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Su-Hui/drm-amd-amdgpu-Use-__packed-instead-of-pragma-pack/20230620-165739 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230620085543.576733-1-suhui%40nfschina.com patch subject: [PATCH] drm/amd/amdgpu: Use “__packed“ instead of "pragma pack()" config: mips-randconfig-m031-20230620 (https://download.01.org/0day-ci/archive/20230621/202306210527.oxvd2jlz-...@intel.com/config) compiler: mips-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230621/202306210527.oxvd2jlz-...@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Reported-by: Dan Carpenter | Closes: https://lore.kernel.org/r/202306210527.oxvd2jlz-...@intel.com/ New smatch warnings: drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:5914 amdgpu_pci_slot_reset() error: uninitialized symbol 'memsize'. drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c:2244 amdgpu_fill_buffer() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/amdgpu_benchmark.c:55 amdgpu_benchmark_do_move() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:534 amdgpu_vram_mgr_new() error: uninitialized symbol 'cur_size'. drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c:534 amdgpu_vram_mgr_new() error: uninitialized symbol 'size'. drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1274 amdgpu_ras_query_error_count() error: uninitialized symbol 'ret'. drivers/gpu/drm/amd/amdgpu/amdgpu_securedisplay.c:141 amdgpu_securedisplay_debugfs_write() error: uninitialized symbol 'phy_id'. drivers/gpu/drm/amd/amdgpu/aldebaran.c:103 aldebaran_mode2_suspend_ip() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/aldebaran.c:385 aldebaran_mode2_restore_hwcontext() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/sienna_cichlid.c:96 sienna_cichlid_mode2_suspend_ip() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/smu_v13_0_10.c:95 smu_v13_0_10_mode2_suspend_ip() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c:612 mmhub_v2_0_update_medium_grain_clock_gating() error: uninitialized symbol 'def'. drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:1183 amdgpu_gfx_cp_init_microcode() error: uninitialized symbol 'ucode_fw'. drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:1184 amdgpu_gfx_cp_init_microcode() error: uninitialized symbol 'fw_size'. drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c:594 sdma_v4_0_init_microcode() error: uninitialized symbol 'ret'. drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c:251 sdma_v5_0_init_microcode() error: uninitialized symbol 'ret'. drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c:1021 sdma_v5_0_ring_test_ring() error: uninitialized symbol 'index'. drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c:905 sdma_v6_0_ring_test_ring() error: uninitialized symbol 'index'. drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c:145 sdma_v4_4_2_init_microcode() error: uninitialized symbol 'ret'. drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c:1390 sdma_v4_4_2_sw_init() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c:855 sdma_v5_2_ring_test_ring() error: uninitialized symbol 'index'. drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c:361 vcn_v3_0_hw_init() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c:222 vcn_v4_0_3_hw_init() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c:281 vcn_v4_0_hw_init() error: uninitialized symbol 'r'. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c:592 amdgpu_amdkfd_get_xgmi_bandwidth_mbytes() error: uninitialized symbol 'peer_adev'. drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/vangogh_ppt.c:1011 vangogh_get_dpm_ultimate_freq() error: uninitialized symbol 'mclk_mask'. drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/vangogh_ppt.c:1016 vangogh_get_dpm_ultimate_freq() error: uninitialized symbol 'soc_mask'. drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/vangogh_ppt
Re: [PATCH] drm/amd/amdgpu: Use “__packed“ instead of "pragma pack()"
On 2023/6/21 14:11, Dan Carpenter wrote: When there was a #pragma then Sparse just turned off. The Sparse warnings are places where people forgot to put the __user in their casts or didn't annotate endianness correctly. It's not a "bug" to forget to annotate endianness or user pointers. That's how we used to do it prior to 2003. But these days it feels strange and dangerous to see these sorts of warnings. Got it. And it is really strange when I first saw these warnings. Thanks for your explanation! Su Hui Smatch also disabled some uninitialized variable checks. These are mostly false positives where we have a loop: int r; while (something) { r = frob(); } return r; Smatch complains that we don't necessarily enter the loop. I think I'm going to disable this type of "enter the loop" warning when you don't have the cross function database available. That will silence these for the kbuild bot. regards, dan carpenter