Re: [PATCH v3 4/6] mm: ioremap: Add arch_ioremap/iounmap()

From: Arnd Bergmann
Date: Tue May 24 2022 - 08:35:50 EST


On Tue, May 24, 2022 at 11:48 AM Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> wrote:
> >>> mm/ioremap.c:59:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const *addr @@ got void [noderef] __iomem *vaddr @@
> > mm/ioremap.c:59:16: sparse: expected void const *addr
> > mm/ioremap.c:59:16: sparse: got void [noderef] __iomem *vaddr
> >
> > vim +59 mm/ioremap.c
> >
> > 51
> > 52 void iounmap(volatile void __iomem *addr)
> > 53 {
> > 54 void __iomem *vaddr = (void __iomem *)((unsigned long)addr & PAGE_MASK);
> > 55
> > 56 if (arch_iounmap(vaddr))
> > 57 return;
> > 58
> > > 59 vunmap(vaddr);
>
> 1) Will add generic "arch_ioremap/arch_iounmap define"
>
> 2) and change this to vunmap((void *)vaddr);

I think this need an extra __force to actually suppress the sparse
warning, as in

vunmap((void __force *)vaddr);

Using __force is usually wrong, this is one of the exceptions, so
maybe add a comment
as well.

Arnd