Dan, Can you perhaps help me understand the following sparse warnings, they seem like false-positives to me. But I'm not used to sparse giving false-positives so I think I might be missing something here ? On 4/3/23 22:39, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: 31bd35b66249699343d2416658f57e97314a433a > commit: 0c18184de990e63f708b090bcb9fc6c0fbc427cd [3256/8744] platform/x86: apple-gmux: support MMIO gmux on T2 Macs > config: x86_64-randconfig-s023-20230403 (https://download.01.org/0day-ci/archive/20230404/202304040401.IMxt7Ubi-lkp@xxxxxxxxx/config) > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 > reproduce: > # apt-get install sparse > # sparse version: v0.6.4-39-gce1a6720-dirty > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0c18184de990e63f708b090bcb9fc6c0fbc427cd > 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 0c18184de990e63f708b090bcb9fc6c0fbc427cd > # save the config file > mkdir build_dir && cp config build_dir/.config > make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 olddefconfig > make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/platform/x86/ > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@xxxxxxxxx> > | Link: https://lore.kernel.org/oe-kbuild-all/202304040401.IMxt7Ubi-lkp@xxxxxxxxx/ > > sparse warnings: (new ones prefixed by >>) >>> drivers/platform/x86/apple-gmux.c:224:48: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:224:48: sparse: expected void const [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:224:48: sparse: got unsigned char [usertype] * So apple-gmux.c:224 for the commit these sparse warnings are about reads: u8 gwr = ioread8(gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); Where gmux_data is a "struct apple_gmux_data *" and the iomem_base member is: u8 *__iomem iomem_base; And GMUX_MMIO_COMMAND_SEND is: #define GMUX_MMIO_COMMAND_SEND 0x0f So I don't understand this warnining ? Maybe sparse tracks what is being assigned to apple_gmux_data->iomem_base else where ? The assignment is done like this: gmux_data->iomem_base = ioremap(gmux_data->iostart, gmux_data->iolen); And ioremap() returns a "void __iomem *" so even if the assignment is tracked things still seem fine ? Regards, Hans > drivers/platform/x86/apple-gmux.c:227:53: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:227:53: sparse: expected void const [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:227:53: sparse: got unsigned char [usertype] * >>> drivers/platform/x86/apple-gmux.c:241:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:241:55: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:241:55: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:243:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:243:39: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:243:39: sparse: got unsigned char [usertype] * >>> drivers/platform/x86/apple-gmux.c:245:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:245:32: sparse: expected void const [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:245:32: sparse: got unsigned char [usertype] *[noderef] iomem_base >>> drivers/platform/x86/apple-gmux.c:256:32: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:256:32: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:256:32: sparse: got unsigned char [usertype] *[noderef] iomem_base > drivers/platform/x86/apple-gmux.c:258:53: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:258:53: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:258:53: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:260:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:260:39: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:260:39: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:272:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:272:55: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:272:55: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:274:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:274:39: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:274:39: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:276:15: sparse: expected void const [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:276:15: sparse: got unsigned char [usertype] *[noderef] iomem_base >>> drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32 >>> drivers/platform/x86/apple-gmux.c:286:19: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@ > drivers/platform/x86/apple-gmux.c:286:19: sparse: expected unsigned int [usertype] > drivers/platform/x86/apple-gmux.c:286:19: sparse: got restricted __be32 [usertype] > drivers/platform/x86/apple-gmux.c:286:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:286:46: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:286:46: sparse: got unsigned char [usertype] *[noderef] iomem_base > drivers/platform/x86/apple-gmux.c:287:53: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:287:53: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:287:53: sparse: got unsigned char [usertype] * > drivers/platform/x86/apple-gmux.c:289:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@ > drivers/platform/x86/apple-gmux.c:289:39: sparse: expected void [noderef] __iomem * > drivers/platform/x86/apple-gmux.c:289:39: sparse: got unsigned char [usertype] * >>> drivers/platform/x86/apple-gmux.c:739:39: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected unsigned char [usertype] *[noderef] iomem_base @@ got void [noderef] __iomem * @@ > drivers/platform/x86/apple-gmux.c:739:39: sparse: expected unsigned char [usertype] *[noderef] iomem_base > drivers/platform/x86/apple-gmux.c:739:39: sparse: got void [noderef] __iomem * >>> drivers/platform/x86/apple-gmux.c:889:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:889:34: sparse: expected void volatile [noderef] __iomem *addr > drivers/platform/x86/apple-gmux.c:889:34: sparse: got unsigned char [usertype] *[noderef] iomem_base > drivers/platform/x86/apple-gmux.c:916:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] iomem_base @@ > drivers/platform/x86/apple-gmux.c:916:34: sparse: expected void volatile [noderef] __iomem *addr > drivers/platform/x86/apple-gmux.c:916:34: sparse: got unsigned char [usertype] *[noderef] iomem_base >>> drivers/platform/x86/apple-gmux.c:224:26: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:227:31: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:241:33: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:243:17: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:245:23: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:256:23: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:258:31: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:260:17: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:272:33: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:274:17: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:286:37: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:287:31: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:289:17: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c: note: in included file: >>> include/linux/apple-gmux.h:69:41: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *[noderef] __iomem iomem_base @@ got void [noderef] __iomem * @@ > include/linux/apple-gmux.h:69:41: sparse: expected unsigned char [usertype] *[noderef] __iomem iomem_base > include/linux/apple-gmux.h:69:41: sparse: got void [noderef] __iomem * >>> include/linux/apple-gmux.h:80:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@ > include/linux/apple-gmux.h:80:34: sparse: expected void const [noderef] __iomem * > include/linux/apple-gmux.h:80:34: sparse: got unsigned char [usertype] * >>> include/linux/apple-gmux.h:81:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] __iomem iomem_base @@ > include/linux/apple-gmux.h:81:17: sparse: expected void volatile [noderef] __iomem *addr > include/linux/apple-gmux.h:81:17: sparse: got unsigned char [usertype] *[noderef] __iomem iomem_base >>> include/linux/apple-gmux.h:72:14: sparse: sparse: dereference of noderef expression > include/linux/apple-gmux.h:80:23: sparse: sparse: dereference of noderef expression > include/linux/apple-gmux.h:81:17: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:740:22: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:888:13: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:889:25: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:915:13: sparse: sparse: dereference of noderef expression > drivers/platform/x86/apple-gmux.c:916:25: sparse: sparse: dereference of noderef expression > > vim +224 drivers/platform/x86/apple-gmux.c > > 220 > 221 static int gmux_mmio_wait(struct apple_gmux_data *gmux_data) > 222 { > 223 int i = 200; > > 224 u8 gwr = ioread8(gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 225 > 226 while (i && gwr) { > > 227 gwr = ioread8(gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 228 udelay(100); > 229 i--; > 230 } > 231 > 232 return !!i; > 233 } > 234 > 235 static u8 gmux_mmio_read8(struct apple_gmux_data *gmux_data, int port) > 236 { > 237 u8 val; > 238 > 239 mutex_lock(&gmux_data->index_lock); > 240 gmux_mmio_wait(gmux_data); > > 241 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT); > 242 iowrite8(GMUX_MMIO_READ | sizeof(val), > 243 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 244 gmux_mmio_wait(gmux_data); > > 245 val = ioread8(gmux_data->iomem_base); > 246 mutex_unlock(&gmux_data->index_lock); > 247 > 248 return val; > 249 } > 250 > 251 static void gmux_mmio_write8(struct apple_gmux_data *gmux_data, int port, > 252 u8 val) > 253 { > 254 mutex_lock(&gmux_data->index_lock); > 255 gmux_mmio_wait(gmux_data); > > 256 iowrite8(val, gmux_data->iomem_base); > 257 > 258 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT); > 259 iowrite8(GMUX_MMIO_WRITE | sizeof(val), > 260 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 261 > 262 gmux_mmio_wait(gmux_data); > 263 mutex_unlock(&gmux_data->index_lock); > 264 } > 265 > 266 static u32 gmux_mmio_read32(struct apple_gmux_data *gmux_data, int port) > 267 { > 268 u32 val; > 269 > 270 mutex_lock(&gmux_data->index_lock); > 271 gmux_mmio_wait(gmux_data); > > 272 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT); > 273 iowrite8(GMUX_MMIO_READ | sizeof(val), > 274 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 275 gmux_mmio_wait(gmux_data); > > 276 val = be32_to_cpu(ioread32(gmux_data->iomem_base)); > 277 mutex_unlock(&gmux_data->index_lock); > 278 > 279 return val; > 280 } > 281 > 282 static void gmux_mmio_write32(struct apple_gmux_data *gmux_data, int port, > 283 u32 val) > 284 { > 285 mutex_lock(&gmux_data->index_lock); > > 286 iowrite32(cpu_to_be32(val), gmux_data->iomem_base); > > 287 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT); > 288 iowrite8(GMUX_MMIO_WRITE | sizeof(val), > 289 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND); > 290 gmux_mmio_wait(gmux_data); > 291 mutex_unlock(&gmux_data->index_lock); > 292 } > 293 >