[freescale-fslc:pr/416 15428/20667] sound/soc/fsl/imx-pcm512x.c:429:9: warning: 'memcpy' reading 360 bytes from a region of size 120
by kernel test robot
tree: https://github.com/Freescale/linux-fslc pr/416
head: 915e71b823c877d351de1cbe650344ef6eace94b
commit: a452c44357d9c68c27c39327e50b41e4b6cffe8d [15428/20667] MLK-25015: sound: soc: codecs: pcm512x: set input sclk
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 11.2.0
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
# https://github.com/Freescale/linux-fslc/commit/a452c44357d9c68c27c39327e5...
git remote add freescale-fslc https://github.com/Freescale/linux-fslc
git fetch --no-tags freescale-fslc pr/416
git checkout a452c44357d9c68c27c39327e50b41e4b6cffe8d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
226 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ^~
sound/soc/fsl/imx-pcm512x.c:246:21: note: in expansion of macro 'do_div'
246 | if (do_div(sample_rate, 8000)) {
| ^~~~~~
In file included from include/linux/kernel.h:11,
from include/linux/list.h:9,
from include/linux/module.h:9,
from sound/soc/fsl/imx-pcm512x.c:13:
include/asm-generic/div64.h:239:32: warning: right shift count >= width of type [-Wshift-count-overflow]
239 | } else if (likely(((n) >> 32) == 0)) { \
| ^~
include/linux/compiler.h:77:45: note: in definition of macro 'likely'
77 | # define likely(x) __builtin_expect(!!(x), 1)
| ^
sound/soc/fsl/imx-pcm512x.c:246:21: note: in expansion of macro 'do_div'
246 | if (do_div(sample_rate, 8000)) {
| ^~~~~~
In file included from ./arch/parisc/include/generated/asm/div64.h:1,
from include/linux/kernel.h:18,
from include/linux/list.h:9,
from include/linux/module.h:9,
from sound/soc/fsl/imx-pcm512x.c:13:
include/asm-generic/div64.h:243:36: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types]
243 | __rem = __div64_32(&(n), __base); \
| ^~~~
| |
| unsigned int *
sound/soc/fsl/imx-pcm512x.c:246:21: note: in expansion of macro 'do_div'
246 | if (do_div(sample_rate, 8000)) {
| ^~~~~~
include/asm-generic/div64.h:217:38: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'unsigned int *'
217 | extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
| ~~~~~~~~~~^~~~~~~~
In file included from sound/soc/fsl/imx-pcm512x.c:21:
sound/soc/fsl/imx-pcm512x.c: At top level:
sound/soc/fsl/imx-pcm512x.c:357:37: warning: initialized field overwritten [-Woverride-init]
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~
include/sound/soc.h:919:27: note: in definition of macro 'SND_SOC_DAILINK_REG3'
919 | .codecs = codec, \
| ^~~~~
include/sound/soc.h:924:53: note: in expansion of macro 'SND_SOC_DAILINK_REG1'
924 | #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
| ^~~~
sound/soc/fsl/imx-pcm512x.c:357:17: note: in expansion of macro 'SND_SOC_DAILINK_REG'
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm512x.c:357:37: note: (near initialization for 'imx_pcm512x_dai[0].codecs')
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~
include/sound/soc.h:919:27: note: in definition of macro 'SND_SOC_DAILINK_REG3'
919 | .codecs = codec, \
| ^~~~~
include/sound/soc.h:924:53: note: in expansion of macro 'SND_SOC_DAILINK_REG1'
924 | #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
| ^~~~
sound/soc/fsl/imx-pcm512x.c:357:17: note: in expansion of macro 'SND_SOC_DAILINK_REG'
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/list.h:9,
from include/linux/module.h:9,
from sound/soc/fsl/imx-pcm512x.c:13:
include/linux/kernel.h:47:25: warning: initialized field overwritten [-Woverride-init]
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^
include/sound/soc.h:920:27: note: in expansion of macro 'ARRAY_SIZE'
920 | .num_codecs = ARRAY_SIZE(codec), \
| ^~~~~~~~~~
include/sound/soc.h:914:42: note: in expansion of macro 'SND_SOC_DAILINK_REG3'
914 | #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
| ^~~~~~~~~~~~~~~~~~~~
include/sound/soc.h:924:53: note: in expansion of macro 'SND_SOC_DAILINK_REG1'
924 | #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
| ^~~~
include/sound/soc.h:926:9: note: in expansion of macro 'SND_SOC_DAILINK_REGx'
926 | SND_SOC_DAILINK_REGx(__VA_ARGS__, \
| ^~~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm512x.c:357:17: note: in expansion of macro 'SND_SOC_DAILINK_REG'
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:47:25: note: (near initialization for 'imx_pcm512x_dai[0].num_codecs')
47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^
include/sound/soc.h:920:27: note: in expansion of macro 'ARRAY_SIZE'
920 | .num_codecs = ARRAY_SIZE(codec), \
| ^~~~~~~~~~
include/sound/soc.h:914:42: note: in expansion of macro 'SND_SOC_DAILINK_REG3'
914 | #define SND_SOC_DAILINK_REG1(name) SND_SOC_DAILINK_REG3(name##_cpus, name##_codecs, name##_platforms)
| ^~~~~~~~~~~~~~~~~~~~
include/sound/soc.h:924:53: note: in expansion of macro 'SND_SOC_DAILINK_REG1'
924 | #define SND_SOC_DAILINK_REGx(_1, _2, _3, func, ...) func
| ^~~~
include/sound/soc.h:926:9: note: in expansion of macro 'SND_SOC_DAILINK_REGx'
926 | SND_SOC_DAILINK_REGx(__VA_ARGS__, \
| ^~~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm512x.c:357:17: note: in expansion of macro 'SND_SOC_DAILINK_REG'
357 | SND_SOC_DAILINK_REG(hifi),
| ^~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm512x.c: In function 'imx_pcm512x_probe':
>> sound/soc/fsl/imx-pcm512x.c:429:9: warning: 'memcpy' reading 360 bytes from a region of size 120 [-Wstringop-overread]
429 | memcpy(data->dai_link, imx_pcm512x_dai,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430 | sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(data->dai_link));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/soc/fsl/imx-pcm512x.c:348:32: note: source object 'imx_pcm512x_dai' of size 120
348 | static struct snd_soc_dai_link imx_pcm512x_dai[] = {
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for PCIE_MOBIVEIL_HOST
Depends on PCI && PCI_MSI_IRQ_DOMAIN
Selected by
- PCIE_MOBIVEIL_PLAT && PCI && (ARCH_ZYNQMP || COMPILE_TEST && OF
vim +/memcpy +429 sound/soc/fsl/imx-pcm512x.c
8efc3af011c524 Adrian Alonso 2020-11-09 360
8efc3af011c524 Adrian Alonso 2020-11-09 361 static int imx_pcm512x_probe(struct platform_device *pdev)
8efc3af011c524 Adrian Alonso 2020-11-09 362 {
8efc3af011c524 Adrian Alonso 2020-11-09 363 struct device_node *bitclkmaster, *framemaster = NULL;
8efc3af011c524 Adrian Alonso 2020-11-09 364 struct device_node *cpu_np, *codec_np = NULL;
8efc3af011c524 Adrian Alonso 2020-11-09 365 struct device_node *np = pdev->dev.of_node;
8efc3af011c524 Adrian Alonso 2020-11-09 366 struct platform_device *cpu_pdev = NULL;
8efc3af011c524 Adrian Alonso 2020-11-09 367 struct snd_soc_dai_link_component *comp;
8efc3af011c524 Adrian Alonso 2020-11-09 368 struct imx_pcm512x_data *data;
8efc3af011c524 Adrian Alonso 2020-11-09 369 struct i2c_client *codec_dev;
8efc3af011c524 Adrian Alonso 2020-11-09 370 int ret;
8efc3af011c524 Adrian Alonso 2020-11-09 371
8efc3af011c524 Adrian Alonso 2020-11-09 372 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
8efc3af011c524 Adrian Alonso 2020-11-09 373 if (!data)
8efc3af011c524 Adrian Alonso 2020-11-09 374 return -ENOMEM;
8efc3af011c524 Adrian Alonso 2020-11-09 375
8efc3af011c524 Adrian Alonso 2020-11-09 376 comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL);
8efc3af011c524 Adrian Alonso 2020-11-09 377 if (!comp)
8efc3af011c524 Adrian Alonso 2020-11-09 378 return -ENOMEM;
8efc3af011c524 Adrian Alonso 2020-11-09 379
8efc3af011c524 Adrian Alonso 2020-11-09 380 cpu_np = of_parse_phandle(np, "audio-cpu", 0);
8efc3af011c524 Adrian Alonso 2020-11-09 381 if (!cpu_np) {
8efc3af011c524 Adrian Alonso 2020-11-09 382 dev_err(&pdev->dev, "audio dai phandle missing or invalid\n");
8efc3af011c524 Adrian Alonso 2020-11-09 383 ret = -EINVAL;
8efc3af011c524 Adrian Alonso 2020-11-09 384 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 385 }
8efc3af011c524 Adrian Alonso 2020-11-09 386
8efc3af011c524 Adrian Alonso 2020-11-09 387 codec_np = of_parse_phandle(np, "audio-codec", 0);
8efc3af011c524 Adrian Alonso 2020-11-09 388 if (!codec_np) {
8efc3af011c524 Adrian Alonso 2020-11-09 389 dev_err(&pdev->dev, "audio codec phandle missing or invalid\n");
8efc3af011c524 Adrian Alonso 2020-11-09 390 ret = -EINVAL;
8efc3af011c524 Adrian Alonso 2020-11-09 391 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 392 }
8efc3af011c524 Adrian Alonso 2020-11-09 393
8efc3af011c524 Adrian Alonso 2020-11-09 394 cpu_pdev = of_find_device_by_node(cpu_np);
8efc3af011c524 Adrian Alonso 2020-11-09 395 if (!cpu_pdev) {
8efc3af011c524 Adrian Alonso 2020-11-09 396 dev_err(&pdev->dev, "failed to find SAI platform device\n");
8efc3af011c524 Adrian Alonso 2020-11-09 397 ret = -EINVAL;
8efc3af011c524 Adrian Alonso 2020-11-09 398 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 399 }
8efc3af011c524 Adrian Alonso 2020-11-09 400
8efc3af011c524 Adrian Alonso 2020-11-09 401 codec_dev = of_find_i2c_device_by_node(codec_np);
8efc3af011c524 Adrian Alonso 2020-11-09 402 if (!codec_dev || !codec_dev->dev.driver) {
8efc3af011c524 Adrian Alonso 2020-11-09 403 dev_err(&pdev->dev, "failed to find codec device\n");
8efc3af011c524 Adrian Alonso 2020-11-09 404 ret = -EPROBE_DEFER;
8efc3af011c524 Adrian Alonso 2020-11-09 405 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 406 }
8efc3af011c524 Adrian Alonso 2020-11-09 407
8efc3af011c524 Adrian Alonso 2020-11-09 408 data->dac_gain_limit = of_property_read_bool(np, "dac,24db_digital_gain");
8efc3af011c524 Adrian Alonso 2020-11-09 409 data->dac_auto_mute = of_property_read_bool(np, "dac,auto_mute_amp");
8efc3af011c524 Adrian Alonso 2020-11-09 410 data->dac_gpio_unmute = of_property_read_bool(np, "dac,unmute_amp");
8efc3af011c524 Adrian Alonso 2020-11-09 411 data->dac_led_status = of_property_read_bool(np, "dac,led_status");
8efc3af011c524 Adrian Alonso 2020-11-09 412
8efc3af011c524 Adrian Alonso 2020-11-09 413 if (data->dac_auto_mute || data->dac_gpio_unmute) {
8efc3af011c524 Adrian Alonso 2020-11-09 414 data->mute_gpio = devm_gpiod_get_optional(&pdev->dev,
8efc3af011c524 Adrian Alonso 2020-11-09 415 "mute-amp", GPIOD_OUT_LOW);
8efc3af011c524 Adrian Alonso 2020-11-09 416 if (IS_ERR(data->mute_gpio)) {
8efc3af011c524 Adrian Alonso 2020-11-09 417 dev_err(&pdev->dev, "failed to get mute amp gpio\n");
8efc3af011c524 Adrian Alonso 2020-11-09 418 ret = PTR_ERR(data->mute_gpio);
8efc3af011c524 Adrian Alonso 2020-11-09 419 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 420 }
8efc3af011c524 Adrian Alonso 2020-11-09 421 }
8efc3af011c524 Adrian Alonso 2020-11-09 422
8efc3af011c524 Adrian Alonso 2020-11-09 423 if (data->dac_auto_mute && data->dac_gpio_unmute)
8efc3af011c524 Adrian Alonso 2020-11-09 424 data->card.set_bias_level = imx_pcm512x_set_bias_level;
8efc3af011c524 Adrian Alonso 2020-11-09 425
8efc3af011c524 Adrian Alonso 2020-11-09 426 platform_set_drvdata(pdev, &data->card);
8efc3af011c524 Adrian Alonso 2020-11-09 427 snd_soc_card_set_drvdata(&data->card, data);
8efc3af011c524 Adrian Alonso 2020-11-09 428
8efc3af011c524 Adrian Alonso 2020-11-09 @429 memcpy(data->dai_link, imx_pcm512x_dai,
8efc3af011c524 Adrian Alonso 2020-11-09 430 sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(data->dai_link));
8efc3af011c524 Adrian Alonso 2020-11-09 431
8efc3af011c524 Adrian Alonso 2020-11-09 432 data->card.owner = THIS_MODULE;
8efc3af011c524 Adrian Alonso 2020-11-09 433 data->card.dev = &pdev->dev;
8efc3af011c524 Adrian Alonso 2020-11-09 434 data->card.dai_link = data->dai_link;
8efc3af011c524 Adrian Alonso 2020-11-09 435 data->card.num_links = 1;
8efc3af011c524 Adrian Alonso 2020-11-09 436
8efc3af011c524 Adrian Alonso 2020-11-09 437 ret = snd_soc_of_parse_card_name(&data->card, "model");
8efc3af011c524 Adrian Alonso 2020-11-09 438 if (ret) {
8efc3af011c524 Adrian Alonso 2020-11-09 439 dev_err(&pdev->dev, "failed to find card model name\n");
8efc3af011c524 Adrian Alonso 2020-11-09 440 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 441 }
8efc3af011c524 Adrian Alonso 2020-11-09 442
8efc3af011c524 Adrian Alonso 2020-11-09 443 if (of_property_read_bool(np, "audio-routing")) {
8efc3af011c524 Adrian Alonso 2020-11-09 444 ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
8efc3af011c524 Adrian Alonso 2020-11-09 445 if (ret) {
8efc3af011c524 Adrian Alonso 2020-11-09 446 dev_err(&pdev->dev, "failed to parse audio-routing\n");
8efc3af011c524 Adrian Alonso 2020-11-09 447 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 448 }
8efc3af011c524 Adrian Alonso 2020-11-09 449 }
8efc3af011c524 Adrian Alonso 2020-11-09 450
8efc3af011c524 Adrian Alonso 2020-11-09 451 if (of_property_read_bool(np, "audio-widgets")) {
8efc3af011c524 Adrian Alonso 2020-11-09 452 ret = snd_soc_of_parse_audio_simple_widgets(&data->card, "audio-widgets");
8efc3af011c524 Adrian Alonso 2020-11-09 453 if (ret) {
8efc3af011c524 Adrian Alonso 2020-11-09 454 dev_err(&pdev->dev, "failed to parse audio-widgets\n");
8efc3af011c524 Adrian Alonso 2020-11-09 455 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 456 }
8efc3af011c524 Adrian Alonso 2020-11-09 457 }
8efc3af011c524 Adrian Alonso 2020-11-09 458
8efc3af011c524 Adrian Alonso 2020-11-09 459 data->daifmt = snd_soc_of_parse_daifmt(np, NULL, &bitclkmaster, &framemaster);
8efc3af011c524 Adrian Alonso 2020-11-09 460 data->daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
8efc3af011c524 Adrian Alonso 2020-11-09 461
8efc3af011c524 Adrian Alonso 2020-11-09 462 if (codec_np == bitclkmaster)
8efc3af011c524 Adrian Alonso 2020-11-09 463 data->daifmt |= (codec_np == framemaster) ?
8efc3af011c524 Adrian Alonso 2020-11-09 464 SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS;
8efc3af011c524 Adrian Alonso 2020-11-09 465 else
8efc3af011c524 Adrian Alonso 2020-11-09 466 data->daifmt |= (codec_np == framemaster) ?
8efc3af011c524 Adrian Alonso 2020-11-09 467 SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS;
8efc3af011c524 Adrian Alonso 2020-11-09 468
8efc3af011c524 Adrian Alonso 2020-11-09 469 if (!bitclkmaster)
8efc3af011c524 Adrian Alonso 2020-11-09 470 of_node_put(bitclkmaster);
8efc3af011c524 Adrian Alonso 2020-11-09 471 if (!framemaster)
8efc3af011c524 Adrian Alonso 2020-11-09 472 of_node_put(framemaster);
8efc3af011c524 Adrian Alonso 2020-11-09 473
8efc3af011c524 Adrian Alonso 2020-11-09 474 if (of_property_read_bool(codec_np, "clocks"))
8efc3af011c524 Adrian Alonso 2020-11-09 475 data->dac_sclk = true;
8efc3af011c524 Adrian Alonso 2020-11-09 476
8efc3af011c524 Adrian Alonso 2020-11-09 477 data->dai_link[0].cpus = &comp[0];
8efc3af011c524 Adrian Alonso 2020-11-09 478 data->dai_link[0].num_cpus = 1;
8efc3af011c524 Adrian Alonso 2020-11-09 479 data->dai_link[0].codecs = &comp[1];
8efc3af011c524 Adrian Alonso 2020-11-09 480 data->dai_link[0].num_codecs = 1;
8efc3af011c524 Adrian Alonso 2020-11-09 481 data->dai_link[0].platforms = &comp[2];
8efc3af011c524 Adrian Alonso 2020-11-09 482 data->dai_link[0].num_platforms = 1;
8efc3af011c524 Adrian Alonso 2020-11-09 483
8efc3af011c524 Adrian Alonso 2020-11-09 484 data->dai_link[0].cpus->of_node = cpu_np;
8efc3af011c524 Adrian Alonso 2020-11-09 485 data->dai_link[0].platforms->of_node = cpu_np;
8efc3af011c524 Adrian Alonso 2020-11-09 486 data->dai_link[0].codecs->of_node = codec_np;
8efc3af011c524 Adrian Alonso 2020-11-09 487 data->dai_link[0].codecs->dai_name = "pcm512x-hifi";
8efc3af011c524 Adrian Alonso 2020-11-09 488 data->dai_link[0].dai_fmt = data->daifmt;
8efc3af011c524 Adrian Alonso 2020-11-09 489
8efc3af011c524 Adrian Alonso 2020-11-09 490 ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
8efc3af011c524 Adrian Alonso 2020-11-09 491 if (ret) {
8efc3af011c524 Adrian Alonso 2020-11-09 492 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
8efc3af011c524 Adrian Alonso 2020-11-09 493 goto fail;
8efc3af011c524 Adrian Alonso 2020-11-09 494 }
8efc3af011c524 Adrian Alonso 2020-11-09 495
8efc3af011c524 Adrian Alonso 2020-11-09 496 if (data->dac_gpio_unmute && data->dac_auto_mute)
8efc3af011c524 Adrian Alonso 2020-11-09 497 gpiod_set_value_cansleep(data->mute_gpio, 1);
8efc3af011c524 Adrian Alonso 2020-11-09 498
8efc3af011c524 Adrian Alonso 2020-11-09 499 ret = 0;
8efc3af011c524 Adrian Alonso 2020-11-09 500 fail:
8efc3af011c524 Adrian Alonso 2020-11-09 501 if (cpu_np)
8efc3af011c524 Adrian Alonso 2020-11-09 502 of_node_put(cpu_np);
8efc3af011c524 Adrian Alonso 2020-11-09 503 if (codec_np)
8efc3af011c524 Adrian Alonso 2020-11-09 504 of_node_put(codec_np);
8efc3af011c524 Adrian Alonso 2020-11-09 505
8efc3af011c524 Adrian Alonso 2020-11-09 506 return ret;
8efc3af011c524 Adrian Alonso 2020-11-09 507 }
8efc3af011c524 Adrian Alonso 2020-11-09 508
:::::: The code at line 429 was first introduced by commit
:::::: 8efc3af011c524745935866310f8ec44a37bf384 MLK-24930-1: sound: soc: fsl: imx pcm512x: iqaudio dac
:::::: TO: Adrian Alonso <adrian.alonso(a)nxp.com>
:::::: CC: Adrian Alonso <adrian.alonso(a)nxp.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month
[linux-rt-devel:linux-5.14.y-rt-rebase 143/245] kernel/futex.c:1887:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
by kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-5.14.y-rt-rebase
head: 0eead4e5a60cb716ec911a552787a69332cf6943
commit: 7384201f9701c226cb1dd04cf76c12c33762bb30 [143/245] futex: Validate waiter correctly in futex_proxy_trylock_atomic()
config: mips-randconfig-c004-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 44d0a99a12ec7ead4d2f5ef649ba05b40f6d463d)
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/rt/linux-rt-devel.git/com...
git remote add linux-rt-devel https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git
git fetch --no-tags linux-rt-devel linux-5.14.y-rt-rebase
git checkout 7384201f9701c226cb1dd04cf76c12c33762bb30
# save the attached .config 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(a)intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
^
kernel/futex.c:3714:6: note: Assuming the condition is false
if (op & FUTEX_CLOCK_REALTIME) {
^~~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex.c:3714:2: note: Taking false branch
if (op & FUTEX_CLOCK_REALTIME) {
^
kernel/futex.c:3721:2: note: 'Default' branch taken. Execution continues on line 3732
switch (cmd) {
^
kernel/futex.c:3732:2: note: Control jumps to 'case 5:' at line 3747
switch (cmd) {
^
kernel/futex.c:3748:10: note: Calling 'futex_wake_op'
return futex_wake_op(uaddr, flags, uaddr2, val, val2, val3);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex.c:1699:2: note: Taking false branch
if (unlikely(ret != 0))
^
kernel/futex.c:1702:2: note: Taking false branch
if (unlikely(ret != 0))
^
kernel/futex.c:1710:11: note: Calling 'futex_atomic_op_inuser'
op_ret = futex_atomic_op_inuser(op, uaddr2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex.c:1643:6: note: 'oldval' declared without an initial value
int oldval, ret;
^~~~~~
kernel/futex.c:1645:6: note: Assuming the condition is false
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex.c:1645:2: note: Taking false branch
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) {
^
kernel/futex.c:1660:8: note: Calling 'arch_futex_atomic_op_inuser'
ret = arch_futex_atomic_op_inuser(op, oparg, &oldval, uaddr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/mips/include/asm/futex.h:92:7: note: Assuming the condition is false
if (!access_ok(uaddr, sizeof(u32)))
^
arch/mips/include/asm/uaccess.h:88:2: note: expanded from macro 'access_ok'
likely(__access_ok((addr), (size)))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:77:38: note: expanded from macro 'likely'
# define likely(x) __builtin_expect(!!(x), 1)
^~~~
arch/mips/include/asm/futex.h:92:2: note: Taking false branch
if (!access_ok(uaddr, sizeof(u32)))
^
arch/mips/include/asm/futex.h:95:2: note: Control jumps to 'case 3:' at line 108
switch (op) {
^
arch/mips/include/asm/futex.h:109:3: note: Left side of '&&' is true
__futex_atomic_op("and $1, %1, %z5",
^
arch/mips/include/asm/futex.h:24:6: note: expanded from macro '__futex_atomic_op'
if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) { \
^
arch/mips/include/asm/mach-rc32434/cpu-feature-overrides.h:34:24: note: expanded from macro 'cpu_has_llsc'
#define cpu_has_llsc 1
^
arch/mips/include/asm/futex.h:109:3: note: Taking false branch
__futex_atomic_op("and $1, %1, %z5",
^
arch/mips/include/asm/futex.h:24:2: note: expanded from macro '__futex_atomic_op'
if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) { \
^
arch/mips/include/asm/futex.h:109:3: note: Taking true branch
__futex_atomic_op("and $1, %1, %z5",
^
arch/mips/include/asm/futex.h:53:9: note: expanded from macro '__futex_atomic_op'
} else if (cpu_has_llsc) { \
^
arch/mips/include/asm/futex.h:111:3: note: Execution continues on line 120
break;
^
arch/mips/include/asm/futex.h:120:6: note: Assuming 'ret' is not equal to 0
if (!ret)
^~~~
arch/mips/include/asm/futex.h:120:2: note: Taking false branch
if (!ret)
^
arch/mips/include/asm/futex.h:123:2: note: Returning without writing to '*oval'
return ret;
^
kernel/futex.c:1660:8: note: Returning from 'arch_futex_atomic_op_inuser'
ret = arch_futex_atomic_op_inuser(op, oparg, &oldval, uaddr);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex.c:1662:6: note: Assuming 'ret' is 0
if (ret)
^~~
kernel/futex.c:1662:2: note: Taking false branch
if (ret)
^
kernel/futex.c:1665:2: note: Control jumps to 'case 4:' at line 1676
switch (cmp) {
^
kernel/futex.c:1677:17: note: The left operand of '>' is a garbage value
return oldval > cmparg;
~~~~~~ ^
>> kernel/futex.c:1887:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]
ret = -EINVAL;
^ ~~~~~~~
kernel/futex.c:1887:3: note: Value stored to 'ret' is never read
ret = -EINVAL;
^ ~~~~~~~
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.
5 warnings generated.
drivers/soundwire/stream.c:847:10: warning: Use of memory after it is freed [clang-analyzer-unix.Malloc]
kfree(bus->defer_msg.msg->buf);
^
drivers/soundwire/stream.c:1755:6: note: Assuming 'stream' is non-null
if (!stream) {
^~~~~~~
drivers/soundwire/stream.c:1755:2: note: Taking false branch
if (!stream) {
^
drivers/soundwire/stream.c:1762:6: note: Assuming field 'state' is equal to SDW_STREAM_ENABLED
if (stream->state != SDW_STREAM_ENABLED) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/soundwire/stream.c:1762:2: note: Taking false branch
if (stream->state != SDW_STREAM_ENABLED) {
^
drivers/soundwire/stream.c:1769:8: note: Calling '_sdw_disable_stream'
ret = _sdw_disable_stream(stream);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/soundwire/stream.c:1700:2: note: Left side of '&&' is false
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
^
include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
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/soundwire/stream.c:1700:2: note: Taking false branch
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
^
include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
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)
^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^
drivers/soundwire/stream.c:1700:2: note: Loop condition is false. Exiting loop
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
^
include/linux/list.h:628:13: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
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)
^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
do { \
^
drivers/soundwire/stream.c:1700:2: note: Loop condition is false. Execution continues on line 1710
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
^
include/linux/list.h:628:2: note: expanded from macro 'list_for_each_entry'
for (pos = list_first_entry(head, typeof(*pos), member); \
^
drivers/soundwire/stream.c:1712:2: note: Left side of '&&' is false
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
^
vim +/ret +1887 kernel/futex.c
1825
1826 /**
1827 * futex_proxy_trylock_atomic() - Attempt an atomic lock for the top waiter
1828 * @pifutex: the user address of the to futex
1829 * @hb1: the from futex hash bucket, must be locked by the caller
1830 * @hb2: the to futex hash bucket, must be locked by the caller
1831 * @key1: the from futex key
1832 * @key2: the to futex key
1833 * @ps: address to store the pi_state pointer
1834 * @exiting: Pointer to store the task pointer of the owner task
1835 * which is in the middle of exiting
1836 * @set_waiters: force setting the FUTEX_WAITERS bit (1) or not (0)
1837 *
1838 * Try and get the lock on behalf of the top waiter if we can do it atomically.
1839 * Wake the top waiter if we succeed. If the caller specified set_waiters,
1840 * then direct futex_lock_pi_atomic() to force setting the FUTEX_WAITERS bit.
1841 * hb1 and hb2 must be held by the caller.
1842 *
1843 * @exiting is only set when the return value is -EBUSY. If so, this holds
1844 * a refcount on the exiting task on return and the caller needs to drop it
1845 * after waiting for the exit to complete.
1846 *
1847 * Return:
1848 * - 0 - failed to acquire the lock atomically;
1849 * - >0 - acquired the lock, return value is vpid of the top_waiter
1850 * - <0 - error
1851 */
1852 static int
1853 futex_proxy_trylock_atomic(u32 __user *pifutex, struct futex_hash_bucket *hb1,
1854 struct futex_hash_bucket *hb2, union futex_key *key1,
1855 union futex_key *key2, struct futex_pi_state **ps,
1856 struct task_struct **exiting, int set_waiters)
1857 {
1858 struct futex_q *top_waiter = NULL;
1859 u32 curval;
1860 int ret, vpid;
1861
1862 if (get_futex_value_locked(&curval, pifutex))
1863 return -EFAULT;
1864
1865 if (unlikely(should_fail_futex(true)))
1866 return -EFAULT;
1867
1868 /*
1869 * Find the top_waiter and determine if there are additional waiters.
1870 * If the caller intends to requeue more than 1 waiter to pifutex,
1871 * force futex_lock_pi_atomic() to set the FUTEX_WAITERS bit now,
1872 * as we have means to handle the possible fault. If not, don't set
1873 * the bit unnecessarily as it will force the subsequent unlock to enter
1874 * the kernel.
1875 */
1876 top_waiter = futex_top_waiter(hb1, key1);
1877
1878 /* There are no waiters, nothing for us to do. */
1879 if (!top_waiter)
1880 return 0;
1881
1882 /*
1883 * Ensure that this is a waiter sitting in futex_wait_requeue_pi()
1884 * and waiting on the 'waitqueue' futex which is always !PI.
1885 */
1886 if (!top_waiter->rt_waiter || top_waiter->pi_state)
> 1887 ret = -EINVAL;
1888
1889 /* Ensure we requeue to the expected futex. */
1890 if (!match_futex(top_waiter->requeue_pi_key, key2))
1891 return -EINVAL;
1892
1893 /*
1894 * Try to take the lock for top_waiter. Set the FUTEX_WAITERS bit in
1895 * the contended case or if set_waiters is 1. The pi_state is returned
1896 * in ps in contended cases.
1897 */
1898 vpid = task_pid_vnr(top_waiter->task);
1899 ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task,
1900 exiting, set_waiters);
1901 if (ret == 1) {
1902 requeue_pi_wake_futex(top_waiter, key2, hb2);
1903 return vpid;
1904 }
1905 return ret;
1906 }
1907
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month
[freescale-fslc:pr/416 14383/20667] drivers/pci/controller/dwc/pci-imx6.c:1961: undefined reference to `dw_pcie_link_up'
by kernel test robot
Hi Jindong,
FYI, the error/warning still remains.
tree: https://github.com/Freescale/linux-fslc pr/416
head: 915e71b823c877d351de1cbe650344ef6eace94b
commit: 61b7aecf354c8e55cffc466be937c184b8aaadb0 [14383/20667] MA-17597-5 pci: controller: dwc: support module build
config: x86_64-randconfig-a006-20210816 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/Freescale/linux-fslc/commit/61b7aecf354c8e55cffc466be9...
git remote add freescale-fslc https://github.com/Freescale/linux-fslc
git fetch --no-tags freescale-fslc pr/416
git checkout 61b7aecf354c8e55cffc466be937c184b8aaadb0
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `imx6_pcie_start_link':
>> drivers/pci/controller/dwc/pci-imx6.c:1961: undefined reference to `dw_pcie_link_up'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
>> ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o:drivers/pci/controller/dwc/pcie-designware.h:288: more undefined references to `dw_pcie_write_dbi' follow
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `imx6_pcie_establish_link':
>> drivers/pci/controller/dwc/pci-imx6.c:1816: undefined reference to `dw_pcie_wait_for_link'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
>> drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `imx6_pcie_establish_link':
drivers/pci/controller/dwc/pci-imx6.c:1864: undefined reference to `dw_pcie_wait_for_link'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readw_dbi':
drivers/pci/controller/dwc/pcie-designware.h:303: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writew_dbi':
drivers/pci/controller/dwc/pcie-designware.h:298: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_readl_dbi':
drivers/pci/controller/dwc/pcie-designware.h:293: undefined reference to `dw_pcie_read_dbi'
ld: drivers/pci/controller/dwc/pci-imx6.o: in function `dw_pcie_writel_dbi':
drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
ld: drivers/pci/controller/dwc/pcie-designware.h:288: undefined reference to `dw_pcie_write_dbi'
vim +1961 drivers/pci/controller/dwc/pci-imx6.c
0ee2c1f2429f74 drivers/pci/controller/dwc/pci-imx6.c Leonard Crestez 2018-08-27 1794
e7d7705ace9494 drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-11 1795 static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie)
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1796 {
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1797 struct dw_pcie *pci = imx6_pcie->pci;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1798 struct device *dev = pci->dev;
1c7fae18a1fb6b drivers/pci/host/pci-imx6.c Bjorn Helgaas 2015-06-12 1799 u32 tmp;
a0427464cf4c4a drivers/pci/host/pci-imx6.c Troy Kisky 2015-06-12 1800 int ret;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1801
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1802 /*
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1803 * Force Gen1 operation when starting the link. In case the link is
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1804 * started in Gen2 mode, there is a possibility the devices on the
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1805 * bus will not be detected at all. This happens with PCIe switches.
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1806 */
af235be4424b00 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-08 1807 if (!IS_ENABLED(CONFIG_PCI_IMX6_COMPLIANCE_TEST)) {
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1808 tmp = dw_pcie_readl_dbi(pci, PCIE_RC_LCR);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1809 tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1810 tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1811 dw_pcie_writel_dbi(pci, PCIE_RC_LCR, tmp);
af235be4424b00 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-08 1812 }
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1813
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1814 /* Start LTSSM. */
0ee2c1f2429f74 drivers/pci/controller/dwc/pci-imx6.c Leonard Crestez 2018-08-27 1815 imx6_pcie_ltssm_enable(dev);
ee6f37175b3f7a drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-04-14 @1816 ret = dw_pcie_wait_for_link(pci);
caf3f562e1161a drivers/pci/host/pci-imx6.c Fabio Estevam 2016-12-27 1817 if (ret)
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1818 goto err_reset_phy;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1819
e76f906f9773bc drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-01-25 1820 if (imx6_pcie->link_gen >= 2) {
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1821 /* Fill up target link speed before speed change. */
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1822 tmp = dw_pcie_readl_dbi(pci, PCIE_RC_LC2SR);
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1823 tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK;
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1824 tmp |= imx6_pcie->link_gen;
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1825 dw_pcie_writel_dbi(pci, PCIE_RC_LC2SR, tmp);
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1826
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1827 tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1828 tmp &= ~PORT_LOGIC_SPEED_CHANGE;
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1829 dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp);
12589ba98b1145 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-06-22 1830
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1831 /* Allow Gen2 mode after the link is up. */
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1832 tmp = dw_pcie_readl_dbi(pci, PCIE_RC_LCR);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1833 tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK;
e76f906f9773bc drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-01-25 1834 tmp |= imx6_pcie->link_gen;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1835 dw_pcie_writel_dbi(pci, PCIE_RC_LCR, tmp);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1836
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1837 /*
93b226f9c65a95 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1838 * Start Directed Speed Change so the best possible
93b226f9c65a95 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1839 * speed both link partners support can be negotiated.
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1840 */
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1841 tmp = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1842 tmp |= PORT_LOGIC_SPEED_CHANGE;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1843 dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, tmp);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1844
4c458bb347ae01 drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-02-01 1845 if (imx6_pcie->drvdata->flags &
4c458bb347ae01 drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-02-01 1846 IMX6_PCIE_FLAG_IMX6_SPEED_CHANGE) {
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1847 /*
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1848 * On i.MX7, DIRECT_SPEED_CHANGE behaves differently
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1849 * from i.MX6 family when no link speed transition
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1850 * occurs and we go Gen1 -> yep, Gen1. The difference
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1851 * is that, in such case, it will not be cleared by HW
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1852 * which will cause the following code to report false
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1853 * failure.
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1854 */
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1855
e7d7705ace9494 drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-11 1856 ret = imx6_pcie_wait_for_speed_change(imx6_pcie);
a0427464cf4c4a drivers/pci/host/pci-imx6.c Troy Kisky 2015-06-12 1857 if (ret) {
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1858 dev_err(dev, "Failed to bring link up!\n");
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1859 goto err_reset_phy;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1860 }
e6dcd87fff69a9 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1861 }
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1862
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1863 /* Make sure link training is finished as well! */
ee6f37175b3f7a drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-04-14 1864 ret = dw_pcie_wait_for_link(pci);
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1865 if (ret) {
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1866 dev_err(dev, "Failed to bring link up!\n");
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1867 goto err_reset_phy;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1868 }
93b226f9c65a95 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1869 } else {
93b226f9c65a95 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1870 dev_info(dev, "Link: Gen2 disabled\n");
93b226f9c65a95 drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1871 }
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1872
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1873 tmp = dw_pcie_readl_dbi(pci, PCIE_RC_LCSR);
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1874 dev_info(dev, "Link up, Gen%i\n", (tmp >> 16) & 0xf);
a0427464cf4c4a drivers/pci/host/pci-imx6.c Troy Kisky 2015-06-12 1875 return 0;
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1876
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1877 err_reset_phy:
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1878 dev_dbg(dev, "PHY DEBUG_R0=0x%08x DEBUG_R1=0x%08x\n",
60ef4b072ba089 drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-04-14 1879 dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0),
60ef4b072ba089 drivers/pci/controller/dwc/pci-imx6.c Andrey Smirnov 2019-04-14 1880 dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1));
2a6a85d5368e55 drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-11 1881 imx6_pcie_reset_phy(imx6_pcie);
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1882 if (!IS_ENABLED(CONFIG_PCI_IMX6_COMPLIANCE_TEST)) {
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1883 imx6_pcie_clk_disable(imx6_pcie);
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1884 if (imx6_pcie->vpcie != NULL)
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1885 regulator_disable(imx6_pcie->vpcie);
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1886 if (imx6_pcie->epdev_on != NULL)
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1887 regulator_disable(imx6_pcie->epdev_on);
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1888 }
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1889
54a47a83421a3b drivers/pci/host/pci-imx6.c Lucas Stach 2016-01-25 1890 return ret;
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1891 }
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1892
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1893 static void pci_imx_set_msi_en(struct pcie_port *pp)
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1894 {
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1895 u16 val;
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1896 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1897
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1898 if (pci_msi_enabled()) {
7b842d74f6f105 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-02-20 1899 dw_pcie_dbi_ro_wr_en(pci);
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1900 val = dw_pcie_readw_dbi(pci, PCIE_RC_IMX6_MSI_CAP +
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1901 PCI_MSI_FLAGS);
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1902 val |= PCI_MSI_FLAGS_ENABLE;
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1903 val &= ~PCI_MSI_FLAGS_64BIT;
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1904 dw_pcie_writew_dbi(pci, PCIE_RC_IMX6_MSI_CAP + PCI_MSI_FLAGS,
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1905 val);
7b842d74f6f105 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-02-20 1906 dw_pcie_dbi_ro_wr_dis(pci);
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1907 }
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1908 }
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1909
4a301766f5263d drivers/pci/dwc/pci-imx6.c Bjorn Andersson 2017-07-15 1910 static int imx6_pcie_host_init(struct pcie_port *pp)
fa33a6d87eac1a drivers/pci/host/pci-imx6.c Marek Vasut 2013-12-12 1911 {
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1912 struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1913 struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci);
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1914
d95659f2bbd85d drivers/pci/controller/dwc/pci-imx6.c Fugang Duan 2019-11-02 1915 if (gpio_is_valid(imx6_pcie->dis_gpio))
d95659f2bbd85d drivers/pci/controller/dwc/pci-imx6.c Fugang Duan 2019-11-02 1916 gpio_set_value_cansleep(imx6_pcie->dis_gpio, 1);
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1917 dw_pcie_setup_rc(pp);
f503843f85d287 drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-22 1918 pci_imx_set_msi_en(pp);
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1919 if (imx6_pcie_establish_link(imx6_pcie))
d1fcbc345b82cd drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2019-11-28 1920 return -ENODEV;
6e8f69523e69ae drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-10-19 1921 dw_pcie_msi_init(pp);
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1922
4a301766f5263d drivers/pci/dwc/pci-imx6.c Bjorn Andersson 2017-07-15 1923 return 0;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1924 }
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1925
4ab2e7c0df6b8b drivers/pci/dwc/pci-imx6.c Jisheng Zhang 2017-06-05 1926 static const struct dw_pcie_host_ops imx6_pcie_host_ops = {
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1927 .host_init = imx6_pcie_host_init,
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1928 };
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1929
bde4a5a00e761f drivers/pci/dwc/pci-imx6.c Andrey Smirnov 2017-03-28 1930 static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1931 struct platform_device *pdev)
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1932 {
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1933 struct dw_pcie *pci = imx6_pcie->pci;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1934 struct pcie_port *pp = &pci->pp;
442ec4c04d1235 drivers/pci/dwc/pci-imx6.c Kishon Vijay Abraham I 2017-02-15 1935 struct device *dev = &pdev->dev;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1936 int ret;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1937
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1938 if (IS_ENABLED(CONFIG_PCI_MSI)) {
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1939 pp->msi_irq = platform_get_irq_byname(pdev, "msi");
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1940 if (pp->msi_irq <= 0) {
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1941 dev_err(dev, "failed to get MSI irq\n");
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1942 return -ENODEV;
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1943 }
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1944 }
d1dc9749a5b823 drivers/pci/host/pci-imx6.c Lucas Stach 2014-03-28 1945
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1946 pp->ops = &imx6_pcie_host_ops;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1947
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1948 ret = dw_pcie_host_init(pp);
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1949 if (ret) {
13957652f7242a drivers/pci/host/pci-imx6.c Bjorn Helgaas 2016-10-06 1950 dev_err(dev, "failed to initialize host\n");
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1951 return ret;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1952 }
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1953
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1954 return 0;
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1955 }
bb38919ec56e07 drivers/pci/host/pci-imx6.c Sean Cross 2013-09-26 1956
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1957 static int imx6_pcie_start_link(struct dw_pcie *pci)
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1958 {
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1959 struct device *dev = pci->dev;
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1960
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 @1961 if (dw_pcie_link_up(pci)) {
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1962 dev_dbg(dev, "link is already up\n");
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1963 return 0;
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1964 }
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1965
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1966 /* Start LTSSM. */
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1967 imx6_pcie_ltssm_enable(dev);
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1968
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1969 return 0;
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1970 }
112ade807b909b drivers/pci/controller/dwc/pci-imx6.c Richard Zhu 2020-05-14 1971
:::::: The code at line 1961 was first introduced by commit
:::::: 112ade807b909b5bb44dd16eca0313a2085b4c0c MLK-24012-12 pci: imx: add the imx8qxp ep support
:::::: TO: Richard Zhu <hongxing.zhu(a)nxp.com>
:::::: CC: Richard Zhu <hongxing.zhu(a)nxp.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month
[djwong-xfs:defrag-freespace 309/310] fs/xfs/libxfs/xfs_bmap.c:6593:16: warning: variable 'rtxlen_in' set but not used
by kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git defrag-freespace
head: eac62500d5481c286ef5fac0873d1707175312b6
commit: e17e75a18c97e1f807f4e82707349ffa38c94fa3 [309/310] xfs: fallocate free space into a file
config: x86_64-randconfig-a011-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 44d0a99a12ec7ead4d2f5ef649ba05b40f6d463d)
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
# https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/comm...
git remote add djwong-xfs https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git
git fetch --no-tags djwong-xfs defrag-freespace
git checkout e17e75a18c97e1f807f4e82707349ffa38c94fa3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
>> fs/xfs/libxfs/xfs_bmap.c:6593:16: warning: variable 'rtxlen_in' set but not used [-Wunused-but-set-variable]
xfs_extlen_t rtxlen_in, rtxlen_out;
^
>> fs/xfs/libxfs/xfs_bmap.c:6611:25: warning: variable 'rtxlen_out' is uninitialized when used here [-Wuninitialized]
mval->br_blockcount = rtxlen_out * mp->m_sb.sb_rextsize;
^~~~~~~~~~
fs/xfs/libxfs/xfs_bmap.c:6593:37: note: initialize the variable 'rtxlen_out' to silence this warning
xfs_extlen_t rtxlen_in, rtxlen_out;
^
= 0
>> fs/xfs/libxfs/xfs_bmap.c:6605:7: warning: variable 'rtx_out' is uninitialized when used here [-Wuninitialized]
if (rtx_out == NULLRTBLOCK)
^~~~~~~
fs/xfs/libxfs/xfs_bmap.c:6592:32: note: initialize the variable 'rtx_out' to silence this warning
xfs_rtblock_t rtx_in, rtx_out;
^
= 0
3 warnings generated.
vim +/rtxlen_in +6593 fs/xfs/libxfs/xfs_bmap.c
6541
6542 /*
6543 * Given a file and a free physical extent, map it into the file at the same
6544 * offset if the file were a sparse image of the physical device. Set @mval to
6545 * whatever mapping we added to the file.
6546 */
6547 int
6548 xfs_bmapi_freesp(
6549 struct xfs_trans **tpp,
6550 struct xfs_inode *ip,
6551 xfs_fsblock_t fsbno,
6552 xfs_extlen_t len,
6553 struct xfs_bmbt_irec *mval)
6554 {
6555 struct xfs_bmbt_irec irec;
6556 struct xfs_mount *mp = ip->i_mount;
6557 xfs_fileoff_t startoff;
6558 bool isrt = XFS_IS_REALTIME_INODE(ip);
6559 int nimaps;
6560 int error;
6561
6562 trace_xfs_bmapi_freesp(ip, fsbno, len);
6563
6564 error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
6565 XFS_IEXT_ADD_NOSPLIT_CNT);
6566 if (error)
6567 return error;
6568
6569 if (isrt)
6570 startoff = fsbno;
6571 else
6572 startoff = xfs_fsblock_to_fileoff(mp, fsbno);
6573
6574 /* Make sure the entire range is a hole. */
6575 nimaps = 1;
6576 error = xfs_bmapi_read(ip, startoff, len, &irec, &nimaps, 0);
6577 if (error)
6578 return error;
6579
6580 if (irec.br_startoff != startoff ||
6581 irec.br_startblock != HOLESTARTBLOCK ||
6582 irec.br_blockcount < len)
6583 return -EINVAL;
6584
6585 /*
6586 * Allocate the physical extent. We should not have dropped the lock
6587 * since the scan of the free space metadata, so this should work,
6588 * though the length may be adjusted to play nicely with metadata space
6589 * reservations.
6590 */
6591 if (isrt) {
6592 xfs_rtblock_t rtx_in, rtx_out;
> 6593 xfs_extlen_t rtxlen_in, rtxlen_out;
6594 uint32_t mod;
6595
6596 rtx_in = div_u64_rem(fsbno, mp->m_sb.sb_rextsize, &mod);
6597 ASSERT(mod == 0);
6598 rtxlen_in = len / mp->m_sb.sb_rextsize;
6599 ASSERT(len % mp->m_sb.sb_rextsize == 0);
6600
6601 error = xfs_rtallocate_extent(*tpp, rtx_in, 1, rtxlen_in,
6602 &rtxlen_out, 0, 1, &rtx_out);
6603 if (error)
6604 return error;
> 6605 if (rtx_out == NULLRTBLOCK)
6606 return -ENOSPC;
6607 if (rtx_out != rtx_in) {
6608 ASSERT(0);
6609 return -EFSCORRUPTED;
6610 }
> 6611 mval->br_blockcount = rtxlen_out * mp->m_sb.sb_rextsize;
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month
[osandov:btrfs-send-encoded 8/14] fs/btrfs/ioctl.c:4957:38: sparse: sparse: incorrect type in argument 2 (different address spaces)
by kernel test robot
tree: https://github.com/osandov/linux.git btrfs-send-encoded
head: d3940b20ce9f2cf1e25106a87ddd90e165e34674
commit: ced2f02da25627eccaa276c08183a2764795c93f [8/14] btrfs: add BTRFS_IOC_ENCODED_READ
config: arc-randconfig-s031-20210816 (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-348-gf0e6938b-dirty
# https://github.com/osandov/linux/commit/ced2f02da25627eccaa276c08183a2764...
git remote add osandov https://github.com/osandov/linux.git
git fetch --no-tags osandov btrfs-send-encoded
git checkout ced2f02da25627eccaa276c08183a2764795c93f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
sparse warnings: (new ones prefixed by >>)
>> fs/btrfs/ioctl.c:4957:38: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct iovec const [noderef] __user *uvec @@ got struct iovec const *[addressable] iov @@
fs/btrfs/ioctl.c:4957:38: sparse: expected struct iovec const [noderef] __user *uvec
fs/btrfs/ioctl.c:4957:38: sparse: got struct iovec const *[addressable] iov
fs/btrfs/ioctl.c:408:6: sparse: sparse: context imbalance in 'btrfs_exclop_start_try_lock' - wrong count at exit
fs/btrfs/ioctl.c:419:6: sparse: sparse: context imbalance in 'btrfs_exclop_start_unlock' - unexpected unlock
vim +4957 fs/btrfs/ioctl.c
4906
4907 static int btrfs_ioctl_encoded_read(struct file *file, void __user *argp,
4908 bool compat)
4909 {
4910 struct btrfs_ioctl_encoded_io_args args;
4911 size_t copy_end_kernel = offsetofend(struct btrfs_ioctl_encoded_io_args,
4912 flags);
4913 size_t copy_end;
4914 struct iovec iovstack[UIO_FASTIOV];
4915 struct iovec *iov = iovstack;
4916 struct iov_iter iter;
4917 loff_t pos;
4918 struct kiocb kiocb;
4919 ssize_t ret;
4920
4921 if (!capable(CAP_SYS_ADMIN)) {
4922 ret = -EPERM;
4923 goto out_acct;
4924 }
4925
4926 if (compat) {
4927 #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
4928 struct btrfs_ioctl_encoded_io_args_32 args32;
4929
4930 copy_end = offsetofend(struct btrfs_ioctl_encoded_io_args_32,
4931 flags);
4932 if (copy_from_user(&args32, argp, copy_end)) {
4933 ret = -EFAULT;
4934 goto out_acct;
4935 }
4936 args.iov = compat_ptr(args32.iov);
4937 args.iovcnt = args32.iovcnt;
4938 args.offset = args32.offset;
4939 args.flags = args32.flags;
4940 #else
4941 return -ENOTTY;
4942 #endif
4943 } else {
4944 copy_end = copy_end_kernel;
4945 if (copy_from_user(&args, argp, copy_end)) {
4946 ret = -EFAULT;
4947 goto out_acct;
4948 }
4949 }
4950 if (args.flags != 0) {
4951 ret = -EINVAL;
4952 goto out_acct;
4953 }
4954 memset((char *)&args + copy_end_kernel, 0,
4955 sizeof(args) - copy_end_kernel);
4956
> 4957 ret = import_iovec(READ, args.iov, args.iovcnt, ARRAY_SIZE(iovstack),
4958 &iov, &iter);
4959 if (ret < 0)
4960 goto out_acct;
4961
4962 if (iov_iter_count(&iter) == 0) {
4963 ret = 0;
4964 goto out_iov;
4965 }
4966 pos = args.offset;
4967 ret = rw_verify_area(READ, file, &pos, args.len);
4968 if (ret < 0)
4969 goto out_iov;
4970
4971 init_sync_kiocb(&kiocb, file);
4972 ret = kiocb_set_rw_flags(&kiocb, 0);
4973 if (ret)
4974 goto out_iov;
4975 kiocb.ki_pos = pos;
4976
4977 ret = btrfs_encoded_read(&kiocb, &iter, &args);
4978 if (ret >= 0) {
4979 fsnotify_access(file);
4980 if (copy_to_user(argp + copy_end,
4981 (char *)&args + copy_end_kernel,
4982 sizeof(args) - copy_end_kernel))
4983 ret = -EFAULT;
4984 }
4985
4986 out_iov:
4987 kfree(iov);
4988 out_acct:
4989 if (ret > 0)
4990 add_rchar(current, ret);
4991 inc_syscr(current);
4992 return ret;
4993 }
4994
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month
[linux-next:master 5608/8423] drivers/cxl/core/bus.c:516:1: warning: stack frame size (1032) exceeds limit (1024) in function 'devm_cxl_add_decoder'
by kernel test robot
Hi Ben,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: b9011c7e671dbbf59bb753283ddfd03f0c9eb865
commit: 5161a55c069f53d88da49274cbef6e3c74eadea9 [5608/8423] cxl: Move cxl_core to new directory
config: mips-randconfig-c004-20210816 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2c6448cdc2f68f8c28fd0bd9404182b81306e6e6)
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/next/linux-next.git/commi...
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout 5161a55c069f53d88da49274cbef6e3c74eadea9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
>> drivers/cxl/core/bus.c:516:1: warning: stack frame size (1032) exceeds limit (1024) in function 'devm_cxl_add_decoder' [-Wframe-larger-than]
devm_cxl_add_decoder(struct device *host, struct cxl_port *port, int nr_targets,
^
1 warning generated.
vim +/devm_cxl_add_decoder +516 drivers/cxl/core/bus.c
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 514
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 515 struct cxl_decoder *
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 @516 devm_cxl_add_decoder(struct device *host, struct cxl_port *port, int nr_targets,
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 517 resource_size_t base, resource_size_t len,
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 518 int interleave_ways, int interleave_granularity,
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 519 enum cxl_decoder_type type, unsigned long flags)
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 520 {
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 521 struct cxl_decoder *cxld;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 522 struct device *dev;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 523 int rc;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 524
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 525 cxld = cxl_decoder_alloc(port, nr_targets, base, len, interleave_ways,
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 526 interleave_granularity, type, flags);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 527 if (IS_ERR(cxld))
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 528 return cxld;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 529
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 530 dev = &cxld->dev;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 531 rc = dev_set_name(dev, "decoder%d.%d", port->id, cxld->id);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 532 if (rc)
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 533 goto err;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 534
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 535 rc = device_add(dev);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 536 if (rc)
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 537 goto err;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 538
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 539 rc = devm_add_action_or_reset(host, unregister_dev, dev);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 540 if (rc)
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 541 return ERR_PTR(rc);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 542 return cxld;
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 543
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 544 err:
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 545 put_device(dev);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 546 return ERR_PTR(rc);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 547 }
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 548 EXPORT_SYMBOL_GPL(devm_cxl_add_decoder);
40ba17afdfabb0 drivers/cxl/core.c Dan Williams 2021-06-09 549
:::::: The code at line 516 was first introduced by commit
:::::: 40ba17afdfabb01688c61565dbe02a916241bc05 cxl/acpi: Introduce cxl_decoder objects
:::::: TO: Dan Williams <dan.j.williams(a)intel.com>
:::::: CC: Dan Williams <dan.j.williams(a)intel.com>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
1 year, 1 month