Content-Type: multipart/mixed; boundary="===============1621496923553815810==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH v1 6/6] i2c: npcm: Support NPCM845 Date: Mon, 07 Feb 2022 20:34:23 +0800 Message-ID: <202202072020.toQ349pg-lkp@intel.com> In-Reply-To: <20220207063338.6570-7-warp5tw@gmail.com> List-Id: --===============1621496923553815810== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Tyrone, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on wsa/i2c/for-next] [also build test WARNING on v5.17-rc3 next-20220207] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Tyrone-Ting/i2c-npcm-Bug-f= ixes-timeout-spurious-interrupts/20220207-144704 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/f= or-next config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20220= 207/202202072020.toQ349pg-lkp(a)intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0d8850= ae2cae85d49bea6ae0799fa41c7202c05c) reproduce (this is a W=3D1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/= make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/580220fb38f28f5ab9ad2c4d3= 9d4738719f39a7a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Tyrone-Ting/i2c-npcm-Bug-fixes-tim= eout-spurious-interrupts/20220207-144704 git checkout 580220fb38f28f5ab9ad2c4d39d4738719f39a7a # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W=3D= 1 O=3Dbuild_dir ARCH=3Dhexagon SHELL=3D/bin/bash drivers/i2c/busses/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> drivers/i2c/busses/i2c-npcm7xx.c:2164:12: warning: comparison of distinc= t pointer types ('typeof (bus->adap.timeout) *' (aka 'int *') and 'typeof (= usecs_to_jiffies(timeout_usec)) *' (aka 'unsigned long *')) [-Wcompare-dist= inct-pointer-types] timeout =3D max(bus->adap.timeout, usecs_to_jiffies(timeout_usec= )); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:52:19: note: expanded from macro 'max' #define max(x, y) __careful_cmp(x, y, >) ^~~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp' __builtin_choose_expr(__safe_cmp(x, y), \ ^~~~~~~~~~~~~~~~ include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp' (__typecheck(x, y) && __no_side_effects(x, y)) ^~~~~~~~~~~~~~~~~ include/linux/minmax.h:20:28: note: expanded from macro '__typecheck' (!!(sizeof((typeof(x) *)1 =3D=3D (typeof(y) *)1))) ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ 1 warning generated. vim +2164 drivers/i2c/busses/i2c-npcm7xx.c 56a1485b102ed1 Tali Perry 2020-05-27 2103 = 56a1485b102ed1 Tali Perry 2020-05-27 2104 static int npcm_i2c_master_xfer= (struct i2c_adapter *adap, struct i2c_msg *msgs, 56a1485b102ed1 Tali Perry 2020-05-27 2105 int num) 56a1485b102ed1 Tali Perry 2020-05-27 2106 { 56a1485b102ed1 Tali Perry 2020-05-27 2107 struct npcm_i2c *bus =3D conta= iner_of(adap, struct npcm_i2c, adap); 56a1485b102ed1 Tali Perry 2020-05-27 2108 struct i2c_msg *msg0, *msg1; 56a1485b102ed1 Tali Perry 2020-05-27 2109 unsigned long time_left, flags; 56a1485b102ed1 Tali Perry 2020-05-27 2110 u16 nwrite, nread; 56a1485b102ed1 Tali Perry 2020-05-27 2111 u8 *write_data, *read_data; 56a1485b102ed1 Tali Perry 2020-05-27 2112 u8 slave_addr; 692c41a2a403a7 Tali Perry 2022-02-07 2113 unsigned long timeout; 56a1485b102ed1 Tali Perry 2020-05-27 2114 bool read_block =3D false; 56a1485b102ed1 Tali Perry 2020-05-27 2115 bool read_PEC =3D false; 56a1485b102ed1 Tali Perry 2020-05-27 2116 u8 bus_busy; 56a1485b102ed1 Tali Perry 2020-05-27 2117 unsigned long timeout_usec; 56a1485b102ed1 Tali Perry 2020-05-27 2118 = 56a1485b102ed1 Tali Perry 2020-05-27 2119 if (bus->state =3D=3D I2C_DISA= BLE) { 56a1485b102ed1 Tali Perry 2020-05-27 2120 dev_err(bus->dev, "I2C%d modu= le is disabled", bus->num); 56a1485b102ed1 Tali Perry 2020-05-27 2121 return -EINVAL; 56a1485b102ed1 Tali Perry 2020-05-27 2122 } 56a1485b102ed1 Tali Perry 2020-05-27 2123 = 56a1485b102ed1 Tali Perry 2020-05-27 2124 msg0 =3D &msgs[0]; 56a1485b102ed1 Tali Perry 2020-05-27 2125 slave_addr =3D msg0->addr; 56a1485b102ed1 Tali Perry 2020-05-27 2126 if (msg0->flags & I2C_M_RD) { = /* read */ 56a1485b102ed1 Tali Perry 2020-05-27 2127 nwrite =3D 0; 56a1485b102ed1 Tali Perry 2020-05-27 2128 write_data =3D NULL; 56a1485b102ed1 Tali Perry 2020-05-27 2129 read_data =3D msg0->buf; 56a1485b102ed1 Tali Perry 2020-05-27 2130 if (msg0->flags & I2C_M_RECV_= LEN) { 56a1485b102ed1 Tali Perry 2020-05-27 2131 nread =3D 1; 56a1485b102ed1 Tali Perry 2020-05-27 2132 read_block =3D true; 56a1485b102ed1 Tali Perry 2020-05-27 2133 if (msg0->flags & I2C_CLIENT= _PEC) 56a1485b102ed1 Tali Perry 2020-05-27 2134 read_PEC =3D true; 56a1485b102ed1 Tali Perry 2020-05-27 2135 } else { 56a1485b102ed1 Tali Perry 2020-05-27 2136 nread =3D msg0->len; 56a1485b102ed1 Tali Perry 2020-05-27 2137 } 56a1485b102ed1 Tali Perry 2020-05-27 2138 } else { /* write */ 56a1485b102ed1 Tali Perry 2020-05-27 2139 nwrite =3D msg0->len; 56a1485b102ed1 Tali Perry 2020-05-27 2140 write_data =3D msg0->buf; 56a1485b102ed1 Tali Perry 2020-05-27 2141 nread =3D 0; 56a1485b102ed1 Tali Perry 2020-05-27 2142 read_data =3D NULL; 56a1485b102ed1 Tali Perry 2020-05-27 2143 if (num =3D=3D 2) { 56a1485b102ed1 Tali Perry 2020-05-27 2144 msg1 =3D &msgs[1]; 56a1485b102ed1 Tali Perry 2020-05-27 2145 read_data =3D msg1->buf; 56a1485b102ed1 Tali Perry 2020-05-27 2146 if (msg1->flags & I2C_M_RECV= _LEN) { 56a1485b102ed1 Tali Perry 2020-05-27 2147 nread =3D 1; 56a1485b102ed1 Tali Perry 2020-05-27 2148 read_block =3D true; 56a1485b102ed1 Tali Perry 2020-05-27 2149 if (msg1->flags & I2C_CLIEN= T_PEC) 56a1485b102ed1 Tali Perry 2020-05-27 2150 read_PEC =3D true; 56a1485b102ed1 Tali Perry 2020-05-27 2151 } else { 56a1485b102ed1 Tali Perry 2020-05-27 2152 nread =3D msg1->len; 56a1485b102ed1 Tali Perry 2020-05-27 2153 read_block =3D false; 56a1485b102ed1 Tali Perry 2020-05-27 2154 } 56a1485b102ed1 Tali Perry 2020-05-27 2155 } 56a1485b102ed1 Tali Perry 2020-05-27 2156 } 56a1485b102ed1 Tali Perry 2020-05-27 2157 = 06be67266a0c9a Tali Perry 2020-08-31 2158 /* 06be67266a0c9a Tali Perry 2020-08-31 2159 * Adaptive TimeOut: estimated= time in usec + 100% margin: 06be67266a0c9a Tali Perry 2020-08-31 2160 * 2: double the timeout for c= lock stretching case 06be67266a0c9a Tali Perry 2020-08-31 2161 * 9: bits per transaction (in= cluding the ack/nack) 06be67266a0c9a Tali Perry 2020-08-31 2162 */ 06be67266a0c9a Tali Perry 2020-08-31 2163 timeout_usec =3D (2 * 9 * USEC= _PER_SEC / bus->bus_freq) * (2 + nread + nwrite); 692c41a2a403a7 Tali Perry 2022-02-07 @2164 timeout =3D max(bus->adap.time= out, usecs_to_jiffies(timeout_usec)); 56a1485b102ed1 Tali Perry 2020-05-27 2165 if (nwrite >=3D 32 * 1024 || n= read >=3D 32 * 1024) { 56a1485b102ed1 Tali Perry 2020-05-27 2166 dev_err(bus->dev, "i2c%d buff= er too big\n", bus->num); 56a1485b102ed1 Tali Perry 2020-05-27 2167 return -EINVAL; 56a1485b102ed1 Tali Perry 2020-05-27 2168 } 56a1485b102ed1 Tali Perry 2020-05-27 2169 = 692c41a2a403a7 Tali Perry 2022-02-07 2170 time_left =3D jiffies + timeou= t + 1; 56a1485b102ed1 Tali Perry 2020-05-27 2171 do { 56a1485b102ed1 Tali Perry 2020-05-27 2172 /* 56a1485b102ed1 Tali Perry 2020-05-27 2173 * we must clear slave addres= s immediately when the bus is not 56a1485b102ed1 Tali Perry 2020-05-27 2174 * busy, so we spinlock it, b= ut we don't keep the lock for the 56a1485b102ed1 Tali Perry 2020-05-27 2175 * entire while since it is t= oo long. 56a1485b102ed1 Tali Perry 2020-05-27 2176 */ 56a1485b102ed1 Tali Perry 2020-05-27 2177 spin_lock_irqsave(&bus->lock,= flags); 56a1485b102ed1 Tali Perry 2020-05-27 2178 bus_busy =3D ioread8(bus->reg= + NPCM_I2CCST) & NPCM_I2CCST_BB; f54736925a4f83 Tali Perry 2020-05-27 2179 #if IS_ENABLED(CONFIG_I2C_SLAVE) f54736925a4f83 Tali Perry 2020-05-27 2180 if (!bus_busy && bus->slave) f54736925a4f83 Tali Perry 2020-05-27 2181 iowrite8((bus->slave->addr &= 0x7F), f54736925a4f83 Tali Perry 2020-05-27 2182 bus->reg + NPCM_I2CADDR1); f54736925a4f83 Tali Perry 2020-05-27 2183 #endif 56a1485b102ed1 Tali Perry 2020-05-27 2184 spin_unlock_irqrestore(&bus->= lock, flags); 56a1485b102ed1 Tali Perry 2020-05-27 2185 = 56a1485b102ed1 Tali Perry 2020-05-27 2186 } while (time_is_after_jiffies= (time_left) && bus_busy); 56a1485b102ed1 Tali Perry 2020-05-27 2187 = 56a1485b102ed1 Tali Perry 2020-05-27 2188 if (bus_busy) { 56a1485b102ed1 Tali Perry 2020-05-27 2189 iowrite8(NPCM_I2CCST_BB, bus-= >reg + NPCM_I2CCST); 56a1485b102ed1 Tali Perry 2020-05-27 2190 npcm_i2c_reset(bus); 56a1485b102ed1 Tali Perry 2020-05-27 2191 i2c_recover_bus(adap); 56a1485b102ed1 Tali Perry 2020-05-27 2192 return -EAGAIN; 56a1485b102ed1 Tali Perry 2020-05-27 2193 } 56a1485b102ed1 Tali Perry 2020-05-27 2194 = 56a1485b102ed1 Tali Perry 2020-05-27 2195 npcm_i2c_init_params(bus); 692c41a2a403a7 Tali Perry 2022-02-07 2196 bus->dest_addr =3D slave_addr = << 1; 56a1485b102ed1 Tali Perry 2020-05-27 2197 bus->msgs =3D msgs; 56a1485b102ed1 Tali Perry 2020-05-27 2198 bus->msgs_num =3D num; 56a1485b102ed1 Tali Perry 2020-05-27 2199 bus->cmd_err =3D 0; 56a1485b102ed1 Tali Perry 2020-05-27 2200 bus->read_block_use =3D read_b= lock; 56a1485b102ed1 Tali Perry 2020-05-27 2201 = 56a1485b102ed1 Tali Perry 2020-05-27 2202 reinit_completion(&bus->cmd_co= mplete); 56a1485b102ed1 Tali Perry 2020-05-27 2203 = 8b4b09a6da0b25 Tali Perry 2022-02-07 2204 npcm_i2c_int_enable(bus, true); 8b4b09a6da0b25 Tali Perry 2022-02-07 2205 = 8b4b09a6da0b25 Tali Perry 2022-02-07 2206 if (npcm_i2c_master_start_xmit= (bus, slave_addr, nwrite, nread, 8b4b09a6da0b25 Tali Perry 2022-02-07 2207 write_data, read_dat= a, read_PEC, 8b4b09a6da0b25 Tali Perry 2022-02-07 2208 read_block)) { 56a1485b102ed1 Tali Perry 2020-05-27 2209 time_left =3D wait_for_comple= tion_timeout(&bus->cmd_complete, 56a1485b102ed1 Tali Perry 2020-05-27 2210 timeout); 56a1485b102ed1 Tali Perry 2020-05-27 2211 = 56a1485b102ed1 Tali Perry 2020-05-27 2212 if (time_left =3D=3D 0) { 56a1485b102ed1 Tali Perry 2020-05-27 2213 if (bus->timeout_cnt < ULLON= G_MAX) 56a1485b102ed1 Tali Perry 2020-05-27 2214 bus->timeout_cnt++; 56a1485b102ed1 Tali Perry 2020-05-27 2215 if (bus->master_or_slave =3D= =3D I2C_MASTER) { 56a1485b102ed1 Tali Perry 2020-05-27 2216 i2c_recover_bus(adap); 56a1485b102ed1 Tali Perry 2020-05-27 2217 bus->cmd_err =3D -EIO; 56a1485b102ed1 Tali Perry 2020-05-27 2218 bus->state =3D I2C_IDLE; 56a1485b102ed1 Tali Perry 2020-05-27 2219 } 56a1485b102ed1 Tali Perry 2020-05-27 2220 } 56a1485b102ed1 Tali Perry 2020-05-27 2221 } 56a1485b102ed1 Tali Perry 2020-05-27 2222 = 56a1485b102ed1 Tali Perry 2020-05-27 2223 /* if there was BER, check if = need to recover the bus: */ 56a1485b102ed1 Tali Perry 2020-05-27 2224 if (bus->cmd_err =3D=3D -EAGAI= N) 8b4b09a6da0b25 Tali Perry 2022-02-07 2225 bus->cmd_err =3D i2c_recover_= bus(adap); 56a1485b102ed1 Tali Perry 2020-05-27 2226 = 8947efc077168c Tali Perry 2020-09-20 2227 /* 8947efc077168c Tali Perry 2020-09-20 2228 * After any type of error, ch= eck if LAST bit is still set, 8947efc077168c Tali Perry 2020-09-20 2229 * due to a HW issue. 8947efc077168c Tali Perry 2020-09-20 2230 * It cannot be cleared withou= t resetting the module. 8947efc077168c Tali Perry 2020-09-20 2231 */ 8b4b09a6da0b25 Tali Perry 2022-02-07 2232 else if (bus->cmd_err && 8947efc077168c Tali Perry 2020-09-20 2233 (NPCM_I2CRXF_CTL_LAST_PEC & = ioread8(bus->reg + NPCM_I2CRXF_CTL))) 8947efc077168c Tali Perry 2020-09-20 2234 npcm_i2c_reset(bus); 8947efc077168c Tali Perry 2020-09-20 2235 = 8b4b09a6da0b25 Tali Perry 2022-02-07 2236 /* after any xfer, successful = or not, stall and EOB must be disabled */ 8b4b09a6da0b25 Tali Perry 2022-02-07 2237 npcm_i2c_stall_after_start(bus= , false); 8b4b09a6da0b25 Tali Perry 2022-02-07 2238 npcm_i2c_eob_int(bus, false); 8b4b09a6da0b25 Tali Perry 2022-02-07 2239 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============1621496923553815810==--