Hi Mathieu,
I love your patch! Perhaps something to improve:
[auto build test WARNING on soc/for-next]
[also build test WARNING on linux/master linus/master v5.14-rc6 next-20210819]
[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/Mathieu-Poirier/coresight-Patche...
base:
https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
config: arm-randconfig-c002-20210818 (attached as .config)
compiler: clang version 14.0.0 (
https://github.com/llvm/llvm-project
d2b574a4dea5b718e4386bf2e26af0126e5978ce)
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://github.com/0day-ci/linux/commit/832a1a28927177c3641fb635e4f623ff0...
git remote add linux-review
https://github.com/0day-ci/linux
git fetch --no-tags linux-review
Mathieu-Poirier/coresight-Patches-for-v5-15/20210819-034401
git checkout 832a1a28927177c3641fb635e4f623ff0652d3e1
# save the attached .config 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(a)intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
if (err < 0)
^
drivers/hwmon/nct6775.c:2347:26: note: Calling 'LM75_TEMP_TO_REG'
data->temp[index][nr] = LM75_TEMP_TO_REG(val);
^~~~~~~~~~~~~~~~~~~~~
drivers/hwmon/lm75.h:27:14: note: Assuming '__UNIQUE_ID___x175' is <=
'__UNIQUE_ID___y176'
int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
^
include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:124:48: note: expanded from macro 'clamp_t'
#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:112:27: note: expanded from macro 'max_t'
#define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >)
^
note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/minmax.h:104:48: note: expanded from macro 'min_t'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
include/linux/minmax.h:38:14: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:31:25: note: expanded from macro '__cmp_once'
typeof(x) unique_x = (x); \
^
drivers/hwmon/lm75.h:27:14: note: '?' condition is false
int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
^
include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
^
include/linux/minmax.h:124:48: note: expanded from macro 'clamp_t'
#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
^
include/linux/minmax.h:112:27: note: expanded from macro 'max_t'
#define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >)
^
include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
^
include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
__cmp(unique_x, unique_y, op); })
^
include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
^
drivers/hwmon/lm75.h:27:14: note: '__UNIQUE_ID___x177' is <
'__UNIQUE_ID___y178'
int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
^
include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:124:36: note: expanded from macro 'clamp_t'
#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:104:27: note: expanded from macro 'min_t'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
__cmp(unique_x, unique_y, op); })
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
^~~
drivers/hwmon/lm75.h:27:14: note: '?' condition is true
int ntemp = clamp_val(temp, LM75_TEMP_MIN, LM75_TEMP_MAX);
^
include/linux/minmax.h:137:32: note: expanded from macro 'clamp_val'
#define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi)
^
include/linux/minmax.h:124:36: note: expanded from macro 'clamp_t'
#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi)
^
include/linux/minmax.h:104:27: note: expanded from macro 'min_t'
#define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <)
^
include/linux/minmax.h:38:3: note: expanded from macro '__careful_cmp'
__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
^
include/linux/minmax.h:33:3: note: expanded from macro '__cmp_once'
__cmp(unique_x, unique_y, op); })
^
include/linux/minmax.h:28:26: note: expanded from macro '__cmp'
#define __cmp(x, y, op) ((x) op (y) ? (x) : (y))
^
drivers/hwmon/lm75.h:29:12: note: 'ntemp' is < 0
ntemp += (ntemp < 0 ? -250 : 250);
^~~~~
drivers/hwmon/lm75.h:29:12: note: '?' condition is true
drivers/hwmon/lm75.h:30:29: note: The result of the left shift is undefined because the
left operand is negative
return (u16)((ntemp / 500) << 7);
~~~~~~~~~~~~~ ^
Suppressed 2 warnings (2 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use
-system-headers to display errors from system headers as well.
9 warnings generated.
> drivers/hwtracing/coresight/coresight-config.c:167:4: warning:
Value stored to 'name' is never read [clang-analyzer-deadcode.DeadStores]
name = feat_csdev->feat_desc->params_desc[j].name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-config.c:167:4: note: Value stored to
'name' is never read
name = feat_csdev->feat_desc->params_desc[j].name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-config.c:206:4: warning: Value stored to
'name' is never read [clang-analyzer-deadcode.DeadStores]
name = feat_csdev->feat_desc->params_desc[j].name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-config.c:206:4: note: Value stored to
'name' is never read
name = feat_csdev->feat_desc->params_desc[j].name;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/hwtracing/coresight/coresight-config.c:234:3: warning:
Value stored to 'csdev' is never read [clang-analyzer-deadcode.DeadStores]
csdev = feat_csdev->csdev;
^ ~~~~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-config.c:234:3: note: Value stored to
'csdev' is never read
csdev = feat_csdev->csdev;
^ ~~~~~~~~~~~~~~~~~
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use
-system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use
-system-headers to display errors from system headers as well.
6 warnings generated.
Suppressed 6 warnings (6 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use
-system-headers to display errors from system headers as well.
10 warnings generated.
drivers/hwtracing/coresight/coresight-tmc-etr.c:763:33: warning: Value stored to
'etr' during its initialization is never read
[clang-analyzer-deadcode.DeadStores]
struct coresight_device *tmp, *etr = drvdata->csdev;
^~~ ~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:763:33: note: Value stored to
'etr' during its initialization is never read
struct coresight_device *tmp, *etr = drvdata->csdev;
^~~ ~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:902:2: warning: Called function pointer
is null (null dereference) [clang-analyzer-core.CallAndMessage]
etr_buf->ops->free(etr_buf);
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:1408:6: note: Assuming
'etr_buf' is non-null
if (!etr_buf)
^~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:1408:2: note: Taking false branch
if (!etr_buf)
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:1413:2: note: Taking false branch
if (!refcount_dec_and_test(&etr_buf->refcount)) {
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:1426:6: note: Assuming 'buf' is
null
if (buf && WARN_ON(buf != etr_buf))
^~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:1426:10: note: Left side of
'&&' is false
if (buf && WARN_ON(buf != etr_buf))
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:1429:2: note: Calling
'tmc_free_etr_buf'
tmc_free_etr_buf(etr_perf->etr_buf);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:10: note: Assuming field
'ops' is non-null
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:10: note: Left side of '||'
is false
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:27: note: Assuming field
'free' is null
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:2: note: Taking true branch
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
if (unlikely(__ret_warn_on)) \
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:2: note: Loop condition is false.
Exiting loop
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:123:3: note: expanded from macro 'WARN_ON'
__WARN(); \
^
include/asm-generic/bug.h:88:19: note: expanded from macro '__WARN'
#define __WARN() __WARN_printf(TAINT_WARN, NULL)
^
include/asm-generic/bug.h:90:3: note: expanded from macro '__WARN_printf'
instrumentation_begin(); \
^
include/linux/instrumentation.h:57:34: note: expanded from macro
'instrumentation_begin'
# define instrumentation_begin() do { } while(0)
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:2: note: Loop condition is false.
Exiting loop
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:123:3: note: expanded from macro 'WARN_ON'
__WARN(); \
^
include/asm-generic/bug.h:88:19: note: expanded from macro '__WARN'
#define __WARN() __WARN_printf(TAINT_WARN, NULL)
^
include/asm-generic/bug.h:92:3: note: expanded from macro '__WARN_printf'
instrumentation_end(); \
^
include/linux/instrumentation.h:58:33: note: expanded from macro
'instrumentation_end'
# define instrumentation_end() do { } while(0)
^
drivers/hwtracing/coresight/coresight-tmc-etr.c:901:2: note: Loop condition is false.
Exiting loop
WARN_ON(!etr_buf->ops || !etr_buf->ops->free);
^
include/asm-generic/bug.h:123:3: note: expanded from macro 'WARN_ON'
__WARN(); \
^
include/asm-generic/bug.h:88:19: note: expanded from macro '__WARN'
#define __WARN() __WARN_printf(TAINT_WARN, NULL)
vim +/name +167 drivers/hwtracing/coresight/coresight-config.c
133
134 /*
135 * For the selected presets, we set the register associated with the parameter, to
136 * the value of the preset index associated with the parameter.
137 */
138 static int cscfg_update_presets(struct cscfg_config_csdev *config_csdev, int
preset)
139 {
140 int i, j, val_idx = 0, nr_cfg_params;
141 struct cscfg_parameter_csdev *param_csdev;
142 struct cscfg_feature_csdev *feat_csdev;
143 const struct cscfg_config_desc *config_desc = config_csdev->config_desc;
144 const char *name;
145 const u64 *preset_base;
146 u64 val;
147
148 /* preset in range 1 to nr_presets */
149 if (preset < 1 || preset > config_desc->nr_presets)
150 return -EINVAL;
151 /*
152 * Go through the array of features, assigning preset values to
153 * feature parameters in the order they appear.
154 * There should be precisely the same number of preset values as the
155 * sum of number of parameters over all the features - but we will
156 * ensure there is no overrun.
157 */
158 nr_cfg_params = config_desc->nr_total_params;
159 preset_base = &config_desc->presets[(preset - 1) * nr_cfg_params];
160 for (i = 0; i < config_csdev->nr_feat; i++) {
161 feat_csdev = config_csdev->feats_csdev[i];
162 if (!feat_csdev->nr_params)
163 continue;
164
165 for (j = 0; j < feat_csdev->nr_params; j++) {
166 param_csdev = &feat_csdev->params_csdev[j];
167 name = feat_csdev->feat_desc->params_desc[j].name;
168 val = preset_base[val_idx++];
169 if (param_csdev->val64) {
170 dev_dbg(&config_csdev->csdev->dev,
171 "set param %s (%lld)", name, val);
172 param_csdev->reg_csdev->reg_desc.val64 = val;
173 } else {
174 param_csdev->reg_csdev->reg_desc.val32 = (u32)val;
175 dev_dbg(&config_csdev->csdev->dev,
176 "set param %s (%d)", name, (u32)val);
177 }
178 }
179
180 /* exit early if all params filled */
181 if (val_idx >= nr_cfg_params)
182 break;
183 }
184 return 0;
185 }
186
187 /*
188 * if we are not using a preset, then need to update the feature params
189 * with current values. This sets the register associated with the parameter
190 * with the current value of that parameter.
191 */
192 static int cscfg_update_curr_params(struct cscfg_config_csdev *config_csdev)
193 {
194 int i, j;
195 struct cscfg_feature_csdev *feat_csdev;
196 struct cscfg_parameter_csdev *param_csdev;
197 const char *name;
198 u64 val;
199
200 for (i = 0; i < config_csdev->nr_feat; i++) {
201 feat_csdev = config_csdev->feats_csdev[i];
202 if (!feat_csdev->nr_params)
203 continue;
204 for (j = 0; j < feat_csdev->nr_params; j++) {
205 param_csdev = &feat_csdev->params_csdev[j];
206 name = feat_csdev->feat_desc->params_desc[j].name;
207 val = param_csdev->current_value;
208 if (param_csdev->val64) {
209 dev_dbg(&config_csdev->csdev->dev,
210 "set param %s (%lld)", name, val);
211 param_csdev->reg_csdev->reg_desc.val64 = val;
212 } else {
213 param_csdev->reg_csdev->reg_desc.val32 = (u32)val;
214 dev_dbg(&config_csdev->csdev->dev,
215 "set param %s (%d)", name, (u32)val);
216 }
217 }
218 }
219 return 0;
220 }
221
222 /*
223 * Configuration values will be programmed into the driver locations if enabling,
or read
224 * from relevant locations on disable.
225 */
226 static int cscfg_prog_config(struct cscfg_config_csdev *config_csdev, bool enable)
227 {
228 int i, err = 0;
229 struct cscfg_feature_csdev *feat_csdev;
230 struct coresight_device *csdev;
231
232 for (i = 0; i < config_csdev->nr_feat; i++) {
233 feat_csdev = config_csdev->feats_csdev[i];
234 csdev = feat_csdev->csdev;
235 dev_dbg(&csdev->dev, "cfg %s; %s feature:%s",
config_csdev->config_desc->name,
236 enable ? "enable" : "disable",
feat_csdev->feat_desc->name);
237
238 if (enable)
239 err = cscfg_set_on_enable(feat_csdev);
240 else
241 cscfg_save_on_disable(feat_csdev);
242
243 if (err)
244 break;
245 }
246 return err;
247 }
248
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org