drivers/infiniband/hw/hfi1/pio_copy.c:421:24: sparse: sparse: cast removes address space '__iomem' of expression
From: kernel test robot
Date: Thu Jun 25 2020 - 17:40:05 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 908f7d12d3ba51dfe0449b9723199b423f97ca9a
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces
date: 7 days ago
config: x86_64-randconfig-s022-20200625 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-dirty
git checkout 670d0a4b10704667765f7d18f7592993d02783aa
# save the attached .config to linux build tree
make W=1 C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
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/infiniband/hw/hfi1/pio_copy.c:421:24: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/infiniband/hw/hfi1/pio_copy.c:421:24: sparse: sparse: cast removes address space '__iomem' of expression
drivers/infiniband/hw/hfi1/pio_copy.c:547:24: sparse: sparse: cast removes address space '__iomem' of expression
drivers/infiniband/hw/hfi1/pio_copy.c:547:24: sparse: sparse: cast removes address space '__iomem' of expression
--
drivers/net/wireless/intel/iwlwifi/mvm/..//fw/file.h:330:19: sparse: sparse: mixed bitwiseness
drivers/net/wireless/intel/iwlwifi/mvm/..//fw/file.h:484:19: sparse: sparse: mixed bitwiseness
>> drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3002:63: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected unsigned char const [usertype] *ies @@ got unsigned char const [noderef] __rcu * @@
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3002:63: sparse: expected unsigned char const [usertype] *ies
>> drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3002:63: sparse: got unsigned char const [noderef] __rcu *
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3003:38: sparse: sparse: dereference of noderef expression
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3003:38: sparse: sparse: dereference of noderef expression
vim +/__iomem +421 drivers/infiniband/hw/hfi1/pio_copy.c
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 384
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 385 /*
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 386 * Mid copy helper, "mixed case" - source is 64-bit aligned but carry
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 387 * bytes are non-zero.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 388 *
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 389 * Whole u64s must be written to the chip, so bytes must be manually merged.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 390 *
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 391 * @pbuf: destination buffer
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 392 * @from: data source, is QWORD aligned.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 393 * @nbytes: bytes to copy
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 394 *
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 395 * Must handle nbytes < 8.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 396 */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 397 static void mid_copy_mix(struct pio_buf *pbuf, const void *from, size_t nbytes)
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 398 {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 399 void __iomem *dest = pbuf->start + (pbuf->qw_written * sizeof(u64));
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 400 void __iomem *dend; /* 8-byte data end */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 401 unsigned long qw_to_write = nbytes >> 3;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 402 unsigned long bytes_left = nbytes & 0x7;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 403
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 404 /* calculate 8-byte data end */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 405 dend = dest + (qw_to_write * sizeof(u64));
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 406
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 407 if (pbuf->qw_written < PIO_BLOCK_QWS) {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 408 /*
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 409 * Still within SOP block. We don't need to check for
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 410 * wrap because we are still in the first block and
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 411 * can only wrap on block boundaries.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 412 */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 413 void __iomem *send; /* SOP end */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 414 void __iomem *xend;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 415
4d114fdd90ab41 drivers/staging/rdma/hfi1/pio_copy.c Jubin John 2016-02-14 416 /*
4d114fdd90ab41 drivers/staging/rdma/hfi1/pio_copy.c Jubin John 2016-02-14 417 * calculate the end of data or end of block, whichever
4d114fdd90ab41 drivers/staging/rdma/hfi1/pio_copy.c Jubin John 2016-02-14 418 * comes first
4d114fdd90ab41 drivers/staging/rdma/hfi1/pio_copy.c Jubin John 2016-02-14 419 */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 420 send = pbuf->start + PIO_BLOCK_SIZE;
c754db403d7408 drivers/staging/rdma/hfi1/pio_copy.c Bhumika Goyal 2016-02-26 @421 xend = min(send, dend);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 422
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 423 /* shift up to SOP=1 space */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 424 dest += SOP_DISTANCE;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 425 xend += SOP_DISTANCE;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 426
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 427 /* write 8-byte chunk data */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 428 while (dest < xend) {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 429 merge_write8(pbuf, dest, from);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 430 from += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 431 dest += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 432 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 433
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 434 /* shift down to SOP=0 space */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 435 dest -= SOP_DISTANCE;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 436 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 437 /*
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 438 * At this point dest could be (either, both, or neither):
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 439 * - at dend
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 440 * - at the wrap
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 441 */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 442
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 443 /*
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 444 * If the wrap comes before or matches the data end,
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 445 * copy until until the wrap, then wrap.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 446 *
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 447 * If dest is at the wrap, we will fall into the if,
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 448 * not do the loop, when wrap.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 449 *
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 450 * If the data ends at the end of the SOP above and
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 451 * the buffer wraps, then pbuf->end == dend == dest
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 452 * and nothing will get written.
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 453 */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 454 if (pbuf->end <= dend) {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 455 while (dest < pbuf->end) {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 456 merge_write8(pbuf, dest, from);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 457 from += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 458 dest += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 459 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 460
8af8d2970ed984 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-10-25 461 dest -= pbuf->sc->size;
8af8d2970ed984 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-10-25 462 dend -= pbuf->sc->size;
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 463 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 464
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 465 /* write 8-byte non-SOP, non-wrap chunk data */
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 466 while (dest < dend) {
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 467 merge_write8(pbuf, dest, from);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 468 from += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 469 dest += sizeof(u64);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 470 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 471
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 472 pbuf->qw_written += qw_to_write;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 473
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 474 /* handle carry and left-over bytes */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 475 if (pbuf->carry_bytes + bytes_left >= 8) {
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 476 unsigned long nread;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 477
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 478 /* there is enough to fill another qw - fill carry */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 479 nread = 8 - pbuf->carry_bytes;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 480 read_extra_bytes(pbuf, from, nread);
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 481
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 482 /*
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 483 * One more write - but need to make sure dest is correct.
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 484 * Check for wrap and the possibility the write
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 485 * should be in SOP space.
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 486 *
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 487 * The two checks immediately below cannot both be true, hence
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 488 * the else. If we have wrapped, we cannot still be within the
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 489 * first block. Conversely, if we are still in the first block,
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 490 * we cannot have wrapped. We do the wrap check first as that
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 491 * is more likely.
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 492 */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 493 /* adjust if we have wrapped */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 494 if (dest >= pbuf->end)
8af8d2970ed984 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-10-25 495 dest -= pbuf->sc->size;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 496 /* jump to the SOP range if within the first block */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 497 else if (pbuf->qw_written < PIO_BLOCK_QWS)
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 498 dest += SOP_DISTANCE;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 499
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 500 /* flush out full carry */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 501 carry8_write8(pbuf->carry, dest);
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 502 pbuf->qw_written++;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 503
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 504 /* now adjust and read the rest of the bytes into carry */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 505 bytes_left -= nread;
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 506 from += nread; /* from is now not aligned */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 507 read_low_bytes(pbuf, from, bytes_left);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 508 } else {
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 509 /* not enough to fill another qw, append the rest to carry */
a4309d94f71067 drivers/infiniband/hw/hfi1/pio_copy.c Sebastian Sanchez 2016-09-25 510 read_extra_bytes(pbuf, from, bytes_left);
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 511 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 512 }
7724105686e718 drivers/staging/rdma/hfi1/pio_copy.c Mike Marciniszyn 2015-07-30 513
:::::: The code at line 421 was first introduced by commit
:::::: c754db403d740827e49f5f9dedd9594ff55ccbe7 Staging: rdma: Use min macro instead of ternary operator
:::::: TO: Bhumika Goyal <bhumirks@xxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip