From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/clk/at91/clk-master.c:197:7: warning: Division by zero [clang-analyzer-core.DivideZero]
Date: Sun, 28 Nov 2021 07:41:48 +0800 [thread overview]
Message-ID: <202111280723.1QYfzt93-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 17217 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Claudiu Beznea <claudiu.beznea@microchip.com>
CC: Stephen Boyd <sboyd@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4f0dda359c4563cbb1b0f97b0dbbcdc553156541
commit: 7029db09b2025f863f191b3d5b1d7859a5e26a8d clk: at91: clk-master: add notifier for divider
date: 5 weeks ago
:::::: branch date: 3 hours ago
:::::: commit date: 5 weeks ago
config: arm-randconfig-c002-20211114 (https://download.01.org/0day-ci/archive/20211128/202111280723.1QYfzt93-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c3dddeeafb529e769cde87bd29ef6271ac6bfa5c)
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 arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7029db09b2025f863f191b3d5b1d7859a5e26a8d
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 7029db09b2025f863f191b3d5b1d7859a5e26a8d
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
drivers/pinctrl/stm32/pinctrl-stm32.c:1465:7: note: Assuming the condition is false
if (hwlock_id == -EPROBE_DEFER)
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1465:3: note: Taking false branch
if (hwlock_id == -EPROBE_DEFER)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1471:2: note: Loop condition is false. Exiting loop
spin_lock_init(&pctl->irqmux_lock);
^
include/linux/spinlock.h:353:34: note: expanded from macro 'spin_lock_init'
# define spin_lock_init(_lock) \
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1481:6: note: Assuming field 'pins' is non-null
if (!pctl->pins)
^~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1481:2: note: Taking false branch
if (!pctl->pins)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1485:6: note: 'ret' is 0
if (ret)
^~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1485:2: note: Taking false branch
if (ret)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1489:6: note: Assuming 'ret' is 0
if (ret) {
^~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1489:2: note: Taking false branch
if (ret) {
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1494:6: note: Assuming field 'domain' is non-null
if (pctl->domain) {
^~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1494:2: note: Taking true branch
if (pctl->domain) {
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1495:9: note: Calling 'stm32_pctrl_dt_setup_irq'
ret = stm32_pctrl_dt_setup_irq(pdev, pctl);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1333:6: note: Calling 'IS_ERR'
if (IS_ERR(pctl->regmap))
^~~~~~~~~~~~~~~~~~~~
include/linux/err.h:36:9: note: Assuming the condition is false
return IS_ERR_VALUE((unsigned long)ptr);
^
include/linux/err.h:22:34: note: expanded from macro 'IS_ERR_VALUE'
#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
return IS_ERR_VALUE((unsigned long)ptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1333:6: note: Returning from 'IS_ERR'
if (IS_ERR(pctl->regmap))
^~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1333:2: note: Taking false branch
if (IS_ERR(pctl->regmap))
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1339:6: note: Assuming 'ret' is 0
if (ret)
^~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1339:2: note: Taking false branch
if (ret)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1343:6: note: Assuming 'ret' is 0
if (ret)
^~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1343:2: note: Taking false branch
if (ret)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1348:2: note: Loop condition is true. Entering loop body
for (i = 0; i < STM32_GPIO_PINS_PER_BANK; i++) {
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1349:3: note: 'mux' initialized here
struct reg_field mux;
^~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/stm32/pinctrl-stm32.c:1355:3: note: Loop condition is false. Exiting loop
dev_dbg(dev, "irqmux%d: reg:%#x, lsb:%d, msb:%d\n",
^
include/linux/dev_printk.h:158:2: note: expanded from macro 'dev_dbg'
dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
^
include/linux/dev_printk.h:128:3: note: expanded from macro 'dev_printk'
dev_printk_index_emit(level, fmt); \
^
include/linux/dev_printk.h:105:2: note: expanded from macro 'dev_printk_index_emit'
printk_index_subsys_emit("%s %s: ", level, fmt)
^
include/linux/printk.h:413:2: note: expanded from macro 'printk_index_subsys_emit'
__printk_index_emit(fmt, level, subsys_fmt_prefix)
^
include/linux/printk.h:392:34: note: expanded from macro '__printk_index_emit'
#define __printk_index_emit(...) do {} while (0)
^
drivers/pinctrl/stm32/pinctrl-stm32.c:1358:21: note: Passed-by-value struct argument contains uninitialized data (e.g., field: 'id_size')
pctl->irqmux[i] = devm_regmap_field_alloc(dev, rm, mux);
^ ~~~
1 warning generated.
>> drivers/clk/at91/clk-master.c:197:7: warning: Division by zero [clang-analyzer-core.DivideZero]
rate /= characteristics->divisors[div_index];
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:278:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:8: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/irqflags.h:237:36: note: expanded from macro 'local_irq_save'
#define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
^
include/linux/irqflags.h:169:2: note: expanded from macro 'raw_local_irq_save'
do { \
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:278:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:8: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/irqflags.h:237:31: note: expanded from macro 'local_irq_save'
#define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:278:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:31: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/spinlock_api_up.h:31:27: note: expanded from macro '__LOCK'
do { preempt_disable(); ___LOCK(lock); } while (0)
^
include/linux/spinlock_api_up.h:28:3: note: expanded from macro '___LOCK'
do { __acquire(lock); (void)(lock); } while (0)
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:278:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:31: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/spinlock_api_up.h:31:3: note: expanded from macro '__LOCK'
do { preempt_disable(); ___LOCK(lock); } while (0)
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:278:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:3: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
drivers/clk/at91/clk-master.c:260:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(master_div->lock, flags);
^
include/linux/spinlock.h:393:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
vim +197 drivers/clk/at91/clk-master.c
7a110b9107ed8f Claudiu Beznea 2020-11-19 160
7029db09b2025f Claudiu Beznea 2021-10-11 161 /* This function must be called with lock acquired. */
7029db09b2025f Claudiu Beznea 2021-10-11 162 static int clk_master_div_set(struct clk_master *master,
7029db09b2025f Claudiu Beznea 2021-10-11 163 unsigned long parent_rate, int div)
7a110b9107ed8f Claudiu Beznea 2020-11-19 164 {
7a110b9107ed8f Claudiu Beznea 2020-11-19 165 const struct clk_master_characteristics *characteristics =
7a110b9107ed8f Claudiu Beznea 2020-11-19 166 master->characteristics;
7029db09b2025f Claudiu Beznea 2021-10-11 167 unsigned long rate = parent_rate;
7029db09b2025f Claudiu Beznea 2021-10-11 168 unsigned int max_div = 0, div_index = 0, max_div_index = 0;
7029db09b2025f Claudiu Beznea 2021-10-11 169 unsigned int i, mckr, tmp;
36971566ea7a51 Claudiu Beznea 2021-10-11 170 int ret;
7a110b9107ed8f Claudiu Beznea 2020-11-19 171
7a110b9107ed8f Claudiu Beznea 2020-11-19 172 for (i = 0; i < ARRAY_SIZE(characteristics->divisors); i++) {
7a110b9107ed8f Claudiu Beznea 2020-11-19 173 if (!characteristics->divisors[i])
7a110b9107ed8f Claudiu Beznea 2020-11-19 174 break;
7a110b9107ed8f Claudiu Beznea 2020-11-19 175
7029db09b2025f Claudiu Beznea 2021-10-11 176 if (div == characteristics->divisors[i])
7029db09b2025f Claudiu Beznea 2021-10-11 177 div_index = i;
7029db09b2025f Claudiu Beznea 2021-10-11 178
7029db09b2025f Claudiu Beznea 2021-10-11 179 if (max_div < characteristics->divisors[i]) {
7029db09b2025f Claudiu Beznea 2021-10-11 180 max_div = characteristics->divisors[i];
7029db09b2025f Claudiu Beznea 2021-10-11 181 max_div_index = i;
7a110b9107ed8f Claudiu Beznea 2020-11-19 182 }
7a110b9107ed8f Claudiu Beznea 2020-11-19 183 }
7a110b9107ed8f Claudiu Beznea 2020-11-19 184
7029db09b2025f Claudiu Beznea 2021-10-11 185 if (div > max_div)
7029db09b2025f Claudiu Beznea 2021-10-11 186 div_index = max_div_index;
7a110b9107ed8f Claudiu Beznea 2020-11-19 187
36971566ea7a51 Claudiu Beznea 2021-10-11 188 ret = regmap_read(master->regmap, master->layout->offset, &mckr);
36971566ea7a51 Claudiu Beznea 2021-10-11 189 if (ret)
7029db09b2025f Claudiu Beznea 2021-10-11 190 return ret;
36971566ea7a51 Claudiu Beznea 2021-10-11 191
a27748adeacab6 Claudiu Beznea 2021-10-11 192 mckr &= master->layout->mask;
a27748adeacab6 Claudiu Beznea 2021-10-11 193 tmp = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK;
7029db09b2025f Claudiu Beznea 2021-10-11 194 if (tmp == div_index)
7029db09b2025f Claudiu Beznea 2021-10-11 195 return 0;
7029db09b2025f Claudiu Beznea 2021-10-11 196
7029db09b2025f Claudiu Beznea 2021-10-11 @197 rate /= characteristics->divisors[div_index];
7029db09b2025f Claudiu Beznea 2021-10-11 198 if (rate < characteristics->output.min)
7029db09b2025f Claudiu Beznea 2021-10-11 199 pr_warn("master clk div is underclocked");
7029db09b2025f Claudiu Beznea 2021-10-11 200 else if (rate > characteristics->output.max)
7029db09b2025f Claudiu Beznea 2021-10-11 201 pr_warn("master clk div is overclocked");
36971566ea7a51 Claudiu Beznea 2021-10-11 202
36971566ea7a51 Claudiu Beznea 2021-10-11 203 mckr &= ~(MASTER_DIV_MASK << MASTER_DIV_SHIFT);
7029db09b2025f Claudiu Beznea 2021-10-11 204 mckr |= (div_index << MASTER_DIV_SHIFT);
36971566ea7a51 Claudiu Beznea 2021-10-11 205 ret = regmap_write(master->regmap, master->layout->offset, mckr);
36971566ea7a51 Claudiu Beznea 2021-10-11 206 if (ret)
7029db09b2025f Claudiu Beznea 2021-10-11 207 return ret;
36971566ea7a51 Claudiu Beznea 2021-10-11 208
7a110b9107ed8f Claudiu Beznea 2020-11-19 209 while (!clk_master_ready(master))
7a110b9107ed8f Claudiu Beznea 2020-11-19 210 cpu_relax();
7029db09b2025f Claudiu Beznea 2021-10-11 211
7029db09b2025f Claudiu Beznea 2021-10-11 212 master->div = characteristics->divisors[div_index];
7a110b9107ed8f Claudiu Beznea 2020-11-19 213
7a110b9107ed8f Claudiu Beznea 2020-11-19 214 return 0;
7a110b9107ed8f Claudiu Beznea 2020-11-19 215 }
7a110b9107ed8f Claudiu Beznea 2020-11-19 216
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
next reply other threads:[~2021-11-27 23:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 23:41 kernel test robot [this message]
2022-05-25 2:41 drivers/clk/at91/clk-master.c:197:7: warning: Division by zero [clang-analyzer-core.DivideZero] kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202111280723.1QYfzt93-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.