* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-03-31 22:20 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-03-31 22:20 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 31969 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Simon Trimmer <simont@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e729dbe8ea1c6145ae7b9efd6a00a5613746d3b0
commit: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
date: 6 months ago
:::::: branch date: 2 hours ago
:::::: commit date: 6 months ago
config: mips-randconfig-c004-20220331 (https://download.01.org/0day-ci/archive/20220401/202204010650.0w4OEiqY-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 0f6d9501cf49ce02937099350d08f20c4af86f3d)
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 mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 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 >>)
^
include/linux/uaccess.h:193:2: note: Returning zero (loaded from 'n'), which participates in a condition later
return n;
^~~~~~~~
drivers/hwtracing/stm/core.c:736:6: note: Returning from 'copy_from_user'
if (copy_from_user(&size, arg, sizeof(size)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/stm/core.c:736:2: note: Taking false branch
if (copy_from_user(&size, arg, sizeof(size)))
^
drivers/hwtracing/stm/core.c:739:11: note: The left operand of '<' is a garbage value
if (size < sizeof(*id) || size >= PATH_MAX + sizeof(*id))
~~~~ ^
drivers/hwtracing/stm/core.c:821:10: warning: 5th function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
err = stm_data->set_options(stm_data,
^
drivers/hwtracing/stm/core.c:803:2: note: 'options' declared without an initial value
u64 options;
^~~~~~~~~~~
drivers/hwtracing/stm/core.c:805:2: note: Control jumps to 'case 2148017410:' at line 816
switch (cmd) {
^
drivers/hwtracing/stm/core.c:817:7: note: Calling 'copy_from_user'
if (copy_from_user(&options, (u64 __user *)arg, sizeof(u64)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:191:2: note: Taking true branch
if (likely(check_copy_size(to, n, false)))
^
include/linux/uaccess.h:192:7: note: Calling '_copy_from_user'
n = _copy_from_user(to, from, n);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:157:7: note: Calling 'should_fail_usercopy'
if (!should_fail_usercopy() && likely(access_ok(from, n))) {
^~~~~~~~~~~~~~~~~~~~~~
include/linux/fault-inject-usercopy.h:18:49: note: Returning zero, which participates in a condition later
static inline bool should_fail_usercopy(void) { return false; }
^~~~~~~~~~~~
include/linux/uaccess.h:157:7: note: Returning from 'should_fail_usercopy'
if (!should_fail_usercopy() && likely(access_ok(from, n))) {
^~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:157:6: note: Left side of '&&' is true
if (!should_fail_usercopy() && likely(access_ok(from, n))) {
^
include/linux/uaccess.h:157:2: note: Taking true branch
if (!should_fail_usercopy() && likely(access_ok(from, n))) {
^
include/linux/uaccess.h:159:9: note: Calling 'raw_copy_from_user'
res = raw_copy_from_user(to, from, n);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/include/asm/uaccess.h:455:2: note: Returning without writing to '*to'
return __cu_len_r;
^
include/linux/uaccess.h:159:9: note: Returning from 'raw_copy_from_user'
res = raw_copy_from_user(to, from, n);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:161:6: note: Assuming 'res' is 0, which participates in a condition later
if (unlikely(res))
^
include/linux/compiler.h:78:40: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^~~~
include/linux/uaccess.h:161:2: note: Taking false branch
if (unlikely(res))
^
include/linux/uaccess.h:163:2: note: Returning without writing to '*to'
return res;
^
include/linux/uaccess.h:163:2: note: Returning zero (loaded from 'res'), which participates in a condition later
return res;
^~~~~~~~~~
include/linux/uaccess.h:192:7: note: Returning from '_copy_from_user'
n = _copy_from_user(to, from, n);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:193:2: note: Returning without writing to '*to'
return n;
^
include/linux/uaccess.h:193:2: note: Returning zero (loaded from 'n'), which participates in a condition later
return n;
^~~~~~~~
drivers/hwtracing/stm/core.c:817:7: note: Returning from 'copy_from_user'
if (copy_from_user(&options, (u64 __user *)arg, sizeof(u64)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/stm/core.c:817:3: note: Taking false branch
if (copy_from_user(&options, (u64 __user *)arg, sizeof(u64)))
^
drivers/hwtracing/stm/core.c:820:7: note: Assuming field 'set_options' is non-null
if (stm_data->set_options)
^~~~~~~~~~~~~~~~~~~~~
drivers/hwtracing/stm/core.c:820:3: note: Taking true branch
if (stm_data->set_options)
^
drivers/hwtracing/stm/core.c:821:10: note: 5th function call argument is an uninitialized value
err = stm_data->set_options(stm_data,
^
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Loop condition is false. Exiting loop
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/firmware/cirrus/cs_dsp.c:2762:7: note: Assuming field 'control_remove' is null
if (dsp->client_ops->control_remove)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2762:3: note: Taking false branch
if (dsp->client_ops->control_remove)
^
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Calling 'cs_dsp_free_ctl_blk'
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:907:2: note: Memory is released
kfree(ctl);
^~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Returning; memory was released
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c3 Simon Trimmer 2021-09-13 1203
f6bc909e7673c3 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1210
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1212
f6bc909e7673c3 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1216
f6bc909e7673c3 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1219
f6bc909e7673c3 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1226
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1228
f6bc909e7673c3 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1232
f6bc909e7673c3 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1235
f6bc909e7673c3 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1249
f6bc909e7673c3 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1259
f6bc909e7673c3 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1277
f6bc909e7673c3 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1279
f6bc909e7673c3 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1286
f6bc909e7673c3 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1288
f6bc909e7673c3 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1293
f6bc909e7673c3 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1299
f6bc909e7673c3 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1302
f6bc909e7673c3 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1308
f6bc909e7673c3 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1311
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1314
f6bc909e7673c3 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1320
f6bc909e7673c3 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1323
f6bc909e7673c3 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c3 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1332
f6bc909e7673c3 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1368
f6bc909e7673c3 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1378
f6bc909e7673c3 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1382
f6bc909e7673c3 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c3 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1392
f6bc909e7673c3 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1399
f6bc909e7673c3 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c3 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1409
f6bc909e7673c3 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1421
f6bc909e7673c3 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1425
f6bc909e7673c3 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1431
f6bc909e7673c3 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1435
f6bc909e7673c3 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1437
f6bc909e7673c3 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1442
f6bc909e7673c3 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1445
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-02-25 22:38 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-02-25 22:38 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 32388 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: David Rhodes <drhodes@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 53ab78cd6d5aba25575a7cfb95729336ba9497d8
commit: bae9e13fc55cbc5ae25409385b2f1ba9187082d0 ASoC: cs35l41: DSP Support
date: 3 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 3 months ago
config: riscv-randconfig-c006-20220225 (https://download.01.org/0day-ci/archive/20220226/202202260637.5XfUPhNX-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bae9e13fc55cbc5ae25409385b2f1ba9187082d0
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout bae9e13fc55cbc5ae25409385b2f1ba9187082d0
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 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 >>)
^
include/linux/err.h:36:2: note: Returning zero, which participates in a condition later
return IS_ERR_VALUE((unsigned long)ptr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/base/core.c:4277:6: note: Returning from 'IS_ERR'
if (IS_ERR(new_parent_kobj)) {
^~~~~~~~~~~~~~~~~~~~~~~
drivers/base/core.c:4277:2: note: Taking false branch
if (IS_ERR(new_parent_kobj)) {
^
drivers/base/core.c:4283:2: note: Taking false branch
pr_debug("device: '%s': %s: moving to '%s'\n", dev_name(dev),
^
include/linux/printk.h:576:2: note: expanded from macro 'pr_debug'
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
^
include/linux/printk.h:131:2: note: expanded from macro 'no_printk'
if (0) \
^
drivers/base/core.c:4286:6: note: Assuming 'error' is 0
if (error) {
^~~~~
drivers/base/core.c:4286:2: note: Taking false branch
if (error) {
^
drivers/base/core.c:4293:6: note: Assuming 'old_parent' is null
if (old_parent)
^~~~~~~~~~
drivers/base/core.c:4293:2: note: Taking false branch
if (old_parent)
^
drivers/base/core.c:4295:6: note: Assuming 'new_parent' is null
if (new_parent) {
^~~~~~~~~~
drivers/base/core.c:4295:2: note: Taking false branch
if (new_parent) {
^
drivers/base/core.c:4301:6: note: Assuming field 'class' is null
if (dev->class) {
^~~~~~~~~~
drivers/base/core.c:4301:2: note: Taking false branch
if (dev->class) {
^
drivers/base/core.c:4321:2: note: Control jumps to 'case DPM_ORDER_PARENT_BEFORE_DEV:' at line 4328
switch (dpm_order) {
^
drivers/base/core.c:4330:28: note: Passing null pointer value via 1st parameter 'deva'
devices_kset_move_before(new_parent, dev);
^~~~~~~~~~
drivers/base/core.c:4330:3: note: Calling 'devices_kset_move_before'
devices_kset_move_before(new_parent, dev);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/base/core.c:2706:6: note: Assuming 'devices_kset' is non-null
if (!devices_kset)
^~~~~~~~~~~~~
drivers/base/core.c:2706:2: note: Taking false branch
if (!devices_kset)
^
drivers/base/core.c:2708:2: note: Taking false branch
pr_debug("devices_kset: Moving %s before %s\n",
^
include/linux/printk.h:576:2: note: expanded from macro 'pr_debug'
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
^
include/linux/printk.h:131:2: note: expanded from macro 'no_printk'
if (0) \
^
drivers/base/core.c:2711:17: note: Passing null pointer value via 1st parameter 'list'
list_move_tail(&deva->kobj.entry, &devb->kobj.entry);
^~~~~~~~~~~~~~~~~
drivers/base/core.c:2711:2: note: Calling 'list_move_tail'
list_move_tail(&deva->kobj.entry, &devb->kobj.entry);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:229:19: note: Passing null pointer value via 1st parameter 'entry'
__list_del_entry(list);
^~~~
include/linux/list.h:229:2: note: Calling '__list_del_entry'
__list_del_entry(list);
^~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:134:6: note: Assuming the condition is false
if (!__list_del_entry_valid(entry))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:134:2: note: Taking false branch
if (!__list_del_entry_valid(entry))
^
include/linux/list.h:137:13: note: Access to field 'prev' results in a dereference of a null pointer (loaded from variable 'entry')
__list_del(entry->prev, entry->next);
^~~~~
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.
3 warnings generated.
drivers/leds/uleds.c:150:4: warning: Value stored to 'retval' is never read [clang-analyzer-deadcode.DeadStores]
retval = copy_to_user(buffer, &udev->brightness,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/uleds.c:150:4: note: Value stored to 'retval' is never read
retval = copy_to_user(buffer, &udev->brightness,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
7 warnings generated.
>> drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:137:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2280:2: note: Loop condition is false. Execution continues on line 2283
list_for_each_entry(ctl, &dsp->ctl_list, list)
^
include/linux/list.h:630:2: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
drivers/firmware/cirrus/cs_dsp.c:2283:2: note: Calling 'cs_dsp_free_alg_regions'
cs_dsp_free_alg_regions(dsp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1592:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->alg_regions)) {
^
drivers/firmware/cirrus/cs_dsp.c:1597:3: note: Memory is released
kfree(alg_region);
^~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1592:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->alg_regions)) {
^
drivers/firmware/cirrus/cs_dsp.c:1596:3: note: Calling 'list_del'
list_del(&alg_region->list);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:148:2: note: Calling '__list_del_entry'
__list_del_entry(entry);
^~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:134:6: note: Assuming the condition is false
if (!__list_del_entry_valid(entry))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:134:2: note: Taking false branch
if (!__list_del_entry_valid(entry))
^
include/linux/list.h:137:13: note: Use of memory after it is freed
__list_del(entry->prev, entry->next);
^~~~~~~~~~~
include/linux/list.h:149:14: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
entry->next = LIST_POISON1;
^
drivers/firmware/cirrus/cs_dsp.c:2280:2: note: Loop condition is false. Execution continues on line 2283
list_for_each_entry(ctl, &dsp->ctl_list, list)
^
include/linux/list.h:630:2: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
drivers/firmware/cirrus/cs_dsp.c:2283:2: note: Calling 'cs_dsp_free_alg_regions'
cs_dsp_free_alg_regions(dsp);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1592:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->alg_regions)) {
^
drivers/firmware/cirrus/cs_dsp.c:1597:3: note: Memory is released
kfree(alg_region);
^~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1592:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->alg_regions)) {
^
drivers/firmware/cirrus/cs_dsp.c:1596:3: note: Calling 'list_del'
list_del(&alg_region->list);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:149:14: note: Use of memory after it is freed
entry->next = LIST_POISON1;
~~~~~~~~~~~ ^
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.
8 warnings generated.
drivers/media/dvb-frontends/zd1301_demod.c:40:26: warning: Value stored to 'pdev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:40:26: note: Value stored to 'pdev' during its initialization is never read
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:148:26: warning: Value stored to 'pdev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:148:26: note: Value stored to 'pdev' during its initialization is never read
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:181:26: warning: Value stored to 'pdev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:181:26: note: Value stored to 'pdev' during its initialization is never read
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:215:26: warning: Value stored to 'pdev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:215:26: note: Value stored to 'pdev' during its initialization is never read
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:229:26: warning: Value stored to 'pdev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct platform_device *pdev = dev->pdev;
^~~~ ~~~~~~~~~
drivers/media/dvb-frontends/zd1301_demod.c:229:26: note: Value stored to 'pdev' during its initialization is never read
struct platform_device *pdev = dev->pdev;
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c3 Simon Trimmer 2021-09-13 1203
f6bc909e7673c3 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1210
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1212
f6bc909e7673c3 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1216
f6bc909e7673c3 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1219
f6bc909e7673c3 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1226
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1228
f6bc909e7673c3 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1232
f6bc909e7673c3 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1235
f6bc909e7673c3 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1249
f6bc909e7673c3 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1259
f6bc909e7673c3 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1277
f6bc909e7673c3 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1279
f6bc909e7673c3 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1286
f6bc909e7673c3 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1288
f6bc909e7673c3 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1293
f6bc909e7673c3 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1299
f6bc909e7673c3 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1302
f6bc909e7673c3 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1308
f6bc909e7673c3 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1311
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1314
f6bc909e7673c3 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1320
f6bc909e7673c3 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1323
f6bc909e7673c3 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c3 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1332
f6bc909e7673c3 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1368
f6bc909e7673c3 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1378
f6bc909e7673c3 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1382
f6bc909e7673c3 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c3 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1392
f6bc909e7673c3 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1399
f6bc909e7673c3 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c3 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1409
f6bc909e7673c3 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1421
f6bc909e7673c3 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1425
f6bc909e7673c3 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1431
f6bc909e7673c3 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1435
f6bc909e7673c3 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1437
f6bc909e7673c3 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1442
f6bc909e7673c3 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1445
:::::: The code at line 1211 was first introduced by commit
:::::: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
:::::: TO: Simon Trimmer <simont@opensource.cirrus.com>
:::::: CC: Mark Brown <broonie@kernel.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2022-01-28 2:26 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2022-01-28 2:26 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 32690 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Simon Trimmer <simont@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 23a46422c56144939c091c76cf389aa863ce9c18
commit: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
date: 4 months ago
:::::: branch date: 7 hours ago
:::::: commit date: 4 months ago
config: arm-randconfig-c002-20220123 (https://download.01.org/0day-ci/archive/20220128/202201281003.OMEIIoP1-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 7b3d30728816403d1fd73cc5082e9fb761262bce)
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=f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
# 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/media/i2c/tvp7002.c:627:2: note: Taking false branch
if (error < 0)
^
drivers/media/i2c/tvp7002.c:633:6: note: 'error' is >= 0
if (error < 0)
^~~~~
drivers/media/i2c/tvp7002.c:633:2: note: Taking false branch
if (error < 0)
^
drivers/media/i2c/tvp7002.c:637:37: note: The right operand of '&' is a garbage value
lpfr = lpf_lsb | ((TVP7002_CL_MASK & lpf_msb) << TVP7002_CL_SHIFT);
^ ~~~~~~~
drivers/media/i2c/tvp7002.c:638:37: warning: The right operand of '&' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
cpln = cpl_lsb | ((TVP7002_CL_MASK & cpl_msb) << TVP7002_CL_SHIFT);
^
drivers/media/i2c/tvp7002.c:753:2: note: Calling 'tvp7002_query_dv'
tvp7002_query_dv(sd, &detected);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp7002.c:618:2: note: 'cpl_msb' declared without an initial value
u8 cpl_msb;
^~~~~~~~~~
drivers/media/i2c/tvp7002.c:627:6: note: Assuming 'error' is >= 0
if (error < 0)
^~~~~~~~~
drivers/media/i2c/tvp7002.c:627:2: note: Taking false branch
if (error < 0)
^
drivers/media/i2c/tvp7002.c:631:2: note: Calling 'tvp7002_read_err'
tvp7002_read_err(sd, TVP7002_CLK_L_STAT_MSBS, &cpl_msb, &error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp7002.c:475:2: note: Taking false branch
if (!*err)
^
drivers/media/i2c/tvp7002.c:477:1: note: Returning without writing to '*dst'
}
^
drivers/media/i2c/tvp7002.c:631:2: note: Returning from 'tvp7002_read_err'
tvp7002_read_err(sd, TVP7002_CLK_L_STAT_MSBS, &cpl_msb, &error);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp7002.c:633:6: note: 'error' is >= 0
if (error < 0)
^~~~~
drivers/media/i2c/tvp7002.c:633:2: note: Taking false branch
if (error < 0)
^
drivers/media/i2c/tvp7002.c:638:37: note: The right operand of '&' is a garbage value
cpln = cpl_lsb | ((TVP7002_CL_MASK & cpl_msb) << TVP7002_CL_SHIFT);
^ ~~~~~~~
drivers/media/i2c/tvp7002.c:1004:2: warning: Value stored to 'error' is never read [clang-analyzer-deadcode.DeadStores]
error = tvp7002_s_dv_timings(sd, &timings);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp7002.c:1004:2: note: Value stored to 'error' is never read
error = tvp7002_s_dv_timings(sd, &timings);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 10 warnings (9 in non-user code, 1 with check filters).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
8 warnings generated.
Suppressed 8 warnings (8 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.
8 warnings generated.
Suppressed 8 warnings (8 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.
8 warnings generated.
Suppressed 8 warnings (8 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.
8 warnings generated.
Suppressed 8 warnings (8 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
8 warnings generated.
>> drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Loop condition is false. Exiting loop
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/firmware/cirrus/cs_dsp.c:2762:7: note: Assuming field 'control_remove' is null
if (dsp->client_ops->control_remove)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2762:3: note: Taking false branch
if (dsp->client_ops->control_remove)
^
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Calling 'cs_dsp_free_ctl_blk'
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:907:2: note: Memory is released
kfree(ctl);
^~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Returning; memory was released
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c30 Simon Trimmer 2021-09-13 1203
f6bc909e7673c30 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1210
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1212
f6bc909e7673c30 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1216
f6bc909e7673c30 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1219
f6bc909e7673c30 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1226
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1228
f6bc909e7673c30 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1232
f6bc909e7673c30 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1235
f6bc909e7673c30 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1249
f6bc909e7673c30 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1259
f6bc909e7673c30 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1277
f6bc909e7673c30 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1279
f6bc909e7673c30 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1286
f6bc909e7673c30 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1288
f6bc909e7673c30 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1293
f6bc909e7673c30 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1299
f6bc909e7673c30 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1302
f6bc909e7673c30 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1308
f6bc909e7673c30 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1311
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1314
f6bc909e7673c30 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1320
f6bc909e7673c30 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1323
f6bc909e7673c30 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c30 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1332
f6bc909e7673c30 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1368
f6bc909e7673c30 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1378
f6bc909e7673c30 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1382
f6bc909e7673c30 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c30 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1392
f6bc909e7673c30 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1399
f6bc909e7673c30 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c30 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1409
f6bc909e7673c30 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1421
f6bc909e7673c30 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1425
f6bc909e7673c30 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1431
f6bc909e7673c30 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1435
f6bc909e7673c30 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1437
f6bc909e7673c30 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1442
f6bc909e7673c30 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1445
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2021-11-25 20:19 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-25 20:19 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 32433 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Simon Trimmer <simont@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5f53fa508db098c9d372423a6dac31c8a5679cdf
commit: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
date: 8 weeks ago
:::::: branch date: 26 hours ago
:::::: commit date: 8 weeks ago
config: mips-randconfig-c004-20211001 (https://download.01.org/0day-ci/archive/20211126/202111260406.Lk8agNyw-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
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 mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 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/net/wireless/ath/ath10k/htt_rx.c:3180:9: note: Calling 'ath10k_htt_rx_pop_paddr32_list'
ret = ath10k_htt_rx_pop_paddr32_list(htt, &resp->rx_in_ord_ind,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ath/ath10k/htt_rx.c:641:2: note: Assuming 'debug_locks' is 0
lockdep_assert_held(&htt->rx_ring.lock);
^
include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/lockdep.h:310:15: note: expanded from macro 'lockdep_assert'
do { WARN_ON(debug_locks && !(cond)); } while (0)
^~~~~~~~~~~
include/asm-generic/bug.h:121:25: note: expanded from macro 'WARN_ON'
int __ret_warn_on = !!(condition); \
^~~~~~~~~
drivers/net/wireless/ath/ath10k/htt_rx.c:641:2: note: Left side of '&&' is false
lockdep_assert_held(&htt->rx_ring.lock);
^
include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
^
include/linux/lockdep.h:310:27: note: expanded from macro 'lockdep_assert'
do { WARN_ON(debug_locks && !(cond)); } while (0)
^
drivers/net/wireless/ath/ath10k/htt_rx.c:641:2: note: Taking false branch
lockdep_assert_held(&htt->rx_ring.lock);
^
include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
^
include/linux/lockdep.h:310:7: note: expanded from macro 'lockdep_assert'
do { WARN_ON(debug_locks && !(cond)); } while (0)
^
include/asm-generic/bug.h:122:2: note: expanded from macro 'WARN_ON'
if (unlikely(__ret_warn_on)) \
^
drivers/net/wireless/ath/ath10k/htt_rx.c:641:2: note: Loop condition is false. Exiting loop
lockdep_assert_held(&htt->rx_ring.lock);
^
include/linux/lockdep.h:316:2: note: expanded from macro 'lockdep_assert_held'
lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD)
^
include/linux/lockdep.h:310:2: note: expanded from macro 'lockdep_assert'
do { WARN_ON(debug_locks && !(cond)); } while (0)
^
drivers/net/wireless/ath/ath10k/htt_rx.c:646:2: note: Loop condition is true. Entering loop body
while (msdu_count--) {
^
drivers/net/wireless/ath/ath10k/htt_rx.c:650:7: note: Assuming 'msdu' is non-null
if (!msdu) {
^~~~~
drivers/net/wireless/ath/ath10k/htt_rx.c:650:3: note: Taking false branch
if (!msdu) {
^
drivers/net/wireless/ath/ath10k/htt_rx.c:655:8: note: 'is_offload' is true
if (!is_offload && ar->monitor_arvif) {
^~~~~~~~~~
drivers/net/wireless/ath/ath10k/htt_rx.c:655:19: note: Left side of '&&' is false
if (!is_offload && ar->monitor_arvif) {
^
drivers/net/wireless/ath/ath10k/htt_rx.c:667:3: note: Calling '__skb_queue_tail'
__skb_queue_tail(list, msdu);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:2081:2: note: Calling '__skb_queue_before'
__skb_queue_before(list, (struct sk_buff *)list, newsk);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/skbuff.h:2048:2: note: 2nd function call argument is an uninitialized value
__skb_insert(newsk, next->prev, next, list);
^ ~~~~~~~~~~
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
2 warnings generated.
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.
3 warnings generated.
Suppressed 3 warnings (3 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.
2 warnings generated.
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.
2 warnings generated.
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.
3 warnings generated.
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: warning: Value stored to 'nbytes' is never read [clang-analyzer-deadcode.DeadStores]
nbytes = rbytes;
^ ~~~~~~
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: note: Value stored to 'nbytes' is never read
nbytes = rbytes;
^ ~~~~~~
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.
7 warnings generated.
>> drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Loop condition is false. Exiting loop
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/firmware/cirrus/cs_dsp.c:2762:7: note: Assuming field 'control_remove' is null
if (dsp->client_ops->control_remove)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2762:3: note: Taking false branch
if (dsp->client_ops->control_remove)
^
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Calling 'cs_dsp_free_ctl_blk'
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:907:2: note: Memory is released
kfree(ctl);
^~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Returning; memory was released
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c3 Simon Trimmer 2021-09-13 1203
f6bc909e7673c3 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1210
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1212
f6bc909e7673c3 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1216
f6bc909e7673c3 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1219
f6bc909e7673c3 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1226
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1228
f6bc909e7673c3 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1232
f6bc909e7673c3 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1235
f6bc909e7673c3 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1249
f6bc909e7673c3 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1259
f6bc909e7673c3 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1277
f6bc909e7673c3 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1279
f6bc909e7673c3 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1286
f6bc909e7673c3 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1288
f6bc909e7673c3 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1293
f6bc909e7673c3 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1299
f6bc909e7673c3 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1302
f6bc909e7673c3 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1308
f6bc909e7673c3 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1311
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1314
f6bc909e7673c3 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1320
f6bc909e7673c3 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1323
f6bc909e7673c3 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c3 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1332
f6bc909e7673c3 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1368
f6bc909e7673c3 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1378
f6bc909e7673c3 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1382
f6bc909e7673c3 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c3 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1392
f6bc909e7673c3 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1399
f6bc909e7673c3 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c3 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1409
f6bc909e7673c3 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1421
f6bc909e7673c3 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1425
f6bc909e7673c3 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1431
f6bc909e7673c3 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1435
f6bc909e7673c3 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1437
f6bc909e7673c3 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1442
f6bc909e7673c3 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1445
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2021-11-16 1:14 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-16 1:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 33100 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Simon Trimmer <simont@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8ab774587903771821b59471cc723bba6d893942
commit: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
date: 7 weeks ago
:::::: branch date: 22 hours ago
:::::: commit date: 7 weeks ago
config: riscv-randconfig-c006-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 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 >>)
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
^
drivers/hid/usbhid/usbhid.h:94:2: note: expanded from macro 'hid_to_usb_dev'
to_usb_device(hid_dev->dev.parent->parent)
^
include/linux/usb.h:708:26: note: expanded from macro 'to_usb_device'
#define to_usb_device(d) container_of(d, struct usb_device, dev)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/hid/hid-logitech-hidpp.c:2548:48: note: Taking false branch
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
^
drivers/hid/usbhid/usbhid.h:94:2: note: expanded from macro 'hid_to_usb_dev'
to_usb_device(hid_dev->dev.parent->parent)
^
include/linux/usb.h:708:26: note: expanded from macro 'to_usb_device'
#define to_usb_device(d) container_of(d, struct usb_device, dev)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/hid/hid-logitech-hidpp.c:2548:48: note: Loop condition is false. Exiting loop
const struct usb_device_descriptor *udesc = &(hid_to_usb_dev(hid)->descriptor);
^
drivers/hid/usbhid/usbhid.h:94:2: note: expanded from macro 'hid_to_usb_dev'
to_usb_device(hid_dev->dev.parent->parent)
^
include/linux/usb.h:708:26: note: expanded from macro 'to_usb_device'
#define to_usb_device(d) container_of(d, struct usb_device, dev)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/hid/hid-logitech-hidpp.c:2551:16: note: Assigned value is garbage or undefined
int error, j, num_slots = data->num_effects;
^ ~~~~~~~~~~~~~~~~~
Suppressed 4 warnings (4 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.
drivers/leds/flash/leds-lm3601x.c:226:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_CFG_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:226:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_CFG_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:230:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:230:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:234:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:234:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 3 warnings (3 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: warning: Value stored to 'nbytes' is never read [clang-analyzer-deadcode.DeadStores]
nbytes = rbytes;
^ ~~~~~~
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: note: Value stored to 'nbytes' is never read
nbytes = rbytes;
^ ~~~~~~
Suppressed 3 warnings (3 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.
7 warnings generated.
>> drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Loop condition is false. Exiting loop
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/firmware/cirrus/cs_dsp.c:2762:7: note: Assuming field 'control_remove' is null
if (dsp->client_ops->control_remove)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2762:3: note: Taking false branch
if (dsp->client_ops->control_remove)
^
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Calling 'cs_dsp_free_ctl_blk'
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:907:2: note: Memory is released
kfree(ctl);
^~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Returning; memory was released
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c3 Simon Trimmer 2021-09-13 1203
f6bc909e7673c3 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1210
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1212
f6bc909e7673c3 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1216
f6bc909e7673c3 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1219
f6bc909e7673c3 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1226
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1228
f6bc909e7673c3 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1232
f6bc909e7673c3 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1235
f6bc909e7673c3 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1249
f6bc909e7673c3 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1259
f6bc909e7673c3 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1277
f6bc909e7673c3 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1279
f6bc909e7673c3 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1286
f6bc909e7673c3 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1288
f6bc909e7673c3 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1293
f6bc909e7673c3 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1299
f6bc909e7673c3 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1302
f6bc909e7673c3 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1308
f6bc909e7673c3 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1311
f6bc909e7673c3 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c3 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1314
f6bc909e7673c3 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1320
f6bc909e7673c3 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1323
f6bc909e7673c3 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c3 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1332
f6bc909e7673c3 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c3 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1368
f6bc909e7673c3 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1378
f6bc909e7673c3 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1382
f6bc909e7673c3 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c3 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1392
f6bc909e7673c3 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1399
f6bc909e7673c3 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c3 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c3 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1409
f6bc909e7673c3 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c3 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c3 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1421
f6bc909e7673c3 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1425
f6bc909e7673c3 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c3 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1431
f6bc909e7673c3 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c3 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c3 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1435
f6bc909e7673c3 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1437
f6bc909e7673c3 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c3 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c3 Simon Trimmer 2021-09-13 1442
f6bc909e7673c3 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c3 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c3 Simon Trimmer 2021-09-13 1445
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37343 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
@ 2021-11-05 19:41 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-11-05 19:41 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 33598 bytes --]
CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Simon Trimmer <simont@opensource.cirrus.com>
CC: Mark Brown <broonie@kernel.org>
CC: Charles Keepax <ckeepax@opensource.cirrus.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fe91c4725aeed35023ba4f7a1e1adfebb6878c23
commit: f6bc909e7673c30abcbdb329e7d0aa2e83c103d7 firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs
date: 6 weeks ago
:::::: branch date: 4 hours ago
:::::: commit date: 6 weeks ago
config: riscv-randconfig-c006-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout f6bc909e7673c30abcbdb329e7d0aa2e83c103d7
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 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 >>)
3 warnings generated.
Suppressed 3 warnings (3 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.
5 warnings generated.
fs/fscache/page.c:992:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = -ENOBUFS;
^ ~~~~~~~~
fs/fscache/page.c:992:2: note: Value stored to 'ret' is never read
ret = -ENOBUFS;
^ ~~~~~~~~
fs/fscache/page.c:1074:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = -ENOBUFS;
^ ~~~~~~~~
fs/fscache/page.c:1074:2: note: Value stored to 'ret' is never read
ret = -ENOBUFS;
^ ~~~~~~~~
Suppressed 3 warnings (3 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.
3 warnings generated.
Suppressed 3 warnings (3 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
5 warnings generated.
drivers/leds/flash/leds-as3645a.c:382:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
struct device *dev = &flash->client->dev;
^~~ ~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-as3645a.c:382:17: note: Value stored to 'dev' during its initialization is never read
struct device *dev = &flash->client->dev;
^~~ ~~~~~~~~~~~~~~~~~~~
Suppressed 4 warnings (4 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.
drivers/leds/flash/leds-lm3601x.c:226:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_CFG_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:226:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_CFG_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:230:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:230:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:234:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/leds/flash/leds-lm3601x.c:234:3: note: Value stored to 'ret' is never read
ret = regmap_update_bits(led->regmap, LM3601X_ENABLE_REG,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppressed 3 warnings (3 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
Suppressed 4 warnings (4 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.
4 warnings generated.
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: warning: Value stored to 'nbytes' is never read [clang-analyzer-deadcode.DeadStores]
nbytes = rbytes;
^ ~~~~~~
drivers/firmware/broadcom/tee_bnxt_fw.c:146:3: note: Value stored to 'nbytes' is never read
nbytes = rbytes;
^ ~~~~~~
Suppressed 3 warnings (3 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.
7 warnings generated.
>> drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1211:2: note: Value stored to 'adsp1_sizes' is never read
adsp1_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1227:2: warning: Value stored to 'adsp2_sizes' is never read [clang-analyzer-deadcode.DeadStores]
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1227:2: note: Value stored to 'adsp2_sizes' is never read
adsp2_sizes = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/firmware/cirrus/cs_dsp.c:1312:2: warning: Value stored to 'footer' is never read [clang-analyzer-deadcode.DeadStores]
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:1312:2: note: Value stored to 'footer' is never read
footer = (void *)&firmware->data[pos];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:135:13: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
__list_del(entry->prev, entry->next);
^
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:302:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Loop condition is false. Exiting loop
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:322:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:310:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:300:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/firmware/cirrus/cs_dsp.c:2762:7: note: Assuming field 'control_remove' is null
if (dsp->client_ops->control_remove)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2762:3: note: Taking false branch
if (dsp->client_ops->control_remove)
^
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Calling 'cs_dsp_free_ctl_blk'
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:907:2: note: Memory is released
kfree(ctl);
^~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2766:3: note: Returning; memory was released
cs_dsp_free_ctl_blk(ctl);
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/firmware/cirrus/cs_dsp.c:2759:2: note: Loop condition is true. Entering loop body
while (!list_empty(&dsp->ctl_list)) {
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Left side of '&&' is false
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
list_entry((ptr)->next, type, member)
^
include/linux/list.h:511:2: note: expanded from macro 'list_entry'
container_of(ptr, type, member)
^
include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
^
drivers/firmware/cirrus/cs_dsp.c:2760:9: note: Taking false branch
ctl = list_first_entry(&dsp->ctl_list, struct cs_dsp_coeff_ctl, list);
^
vim +/adsp1_sizes +1211 drivers/firmware/cirrus/cs_dsp.c
f6bc909e7673c30 Simon Trimmer 2021-09-13 1203
f6bc909e7673c30 Simon Trimmer 2021-09-13 1204 static unsigned int cs_dsp_adsp1_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1205 const char * const file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1206 unsigned int pos,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1207 const struct firmware *firmware)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1208 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1209 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1210
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1211 adsp1_sizes = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1212
f6bc909e7673c30 Simon Trimmer 2021-09-13 1213 cs_dsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1214 le32_to_cpu(adsp1_sizes->dm), le32_to_cpu(adsp1_sizes->pm),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1215 le32_to_cpu(adsp1_sizes->zm));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1216
f6bc909e7673c30 Simon Trimmer 2021-09-13 1217 return pos + sizeof(*adsp1_sizes);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1218 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1219
f6bc909e7673c30 Simon Trimmer 2021-09-13 1220 static unsigned int cs_dsp_adsp2_parse_sizes(struct cs_dsp *dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1221 const char * const file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1222 unsigned int pos,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1223 const struct firmware *firmware)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1224 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1225 const struct wmfw_adsp2_sizes *adsp2_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1226
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1227 adsp2_sizes = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1228
f6bc909e7673c30 Simon Trimmer 2021-09-13 1229 cs_dsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1230 le32_to_cpu(adsp2_sizes->xm), le32_to_cpu(adsp2_sizes->ym),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1231 le32_to_cpu(adsp2_sizes->pm), le32_to_cpu(adsp2_sizes->zm));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1232
f6bc909e7673c30 Simon Trimmer 2021-09-13 1233 return pos + sizeof(*adsp2_sizes);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1234 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1235
f6bc909e7673c30 Simon Trimmer 2021-09-13 1236 static bool cs_dsp_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1237 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1238 switch (version) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1239 case 0:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1240 cs_dsp_warn(dsp, "Deprecated file format %d\n", version);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1241 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1242 case 1:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1243 case 2:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1244 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1245 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1246 return false;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1247 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1248 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1249
f6bc909e7673c30 Simon Trimmer 2021-09-13 1250 static bool cs_dsp_halo_validate_version(struct cs_dsp *dsp, unsigned int version)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1251 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1252 switch (version) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1253 case 3:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1254 return true;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1255 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1256 return false;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1257 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1258 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1259
f6bc909e7673c30 Simon Trimmer 2021-09-13 1260 static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1261 const char *file)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1262 {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1263 LIST_HEAD(buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1264 struct regmap *regmap = dsp->regmap;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1265 unsigned int pos = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1266 const struct wmfw_header *header;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1267 const struct wmfw_adsp1_sizes *adsp1_sizes;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1268 const struct wmfw_footer *footer;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1269 const struct wmfw_region *region;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1270 const struct cs_dsp_region *mem;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1271 const char *region_name;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1272 char *text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1273 struct cs_dsp_buf *buf;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1274 unsigned int reg;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1275 int regions = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1276 int ret, offset, type;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1277
f6bc909e7673c30 Simon Trimmer 2021-09-13 1278 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1279
f6bc909e7673c30 Simon Trimmer 2021-09-13 1280 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1281 if (pos >= firmware->size) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1282 cs_dsp_err(dsp, "%s: file too short, %zu bytes\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1283 file, firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1284 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1285 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1286
f6bc909e7673c30 Simon Trimmer 2021-09-13 1287 header = (void *)&firmware->data[0];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1288
f6bc909e7673c30 Simon Trimmer 2021-09-13 1289 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1290 cs_dsp_err(dsp, "%s: invalid magic\n", file);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1291 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1292 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1293
f6bc909e7673c30 Simon Trimmer 2021-09-13 1294 if (!dsp->ops->validate_version(dsp, header->ver)) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1295 cs_dsp_err(dsp, "%s: unknown file format %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1296 file, header->ver);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1297 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1298 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1299
f6bc909e7673c30 Simon Trimmer 2021-09-13 1300 cs_dsp_info(dsp, "Firmware version: %d\n", header->ver);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1301 dsp->fw_ver = header->ver;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1302
f6bc909e7673c30 Simon Trimmer 2021-09-13 1303 if (header->core != dsp->type) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1304 cs_dsp_err(dsp, "%s: invalid core %d != %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1305 file, header->core, dsp->type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1306 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1307 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1308
f6bc909e7673c30 Simon Trimmer 2021-09-13 1309 pos = sizeof(*header);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1310 pos = dsp->ops->parse_sizes(dsp, file, pos, firmware);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1311
f6bc909e7673c30 Simon Trimmer 2021-09-13 @1312 footer = (void *)&firmware->data[pos];
f6bc909e7673c30 Simon Trimmer 2021-09-13 1313 pos += sizeof(*footer);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1314
f6bc909e7673c30 Simon Trimmer 2021-09-13 1315 if (le32_to_cpu(header->len) != pos) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1316 cs_dsp_err(dsp, "%s: unexpected header length %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1317 file, le32_to_cpu(header->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1318 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1319 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1320
f6bc909e7673c30 Simon Trimmer 2021-09-13 1321 cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1322 le64_to_cpu(footer->timestamp));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1323
f6bc909e7673c30 Simon Trimmer 2021-09-13 1324 while (pos < firmware->size &&
f6bc909e7673c30 Simon Trimmer 2021-09-13 1325 sizeof(*region) < firmware->size - pos) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1326 region = (void *)&(firmware->data[pos]);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1327 region_name = "Unknown";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1328 reg = 0;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1329 text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1330 offset = le32_to_cpu(region->offset) & 0xffffff;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1331 type = be32_to_cpu(region->type) & 0xff;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1332
f6bc909e7673c30 Simon Trimmer 2021-09-13 1333 switch (type) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1334 case WMFW_NAME_TEXT:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1335 region_name = "Firmware name";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1336 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1337 GFP_KERNEL);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1338 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1339 case WMFW_ALGORITHM_DATA:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1340 region_name = "Algorithm";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1341 ret = cs_dsp_parse_coeff(dsp, region);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1342 if (ret != 0)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1343 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1344 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1345 case WMFW_INFO_TEXT:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1346 region_name = "Information";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1347 text = kzalloc(le32_to_cpu(region->len) + 1,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1348 GFP_KERNEL);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1349 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1350 case WMFW_ABSOLUTE:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1351 region_name = "Absolute";
f6bc909e7673c30 Simon Trimmer 2021-09-13 1352 reg = offset;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1353 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1354 case WMFW_ADSP1_PM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1355 case WMFW_ADSP1_DM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1356 case WMFW_ADSP2_XM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1357 case WMFW_ADSP2_YM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1358 case WMFW_ADSP1_ZM:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1359 case WMFW_HALO_PM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1360 case WMFW_HALO_XM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1361 case WMFW_HALO_YM_PACKED:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1362 mem = cs_dsp_find_region(dsp, type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1363 if (!mem) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1364 cs_dsp_err(dsp, "No region of type: %x\n", type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1365 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1366 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1367 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1368
f6bc909e7673c30 Simon Trimmer 2021-09-13 1369 region_name = cs_dsp_mem_region_name(type);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1370 reg = dsp->ops->region_to_reg(mem, offset);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1371 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1372 default:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1373 cs_dsp_warn(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1374 "%s.%d: Unknown region type %x at %d(%x)\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1375 file, regions, type, pos, pos);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1376 break;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1377 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1378
f6bc909e7673c30 Simon Trimmer 2021-09-13 1379 cs_dsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1380 regions, le32_to_cpu(region->len), offset,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1381 region_name);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1382
f6bc909e7673c30 Simon Trimmer 2021-09-13 1383 if (le32_to_cpu(region->len) >
f6bc909e7673c30 Simon Trimmer 2021-09-13 1384 firmware->size - pos - sizeof(*region)) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1385 cs_dsp_err(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1386 "%s.%d: %s region len %d bytes exceeds file length %zu\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1387 file, regions, region_name,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1388 le32_to_cpu(region->len), firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1389 ret = -EINVAL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1390 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1391 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1392
f6bc909e7673c30 Simon Trimmer 2021-09-13 1393 if (text) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1394 memcpy(text, region->data, le32_to_cpu(region->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1395 cs_dsp_info(dsp, "%s: %s\n", file, text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1396 kfree(text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1397 text = NULL;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1398 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1399
f6bc909e7673c30 Simon Trimmer 2021-09-13 1400 if (reg) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1401 buf = cs_dsp_buf_alloc(region->data,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1402 le32_to_cpu(region->len),
f6bc909e7673c30 Simon Trimmer 2021-09-13 1403 &buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1404 if (!buf) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1405 cs_dsp_err(dsp, "Out of memory\n");
f6bc909e7673c30 Simon Trimmer 2021-09-13 1406 ret = -ENOMEM;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1407 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1408 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1409
f6bc909e7673c30 Simon Trimmer 2021-09-13 1410 ret = regmap_raw_write_async(regmap, reg, buf->buf,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1411 le32_to_cpu(region->len));
f6bc909e7673c30 Simon Trimmer 2021-09-13 1412 if (ret != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1413 cs_dsp_err(dsp,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1414 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1415 file, regions,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1416 le32_to_cpu(region->len), offset,
f6bc909e7673c30 Simon Trimmer 2021-09-13 1417 region_name, ret);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1418 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1419 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1420 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1421
f6bc909e7673c30 Simon Trimmer 2021-09-13 1422 pos += le32_to_cpu(region->len) + sizeof(*region);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1423 regions++;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1424 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1425
f6bc909e7673c30 Simon Trimmer 2021-09-13 1426 ret = regmap_async_complete(regmap);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1427 if (ret != 0) {
f6bc909e7673c30 Simon Trimmer 2021-09-13 1428 cs_dsp_err(dsp, "Failed to complete async write: %d\n", ret);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1429 goto out_fw;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1430 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1431
f6bc909e7673c30 Simon Trimmer 2021-09-13 1432 if (pos > firmware->size)
f6bc909e7673c30 Simon Trimmer 2021-09-13 1433 cs_dsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
f6bc909e7673c30 Simon Trimmer 2021-09-13 1434 file, regions, pos - firmware->size);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1435
f6bc909e7673c30 Simon Trimmer 2021-09-13 1436 cs_dsp_debugfs_save_wmfwname(dsp, file);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1437
f6bc909e7673c30 Simon Trimmer 2021-09-13 1438 out_fw:
f6bc909e7673c30 Simon Trimmer 2021-09-13 1439 regmap_async_complete(regmap);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1440 cs_dsp_buf_free(&buf_list);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1441 kfree(text);
f6bc909e7673c30 Simon Trimmer 2021-09-13 1442
f6bc909e7673c30 Simon Trimmer 2021-09-13 1443 return ret;
f6bc909e7673c30 Simon Trimmer 2021-09-13 1444 }
f6bc909e7673c30 Simon Trimmer 2021-09-13 1445
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37342 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-31 22:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 22:20 drivers/firmware/cirrus/cs_dsp.c:1211:2: warning: Value stored to 'adsp1_sizes' is never read [clang-analyzer-deadcode.DeadStores] kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-02-25 22:38 kernel test robot
2022-01-28 2:26 kernel test robot
2021-11-25 20:19 kernel test robot
2021-11-16 1:14 kernel test robot
2021-11-05 19:41 kernel test robot
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.