[alsa-devel] [asoc:for-5.1 263/274] sound/soc/codecs/wm_adsp.c:3441:23: sparse: warning: restricted __be32 degrades to integer
tree: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.1 head: 7b6b0049e2b70d103adf1b7d0320802f70ddceca commit: 4f2d4eabf57718875b97363a3bd35de490f354c5 [263/274] ASoC: wm_adsp: Add support for multiple compressed buffers reproduce: # apt-get install sparse git checkout 4f2d4eabf57718875b97363a3bd35de490f354c5 make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
All warnings (new ones prefixed by >>):
sound/soc/codecs/wm_adsp.c:880:19: sparse: warning: incorrect type in initializer (different base types) sound/soc/codecs/wm_adsp.c:880:19: sparse: expected unsigned int [usertype] val sound/soc/codecs/wm_adsp.c:880:19: sparse: got restricted __be32 [usertype] sound/soc/codecs/wm_adsp.c:1586:22: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/soc/codecs/wm_adsp.c:2057:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2057:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2057:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2078:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2078:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2078:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2171:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2171:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2171:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2192:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2192:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2192:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2213:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2213:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2213:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3242:14: sparse: warning: incorrect type in assignment (different base types) sound/soc/codecs/wm_adsp.c:3242:14: sparse: expected unsigned int [usertype] data sound/soc/codecs/wm_adsp.c:3242:14: sparse: got restricted __be32 [usertype] sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3440:27: sparse: warning: incorrect type in assignment (different base types) sound/soc/codecs/wm_adsp.c:3440:27: sparse: expected restricted __be32 [addressable] [usertype] versions sound/soc/codecs/wm_adsp.c:3440:27: sparse: got unsigned int
sound/soc/codecs/wm_adsp.c:3441:23: sparse: warning: restricted __be32 degrades to integer
sound/soc/codecs/wm_adsp.c:3452:34: sparse: warning: incorrect type in assignment (different base types) sound/soc/codecs/wm_adsp.c:3452:34: sparse: expected restricted __be32 sound/soc/codecs/wm_adsp.c:3452:34: sparse: got unsigned int
sparse warnings: (new ones prefixed by >>)
sound/soc/codecs/wm_adsp.c:880:19: sparse: warning: incorrect type in initializer (different base types) sound/soc/codecs/wm_adsp.c:880:19: sparse: expected unsigned int [usertype] val sound/soc/codecs/wm_adsp.c:880:19: sparse: got restricted __be32 [usertype] sound/soc/codecs/wm_adsp.c:1586:22: sparse: warning: restricted snd_ctl_elem_type_t degrades to integer sound/soc/codecs/wm_adsp.c:2057:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2057:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2057:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2078:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2078:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2078:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2171:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2171:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2171:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2192:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2192:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2192:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:2213:54: sparse: warning: incorrect type in argument 8 (different base types) sound/soc/codecs/wm_adsp.c:2213:54: sparse: expected unsigned int type sound/soc/codecs/wm_adsp.c:2213:54: sparse: got restricted snd_ctl_elem_type_t [usertype] sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3220:27: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3242:14: sparse: warning: incorrect type in assignment (different base types) sound/soc/codecs/wm_adsp.c:3242:14: sparse: expected unsigned int [usertype] data sound/soc/codecs/wm_adsp.c:3242:14: sparse: got restricted __be32 [usertype] sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3420:29: sparse: warning: cast to restricted __be32 sound/soc/codecs/wm_adsp.c:3440:27: sparse: warning: incorrect type in assignment (different base types)
sound/soc/codecs/wm_adsp.c:3440:27: sparse: expected restricted __be32 [addressable] [usertype] versions sound/soc/codecs/wm_adsp.c:3440:27: sparse: got unsigned int
sound/soc/codecs/wm_adsp.c:3441:23: sparse: warning: restricted __be32 degrades to integer sound/soc/codecs/wm_adsp.c:3452:34: sparse: warning: incorrect type in assignment (different base types)
sound/soc/codecs/wm_adsp.c:3452:34: sparse: expected restricted __be32
sound/soc/codecs/wm_adsp.c:3452:34: sparse: got unsigned int
vim +3441 sound/soc/codecs/wm_adsp.c
3230 3231 static int wm_adsp_write_data_word(struct wm_adsp *dsp, int mem_type, 3232 unsigned int mem_addr, u32 data) 3233 { 3234 struct wm_adsp_region const *mem = wm_adsp_find_region(dsp, mem_type); 3235 unsigned int reg; 3236 3237 if (!mem) 3238 return -EINVAL; 3239 3240 reg = wm_adsp_region_to_reg(mem, mem_addr); 3241
3242 data = cpu_to_be32(data & 0x00ffffffu);
3243 3244 return regmap_raw_write(dsp->regmap, reg, &data, sizeof(data)); 3245 } 3246 3247 static inline int wm_adsp_buffer_read(struct wm_adsp_compr_buf *buf, 3248 unsigned int field_offset, u32 *data) 3249 { 3250 return wm_adsp_read_data_word(buf->dsp, buf->host_buf_mem_type, 3251 buf->host_buf_ptr + field_offset, data); 3252 } 3253 3254 static inline int wm_adsp_buffer_write(struct wm_adsp_compr_buf *buf, 3255 unsigned int field_offset, u32 data) 3256 { 3257 return wm_adsp_write_data_word(buf->dsp, buf->host_buf_mem_type, 3258 buf->host_buf_ptr + field_offset, data); 3259 } 3260 3261 static void wm_adsp_remove_padding(u32 *buf, int nwords, int data_word_size) 3262 { 3263 u8 *pack_in = (u8 *)buf; 3264 u8 *pack_out = (u8 *)buf; 3265 int i, j; 3266 3267 /* Remove the padding bytes from the data read from the DSP */ 3268 for (i = 0; i < nwords; i++) { 3269 for (j = 0; j < data_word_size; j++) 3270 *pack_out++ = *pack_in++; 3271 3272 pack_in += sizeof(*buf) - data_word_size; 3273 } 3274 } 3275 3276 static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf) 3277 { 3278 const struct wm_adsp_fw_caps *caps = wm_adsp_fw[buf->dsp->fw].caps; 3279 struct wm_adsp_buffer_region *region; 3280 u32 offset = 0; 3281 int i, ret; 3282 3283 buf->regions = kcalloc(caps->num_regions, sizeof(*buf->regions), 3284 GFP_KERNEL); 3285 if (!buf->regions) 3286 return -ENOMEM; 3287 3288 for (i = 0; i < caps->num_regions; ++i) { 3289 region = &buf->regions[i]; 3290 3291 region->offset = offset; 3292 region->mem_type = caps->region_defs[i].mem_type; 3293 3294 ret = wm_adsp_buffer_read(buf, caps->region_defs[i].base_offset, 3295 ®ion->base_addr); 3296 if (ret < 0) 3297 return ret; 3298 3299 ret = wm_adsp_buffer_read(buf, caps->region_defs[i].size_offset, 3300 &offset); 3301 if (ret < 0) 3302 return ret; 3303 3304 region->cumulative_size = offset; 3305 3306 adsp_dbg(buf->dsp, 3307 "region=%d type=%d base=%08x off=%08x size=%08x\n", 3308 i, region->mem_type, region->base_addr, 3309 region->offset, region->cumulative_size); 3310 } 3311 3312 return 0; 3313 } 3314 3315 static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf) 3316 { 3317 buf->irq_count = 0xFFFFFFFF; 3318 buf->read_index = -1; 3319 buf->avail = 0; 3320 } 3321 3322 static struct wm_adsp_compr_buf *wm_adsp_buffer_alloc(struct wm_adsp *dsp) 3323 { 3324 struct wm_adsp_compr_buf *buf; 3325 3326 buf = kzalloc(sizeof(*buf), GFP_KERNEL); 3327 if (!buf) 3328 return NULL; 3329 3330 buf->dsp = dsp; 3331 3332 wm_adsp_buffer_clear(buf); 3333 3334 list_add_tail(&buf->list, &dsp->buffer_list); 3335 3336 return buf; 3337 } 3338 3339 static int wm_adsp_buffer_parse_legacy(struct wm_adsp *dsp) 3340 { 3341 struct wm_adsp_alg_region *alg_region; 3342 struct wm_adsp_compr_buf *buf; 3343 u32 xmalg, addr, magic; 3344 int i, ret; 3345 3346 buf = wm_adsp_buffer_alloc(dsp); 3347 if (!buf) 3348 return -ENOMEM; 3349 3350 alg_region = wm_adsp_find_alg_region(dsp, WMFW_ADSP2_XM, dsp->fw_id); 3351 xmalg = sizeof(struct wm_adsp_system_config_xm_hdr) / sizeof(__be32); 3352 3353 addr = alg_region->base + xmalg + ALG_XM_FIELD(magic); 3354 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, &magic); 3355 if (ret < 0) 3356 return ret; 3357 3358 if (magic != WM_ADSP_ALG_XM_STRUCT_MAGIC) 3359 return -ENODEV; 3360 3361 addr = alg_region->base + xmalg + ALG_XM_FIELD(host_buf_ptr); 3362 for (i = 0; i < 5; ++i) { 3363 ret = wm_adsp_read_data_word(dsp, WMFW_ADSP2_XM, addr, 3364 &buf->host_buf_ptr); 3365 if (ret < 0) 3366 return ret; 3367 3368 if (buf->host_buf_ptr) 3369 break; 3370 3371 usleep_range(1000, 2000); 3372 } 3373 3374 if (!buf->host_buf_ptr) 3375 return -EIO; 3376 3377 buf->host_buf_mem_type = WMFW_ADSP2_XM; 3378 3379 ret = wm_adsp_buffer_populate(buf); 3380 if (ret < 0) 3381 return ret; 3382 3383 adsp_dbg(dsp, "legacy host_buf_ptr=%x\n", buf->host_buf_ptr); 3384 3385 return 0; 3386 } 3387 3388 static int wm_adsp_buffer_parse_coeff(struct wm_coeff_ctl *ctl) 3389 { 3390 struct wm_adsp_host_buf_coeff_v1 coeff_v1; 3391 struct wm_adsp_compr_buf *buf; 3392 unsigned int val, reg; 3393 int ret, i; 3394 3395 ret = wm_coeff_base_reg(ctl, ®); 3396 if (ret) 3397 return ret; 3398 3399 for (i = 0; i < 5; ++i) { 3400 ret = regmap_raw_read(ctl->dsp->regmap, reg, &val, sizeof(val)); 3401 if (ret < 0) 3402 return ret; 3403 3404 if (val) 3405 break; 3406 3407 usleep_range(1000, 2000); 3408 } 3409 3410 if (!val) { 3411 adsp_err(ctl->dsp, "Failed to acquire host buffer\n"); 3412 return -EIO; 3413 } 3414 3415 buf = wm_adsp_buffer_alloc(ctl->dsp); 3416 if (!buf) 3417 return -ENOMEM; 3418 3419 buf->host_buf_mem_type = ctl->alg_region.type;
3420 buf->host_buf_ptr = be32_to_cpu(val);
3421 3422 ret = wm_adsp_buffer_populate(buf); 3423 if (ret < 0) 3424 return ret; 3425 3426 /* 3427 * v0 host_buffer coefficients didn't have versioning, so if the 3428 * control is one word, assume version 0. 3429 */ 3430 if (ctl->len == 4) { 3431 adsp_dbg(ctl->dsp, "host_buf_ptr=%x\n", buf->host_buf_ptr); 3432 return 0; 3433 } 3434 3435 ret = regmap_raw_read(ctl->dsp->regmap, reg, &coeff_v1, 3436 sizeof(coeff_v1)); 3437 if (ret < 0) 3438 return ret; 3439
3440 coeff_v1.versions = be32_to_cpu(coeff_v1.versions); 3441 val = coeff_v1.versions & HOST_BUF_COEFF_COMPAT_VER_MASK;
3442 val >>= HOST_BUF_COEFF_COMPAT_VER_SHIFT; 3443 3444 if (val > HOST_BUF_COEFF_SUPPORTED_COMPAT_VER) { 3445 adsp_err(ctl->dsp, 3446 "Host buffer coeff ver %u > supported version %u\n", 3447 val, HOST_BUF_COEFF_SUPPORTED_COMPAT_VER); 3448 return -EINVAL; 3449 } 3450 3451 for (i = 0; i < ARRAY_SIZE(coeff_v1.name); i++)
3452 coeff_v1.name[i] = be32_to_cpu(coeff_v1.name[i]);
3453 3454 wm_adsp_remove_padding((u32 *)&coeff_v1.name, 3455 ARRAY_SIZE(coeff_v1.name), 3456 WM_ADSP_DATA_WORD_SIZE); 3457 3458 buf->name = kasprintf(GFP_KERNEL, "%s-dsp-%s", ctl->dsp->part, 3459 (char *)&coeff_v1.name); 3460 3461 adsp_dbg(ctl->dsp, "host_buf_ptr=%x coeff version %u\n", 3462 buf->host_buf_ptr, val); 3463 3464 return val; 3465 } 3466
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
participants (1)
-
kbuild test robot