:::::: :::::: Manual check reason: "low confidence static check warning: drivers/gpu/drm/mgag200/mgag200_pll.c:239:23: warning: Division by zero. [zerodiv]" ::::::
CC: [email protected] BCC: [email protected] CC: [email protected] TO: Thomas Zimmermann <[email protected]> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: de5c208d533a46a074eb46ea17f672cc005a7269 commit: 2545ac960364d0395802a27374b46f13827b4cf5 drm/mgag200: Abstract pixel PLL via struct mgag200_pll date: 11 months ago :::::: branch date: 11 hours ago :::::: commit date: 11 months ago compiler: ia64-linux-gcc (GCC) 11.3.0 reproduce (cppcheck warning): # apt-get install cppcheck git checkout 2545ac960364d0395802a27374b46f13827b4cf5 cppcheck --quiet --enable=style,performance,portability --template=gcc FILE If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <[email protected]> cppcheck warnings: (new ones prefixed by >>) >> drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:342:14: warning: Local >> variable 'spti' shadows outer variable [shadowVariable] const u32 spti = pteb * sptn; ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:303:6: note: Shadowed declaration u32 spti = ptei & (sptn - 1), lpti, pteb; ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:342:14: note: Shadow variable const u32 spti = pteb * sptn; ^ >> drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:987:20: warning: Local >> variable 'vma' shadows outer variable [shadowVariable] struct nvkm_vma *vma = rb_entry(node, typeof(*vma), tree); ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:980:19: note: Shadowed declaration struct nvkm_vma *vma; ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:987:20: note: Shadow variable struct nvkm_vma *vma = rb_entry(node, typeof(*vma), tree); ^ cppcheck possible warnings: (new ones prefixed by >>, may not real problems) >> drivers/gpu/drm/mgag200/mgag200_pll.c:239:23: warning: Division by zero. >> [zerodiv] fvv = pllreffreq * n / m; ^ drivers/gpu/drm/mgag200/mgag200_pll.c:203:0: note: Assignment 'm=0', assigned value is 0 m = n = p = s = 0; ^ drivers/gpu/drm/mgag200/mgag200_pll.c:213:17: note: Assuming condition is false for (i = 0 ; i < ARRAY_SIZE(pvalues_e4); i++) { ^ drivers/gpu/drm/mgag200/mgag200_pll.c:239:23: note: Division by zero fvv = pllreffreq * n / m; ^ >> drivers/gpu/drm/nouveau/nvkm/engine/fifo/gv100.c:49:39: warning: Signed >> integer overflow for expression '128<<24'. [integerOverflow] nvkm_wo32(memory, offset + 0x0, (128 << 24) | (3 << 16) | 0x00000001); ^ -- >> drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1082:13: warning: Local >> variable 'size' shadows outer argument [shadowArgument] const u32 size = pd_header + desc->size * (1 << desc->bits); ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1035:51: note: Shadowed declaration u32 pd_header, bool managed, u64 addr, u64 size, ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1082:13: note: Shadow variable const u32 size = pd_header + desc->size * (1 << desc->bits); ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1240:7: warning: Local variable 'size' shadows outer argument [shadowArgument] u64 size = limit - start; ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1210:64: note: Shadowed declaration nvkm_vmm_pfn_map(struct nvkm_vmm *vmm, u8 shift, u64 addr, u64 size, u64 *pfn) ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1240:7: note: Shadow variable u64 size = limit - start; ^ >> drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1241:7: warning: Local >> variable 'addr' shadows outer argument [shadowArgument] u64 addr = start; ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1210:54: note: Shadowed declaration nvkm_vmm_pfn_map(struct nvkm_vmm *vmm, u8 shift, u64 addr, u64 size, u64 *pfn) ^ drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c:1241:7: note: Shadow variable u64 addr = start; ^ vim +239 drivers/gpu/drm/mgag200/mgag200_pll.c 2545ac960364d03 Thomas Zimmermann 2021-07-14 187 2545ac960364d03 Thomas Zimmermann 2021-07-14 188 static int mgag200_pixpll_compute_g200se_04(struct mgag200_pll *pixpll, long clock, 2545ac960364d03 Thomas Zimmermann 2021-07-14 189 struct mgag200_pll_values *pixpllc) 2545ac960364d03 Thomas Zimmermann 2021-07-14 190 { 2545ac960364d03 Thomas Zimmermann 2021-07-14 191 static const unsigned int vcomax = 1600000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 192 static const unsigned int vcomin = 800000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 193 static const unsigned int pllreffreq = 25000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 194 static const unsigned int pvalues_e4[] = {16, 14, 12, 10, 8, 6, 4, 2, 1}; 2545ac960364d03 Thomas Zimmermann 2021-07-14 195 2545ac960364d03 Thomas Zimmermann 2021-07-14 196 unsigned int delta, tmpdelta, permitteddelta; 2545ac960364d03 Thomas Zimmermann 2021-07-14 197 unsigned int testp, testm, testn; 2545ac960364d03 Thomas Zimmermann 2021-07-14 198 unsigned int p, m, n, s; 2545ac960364d03 Thomas Zimmermann 2021-07-14 199 unsigned int computed; 2545ac960364d03 Thomas Zimmermann 2021-07-14 200 unsigned int fvv; 2545ac960364d03 Thomas Zimmermann 2021-07-14 201 unsigned int i; 2545ac960364d03 Thomas Zimmermann 2021-07-14 202 2545ac960364d03 Thomas Zimmermann 2021-07-14 203 m = n = p = s = 0; 2545ac960364d03 Thomas Zimmermann 2021-07-14 204 delta = 0xffffffff; 2545ac960364d03 Thomas Zimmermann 2021-07-14 205 2545ac960364d03 Thomas Zimmermann 2021-07-14 206 if (clock < 25000) 2545ac960364d03 Thomas Zimmermann 2021-07-14 207 clock = 25000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 208 clock = clock * 2; 2545ac960364d03 Thomas Zimmermann 2021-07-14 209 2545ac960364d03 Thomas Zimmermann 2021-07-14 210 /* Permited delta is 0.5% as VESA Specification */ 2545ac960364d03 Thomas Zimmermann 2021-07-14 211 permitteddelta = clock * 5 / 1000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 212 2545ac960364d03 Thomas Zimmermann 2021-07-14 213 for (i = 0 ; i < ARRAY_SIZE(pvalues_e4); i++) { 2545ac960364d03 Thomas Zimmermann 2021-07-14 214 testp = pvalues_e4[i]; 2545ac960364d03 Thomas Zimmermann 2021-07-14 215 2545ac960364d03 Thomas Zimmermann 2021-07-14 216 if ((clock * testp) > vcomax) 2545ac960364d03 Thomas Zimmermann 2021-07-14 217 continue; 2545ac960364d03 Thomas Zimmermann 2021-07-14 218 if ((clock * testp) < vcomin) 2545ac960364d03 Thomas Zimmermann 2021-07-14 219 continue; 2545ac960364d03 Thomas Zimmermann 2021-07-14 220 2545ac960364d03 Thomas Zimmermann 2021-07-14 221 for (testn = 50; testn <= 256; testn++) { 2545ac960364d03 Thomas Zimmermann 2021-07-14 222 for (testm = 1; testm <= 32; testm++) { 2545ac960364d03 Thomas Zimmermann 2021-07-14 223 computed = (pllreffreq * testn) / (testm * testp); 2545ac960364d03 Thomas Zimmermann 2021-07-14 224 if (computed > clock) 2545ac960364d03 Thomas Zimmermann 2021-07-14 225 tmpdelta = computed - clock; 2545ac960364d03 Thomas Zimmermann 2021-07-14 226 else 2545ac960364d03 Thomas Zimmermann 2021-07-14 227 tmpdelta = clock - computed; 2545ac960364d03 Thomas Zimmermann 2021-07-14 228 2545ac960364d03 Thomas Zimmermann 2021-07-14 229 if (tmpdelta < delta) { 2545ac960364d03 Thomas Zimmermann 2021-07-14 230 delta = tmpdelta; 2545ac960364d03 Thomas Zimmermann 2021-07-14 231 m = testm; 2545ac960364d03 Thomas Zimmermann 2021-07-14 232 n = testn; 2545ac960364d03 Thomas Zimmermann 2021-07-14 233 p = testp; 2545ac960364d03 Thomas Zimmermann 2021-07-14 234 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 235 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 236 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 237 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 238 2545ac960364d03 Thomas Zimmermann 2021-07-14 @239 fvv = pllreffreq * n / m; 2545ac960364d03 Thomas Zimmermann 2021-07-14 240 fvv = (fvv - 800000) / 50000; 2545ac960364d03 Thomas Zimmermann 2021-07-14 241 if (fvv > 15) 2545ac960364d03 Thomas Zimmermann 2021-07-14 242 fvv = 15; 2545ac960364d03 Thomas Zimmermann 2021-07-14 243 s = fvv << 1; 2545ac960364d03 Thomas Zimmermann 2021-07-14 244 2545ac960364d03 Thomas Zimmermann 2021-07-14 245 if (delta > permitteddelta) { 2545ac960364d03 Thomas Zimmermann 2021-07-14 246 pr_warn("PLL delta too large\n"); 2545ac960364d03 Thomas Zimmermann 2021-07-14 247 return -EINVAL; 2545ac960364d03 Thomas Zimmermann 2021-07-14 248 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 249 2545ac960364d03 Thomas Zimmermann 2021-07-14 250 pixpllc->m = m; 2545ac960364d03 Thomas Zimmermann 2021-07-14 251 pixpllc->n = n; 2545ac960364d03 Thomas Zimmermann 2021-07-14 252 pixpllc->p = p; 2545ac960364d03 Thomas Zimmermann 2021-07-14 253 pixpllc->s = s; 2545ac960364d03 Thomas Zimmermann 2021-07-14 254 2545ac960364d03 Thomas Zimmermann 2021-07-14 255 return 0; 2545ac960364d03 Thomas Zimmermann 2021-07-14 256 } 2545ac960364d03 Thomas Zimmermann 2021-07-14 257 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
