From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, warp5tw@gmail.com,
tali.perry@nuvoton.com, Avi.Fishman@nuvoton.com,
tomer.maimon@nuvoton.com, avifishman70@gmail.com,
tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com,
yuenn@google.com, benjaminfair@google.com, andi.shyti@kernel.org,
wsa+renesas@sang-engineering.com, rand.sec96@gmail.com,
kwliu@nuvoton.com, jjliu0@nuvoton.com, kfting@nuvoton.com
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
openbmc@lists.ozlabs.org
Subject: Re: [PATCH v1 5/7] drivers: i2c: use i2c frequency table
Date: Tue, 13 Aug 2024 10:58:24 +0300 [thread overview]
Message-ID: <d512d659-0891-4219-bc8c-bf272755e3d2@stanley.mountain> (raw)
In-Reply-To: <20240807100244.16872-6-kfting@nuvoton.com>
Hi,
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/warp5tw-gmail-com/i2c-npcm-correct-the-read-write-operation-procedure/20240807-182210
base: https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git i2c/i2c-host
patch link: https://lore.kernel.org/r/20240807100244.16872-6-kfting%40nuvoton.com
patch subject: [PATCH v1 5/7] drivers: i2c: use i2c frequency table
config: arm-randconfig-r073-20240812 (https://download.01.org/0day-ci/archive/20240813/202408130818.FgDP5uNm-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project f86594788ce93b696675c94f54016d27a6c21d18)
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 <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202408130818.FgDP5uNm-lkp@intel.com/
New smatch warnings:
drivers/i2c/busses/i2c-npcm7xx.c:1956 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 21 <= 21 (assuming for loop doesn't break)
drivers/i2c/busses/i2c-npcm7xx.c:1973 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 17 <= 21
Old smatch warnings:
drivers/i2c/busses/i2c-npcm7xx.c:752 npcm_i2c_slave_enable() error: buffer overflow 'npcm_i2caddr' 2 <= 9
drivers/i2c/busses/i2c-npcm7xx.c:1960 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 21 <= 21 (assuming for loop doesn't break)
drivers/i2c/busses/i2c-npcm7xx.c:1974 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 17 <= 21
drivers/i2c/busses/i2c-npcm7xx.c:1976 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 17 <= 21
drivers/i2c/busses/i2c-npcm7xx.c:1979 npcm_i2c_init_clk() error: buffer overflow 'smb_timing' 21 <= 21 (assuming for loop doesn't break)
vim +1956 drivers/i2c/busses/i2c-npcm7xx.c
56a1485b102ed1 Tali Perry 2020-05-27 1919 static int npcm_i2c_init_clk(struct npcm_i2c *bus, u32 bus_freq_hz)
56a1485b102ed1 Tali Perry 2020-05-27 1920 {
a946fe9698f261 Tyrone Ting 2024-08-07 1921 struct SMB_TIMING_T *smb_timing;
a946fe9698f261 Tyrone Ting 2024-08-07 1922 u8 scl_table_cnt = 0, table_size = 0;
a946fe9698f261 Tyrone Ting 2024-08-07 1923
56a1485b102ed1 Tali Perry 2020-05-27 1924 u8 fast_mode = 0;
56a1485b102ed1 Tali Perry 2020-05-27 1925 u32 src_clk_khz;
56a1485b102ed1 Tali Perry 2020-05-27 1926 u32 bus_freq_khz;
56a1485b102ed1 Tali Perry 2020-05-27 1927
56a1485b102ed1 Tali Perry 2020-05-27 1928 src_clk_khz = bus->apb_clk / 1000;
56a1485b102ed1 Tali Perry 2020-05-27 1929 bus_freq_khz = bus_freq_hz / 1000;
56a1485b102ed1 Tali Perry 2020-05-27 1930 bus->bus_freq = bus_freq_hz;
56a1485b102ed1 Tali Perry 2020-05-27 1931
a946fe9698f261 Tyrone Ting 2024-08-07 1932 switch (bus_freq_hz) {
a946fe9698f261 Tyrone Ting 2024-08-07 1933 case I2C_MAX_STANDARD_MODE_FREQ:
a946fe9698f261 Tyrone Ting 2024-08-07 1934 smb_timing = SMB_TIMING_100KHZ;
a946fe9698f261 Tyrone Ting 2024-08-07 1935 table_size = ARRAY_SIZE(SMB_TIMING_100KHZ);
a946fe9698f261 Tyrone Ting 2024-08-07 1936 break;
a946fe9698f261 Tyrone Ting 2024-08-07 1937 case I2C_MAX_FAST_MODE_FREQ:
a946fe9698f261 Tyrone Ting 2024-08-07 1938 smb_timing = SMB_TIMING_400KHZ;
a946fe9698f261 Tyrone Ting 2024-08-07 1939 table_size = ARRAY_SIZE(SMB_TIMING_400KHZ);
56a1485b102ed1 Tali Perry 2020-05-27 1940 fast_mode = I2CCTL3_400K_MODE;
a946fe9698f261 Tyrone Ting 2024-08-07 1941 break;
a946fe9698f261 Tyrone Ting 2024-08-07 1942 case I2C_MAX_FAST_MODE_PLUS_FREQ:
a946fe9698f261 Tyrone Ting 2024-08-07 1943 smb_timing = SMB_TIMING_1000KHZ;
a946fe9698f261 Tyrone Ting 2024-08-07 1944 table_size = ARRAY_SIZE(SMB_TIMING_1000KHZ);
56a1485b102ed1 Tali Perry 2020-05-27 1945 fast_mode = I2CCTL3_400K_MODE;
a946fe9698f261 Tyrone Ting 2024-08-07 1946 break;
a946fe9698f261 Tyrone Ting 2024-08-07 1947 default:
56a1485b102ed1 Tali Perry 2020-05-27 1948 return -EINVAL;
56a1485b102ed1 Tali Perry 2020-05-27 1949 }
56a1485b102ed1 Tali Perry 2020-05-27 1950
a946fe9698f261 Tyrone Ting 2024-08-07 1951 for (scl_table_cnt = 0 ; scl_table_cnt < table_size ; scl_table_cnt++)
a946fe9698f261 Tyrone Ting 2024-08-07 1952 if (bus->apb_clk >= smb_timing[scl_table_cnt].core_clk)
a946fe9698f261 Tyrone Ting 2024-08-07 1953 break;
The minimum smb_timing[scl_table_cnt].core_clk value is 10000000 or 20000000 so
I can't tell just from the context that we are always going to hit this break
statement.
a946fe9698f261 Tyrone Ting 2024-08-07 1954
56a1485b102ed1 Tali Perry 2020-05-27 1955 /* write sclfrq value. bits [6:0] are in I2CCTL2 reg */
a946fe9698f261 Tyrone Ting 2024-08-07 @1956 iowrite8(FIELD_PREP(I2CCTL2_SCLFRQ6_0, smb_timing[scl_table_cnt].sclfrq & 0x7F),
^^^^^^^^^^^^^^^^^^^^^^^^^
56a1485b102ed1 Tali Perry 2020-05-27 1957 bus->reg + NPCM_I2CCTL2);
56a1485b102ed1 Tali Perry 2020-05-27 1958
56a1485b102ed1 Tali Perry 2020-05-27 1959 /* bits [8:7] are in I2CCTL3 reg */
a946fe9698f261 Tyrone Ting 2024-08-07 1960 iowrite8(fast_mode | FIELD_PREP(I2CCTL3_SCLFRQ8_7, (smb_timing[scl_table_cnt].sclfrq >> 7)
a946fe9698f261 Tyrone Ting 2024-08-07 1961 & 0x3),
56a1485b102ed1 Tali Perry 2020-05-27 1962 bus->reg + NPCM_I2CCTL3);
56a1485b102ed1 Tali Perry 2020-05-27 1963
56a1485b102ed1 Tali Perry 2020-05-27 1964 /* Select Bank 0 to access NPCM_I2CCTL4/NPCM_I2CCTL5 */
56a1485b102ed1 Tali Perry 2020-05-27 1965 npcm_i2c_select_bank(bus, I2C_BANK_0);
56a1485b102ed1 Tali Perry 2020-05-27 1966
56a1485b102ed1 Tali Perry 2020-05-27 1967 if (bus_freq_hz >= I2C_MAX_FAST_MODE_FREQ) {
56a1485b102ed1 Tali Perry 2020-05-27 1968 /*
56a1485b102ed1 Tali Perry 2020-05-27 1969 * Set SCL Low/High Time:
56a1485b102ed1 Tali Perry 2020-05-27 1970 * k1 = 2 * SCLLT7-0 -> Low Time = k1 / 2
56a1485b102ed1 Tali Perry 2020-05-27 1971 * k2 = 2 * SCLLT7-0 -> High Time = k2 / 2
56a1485b102ed1 Tali Perry 2020-05-27 1972 */
a946fe9698f261 Tyrone Ting 2024-08-07 @1973 iowrite8(smb_timing[scl_table_cnt].scllt, bus->reg + NPCM_I2CSCLLT);
a946fe9698f261 Tyrone Ting 2024-08-07 1974 iowrite8(smb_timing[scl_table_cnt].sclht, bus->reg + NPCM_I2CSCLHT);
56a1485b102ed1 Tali Perry 2020-05-27 1975
a946fe9698f261 Tyrone Ting 2024-08-07 1976 iowrite8(smb_timing[scl_table_cnt].dbcnt, bus->reg + NPCM_I2CCTL5);
56a1485b102ed1 Tali Perry 2020-05-27 1977 }
56a1485b102ed1 Tali Perry 2020-05-27 1978
a946fe9698f261 Tyrone Ting 2024-08-07 1979 iowrite8(smb_timing[scl_table_cnt].hldt, bus->reg + NPCM_I2CCTL4);
56a1485b102ed1 Tali Perry 2020-05-27 1980
56a1485b102ed1 Tali Perry 2020-05-27 1981 /* Return to Bank 1, and stay there by default: */
56a1485b102ed1 Tali Perry 2020-05-27 1982 npcm_i2c_select_bank(bus, I2C_BANK_1);
56a1485b102ed1 Tali Perry 2020-05-27 1983
56a1485b102ed1 Tali Perry 2020-05-27 1984 return 0;
56a1485b102ed1 Tali Perry 2020-05-27 1985 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next prev parent reply other threads:[~2024-08-13 7:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-07 10:02 [PATCH v1 0/7] i2c: npcm: Bug fixes read/write operation, checkpatch warp5tw
2024-08-07 10:02 ` [PATCH v1 1/7] i2c: npcm: correct the read/write operation procedure warp5tw
2024-08-07 10:02 ` [PATCH v1 2/7] i2c: npcm: use a software flag to indicate a BER condition warp5tw
2024-08-07 10:02 ` [PATCH v1 3/7] i2c: npcm: Modify timeout evaluation mechanism warp5tw
2024-08-07 10:02 ` [PATCH v1 4/7] i2c: npcm: Modify the client address assignment warp5tw
2024-08-07 10:02 ` [PATCH v1 5/7] drivers: i2c: use i2c frequency table warp5tw
2024-08-07 19:55 ` kernel test robot
2024-08-13 7:58 ` Dan Carpenter [this message]
2024-08-07 10:02 ` [PATCH v1 6/7] i2c-npcm7xx.c: Enable slave in eob interrupt warp5tw
2024-08-07 10:02 ` [PATCH v1 7/7] i2c: npcm: fix checkpatch warp5tw
2024-08-09 6:50 ` Andrew Jeffery
2024-08-09 7:17 ` Tyrone Ting
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=d512d659-0891-4219-bc8c-bf272755e3d2@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=Avi.Fishman@nuvoton.com \
--cc=andi.shyti@kernel.org \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=jjliu0@nuvoton.com \
--cc=kfting@nuvoton.com \
--cc=kwliu@nuvoton.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=openbmc@lists.ozlabs.org \
--cc=rand.sec96@gmail.com \
--cc=tali.perry1@gmail.com \
--cc=tali.perry@nuvoton.com \
--cc=tmaimon77@gmail.com \
--cc=tomer.maimon@nuvoton.com \
--cc=venture@google.com \
--cc=warp5tw@gmail.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=yuenn@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®