Skip to contentSkip to conversation

sh: cast away __iomem to remove sparse warning

PATCH In review Baoquan He 3 participants 6 messages May 7, 2022 – Jun 8, 2022 SuperH

lore
Share & tools
lore

Baoquan He

author
#0 lore raw

PATCH 1/1 sh: cast away __iomem to remove sparse warning

LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during a kdump patchset reviewing:
https://lore.kernel.org/all/[email protected]/T/#u

../arch/sh/kernel/crash_dump.c:23:36: sparse: warning: incorrect type in argument 1 (different address spaces)
../arch/sh/kernel/crash_dump.c:23:36: sparse: expected void const *addr
../arch/sh/kernel/crash_dump.c:23:36: sparse: got void [noderef] __iomem *

This warning happened when __iomem pointer is passed into fucntion which doesn't expect it. Casting away the __iomem can fix it.

---
 arch/sh/kernel/crash_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/crash_dump.c +1 -1
index 19ce6a950aac..52d1d54eb6b1 100644
@@ -20,7 +20,7 @@ ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,
 		return 0;
 
 	vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
-	csize = copy_to_iter(vaddr + offset, csize, iter);
+	csize = copy_to_iter((const void __force *)vaddr + offset, csize, iter);
 	iounmap(vaddr);
 
 	return csize;
Signature · 1 line
2.34.1
author
#1 lore raw

Hi,

Quoted 10 lines · Baoquan He

LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during a kdump patchset reviewing:
https://lore.kernel.org/all/[email protected]/T/#u

../arch/sh/kernel/crash_dump.c:23:36: sparse: warning: incorrect type in argument 1 (different address spaces)
../arch/sh/kernel/crash_dump.c:23:36: sparse: expected void const *addr
../arch/sh/kernel/crash_dump.c:23:36: sparse: got void [noderef] __iomem *

This warning happened when __iomem pointer is passed into fucntion which doesn't expect it. Casting away the __iomem can fix it.

This warning was reported by lkp during one patchset posted and reviewing. Since it's not related to the patchset, I just sent it separately so that later code change on arch/sh/kernel/crash_dump.c won't trigger the lkp warning again.

[PATCH v5 RESEND 0/3] Convert vmcore to use an iov_iter
https://lore.kernel.org/all/[email protected]/T/#u

Now the above patchset has been merged into linus's tree, please consider taking this patch.

Thanks
Baoquan

Quoted 23 lines
---
 arch/sh/kernel/crash_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/crash_dump.c +1 -1
index 19ce6a950aac..52d1d54eb6b1 100644
@@ -20,7 +20,7 @@ ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,
 		return 0;
 
 	vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
-	csize = copy_to_iter(vaddr + offset, csize, iter);
+	csize = copy_to_iter((const void __force *)vaddr + offset, csize, iter);
 	iounmap(vaddr);
 
 	return csize;
Signature · 1 line
2.34.1
Tested-by
#2 lore raw
Quoted 19 lines · Baoquan He

Hi,

Quoted 10 lines · Baoquan He

LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during a kdump patchset reviewing:
https://lore.kernel.org/all/[email protected]/T/#u

../arch/sh/kernel/crash_dump.c:23:36: sparse: warning: incorrect type in argument 1 (different address spaces)
../arch/sh/kernel/crash_dump.c:23:36: sparse: expected void const *addr
../arch/sh/kernel/crash_dump.c:23:36: sparse: got void [noderef] __iomem *

This warning happened when __iomem pointer is passed into fucntion which doesn't expect it. Casting away the __iomem can fix it.

This warning was reported by lkp during one patchset posted and reviewing. Since it's not related to the patchset, I just sent it separately so that later code change on arch/sh/kernel/crash_dump.c won't trigger the lkp warning again.

Quoted 12 lines

[PATCH v5 RESEND 0/3] Convert vmcore to use an iov_iter
https://lore.kernel.org/all/[email protected]/T/#u

Now the above patchset has been merged into linus's tree, please consider taking this patch.

Thanks
Baoquan

Quoted 3 lines

Rob

author
#3 lore raw
Quoted 27 lines · Rob Landley
Quoted 24 lines · Baoquan He

Hi,

Quoted 10 lines · Baoquan He

LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during a kdump patchset reviewing:
https://lore.kernel.org/all/[email protected]/T/#u

../arch/sh/kernel/crash_dump.c:23:36: sparse: warning: incorrect type in argument 1 (different address spaces)
../arch/sh/kernel/crash_dump.c:23:36: sparse: expected void const *addr
../arch/sh/kernel/crash_dump.c:23:36: sparse: got void [noderef] __iomem *

This warning happened when __iomem pointer is passed into fucntion which doesn't expect it. Casting away the __iomem can fix it.

This warning was reported by lkp during one patchset posted and reviewing. Since it's not related to the patchset, I just sent it separately so that later code change on arch/sh/kernel/crash_dump.c won't trigger the lkp warning again.

[PATCH v5 RESEND 0/3] Convert vmcore to use an iov_iter
https://lore.kernel.org/all/[email protected]/T/#u

Now the above patchset has been merged into linus's tree, please consider taking this patch.

......

Quoted 1 line

Thanks for testing, Rob.

I guess SuperH arch has been in status of no maintenance, however some generic code change may involve correspondant ARCH change so that we have to touch arch/sh/.

Hi Andrew,

To avoid annoying warning when modifying crash_dump code, could you pick this one?

Thanks
Baoquan

#4 lore raw

Hi!

Quoted 3 lines · Baoquan He

I guess SuperH arch has been in status of no maintenance, however some generic code change may involve correspondant ARCH change so that we have to touch arch/sh/.

It is actually actively maintained by Rich Felker but he is often slow to respond at the moment. I have already offered Rich my help and maybe we can work something out that I can help him with the maintenance.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
author
#5 lore raw
Quoted 10 lines · John Paul Adrian Glaubitz

Hi!

Quoted 3 lines · Baoquan He

I guess SuperH arch has been in status of no maintenance, however some generic code change may involve correspondant ARCH change so that we have to touch arch/sh/.

It is actually actively maintained by Rich Felker but he is often slow to respond at the moment. I have already offered Rich my help and maybe we can work something out that I can help him with the maintenance.

Thanks, Adrian.

Maybe you can start with being a reviewer by adding yourself into MAINTAINERS file like below. You need post below change as patch and got Rich's ACK. Then people will add you to CC when sending patches related to sh code. Or add yourself as maintainer directly if you have done a lot of work on maintaining, surely need get other sh maintainers' ACK too. Personal suggeestion.

MAINTAINERS +1 -0
index a6d3bd9d2a8d..0e7ce3540eb7 100644
@@ -19119,6 +19119,7 @@ F:	drivers/watchdog/sunplus_wdt.c
 SUPERH
 M:	Yoshinori Sato <[email protected]>
 M:	Rich Felker <[email protected]>
+R:	John Paul Adrian Glaubitz <[email protected]>
 L:	[email protected]
 S:	Maintained
 Q:	http://patchwork.kernel.org/project/linux-sh/list/