diff mbox series

sh: cast away __iomem to remove sparse warning

Message ID 20220507013411.74277-1-bhe@redhat.com (mailing list archive)
State New, archived
Headers show
Series sh: cast away __iomem to remove sparse warning | expand

Commit Message

Baoquan He May 7, 2022, 1:34 a.m. UTC
LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during
a kdump patchset reviewing:
https://lore.kernel.org/all/202204082128.JKXXDGpa-lkp@intel.com/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.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
---
 arch/sh/kernel/crash_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Baoquan He May 30, 2022, 12:09 p.m. UTC | #1
Hi,

On 05/07/22 at 09:34am, Baoquan He wrote:
> LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during
> a kdump patchset reviewing:
> https://lore.kernel.org/all/202204082128.JKXXDGpa-lkp@intel.com/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/20220408090636.560886-2-bhe@redhat.com/T/#u

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

Thanks
Baoquan

> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  arch/sh/kernel/crash_dump.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/sh/kernel/crash_dump.c b/arch/sh/kernel/crash_dump.c
> index 19ce6a950aac..52d1d54eb6b1 100644
> --- a/arch/sh/kernel/crash_dump.c
> +++ b/arch/sh/kernel/crash_dump.c
> @@ -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;
> -- 
> 2.34.1
>
Rob Landley June 7, 2022, 10:56 p.m. UTC | #2
On 5/30/22 07:09, Baoquan He wrote:
> Hi,
> 
> On 05/07/22 at 09:34am, Baoquan He wrote:
>> LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during
>> a kdump patchset reviewing:
>> https://lore.kernel.org/all/202204082128.JKXXDGpa-lkp@intel.com/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/20220408090636.560886-2-bhe@redhat.com/T/#u
> 
> Now the above patchset has been merged into linus's tree, please
> consider taking this patch.
> 
> Thanks
> Baoquan
> 
>> 
>> Reported-by: kernel test robot <lkp@intel.com>
>> Signed-off-by: Baoquan He <bhe@redhat.com>

Tested-by: Rob Landley <rob@landley.net>

Rob
Baoquan He June 8, 2022, 1:11 a.m. UTC | #3
On 06/07/22 at 05:56pm, Rob Landley wrote:
> 
> 
> On 5/30/22 07:09, Baoquan He wrote:
> > Hi,
> > 
> > On 05/07/22 at 09:34am, Baoquan He wrote:
> >> LKP reported a sparse warning in arch/sh/kernel/crash_dump.c during
> >> a kdump patchset reviewing:
> >> https://lore.kernel.org/all/202204082128.JKXXDGpa-lkp@intel.com/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/20220408090636.560886-2-bhe@redhat.com/T/#u
> > 
> > Now the above patchset has been merged into linus's tree, please
> > consider taking this patch.
...... 
> Tested-by: Rob Landley <rob@landley.net>

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
John Paul Adrian Glaubitz June 8, 2022, 7:05 a.m. UTC | #4
Hi!

On 6/8/22 03:11, Baoquan He wrote:
> 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
Baoquan He June 8, 2022, 7:52 a.m. UTC | #5
On 06/08/22 at 09:05am, John Paul Adrian Glaubitz wrote:
> Hi!
> 
> On 6/8/22 03:11, Baoquan He wrote:
> > 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.

diff --git a/MAINTAINERS b/MAINTAINERS
index a6d3bd9d2a8d..0e7ce3540eb7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19119,6 +19119,7 @@ F:	drivers/watchdog/sunplus_wdt.c
 SUPERH
 M:	Yoshinori Sato <ysato@users.sourceforge.jp>
 M:	Rich Felker <dalias@libc.org>
+R:	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
 L:	linux-sh@vger.kernel.org
 S:	Maintained
 Q:	http://patchwork.kernel.org/project/linux-sh/list/
diff mbox series

Patch

diff --git a/arch/sh/kernel/crash_dump.c b/arch/sh/kernel/crash_dump.c
index 19ce6a950aac..52d1d54eb6b1 100644
--- a/arch/sh/kernel/crash_dump.c
+++ b/arch/sh/kernel/crash_dump.c
@@ -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;