[riscv:for-next 3/14] arch/riscv/mm/dma-noncoherent.c:107:6: warning: variable 'cbom_hartid' is uninitialized when used here

From: kernel test robot
Date: Thu Aug 11 2022 - 18:42:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git for-next
head: d8357e3bf8f7aabd98bf4dc2709ee877b741cefc
commit: 3aefb2ee5bdd4a8976298415a5a017bf9844bfd5 [3/14] riscv: implement Zicbom-based CMO instructions + the t-head variant
config: riscv-randconfig-r042-20220811 (https://download.01.org/0day-ci/archive/20220812/202208120635.bMNAowDE-lkp@xxxxxxxxx/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 5f1c7e2cc5a3c07cbc2412e851a7283c1841f520)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git/commit/?id=3aefb2ee5bdd4a8976298415a5a017bf9844bfd5
git remote add riscv https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
git fetch --no-tags riscv for-next
git checkout 3aefb2ee5bdd4a8976298415a5a017bf9844bfd5
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/mm/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> arch/riscv/mm/dma-noncoherent.c:107:6: warning: variable 'cbom_hartid' is uninitialized when used here [-Wuninitialized]
cbom_hartid, hartid);
^~~~~~~~~~~
include/linux/printk.h:517:37: note: expanded from macro 'pr_warn'
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/printk.h:464:60: note: expanded from macro 'printk'
#define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/printk.h:436:19: note: expanded from macro 'printk_index_wrap'
_p_func(_fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
arch/riscv/mm/dma-noncoherent.c:87:18: note: initialize the variable 'cbom_hartid' to silence this warning
int cbom_hartid;
^
= 0
1 warning generated.


vim +/cbom_hartid +107 arch/riscv/mm/dma-noncoherent.c

1631ba1259d6d7 Heiko Stuebner 2022-07-07 77
1631ba1259d6d7 Heiko Stuebner 2022-07-07 78 #ifdef CONFIG_RISCV_ISA_ZICBOM
1631ba1259d6d7 Heiko Stuebner 2022-07-07 79 void riscv_init_cbom_blocksize(void)
1631ba1259d6d7 Heiko Stuebner 2022-07-07 80 {
1631ba1259d6d7 Heiko Stuebner 2022-07-07 81 struct device_node *node;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 82 int ret;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 83 u32 val;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 84
1631ba1259d6d7 Heiko Stuebner 2022-07-07 85 for_each_of_cpu_node(node) {
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 86 unsigned long hartid;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 87 int cbom_hartid;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 88
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 89 ret = riscv_of_processor_hartid(node, &hartid);
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 90 if (ret)
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 91 continue;
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 92
1631ba1259d6d7 Heiko Stuebner 2022-07-07 93 if (hartid < 0)
1631ba1259d6d7 Heiko Stuebner 2022-07-07 94 continue;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 95
1631ba1259d6d7 Heiko Stuebner 2022-07-07 96 /* set block-size for cbom extension if available */
1631ba1259d6d7 Heiko Stuebner 2022-07-07 97 ret = of_property_read_u32(node, "riscv,cbom-block-size", &val);
1631ba1259d6d7 Heiko Stuebner 2022-07-07 98 if (ret)
1631ba1259d6d7 Heiko Stuebner 2022-07-07 99 continue;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 100
1631ba1259d6d7 Heiko Stuebner 2022-07-07 101 if (!riscv_cbom_block_size) {
1631ba1259d6d7 Heiko Stuebner 2022-07-07 102 riscv_cbom_block_size = val;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 103 cbom_hartid = hartid;
1631ba1259d6d7 Heiko Stuebner 2022-07-07 104 } else {
1631ba1259d6d7 Heiko Stuebner 2022-07-07 105 if (riscv_cbom_block_size != val)
3aefb2ee5bdd4a Palmer Dabbelt 2022-08-10 106 pr_warn("cbom-block-size mismatched between harts %d and %lu\n",
1631ba1259d6d7 Heiko Stuebner 2022-07-07 @107 cbom_hartid, hartid);
1631ba1259d6d7 Heiko Stuebner 2022-07-07 108 }
1631ba1259d6d7 Heiko Stuebner 2022-07-07 109 }
1631ba1259d6d7 Heiko Stuebner 2022-07-07 110 }
1631ba1259d6d7 Heiko Stuebner 2022-07-07 111 #endif
1631ba1259d6d7 Heiko Stuebner 2022-07-07 112

:::::: The code at line 107 was first introduced by commit
:::::: 1631ba1259d6d7f49b6028f2a1a0fa02be1c522a riscv: Add support for non-coherent devices using zicbom extension

:::::: TO: Heiko Stuebner <heiko@xxxxxxxxx>
:::::: CC: Palmer Dabbelt <palmer@xxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://01.org/lkp