drivers/scsi/fnic/vnic_dev.c:332:32: sparse: sparse: incorrect type in argument 1 (different address spaces)
From: kernel test robot
Date: Wed Aug 05 2020 - 20:03:35 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ecfd7940b8641da6e41ca94eba36876dc2ba827b
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces
date: 7 weeks ago
config: x86_64-randconfig-s021-20200806 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-117-g8c7aee71-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
sparse warnings: (new ones prefixed by >>)
>> drivers/scsi/fnic/vnic_dev.c:332:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned int * @@
>> drivers/scsi/fnic/vnic_dev.c:332:32: sparse: expected void [noderef] __iomem *
drivers/scsi/fnic/vnic_dev.c:332:32: sparse: got unsigned int *
drivers/scsi/fnic/vnic_dev.c:333:37: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned int * @@
drivers/scsi/fnic/vnic_dev.c:333:37: sparse: expected void [noderef] __iomem *
drivers/scsi/fnic/vnic_dev.c:333:37: sparse: got unsigned int *
drivers/scsi/fnic/vnic_dev.c:373:36: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned int * @@
drivers/scsi/fnic/vnic_dev.c:373:36: sparse: expected void [noderef] __iomem *
drivers/scsi/fnic/vnic_dev.c:373:36: sparse: got unsigned int *
>> drivers/scsi/fnic/vnic_dev.c:469:32: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct vnic_wq_ctrl *wq_ctrl @@ got struct vnic_wq_ctrl [noderef] __iomem *ctrl @@
drivers/scsi/fnic/vnic_dev.c:469:32: sparse: expected struct vnic_wq_ctrl *wq_ctrl
>> drivers/scsi/fnic/vnic_dev.c:469:32: sparse: got struct vnic_wq_ctrl [noderef] __iomem *ctrl
>> drivers/scsi/fnic/vnic_dev.c:943:11: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *p @@ got void [noderef] __iomem * @@
drivers/scsi/fnic/vnic_dev.c:943:11: sparse: expected void *p
>> drivers/scsi/fnic/vnic_dev.c:943:11: sparse: got void [noderef] __iomem *
--
>> drivers/scsi/qedf/qedf_debugfs.c:113:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *buf @@ got char [noderef] __user *buffer @@
drivers/scsi/qedf/qedf_debugfs.c:113:23: sparse: expected char *buf
>> drivers/scsi/qedf/qedf_debugfs.c:113:23: sparse: got char [noderef] __user *buffer
>> drivers/scsi/qedf/qedf_debugfs.c:119:40: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *buf @@ got char [noderef] __user * @@
drivers/scsi/qedf/qedf_debugfs.c:119:40: sparse: expected char *buf
>> drivers/scsi/qedf/qedf_debugfs.c:119:40: sparse: got char [noderef] __user *
drivers/scsi/qedf/qedf_debugfs.c:147:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *buf @@ got char [noderef] __user *buffer @@
drivers/scsi/qedf/qedf_debugfs.c:147:23: sparse: expected char *buf
drivers/scsi/qedf/qedf_debugfs.c:147:23: sparse: got char [noderef] __user *buffer
drivers/scsi/qedf/qedf_debugfs.c:196:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *buf @@ got char [noderef] __user *buffer @@
drivers/scsi/qedf/qedf_debugfs.c:196:23: sparse: expected char *buf
drivers/scsi/qedf/qedf_debugfs.c:196:23: sparse: got char [noderef] __user *buffer
--
>> drivers/scsi/qedi/qedi_debugfs.c:109:45: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected char const * @@ got char const [noderef] __user *buffer @@
drivers/scsi/qedi/qedi_debugfs.c:109:45: sparse: expected char const *
>> drivers/scsi/qedi/qedi_debugfs.c:109:45: sparse: got char const [noderef] __user *buffer
>> drivers/scsi/qedi/qedi_debugfs.c:128:23: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char *buf @@ got char [noderef] __user *buffer @@
drivers/scsi/qedi/qedi_debugfs.c:128:23: sparse: expected char *buf
>> drivers/scsi/qedi/qedi_debugfs.c:128:23: sparse: got char [noderef] __user *buffer
drivers/scsi/qedi/qedi_debugfs.c:154:41: sparse: sparse: restricted __le16 degrades to integer
vim +332 drivers/scsi/fnic/vnic_dev.c
5df6d737dd4b0f Abhijeet Joglekar 2009-04-17 318
363f4d937501ba Jason Yan 2020-04-15 319 static int vnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
0a2fdd2215e1fa Satish Kharat 2019-01-18 320 int wait)
0a2fdd2215e1fa Satish Kharat 2019-01-18 321 {
0a2fdd2215e1fa Satish Kharat 2019-01-18 322 struct devcmd2_controller *dc2c = vdev->devcmd2;
0a2fdd2215e1fa Satish Kharat 2019-01-18 323 struct devcmd2_result *result;
0a2fdd2215e1fa Satish Kharat 2019-01-18 324 u8 color;
0a2fdd2215e1fa Satish Kharat 2019-01-18 325 unsigned int i;
0a2fdd2215e1fa Satish Kharat 2019-01-18 326 int delay;
0a2fdd2215e1fa Satish Kharat 2019-01-18 327 int err;
0a2fdd2215e1fa Satish Kharat 2019-01-18 328 u32 fetch_index;
0a2fdd2215e1fa Satish Kharat 2019-01-18 329 u32 posted;
0a2fdd2215e1fa Satish Kharat 2019-01-18 330 u32 new_posted;
0a2fdd2215e1fa Satish Kharat 2019-01-18 331
0a2fdd2215e1fa Satish Kharat 2019-01-18 @332 posted = ioread32(&dc2c->wq_ctrl->posted_index);
0a2fdd2215e1fa Satish Kharat 2019-01-18 333 fetch_index = ioread32(&dc2c->wq_ctrl->fetch_index);
0a2fdd2215e1fa Satish Kharat 2019-01-18 334
0a2fdd2215e1fa Satish Kharat 2019-01-18 335 if (posted == 0xFFFFFFFF || fetch_index == 0xFFFFFFFF) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 336 /* Hardware surprise removal: return error */
0a2fdd2215e1fa Satish Kharat 2019-01-18 337 pr_err("%s: devcmd2 invalid posted or fetch index on cmd %d\n",
0a2fdd2215e1fa Satish Kharat 2019-01-18 338 pci_name(vdev->pdev), _CMD_N(cmd));
0a2fdd2215e1fa Satish Kharat 2019-01-18 339 pr_err("%s: fetch index: %u, posted index: %u\n",
0a2fdd2215e1fa Satish Kharat 2019-01-18 340 pci_name(vdev->pdev), fetch_index, posted);
0a2fdd2215e1fa Satish Kharat 2019-01-18 341
0a2fdd2215e1fa Satish Kharat 2019-01-18 342 return -ENODEV;
0a2fdd2215e1fa Satish Kharat 2019-01-18 343
0a2fdd2215e1fa Satish Kharat 2019-01-18 344 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 345
0a2fdd2215e1fa Satish Kharat 2019-01-18 346 new_posted = (posted + 1) % DEVCMD2_RING_SIZE;
0a2fdd2215e1fa Satish Kharat 2019-01-18 347
0a2fdd2215e1fa Satish Kharat 2019-01-18 348 if (new_posted == fetch_index) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 349 pr_err("%s: devcmd2 wq full while issuing cmd %d\n",
0a2fdd2215e1fa Satish Kharat 2019-01-18 350 pci_name(vdev->pdev), _CMD_N(cmd));
0a2fdd2215e1fa Satish Kharat 2019-01-18 351 pr_err("%s: fetch index: %u, posted index: %u\n",
0a2fdd2215e1fa Satish Kharat 2019-01-18 352 pci_name(vdev->pdev), fetch_index, posted);
0a2fdd2215e1fa Satish Kharat 2019-01-18 353 return -EBUSY;
0a2fdd2215e1fa Satish Kharat 2019-01-18 354
0a2fdd2215e1fa Satish Kharat 2019-01-18 355 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 356 dc2c->cmd_ring[posted].cmd = cmd;
0a2fdd2215e1fa Satish Kharat 2019-01-18 357 dc2c->cmd_ring[posted].flags = 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 358
0a2fdd2215e1fa Satish Kharat 2019-01-18 359 if ((_CMD_FLAGS(cmd) & _CMD_FLAGS_NOWAIT))
0a2fdd2215e1fa Satish Kharat 2019-01-18 360 dc2c->cmd_ring[posted].flags |= DEVCMD2_FNORESULT;
0a2fdd2215e1fa Satish Kharat 2019-01-18 361 if (_CMD_DIR(cmd) & _CMD_DIR_WRITE) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 362 for (i = 0; i < VNIC_DEVCMD_NARGS; i++)
0a2fdd2215e1fa Satish Kharat 2019-01-18 363 dc2c->cmd_ring[posted].args[i] = vdev->args[i];
0a2fdd2215e1fa Satish Kharat 2019-01-18 364
0a2fdd2215e1fa Satish Kharat 2019-01-18 365 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 366
0a2fdd2215e1fa Satish Kharat 2019-01-18 367 /* Adding write memory barrier prevents compiler and/or CPU
0a2fdd2215e1fa Satish Kharat 2019-01-18 368 * reordering, thus avoiding descriptor posting before
0a2fdd2215e1fa Satish Kharat 2019-01-18 369 * descriptor is initialized. Otherwise, hardware can read
0a2fdd2215e1fa Satish Kharat 2019-01-18 370 * stale descriptor fields.
0a2fdd2215e1fa Satish Kharat 2019-01-18 371 */
0a2fdd2215e1fa Satish Kharat 2019-01-18 372 wmb();
0a2fdd2215e1fa Satish Kharat 2019-01-18 373 iowrite32(new_posted, &dc2c->wq_ctrl->posted_index);
0a2fdd2215e1fa Satish Kharat 2019-01-18 374
0a2fdd2215e1fa Satish Kharat 2019-01-18 375 if (dc2c->cmd_ring[posted].flags & DEVCMD2_FNORESULT)
0a2fdd2215e1fa Satish Kharat 2019-01-18 376 return 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 377
0a2fdd2215e1fa Satish Kharat 2019-01-18 378 result = dc2c->result + dc2c->next_result;
0a2fdd2215e1fa Satish Kharat 2019-01-18 379 color = dc2c->color;
0a2fdd2215e1fa Satish Kharat 2019-01-18 380
0a2fdd2215e1fa Satish Kharat 2019-01-18 381 dc2c->next_result++;
0a2fdd2215e1fa Satish Kharat 2019-01-18 382 if (dc2c->next_result == dc2c->result_size) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 383 dc2c->next_result = 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 384 dc2c->color = dc2c->color ? 0 : 1;
0a2fdd2215e1fa Satish Kharat 2019-01-18 385 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 386
0a2fdd2215e1fa Satish Kharat 2019-01-18 387 for (delay = 0; delay < wait; delay++) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 388 udelay(100);
0a2fdd2215e1fa Satish Kharat 2019-01-18 389 if (result->color == color) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 390 if (result->error) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 391 err = -(int) result->error;
0a2fdd2215e1fa Satish Kharat 2019-01-18 392 if (err != ERR_ECMDUNKNOWN ||
0a2fdd2215e1fa Satish Kharat 2019-01-18 393 cmd != CMD_CAPABILITY)
0a2fdd2215e1fa Satish Kharat 2019-01-18 394 pr_err("%s:Error %d devcmd %d\n",
0a2fdd2215e1fa Satish Kharat 2019-01-18 395 pci_name(vdev->pdev),
0a2fdd2215e1fa Satish Kharat 2019-01-18 396 err, _CMD_N(cmd));
0a2fdd2215e1fa Satish Kharat 2019-01-18 397 return err;
0a2fdd2215e1fa Satish Kharat 2019-01-18 398 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 399 if (_CMD_DIR(cmd) & _CMD_DIR_READ) {
0a2fdd2215e1fa Satish Kharat 2019-01-18 400 rmb(); /*prevent reorder while reding result*/
0a2fdd2215e1fa Satish Kharat 2019-01-18 401 for (i = 0; i < VNIC_DEVCMD_NARGS; i++)
0a2fdd2215e1fa Satish Kharat 2019-01-18 402 vdev->args[i] = result->results[i];
0a2fdd2215e1fa Satish Kharat 2019-01-18 403 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 404 return 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 405 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 406 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 407
0a2fdd2215e1fa Satish Kharat 2019-01-18 408 pr_err("%s:Timed out devcmd %d\n", pci_name(vdev->pdev), _CMD_N(cmd));
0a2fdd2215e1fa Satish Kharat 2019-01-18 409
0a2fdd2215e1fa Satish Kharat 2019-01-18 410 return -ETIMEDOUT;
0a2fdd2215e1fa Satish Kharat 2019-01-18 411 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 412
0a2fdd2215e1fa Satish Kharat 2019-01-18 413
363f4d937501ba Jason Yan 2020-04-15 414 static int vnic_dev_init_devcmd1(struct vnic_dev *vdev)
0a2fdd2215e1fa Satish Kharat 2019-01-18 415 {
0a2fdd2215e1fa Satish Kharat 2019-01-18 416 vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0);
0a2fdd2215e1fa Satish Kharat 2019-01-18 417 if (!vdev->devcmd)
0a2fdd2215e1fa Satish Kharat 2019-01-18 418 return -ENODEV;
0a2fdd2215e1fa Satish Kharat 2019-01-18 419
0a2fdd2215e1fa Satish Kharat 2019-01-18 420 vdev->devcmd_rtn = &vnic_dev_cmd1;
0a2fdd2215e1fa Satish Kharat 2019-01-18 421 return 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 422 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 423
0a2fdd2215e1fa Satish Kharat 2019-01-18 424
363f4d937501ba Jason Yan 2020-04-15 425 static int vnic_dev_init_devcmd2(struct vnic_dev *vdev)
0a2fdd2215e1fa Satish Kharat 2019-01-18 426 {
0a2fdd2215e1fa Satish Kharat 2019-01-18 427 int err;
0a2fdd2215e1fa Satish Kharat 2019-01-18 428 unsigned int fetch_index;
0a2fdd2215e1fa Satish Kharat 2019-01-18 429
0a2fdd2215e1fa Satish Kharat 2019-01-18 430 if (vdev->devcmd2)
0a2fdd2215e1fa Satish Kharat 2019-01-18 431 return 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 432
0a2fdd2215e1fa Satish Kharat 2019-01-18 433 vdev->devcmd2 = kzalloc(sizeof(*vdev->devcmd2), GFP_ATOMIC);
0a2fdd2215e1fa Satish Kharat 2019-01-18 434 if (!vdev->devcmd2)
0a2fdd2215e1fa Satish Kharat 2019-01-18 435 return -ENOMEM;
0a2fdd2215e1fa Satish Kharat 2019-01-18 436
0a2fdd2215e1fa Satish Kharat 2019-01-18 437 vdev->devcmd2->color = 1;
0a2fdd2215e1fa Satish Kharat 2019-01-18 438 vdev->devcmd2->result_size = DEVCMD2_RING_SIZE;
0a2fdd2215e1fa Satish Kharat 2019-01-18 439 err = vnic_wq_devcmd2_alloc(vdev, &vdev->devcmd2->wq,
0a2fdd2215e1fa Satish Kharat 2019-01-18 440 DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
0a2fdd2215e1fa Satish Kharat 2019-01-18 441 if (err)
0a2fdd2215e1fa Satish Kharat 2019-01-18 442 goto err_free_devcmd2;
0a2fdd2215e1fa Satish Kharat 2019-01-18 443
0a2fdd2215e1fa Satish Kharat 2019-01-18 444 fetch_index = ioread32(&vdev->devcmd2->wq.ctrl->fetch_index);
0a2fdd2215e1fa Satish Kharat 2019-01-18 445 if (fetch_index == 0xFFFFFFFF) { /* check for hardware gone */
0a2fdd2215e1fa Satish Kharat 2019-01-18 446 pr_err("error in devcmd2 init");
0a2fdd2215e1fa Satish Kharat 2019-01-18 447 return -ENODEV;
0a2fdd2215e1fa Satish Kharat 2019-01-18 448 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 449
0a2fdd2215e1fa Satish Kharat 2019-01-18 450 /*
0a2fdd2215e1fa Satish Kharat 2019-01-18 451 * Don't change fetch_index ever and
0a2fdd2215e1fa Satish Kharat 2019-01-18 452 * set posted_index same as fetch_index
0a2fdd2215e1fa Satish Kharat 2019-01-18 453 * when setting up the WQ for devcmd2.
0a2fdd2215e1fa Satish Kharat 2019-01-18 454 */
0a2fdd2215e1fa Satish Kharat 2019-01-18 455 vnic_wq_init_start(&vdev->devcmd2->wq, 0, fetch_index,
0a2fdd2215e1fa Satish Kharat 2019-01-18 456 fetch_index, 0, 0);
0a2fdd2215e1fa Satish Kharat 2019-01-18 457
0a2fdd2215e1fa Satish Kharat 2019-01-18 458 vnic_wq_enable(&vdev->devcmd2->wq);
0a2fdd2215e1fa Satish Kharat 2019-01-18 459
0a2fdd2215e1fa Satish Kharat 2019-01-18 460 err = vnic_dev_alloc_desc_ring(vdev, &vdev->devcmd2->results_ring,
0a2fdd2215e1fa Satish Kharat 2019-01-18 461 DEVCMD2_RING_SIZE, DEVCMD2_DESC_SIZE);
0a2fdd2215e1fa Satish Kharat 2019-01-18 462 if (err)
0a2fdd2215e1fa Satish Kharat 2019-01-18 463 goto err_free_wq;
0a2fdd2215e1fa Satish Kharat 2019-01-18 464
0a2fdd2215e1fa Satish Kharat 2019-01-18 465 vdev->devcmd2->result =
0a2fdd2215e1fa Satish Kharat 2019-01-18 466 (struct devcmd2_result *) vdev->devcmd2->results_ring.descs;
0a2fdd2215e1fa Satish Kharat 2019-01-18 467 vdev->devcmd2->cmd_ring =
0a2fdd2215e1fa Satish Kharat 2019-01-18 468 (struct vnic_devcmd2 *) vdev->devcmd2->wq.ring.descs;
0a2fdd2215e1fa Satish Kharat 2019-01-18 @469 vdev->devcmd2->wq_ctrl = vdev->devcmd2->wq.ctrl;
0a2fdd2215e1fa Satish Kharat 2019-01-18 470 vdev->args[0] = (u64) vdev->devcmd2->results_ring.base_addr |
0a2fdd2215e1fa Satish Kharat 2019-01-18 471 VNIC_PADDR_TARGET;
0a2fdd2215e1fa Satish Kharat 2019-01-18 472 vdev->args[1] = DEVCMD2_RING_SIZE;
0a2fdd2215e1fa Satish Kharat 2019-01-18 473
0a2fdd2215e1fa Satish Kharat 2019-01-18 474 err = vnic_dev_cmd2(vdev, CMD_INITIALIZE_DEVCMD2, 1000);
0a2fdd2215e1fa Satish Kharat 2019-01-18 475 if (err)
0a2fdd2215e1fa Satish Kharat 2019-01-18 476 goto err_free_desc_ring;
0a2fdd2215e1fa Satish Kharat 2019-01-18 477
0a2fdd2215e1fa Satish Kharat 2019-01-18 478 vdev->devcmd_rtn = &vnic_dev_cmd2;
0a2fdd2215e1fa Satish Kharat 2019-01-18 479
0a2fdd2215e1fa Satish Kharat 2019-01-18 480 return 0;
0a2fdd2215e1fa Satish Kharat 2019-01-18 481
0a2fdd2215e1fa Satish Kharat 2019-01-18 482 err_free_desc_ring:
0a2fdd2215e1fa Satish Kharat 2019-01-18 483 vnic_dev_free_desc_ring(vdev, &vdev->devcmd2->results_ring);
0a2fdd2215e1fa Satish Kharat 2019-01-18 484 err_free_wq:
0a2fdd2215e1fa Satish Kharat 2019-01-18 485 vnic_wq_disable(&vdev->devcmd2->wq);
0a2fdd2215e1fa Satish Kharat 2019-01-18 486 vnic_wq_free(&vdev->devcmd2->wq);
0a2fdd2215e1fa Satish Kharat 2019-01-18 487 err_free_devcmd2:
0a2fdd2215e1fa Satish Kharat 2019-01-18 488 kfree(vdev->devcmd2);
0a2fdd2215e1fa Satish Kharat 2019-01-18 489 vdev->devcmd2 = NULL;
0a2fdd2215e1fa Satish Kharat 2019-01-18 490
0a2fdd2215e1fa Satish Kharat 2019-01-18 491 return err;
0a2fdd2215e1fa Satish Kharat 2019-01-18 492 }
0a2fdd2215e1fa Satish Kharat 2019-01-18 493
:::::: The code at line 332 was first introduced by commit
:::::: 0a2fdd2215e1fa3b417792bd6e9cb719822cbfb6 scsi: fnic: Adding devcmd2 init and posting interfaces
:::::: TO: Satish Kharat <satishkh@xxxxxxxxx>
:::::: CC: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip