drivers/hwspinlock/u8500_hsem.c:52:39: sparse: got void

From: kernel test robot
Date: Tue Aug 11 2020 - 23:47:50 EST


Hi Baolin,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fb893de323e2d39f7a1f6df425703a2edbdf56ea
commit: ffd0bbfb378ecd56eac22bf932ccdbf89ac7f725 hwspinlock: Allow drivers to be built with COMPILE_TEST
date: 5 months ago
config: powerpc64-randconfig-s032-20200812 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.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.2-168-g9554805c-dirty
git checkout ffd0bbfb378ecd56eac22bf932ccdbf89ac7f725
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=powerpc64

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/hwspinlock/u8500_hsem.c:52:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void [noderef] <asn:2> *lock_addr @@ got void *priv @@
drivers/hwspinlock/u8500_hsem.c:52:39: sparse: expected void [noderef] <asn:2> *lock_addr
>> drivers/hwspinlock/u8500_hsem.c:52:39: sparse: got void *priv
drivers/hwspinlock/u8500_hsem.c:65:39: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void [noderef] <asn:2> *lock_addr @@ got void *priv @@
drivers/hwspinlock/u8500_hsem.c:65:39: sparse: expected void [noderef] <asn:2> *lock_addr
drivers/hwspinlock/u8500_hsem.c:65:39: sparse: got void *priv
drivers/hwspinlock/u8500_hsem.c:116:30: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void *priv @@ got void [noderef] <asn:2> * @@
>> drivers/hwspinlock/u8500_hsem.c:116:30: sparse: expected void *priv
drivers/hwspinlock/u8500_hsem.c:116:30: sparse: got void [noderef] <asn:2> *
drivers/hwspinlock/u8500_hsem.c:126:52: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void [noderef] <asn:2> *io_base @@ got void * @@
drivers/hwspinlock/u8500_hsem.c:126:52: sparse: expected void [noderef] <asn:2> *io_base
>> drivers/hwspinlock/u8500_hsem.c:126:52: sparse: got void *

vim +52 drivers/hwspinlock/u8500_hsem.c

f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 49
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 50 static int u8500_hsem_trylock(struct hwspinlock *lock)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 51 {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 @52 void __iomem *lock_addr = lock->priv;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 53
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 54 writel(HSEM_MASTER_ID, lock_addr);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 55
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 56 /* get only first 4 bit and compare to masterID.
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 57 * if equal, we have the semaphore, otherwise
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 58 * someone else has it.
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 59 */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 60 return (HSEM_MASTER_ID == (0x0F & readl(lock_addr)));
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 61 }
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 62
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 63 static void u8500_hsem_unlock(struct hwspinlock *lock)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 64 {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 65 void __iomem *lock_addr = lock->priv;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 66
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 67 /* release the lock by writing 0 to it */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 68 writel(RESET_SEMAPHORE, lock_addr);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 69 }
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 70
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 71 /*
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 72 * u8500: what value is recommended here ?
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 73 */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 74 static void u8500_hsem_relax(struct hwspinlock *lock)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 75 {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 76 ndelay(50);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 77 }
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 78
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 79 static const struct hwspinlock_ops u8500_hwspinlock_ops = {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 80 .trylock = u8500_hsem_trylock,
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 81 .unlock = u8500_hsem_unlock,
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 82 .relax = u8500_hsem_relax,
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 83 };
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 84
571291066d053c Bill Pemberton 2012-11-19 85 static int u8500_hsem_probe(struct platform_device *pdev)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 86 {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 87 struct hwspinlock_pdata *pdata = pdev->dev.platform_data;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 88 struct hwspinlock_device *bank;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 89 struct hwspinlock *hwlock;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 90 void __iomem *io_base;
9d399f0c52951c Baolin Wang 2019-10-14 91 int i, num_locks = U8500_MAX_SEMAPHORE;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 92 ulong val;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 93
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 94 if (!pdata)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 95 return -ENODEV;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 96
5ee45e0c894636 Baolin Wang 2019-09-27 97 io_base = devm_platform_ioremap_resource(pdev, 0);
5ee45e0c894636 Baolin Wang 2019-09-27 98 if (IS_ERR(io_base))
5ee45e0c894636 Baolin Wang 2019-09-27 99 return PTR_ERR(io_base);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 100
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 101 /* make sure protocol 1 is selected */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 102 val = readl(io_base + HSEM_CTRL_REG);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 103 writel((val & ~HSEM_PROTOCOL_1), io_base + HSEM_CTRL_REG);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 104
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 105 /* clear all interrupts */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 106 writel(0xFFFF, io_base + HSEM_ICRALL);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 107
637bcd19beeb9e Baolin Wang 2019-09-27 108 bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
637bcd19beeb9e Baolin Wang 2019-09-27 109 GFP_KERNEL);
5ee45e0c894636 Baolin Wang 2019-09-27 110 if (!bank)
5ee45e0c894636 Baolin Wang 2019-09-27 111 return -ENOMEM;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 112
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 113 platform_set_drvdata(pdev, bank);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 114
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 115 for (i = 0, hwlock = &bank->lock[0]; i < num_locks; i++, hwlock++)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 @116 hwlock->priv = io_base + HSEM_REGISTER_OFFSET + sizeof(u32) * i;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 117
9d399f0c52951c Baolin Wang 2019-10-14 118 return devm_hwspin_lock_register(&pdev->dev, bank,
9d399f0c52951c Baolin Wang 2019-10-14 119 &u8500_hwspinlock_ops,
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 120 pdata->base_id, num_locks);
637bcd19beeb9e Baolin Wang 2019-09-27 121 }
637bcd19beeb9e Baolin Wang 2019-09-27 122
e533a349c0258f Bill Pemberton 2012-11-19 123 static int u8500_hsem_remove(struct platform_device *pdev)
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 124 {
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 125 struct hwspinlock_device *bank = platform_get_drvdata(pdev);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 @126 void __iomem *io_base = bank->lock[0].priv - HSEM_REGISTER_OFFSET;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 127
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 128 /* clear all interrupts */
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 129 writel(0xFFFF, io_base + HSEM_ICRALL);
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 130
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 131 return 0;
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 132 }
f84a8ecfca9229 Mathieu J. Poirier 2011-09-08 133

:::::: The code at line 52 was first introduced by commit
:::::: f84a8ecfca9229e9227c6ec84123b114ee634959 hwspinlock/u8500: add hwspinlock driver

:::::: TO: Mathieu J. Poirier <mathieu.poirier@xxxxxxxxxx>
:::::: CC: Ohad Ben-Cohen <ohad@xxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip