sparse warnings in vop
Hi!
Building vop with make C=1 produces the following:
CHECK drivers/misc/mic/vop/vop_main.cdrivers/misc/mic/vop/vop_main.c:551:58: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:551:58: expected void const volatile [noderef] __iomem *addrdrivers/misc/mic/vop/vop_main.c:551:58: got restricted __le64 *drivers/misc/mic/vop/vop_main.c:560:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:560:49: expected struct mic_device_ctrl *dcdrivers/misc/mic/vop/vop_main.c:560:49: got struct mic_device_ctrl [noderef] __iomem *dcdrivers/misc/mic/vop/vop_main.c:579:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:579:49: expected struct mic_device_ctrl *dcdrivers/misc/mic/vop/vop_main.c:579:49: got struct mic_device_ctrl [noderef] __iomem *dc
Would be nice to fix to silence the noise, but I'm not 100% sure what the right thing to do here is. Tag struct members with __iomem or cast with __force on use?
Signature · 1 line
MST
A message that is not in the archive (sent off-list or not yet received): CAHp75Vfwhfrse47jRR9msFHA4ZqoVvE8RYHZNKxu-_ZiGyS9Sw@mail.gmail.com
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Michael S. Tsirkin
Hi!
Building vop with make C=1 produces the following:CHECK
drivers/misc/mic/vop/vop_main.cdrivers/misc/mic/vop/vop_main.c:551:58: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:551:58: expected void const volatile [noderef]__iomem*addrdrivers/misc/mic/vop/vop_main.c:551:58: got restricted__le64*drivers/misc/mic/vop/vop_main.c:560:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:560:49: expected structmic_device_ctrl*dcdrivers/misc/mic/vop/vop_main.c:560:49: got structmic_device_ctrl[noderef]__iomem*dcdrivers/misc/mic/vop/vop_main.c:579:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:579:49: expected structmic_device_ctrl*dcdrivers/misc/mic/vop/vop_main.c:579:49: got structmic_device_ctrl[noderef]__iomem*dc
Quoted 7 lines
Quoted 3 lines
Would be nice to fix to silence the noise, but I'm not 100% sure what the right thing to do here is. Tag struct members with
__iomemor cast with__forceon use?Sounds right to me.
I don't think either of the above, adding __force is almost always wrong, and __iomem never applies to struct members, only to pointers.
The first problem I see is with:
static struct _vop_vdev *vop_dc_to_vdev(struct mic_device_ctrl *dc)
The argument needs to be an __iomem pointer. In the structure, the first member has type __le64, which gets mentioned in the warning. We usually use __u64 instead (or don't use structures at all for __iomem operations), but I don't think this would cause a warning if the argument is fixed.
Then there is the question of why in the world you would have an MMIO register contain a kernel pointer, but that is more a driver design question than something that causes a warning.
Arnd
Quoted 30 lines · Arnd Bergmann
Quoted 16 lines · Andy Shevchenko
Quoted 15 lines · Michael S. Tsirkin
Hi!
Building vop with make C=1 produces the following:CHECK
drivers/misc/mic/vop/vop_main.cdrivers/misc/mic/vop/vop_main.c:551:58: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:551:58: expected void const volatile [noderef]__iomem*addrdrivers/misc/mic/vop/vop_main.c:551:58: got restricted__le64*drivers/misc/mic/vop/vop_main.c:560:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:560:49: expected structmic_device_ctrl*dcdrivers/misc/mic/vop/vop_main.c:560:49: got structmic_device_ctrl[noderef]__iomem*dcdrivers/misc/mic/vop/vop_main.c:579:49: warning: incorrect type in argument 1 (different address spaces)drivers/misc/mic/vop/vop_main.c:579:49: expected structmic_device_ctrl*dcdrivers/misc/mic/vop/vop_main.c:579:49: got structmic_device_ctrl[noderef]__iomem*dcQuoted 5 lines
Quoted 3 lines
Would be nice to fix to silence the noise, but I'm not 100% sure what the right thing to do here is. Tag struct members with
__iomemor cast with__forceon use?Sounds right to me.
I don't think either of the above, adding
__forceis almost always wrong, and__iomemnever applies to struct members, only to pointers.The first problem I see is with:
Quoted 7 lines
static struct
_vop_vdev*vop_dc_to_vdev(structmic_device_ctrl*dc)The argument needs to be an
__iomempointer. In the structure, the first member has type__le64, which gets mentioned in the warning. We usually use__u64instead (or don't use structures at all for__iomemoperations), but I don't think this would cause a warning if the argument is fixed.
I have submitted a patch which fixes the warnings.
Quoted 3 lines
Then there is the question of why in the world you would have an MMIO register contain a kernel pointer, but that is more a driver design question than something that causes a warning.
It is not a MMIO register, it is the OS running on PCI device accessing system memory which is ioremap'd for the PCI device OS. Also, the data structure is access both by the system OS (not __iomem) as well as the PCI device OS (__iomem). Therefore the structure members cannot be tagged __iomem. Doing so will fix the sparse warning for the PCI device OS but result in new sparse warnings for the system OS. Thanks.