drivers/clk/clk-versaclock3.c:404:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. (fwd)
PATCH 2742/4710 drivers/clk/clk-versaclock3.c:404:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead. (fwd)
---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710] drivers/clk/clk-versaclock3.c:404:2-8:
WARNING: do_div() does a 64-by-32 division,
please consider using div64_ul instead.
BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 0ba5d07205771c50789fd9063950aa75e7f1183f commit: 6e9aff555db7b6816076121ac3feebc3006de9ad [2742/4710] clk: Add support for versa3 clock driver
:::::: branch date: 19 hours ago
:::::: commit date: 7 days ago
config: sparc64-randconfig-r061-20230726 (https://download.01.org/0day-ci/archive/20230727/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230727/[email protected]/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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.
vim +404 drivers/clk/clk-versaclock3.c
6e9aff555db7b6 Biju Das 2023-07-05 382
6e9aff555db7b6 Biju Das 2023-07-05 383 static long vc3_pll_round_rate(struct clk_hw *hw, unsigned long rate,
6e9aff555db7b6 Biju Das 2023-07-05 384 unsigned long *parent_rate)
6e9aff555db7b6 Biju Das 2023-07-05 385 {
6e9aff555db7b6 Biju Das 2023-07-05 386 struct vc3_hw_data *vc3 = container_of(hw, struct vc3_hw_data, hw);
6e9aff555db7b6 Biju Das 2023-07-05 387 const struct vc3_pll_data *pll = vc3->data;
6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc;
6e9aff555db7b6 Biju Das 2023-07-05 389
6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min)
6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll->vco_min;
6e9aff555db7b6 Biju Das 2023-07-05 392 if (rate > pll->vco_max)
6e9aff555db7b6 Biju Das 2023-07-05 393 rate = pll->vco_max;
6e9aff555db7b6 Biju Das 2023-07-05 394
6e9aff555db7b6 Biju Das 2023-07-05 395 vc3->div_int = rate / *parent_rate;
6e9aff555db7b6 Biju Das 2023-07-05 396
6e9aff555db7b6 Biju Das 2023-07-05 397 if (pll->num == VC3_PLL2) {
6e9aff555db7b6 Biju Das 2023-07-05 398 if (vc3->div_int > 0x7ff)
6e9aff555db7b6 Biju Das 2023-07-05 399 rate = *parent_rate * 0x7ff;
6e9aff555db7b6 Biju Das 2023-07-05 400
6e9aff555db7b6 Biju Das 2023-07-05 401 /* Determine best fractional part, which is 16 bit wide */
6e9aff555db7b6 Biju Das 2023-07-05 402 div_frc = rate % *parent_rate;
6e9aff555db7b6 Biju Das 2023-07-05 403 div_frc *= BIT(16) - 1;
6e9aff555db7b6 Biju Das 2023-07-05 @404 do_div(div_frc, *parent_rate);
6e9aff555db7b6 Biju Das 2023-07-05 405
6e9aff555db7b6 Biju Das 2023-07-05 406 vc3->div_frc = (u32)div_frc;
6e9aff555db7b6 Biju Das 2023-07-05 407 rate = (*parent_rate *
6e9aff555db7b6 Biju Das 2023-07-05 408 (vc3->div_int * VC3_2_POW_16 + div_frc) / VC3_2_POW_16);
6e9aff555db7b6 Biju Das 2023-07-05 409 } else {
6e9aff555db7b6 Biju Das 2023-07-05 410 rate = *parent_rate * vc3->div_int;
6e9aff555db7b6 Biju Das 2023-07-05 411 }
6e9aff555db7b6 Biju Das 2023-07-05 412
6e9aff555db7b6 Biju Das 2023-07-05 413 return rate;
6e9aff555db7b6 Biju Das 2023-07-05 414 }
6e9aff555db7b6 Biju Das 2023-07-05 415Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi,
The reproduce link is not working for me.
https://download.01.org/0day-ci/archive/20230727/[email protected]/reproduce
Can you please provide instruction to reproduce this issue?
Cheers,
Biju
Quoted 21 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710]drivers/clk/clk-versaclock3.c:404:2-8:
WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>
Quoted 7 lines
tree:
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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes:
%2BsY49B78%3D&reserved=0
Quoted 56 lines
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider using
div64_ulinstead.vim +404
drivers/clk/clk-versaclock3.c
6e9aff555db7b6Biju Das 2023-07-05 3826e9aff555db7b6Biju Das 2023-07-05 383 static long vc3_pll_round_rate(structclk_hw*hw, unsigned long rate,6e9aff555db7b6Biju Das 2023-07-05 384 unsigned
long*parent_rate)6e9aff555db7b6 Biju Das 2023-07-05 385 { 6e9aff555db7b6 Biju Das 2023-07-05 386 struct vc3_hw_data *vc3 = container_of(hw, struct vc3_hw_data, hw); 6e9aff555db7b6 Biju Das 2023-07-05 387 const struct vc3_pll_data *pll = vc3->data; 6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc; 6e9aff555db7b6 Biju Das 2023-07-05 389 6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min) 6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll->vco_min; 6e9aff555db7b6 Biju Das 2023-07-05 392 if (rate > pll->vco_max) 6e9aff555db7b6 Biju Das 2023-07-05 393 rate = pll->vco_max; 6e9aff555db7b6 Biju Das 2023-07-05 394 6e9aff555db7b6 Biju Das 2023-07-05 395 vc3->div_int = rate / *parent_rate; 6e9aff555db7b6 Biju Das 2023-07-05 396 6e9aff555db7b6 Biju Das 2023-07-05 397 if (pll->num == VC3_PLL2) { 6e9aff555db7b6 Biju Das 2023-07-05 398 if (vc3->div_int > 0x7ff) 6e9aff555db7b6 Biju Das 2023-07-05 399 rate = *parent_rate*
0x7ff;6e9aff555db7b6Biju Das 2023-07-05 4006e9aff555db7b6Biju Das 2023-07-05 401 /* Determine best
fractional part, which is 16 bit wide */6e9aff555db7b6Biju Das 2023-07-05 402div_frc= rate %*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 403div_frc*= BIT(16) - 1;6e9aff555db7b6Biju Das 2023-07-05 @404 do_div(div_frc,*parent_rate);6e9aff555db7b6Biju Das 2023-07-05 4056e9aff555db7b6Biju Das 2023-07-05 406vc3->div_frc=
(u32)div_frc;6e9aff555db7b6 Biju Das 2023-07-05 407 rate = (*parent_rate * 6e9aff555db7b6 Biju Das 2023-07-05 408 (vc3->div_int * VC3_2_POW_16 + div_frc) / VC3_2_POW_16); 6e9aff555db7b6 Biju Das 2023-07-05 409 } else { 6e9aff555db7b6 Biju Das 2023-07-05 410 rate = *parent_rate * vc3->div_int; 6e9aff555db7b6 Biju Das 2023-07-05 411 } 6e9aff555db7b6 Biju Das 2023-07-05 412 6e9aff555db7b6 Biju Das 2023-07-05 413 return rate; 6e9aff555db7b6 Biju Das 2023-07-05 414 } 6e9aff555db7b6 Biju Das 2023-07-05 415--
0-DAY CI Kernel Test Service
Quoted 7 lines · Biju Das
Hi,
The reproduce link is not working for me.
https://download.01.org/0day-ci/archive/20230727/[email protected]/reproduce
Can you please provide instruction to reproduce this issue?
I don't think it's intended to be reproduced. The issue is just that a long value is being passed to an integer that is 32 bit. If the long value will never be very big, then you can just ignore the warning.
julia
Quoted 90 lines
Cheers,
BijuQuoted 21 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710]drivers/clk/clk-versaclock3.c:404:2-8:
WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>Quoted 7 lines
tree:
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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes:%2BsY49B78%3D&reserved=0
Quoted 56 lines
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider using
div64_ulinstead.vim +404
drivers/clk/clk-versaclock3.c
6e9aff555db7b6Biju Das 2023-07-05 3826e9aff555db7b6Biju Das 2023-07-05 383 static long vc3_pll_round_rate(structclk_hw*hw, unsigned long rate,6e9aff555db7b6Biju Das 2023-07-05 384 unsigned
long*parent_rate)6e9aff555db7b6 Biju Das 2023-07-05 385 { 6e9aff555db7b6 Biju Das 2023-07-05 386 struct vc3_hw_data *vc3 = container_of(hw, struct vc3_hw_data, hw); 6e9aff555db7b6 Biju Das 2023-07-05 387 const struct vc3_pll_data *pll = vc3->data; 6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc; 6e9aff555db7b6 Biju Das 2023-07-05 389 6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min) 6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll->vco_min; 6e9aff555db7b6 Biju Das 2023-07-05 392 if (rate > pll->vco_max) 6e9aff555db7b6 Biju Das 2023-07-05 393 rate = pll->vco_max; 6e9aff555db7b6 Biju Das 2023-07-05 394 6e9aff555db7b6 Biju Das 2023-07-05 395 vc3->div_int = rate / *parent_rate; 6e9aff555db7b6 Biju Das 2023-07-05 396 6e9aff555db7b6 Biju Das 2023-07-05 397 if (pll->num == VC3_PLL2) { 6e9aff555db7b6 Biju Das 2023-07-05 398 if (vc3->div_int > 0x7ff) 6e9aff555db7b6 Biju Das 2023-07-05 399 rate = *parent_rate*
0x7ff;6e9aff555db7b6Biju Das 2023-07-05 4006e9aff555db7b6Biju Das 2023-07-05 401 /* Determine best
fractional part, which is 16 bit wide */6e9aff555db7b6Biju Das 2023-07-05 402div_frc= rate %*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 403div_frc*= BIT(16) - 1;6e9aff555db7b6Biju Das 2023-07-05 @404 do_div(div_frc,*parent_rate);6e9aff555db7b6Biju Das 2023-07-05 4056e9aff555db7b6Biju Das 2023-07-05 406vc3->div_frc=
(u32)div_frc;6e9aff555db7b6 Biju Das 2023-07-05 407 rate = (*parent_rate * 6e9aff555db7b6 Biju Das 2023-07-05 408 (vc3->div_int * VC3_2_POW_16 + div_frc) / VC3_2_POW_16); 6e9aff555db7b6 Biju Das 2023-07-05 409 } else { 6e9aff555db7b6 Biju Das 2023-07-05 410 rate = *parent_rate * vc3->div_int; 6e9aff555db7b6 Biju Das 2023-07-05 411 } 6e9aff555db7b6 Biju Das 2023-07-05 412 6e9aff555db7b6 Biju Das 2023-07-05 413 return rate; 6e9aff555db7b6 Biju Das 2023-07-05 414 } 6e9aff555db7b6 Biju Das 2023-07-05 415--
0-DAY CI Kernel Test Service
Hi Julia,
Quoted 9 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)Quoted 2 lines · Biju Das
Hi,
Quoted 8 lines
Quoted 4 lines
The reproduce link is not working for me.
Can you please provide instruction to reproduce this issue?
I don't think it's intended to be reproduced. The issue is just that a long value is being passed to an integer that is 32 bit. If the long value will never be very big, then you can just ignore the warning.
The rate values are well below max 32 bit, 4294967296. So I guess, it is ok.
xtal 0 0 0 24000000 0 0 50000 Y
ref 0 0 0 24000000 0 0 50000 Y
pfd1 0 0 0 24000000 0 0 50000 Y
pll1 0 0 0 600000000 0 0 50000 Y
div2 0 0 0 12000000 0 0 50000 Y
se3_mux 0 0 0 12000000 0 0 50000 Y
se3 0 0 0 12000000 0 0 50000 Y
div1_mux 0 0 0 600000000 0 0 50000 Y
div1 0 0 0 25000000 0 0 50000 Y
diff1_mux 0 0 0 25000000 0 0 50000 Y
diff1 0 0 0 25000000 0 0 50000 Y
pfd3_mux 0 0 0 24000000 0 0 50000 Y
pfd3 0 0 0 960000 0 0 50000 Y
pll3 0 0 0 564480000 0 0 50000 Y
div5 0 0 0 11289600 0 0 50000 Y
se1_mux 0 0 0 11289600 0 0 50000 Y
se1 0 0 0 11289600 0 0 50000 Y
se2_mux 0 0 0 11289600 0 0 50000 Y
se2 0 0 0 11289600 0 0 50000 Y
pfd2_mux 0 0 0 24000000 0 0 50000 Y
pfd2 0 0 0 24000000 0 0 50000 Y
pll2 0 0 0 491519897 0 0 50000 Y
div4_mux 0 0 0 491519897 0 0 50000 Y
div4 0 0 0 12287998 0 0 50000 Y
div3_mux 0 0 0 491519897 0 0 50000 Y
div3 0 0 0 12287998 0 0 50000 Y
diff2_mux 0 0 0 12287998 0 0 50000 Y
diff2 0 0 0 12287998 0 0 50000 YCheers,
Biju
Quoted 97 lines
Quoted 22 lines
Quoted 22 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710]drivers/clk/clk-versaclock3.c:404:2-8:
WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>Quoted 20 lines
Quoted 7 lines
tree:
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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes:%2BsY49B78%3D&reserved=0
Quoted 12 lines
cocci warnings: (new ones prefixed by >>)
Quoted 2 lines
Quoted 2 lines
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider using
div64_ulinstead.vim +404
drivers/clk/clk-versaclock3.c
6e9aff555db7b6Biju Das 2023-07-05 3826e9aff555db7b6Biju Das 2023-07-05 383 static long vc3_pll_round_rate(structclk_hw*hw, unsigned long rate,6e9aff555db7b6Biju Das 2023-07-05 384unsigned
Quoted 5 lines
Quoted 5 lines
long
*parent_rate)6e9aff555db7b6 Biju Das 2023-07-05 385 { 6e9aff555db7b6 Biju Das 2023-07-05 386 struct vc3_hw_data *vc3 =
container_of(hw, struct vc3_hw_data, hw);6e9aff555db7b6Biju Das 2023-07-05 387 const structvc3_pll_data*pll
Quoted 4 lines
Quoted 4 lines
=
vc3->data;6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc; 6e9aff555db7b6 Biju Das 2023-07-05 389 6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min)Quoted 8 lines
Quoted 8 lines
6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll->vco_min; 6e9aff555db7b6 Biju Das 2023-07-05 392 if (rate > pll->vco_max) 6e9aff555db7b6 Biju Das 2023-07-05 393 rate = pll->vco_max; 6e9aff555db7b6 Biju Das 2023-07-05 394 6e9aff555db7b6 Biju Das 2023-07-05 395 vc3->div_int = rate /
*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 3966e9aff555db7b6Biju Das 2023-07-05 397 if (pll->num==VC3_PLL2){
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 398 if (vc3->div_int>
0x7ff)Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 399 rate =
*parent_rateQuoted 7 lines
Quoted 7 lines
*
0x7ff;6e9aff555db7b6Biju Das 2023-07-05 4006e9aff555db7b6Biju Das 2023-07-05 401 /* Determine best
fractional part, which is 16 bit wide */6e9aff555db7b6Biju Das 2023-07-05 402div_frc= rate %*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 403div_frc*= BIT(16) -1;
Quoted 6 lines
Quoted 6 lines
6e9aff555db7b6Biju Das 2023-07-05 @404 do_div(div_frc,*parent_rate);6e9aff555db7b6Biju Das 2023-07-05 4056e9aff555db7b6Biju Das 2023-07-05 406vc3->div_frc=
(u32)div_frc;6e9aff555db7b6Biju Das 2023-07-05 407 rate = (*parent_rate*
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 408 (vc3->div_int*
Quoted 3 lines
Quoted 3 lines
VC3_2_POW_16+div_frc) /VC3_2_POW_16);6e9aff555db7b6 Biju Das 2023-07-05 409 } else { 6e9aff555db7b6 Biju Das 2023-07-05 410 rate = *parent_rate*
Quoted 10 lines
Quoted 9 lines
vc3->div_int;6e9aff555db7b6 Biju Das 2023-07-05 411 } 6e9aff555db7b6 Biju Das 2023-07-05 412 6e9aff555db7b6 Biju Das 2023-07-05 413 return rate; 6e9aff555db7b6 Biju Das 2023-07-05 414 } 6e9aff555db7b6 Biju Das 2023-07-05 415--
0-DAY CI Kernel Test Service
Hi Biju,
Quoted 6 lines · Biju Das
Quoted 6 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)Quoted 2 lines · Biju Das
The reproduce link is not working for me.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Can you please provide instruction to reproduce this issue?
I don't think it's intended to be reproduced. The issue is just that a long value is being passed to an integer that is 32 bit. If the long value will never be very big, then you can just ignore the warning.
The rate values are well below max 32 bit, 4294967296. So I guess, it is ok.
The type of the parent_rate in/output parameter of clk_ops.round_rate() is unsigned long. Hence you should use div64_ul().
Quoted 96 lines
Quoted 96 lines
Quoted 21 lines
Quoted 21 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710]drivers/clk/clk-versaclock3.c:404:2-8:
WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>Quoted 20 lines
Quoted 7 lines
tree:
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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes:%2BsY49B78%3D&reserved=0
Quoted 12 lines
cocci warnings: (new ones prefixed by >>)
Quoted 2 lines
Quoted 2 lines
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider using
div64_ulinstead.vim +404
drivers/clk/clk-versaclock3.c
6e9aff555db7b6Biju Das 2023-07-05 3826e9aff555db7b6Biju Das 2023-07-05 383 static long vc3_pll_round_rate(structclk_hw*hw, unsigned long rate,6e9aff555db7b6Biju Das 2023-07-05 384unsigned
Quoted 5 lines
Quoted 5 lines
long
*parent_rate)6e9aff555db7b6Biju Das 2023-07-05 385 {6e9aff555db7b6Biju Das 2023-07-05 386 structvc3_hw_data*vc3 =container_of(hw, struct vc3_hw_data, hw);6e9aff555db7b6Biju Das 2023-07-05 387 const structvc3_pll_data*pll
Quoted 4 lines
Quoted 4 lines
=
vc3->data;6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc; 6e9aff555db7b6 Biju Das 2023-07-05 389 6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min)Quoted 8 lines
Quoted 8 lines
6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll->vco_min; 6e9aff555db7b6 Biju Das 2023-07-05 392 if (rate > pll->vco_max) 6e9aff555db7b6 Biju Das 2023-07-05 393 rate = pll->vco_max; 6e9aff555db7b6 Biju Das 2023-07-05 394 6e9aff555db7b6 Biju Das 2023-07-05 395 vc3->div_int = rate /
*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 3966e9aff555db7b6Biju Das 2023-07-05 397 if (pll->num==VC3_PLL2){
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 398 if (vc3->div_int>
0x7ff)Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 399 rate =
*parent_rateQuoted 7 lines
Quoted 7 lines
*
0x7ff;6e9aff555db7b6Biju Das 2023-07-05 4006e9aff555db7b6Biju Das 2023-07-05 401 /* Determine best
fractional part, which is 16 bit wide */6e9aff555db7b6Biju Das 2023-07-05 402div_frc= rate %*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 403div_frc*= BIT(16) -1;
Quoted 6 lines
Quoted 6 lines
6e9aff555db7b6Biju Das 2023-07-05 @404 do_div(div_frc,*parent_rate);6e9aff555db7b6Biju Das 2023-07-05 4056e9aff555db7b6Biju Das 2023-07-05 406vc3->div_frc=
(u32)div_frc;6e9aff555db7b6Biju Das 2023-07-05 407 rate = (*parent_rate*
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 408 (vc3->div_int*
Quoted 3 lines
Quoted 3 lines
VC3_2_POW_16+div_frc) /VC3_2_POW_16);6e9aff555db7b6Biju Das 2023-07-05 409 } else {6e9aff555db7b6Biju Das 2023-07-05 410 rate =*parent_rate*
Quoted 10 lines
Quoted 9 lines
vc3->div_int;6e9aff555db7b6 Biju Das 2023-07-05 411 } 6e9aff555db7b6 Biju Das 2023-07-05 412 6e9aff555db7b6 Biju Das 2023-07-05 413 return rate; 6e9aff555db7b6 Biju Das 2023-07-05 414 } 6e9aff555db7b6 Biju Das 2023-07-05 415--
0-DAY CI Kernel Test Service
Signature · 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsHi Geert,
Thanks for the feedback.
Quoted 19 lines
Subject: Re: [linux-next:master 2742/4710]
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)Hi Biju,
Quoted 11 lines · Biju Das
Quoted 11 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)Quoted 3 lines · Biju Das
The reproduce link is not working for me.
Can you please provide instruction to reproduce this issue?
I don't think it's intended to be reproduced. The issue is just that a long value is being passed to an integer that is 32 bit. If the long value will never be very big, then you can just ignore the
Quoted 7 lines
warning.
Quoted 2 lines
The rate values are well below max 32 bit, 4294967296. So I guess, it is
ok.
The type of the
parent_ratein/output parameter ofclk_ops.round_rate()is unsigned long. Hence you should usediv64_ul().
Agreed. Will send a patch to fix this issue.
Cheers,
Biju
Quoted 124 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 21 lines
versaclock3.c:404:2-8: WARNING:
do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead. (fwd)---------- Forwarded message ----------
Date: Thu, 27 Jul 2023 08:50:37 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [linux-next:master 2742/4710]drivers/clk/clk-versaclock3.c:404:2-8:
WARNING:do_div()does a 64-by-32 division, please consider usingdiv64_ulinstead.BCC: [email protected]
CC: [email protected]
CC: Linux Memory Management List <[email protected]>
TO: Biju Das <[email protected]>
CC: Stephen Boyd <[email protected]>Quoted 7 lines
tree:
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 <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes:%2BsY49B78%3D&reserved=0
Quoted 9 lines
cocci warnings: (new ones prefixed by >>)
Quoted 3 lines
Quoted 3 lines
drivers/clk/clk-versaclock3.c:404:2-8: WARNING:
do_div()does a
64-by-32 division, please consider using
div64_ulinstead.vim +404
drivers/clk/clk-versaclock3.cQuoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
6e9aff555db7b6Biju Das 2023-07-05 3826e9aff555db7b6Biju Das 2023-07-05 383 static long vc3_pll_round_rate(structclk_hw*hw, unsigned long rate,6e9aff555db7b6Biju Das 2023-07-05 384unsigned
Quoted 3 lines
Quoted 3 lines
long
*parent_rate)6e9aff555db7b6Biju Das 2023-07-05 385 {6e9aff555db7b6Biju Das 2023-07-05 386 structvc3_hw_data*vc3=
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
container_of(hw, struct vc3_hw_data, hw);6e9aff555db7b6Biju Das 2023-07-05 387 const struct
vc3_pll_dataQuoted 6 lines
Quoted 6 lines
*pll
Quoted 5 lines
Quoted 5 lines
=
vc3->data;6e9aff555db7b6 Biju Das 2023-07-05 388 u64 div_frc; 6e9aff555db7b6 Biju Das 2023-07-05 389 6e9aff555db7b6 Biju Das 2023-07-05 390 if (rate < pll->vco_min) 6e9aff555db7b6 Biju Das 2023-07-05 391 rate = pll-Quoted 9 lines
vco_min;Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
6e9aff555db7b6Biju Das 2023-07-05 392 if (rate >pll->vco_max)6e9aff555db7b6Biju Das 2023-07-05 393 rate = pll-
vco_max;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
6e9aff555db7b6Biju Das 2023-07-05 3946e9aff555db7b6Biju Das 2023-07-05 395vc3->div_int= rate /*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 3966e9aff555db7b6Biju Das 2023-07-05 397 if (pll->num==
VC3_PLL2)Quoted 9 lines
Quoted 9 lines
{
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 398 if (vc3->div_int
0x7ff)Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 399 rate =
*parent_rateQuoted 3 lines
Quoted 3 lines
*
0x7ff;6e9aff555db7b6Biju Das 2023-07-05 4006e9aff555db7b6Biju Das 2023-07-05 401 /* Determinebest
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
fractional part, which is 16 bit wide */
6e9aff555db7b6Biju Das 2023-07-05 402div_frc= rate %*parent_rate;6e9aff555db7b6Biju Das 2023-07-05 403div_frc*=BIT(16) -
Quoted 7 lines
Quoted 7 lines
1;
Quoted 6 lines
Quoted 6 lines
6e9aff555db7b6Biju Das 2023-07-05 @404 do_div(div_frc,*parent_rate);6e9aff555db7b6Biju Das 2023-07-05 4056e9aff555db7b6Biju Das 2023-07-05 406vc3->div_frc=
(u32)div_frc;6e9aff555db7b6Biju Das 2023-07-05 407 rate =(
*parent_rateQuoted 7 lines
Quoted 2 lines
*
Quoted 1 line
Quoted 1 line
6e9aff555db7b6Biju Das 2023-07-05 408 (vc3-
div_intQuoted 4 lines
*
Quoted 3 lines
Quoted 3 lines
VC3_2_POW_16+div_frc) /VC3_2_POW_16);6e9aff555db7b6Biju Das 2023-07-05 409 } else {6e9aff555db7b6Biju Das 2023-07-05 410 rate =
*parent_rateQuoted 11 lines
Quoted 11 lines
*
Quoted 10 lines
Quoted 9 lines
vc3->div_int;6e9aff555db7b6 Biju Das 2023-07-05 411 } 6e9aff555db7b6 Biju Das 2023-07-05 412 6e9aff555db7b6 Biju Das 2023-07-05 413 return rate; 6e9aff555db7b6 Biju Das 2023-07-05 414 } 6e9aff555db7b6 Biju Das 2023-07-05 415--
0-DAY CI Kernel Test Service--
Gr{oetje,eeting}s,Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux- m68k.orgIn personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds