drivers/edac/pnd2_edac.c:295:22: sparse: sparse: incorrect type in assignment (different address spaces)

From: kernel test robot
Date: Sat Aug 08 2020 - 15:48:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 11030fe96b57ad843518b0e9430f3cd4b3610ce2
commit: 670d0a4b10704667765f7d18f7592993d02783aa sparse: use identifiers to define address spaces
date: 7 weeks ago
config: x86_64-randconfig-s031-20200809 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-118-ge1578773-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/edac/pnd2_edac.c:295:22: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected char *base @@ got void [noderef] __iomem * @@
drivers/edac/pnd2_edac.c:295:22: sparse: expected char *base
>> drivers/edac/pnd2_edac.c:295:22: sparse: got void [noderef] __iomem *
>> drivers/edac/pnd2_edac.c:303:25: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got char *base @@
>> drivers/edac/pnd2_edac.c:303:25: sparse: expected void volatile [noderef] __iomem *addr
drivers/edac/pnd2_edac.c:303:25: sparse: got char *base
--
>> drivers/edac/i10nm_base.c:149:19: sparse: sparse: cast removes address space '__iomem' of expression
drivers/edac/i10nm_base.c:170:31: sparse: sparse: cast removes address space '__iomem' of expression
drivers/edac/i10nm_base.c:171:37: sparse: sparse: cast removes address space '__iomem' of expression

vim +295 drivers/edac/pnd2_edac.c

5c71ad17f97e84 Tony Luck 2017-03-09 262
29a3388bfcce7a Stephen Douthit 2019-08-09 263 #define DNV_MCHBAR_SIZE 0x8000
29a3388bfcce7a Stephen Douthit 2019-08-09 264 #define DNV_SB_PORT_SIZE 0x10000
5c71ad17f97e84 Tony Luck 2017-03-09 265 static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *name)
5c71ad17f97e84 Tony Luck 2017-03-09 266 {
5c71ad17f97e84 Tony Luck 2017-03-09 267 struct pci_dev *pdev;
5c71ad17f97e84 Tony Luck 2017-03-09 268 char *base;
5c71ad17f97e84 Tony Luck 2017-03-09 269 u64 addr;
29a3388bfcce7a Stephen Douthit 2019-08-09 270 unsigned long size;
5c71ad17f97e84 Tony Luck 2017-03-09 271
5c71ad17f97e84 Tony Luck 2017-03-09 272 if (op == 4) {
5c71ad17f97e84 Tony Luck 2017-03-09 273 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x1980, NULL);
5c71ad17f97e84 Tony Luck 2017-03-09 274 if (!pdev)
5c71ad17f97e84 Tony Luck 2017-03-09 275 return -ENODEV;
5c71ad17f97e84 Tony Luck 2017-03-09 276
5c71ad17f97e84 Tony Luck 2017-03-09 277 pci_read_config_dword(pdev, off, data);
5c71ad17f97e84 Tony Luck 2017-03-09 278 pci_dev_put(pdev);
5c71ad17f97e84 Tony Luck 2017-03-09 279 } else {
5c71ad17f97e84 Tony Luck 2017-03-09 280 /* MMIO via memory controller hub base address */
5c71ad17f97e84 Tony Luck 2017-03-09 281 if (op == 0 && port == 0x4c) {
5c71ad17f97e84 Tony Luck 2017-03-09 282 addr = get_mem_ctrl_hub_base_addr();
5c71ad17f97e84 Tony Luck 2017-03-09 283 if (!addr)
5c71ad17f97e84 Tony Luck 2017-03-09 284 return -ENODEV;
29a3388bfcce7a Stephen Douthit 2019-08-09 285 size = DNV_MCHBAR_SIZE;
5c71ad17f97e84 Tony Luck 2017-03-09 286 } else {
5c71ad17f97e84 Tony Luck 2017-03-09 287 /* MMIO via sideband register base address */
5c71ad17f97e84 Tony Luck 2017-03-09 288 addr = get_sideband_reg_base_addr();
5c71ad17f97e84 Tony Luck 2017-03-09 289 if (!addr)
5c71ad17f97e84 Tony Luck 2017-03-09 290 return -ENODEV;
5c71ad17f97e84 Tony Luck 2017-03-09 291 addr += (port << 16);
29a3388bfcce7a Stephen Douthit 2019-08-09 292 size = DNV_SB_PORT_SIZE;
5c71ad17f97e84 Tony Luck 2017-03-09 293 }
5c71ad17f97e84 Tony Luck 2017-03-09 294
29a3388bfcce7a Stephen Douthit 2019-08-09 @295 base = ioremap((resource_size_t)addr, size);
5c71ad17f97e84 Tony Luck 2017-03-09 296 if (!base)
5c71ad17f97e84 Tony Luck 2017-03-09 297 return -ENODEV;
5c71ad17f97e84 Tony Luck 2017-03-09 298
5c71ad17f97e84 Tony Luck 2017-03-09 299 if (sz == 8)
5c71ad17f97e84 Tony Luck 2017-03-09 300 *(u32 *)(data + 4) = *(u32 *)(base + off + 4);
5c71ad17f97e84 Tony Luck 2017-03-09 301 *(u32 *)data = *(u32 *)(base + off);
5c71ad17f97e84 Tony Luck 2017-03-09 302
5c71ad17f97e84 Tony Luck 2017-03-09 @303 iounmap(base);
5c71ad17f97e84 Tony Luck 2017-03-09 304 }
5c71ad17f97e84 Tony Luck 2017-03-09 305
5c71ad17f97e84 Tony Luck 2017-03-09 306 edac_dbg(2, "Read %s=%.8x_%.8x\n", name,
5c71ad17f97e84 Tony Luck 2017-03-09 307 (sz == 8) ? *(u32 *)(data + 4) : 0, *(u32 *)data);
5c71ad17f97e84 Tony Luck 2017-03-09 308
5c71ad17f97e84 Tony Luck 2017-03-09 309 return 0;
5c71ad17f97e84 Tony Luck 2017-03-09 310 }
5c71ad17f97e84 Tony Luck 2017-03-09 311

:::::: The code at line 295 was first introduced by commit
:::::: 29a3388bfcce7a6d087051376ea02bf8326a957b EDAC, pnd2: Fix ioremap() size in dnv_rd_reg()

:::::: TO: Stephen Douthit <stephend@xxxxxxxxxxxxxxx>
:::::: CC: Tony Luck <tony.luck@xxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip