Message ID | 20191029064834.23438-12-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/21] arm: remove ioremap_cached | expand |
On Mon, 28 Oct 2019 23:48:24 PDT (-0700), Christoph Hellwig wrote: > All MMU-enabled ports have a non-trivial ioremap and should thus provide > the prototype for their implementation instead of providing a generic > one unless a different symbol is not defined. Note that this only > affects sparc32 nds32 as all others do provide their own version. > > Also update the kerneldoc comments in asm-generic/io.h to explain the > situation around the default ioremap* implementations correctly. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > arch/nds32/include/asm/io.h | 2 ++ > arch/sparc/include/asm/io_32.h | 1 + > include/asm-generic/io.h | 29 ++++++++--------------------- > 3 files changed, 11 insertions(+), 21 deletions(-) > > diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h > index 16f262322b8f..fb0e8a24c7af 100644 > --- a/arch/nds32/include/asm/io.h > +++ b/arch/nds32/include/asm/io.h > @@ -6,6 +6,7 @@ > > #include <linux/types.h> > > +void __iomem *ioremap(phys_addr_t phys_addr, size_t size); > extern void iounmap(volatile void __iomem *addr); > #define __raw_writeb __raw_writeb > static inline void __raw_writeb(u8 val, volatile void __iomem *addr) > @@ -80,4 +81,5 @@ static inline u32 __raw_readl(const volatile void __iomem *addr) > #define writew(v,c) ({ __iowmb(); writew_relaxed((v),(c)); }) > #define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c)); }) > #include <asm-generic/io.h> > + > #endif /* __ASM_NDS32_IO_H */ > diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h > index df2dc1784673..9a52d9506f80 100644 > --- a/arch/sparc/include/asm/io_32.h > +++ b/arch/sparc/include/asm/io_32.h > @@ -127,6 +127,7 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst, > * Bus number may be embedded in the higher bits of the physical address. > * This is why we have no bus number argument to ioremap(). > */ > +void __iomem *ioremap(phys_addr_t offset, size_t size); > void iounmap(volatile void __iomem *addr); > /* Create a virtual mapping cookie for an IO port range */ > void __iomem *ioport_map(unsigned long port, unsigned int nr); > diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h > index a98ed6325727..6a5edc23afe2 100644 > --- a/include/asm-generic/io.h > +++ b/include/asm-generic/io.h > @@ -922,28 +922,16 @@ static inline void *phys_to_virt(unsigned long address) > /** > * DOC: ioremap() and ioremap_*() variants > * > - * If you have an IOMMU your architecture is expected to have both ioremap() > - * and iounmap() implemented otherwise the asm-generic helpers will provide a > - * direct mapping. > + * Architectures with an MMU are expected to provide ioremap() and iounmap() > + * themselves. For NOMMU architectures we provide a default nop-op > + * implementation that expect that the physical address used for MMIO are > + * already marked as uncached, and can be used as kernel virtual addresses. > * > - * There are ioremap_*() call variants, if you have no IOMMU we naturally will > - * default to direct mapping for all of them, you can override these defaults. > - * If you have an IOMMU you are highly encouraged to provide your own > - * ioremap variant implementation as there currently is no safe architecture > - * agnostic default. To avoid possible improper behaviour default asm-generic > - * ioremap_*() variants all return NULL when an IOMMU is available. If you've > - * defined your own ioremap_*() variant you must then declare your own > - * ioremap_*() variant as defined to itself to avoid the default NULL return. > + * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes > + * for specific drivers if the architecture choses to implement them. If they > + * are not implemented we fall back to plain ioremap. > */ > #ifndef CONFIG_MMU > - > -/* > - * Change "struct page" to physical address. > - * > - * This implementation is for the no-MMU case only... if you have an MMU > - * you'll need to provide your own definitions. > - */ > - > #ifndef ioremap > #define ioremap ioremap > static inline void __iomem *ioremap(phys_addr_t offset, size_t size) > @@ -954,14 +942,13 @@ static inline void __iomem *ioremap(phys_addr_t offset, size_t size) > > #ifndef iounmap > #define iounmap iounmap > - > static inline void iounmap(void __iomem *addr) > { > } > #endif > #endif /* CONFIG_MMU */ > + > #ifndef ioremap_nocache > -void __iomem *ioremap(phys_addr_t phys_addr, size_t size); > #define ioremap_nocache ioremap_nocache > static inline void __iomem *ioremap_nocache(phys_addr_t offset, size_t size) > { It looks like the difference in prototype between the architectures is between void __iomem *ioremap(resource_size_t, size_t) void __iomem *ioremap(phys_addr_t, size_t) void __iomem *ioremap(phys_addr_t, unsigned long) void __iomem *ioremap(unsigned long, unsigned long) shouldn't they all just be that first one? In other words, wouldn't it be better to always provide the generic ioremap prototype and unify the ports instead?
Hi Palmer, On Wed, Nov 6, 2019 at 7:11 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > It looks like the difference in prototype between the architectures is between > > void __iomem *ioremap(resource_size_t, size_t) > void __iomem *ioremap(phys_addr_t, size_t) > void __iomem *ioremap(phys_addr_t, unsigned long) > void __iomem *ioremap(unsigned long, unsigned long) > > shouldn't they all just be that first one? In other words, wouldn't it be > better to always provide the generic ioremap prototype and unify the ports > instead? Agreed. But I'd go for the second one. Gr{oetje,eeting}s, Geert
On Wed, Nov 06, 2019 at 07:16:38PM +0100, Geert Uytterhoeven wrote: > > shouldn't they all just be that first one? In other words, wouldn't it be > > better to always provide the generic ioremap prototype and unify the ports > > instead? > > Agreed. But I'd go for the second one. Eventually we should unify it and only have a single prototype. But we have lots of implementations including inline functions, so this will take a few more steps.
On Tue, Oct 29, 2019 at 7:49 AM Christoph Hellwig <hch@lst.de> wrote: > > All MMU-enabled ports have a non-trivial ioremap and should thus provide > the prototype for their implementation instead of providing a generic > one unless a different symbol is not defined. Note that this only > affects sparc32 nds32 as all others do provide their own version. > > Also update the kerneldoc comments in asm-generic/io.h to explain the > situation around the default ioremap* implementations correctly. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
On Wed, Nov 6, 2019 at 7:16 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > > Hi Palmer, > > On Wed, Nov 6, 2019 at 7:11 PM Palmer Dabbelt <palmer@dabbelt.com> wrote: > > It looks like the difference in prototype between the architectures is between > > > > void __iomem *ioremap(resource_size_t, size_t) > > void __iomem *ioremap(phys_addr_t, size_t) > > void __iomem *ioremap(phys_addr_t, unsigned long) > > void __iomem *ioremap(unsigned long, unsigned long) > > > > shouldn't they all just be that first one? In other words, wouldn't it be > > better to always provide the generic ioremap prototype and unify the ports > > instead? > > Agreed. But I'd go for the second one. Right, phys_addr_t is the correct type here, resource_size_t is just a generic type that is at least as long as any resource, and usually the same as phys_addr_t, which is supposed to be used for physical addresses. Arnd
diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h index 16f262322b8f..fb0e8a24c7af 100644 --- a/arch/nds32/include/asm/io.h +++ b/arch/nds32/include/asm/io.h @@ -6,6 +6,7 @@ #include <linux/types.h> +void __iomem *ioremap(phys_addr_t phys_addr, size_t size); extern void iounmap(volatile void __iomem *addr); #define __raw_writeb __raw_writeb static inline void __raw_writeb(u8 val, volatile void __iomem *addr) @@ -80,4 +81,5 @@ static inline u32 __raw_readl(const volatile void __iomem *addr) #define writew(v,c) ({ __iowmb(); writew_relaxed((v),(c)); }) #define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c)); }) #include <asm-generic/io.h> + #endif /* __ASM_NDS32_IO_H */ diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h index df2dc1784673..9a52d9506f80 100644 --- a/arch/sparc/include/asm/io_32.h +++ b/arch/sparc/include/asm/io_32.h @@ -127,6 +127,7 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst, * Bus number may be embedded in the higher bits of the physical address. * This is why we have no bus number argument to ioremap(). */ +void __iomem *ioremap(phys_addr_t offset, size_t size); void iounmap(volatile void __iomem *addr); /* Create a virtual mapping cookie for an IO port range */ void __iomem *ioport_map(unsigned long port, unsigned int nr); diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index a98ed6325727..6a5edc23afe2 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -922,28 +922,16 @@ static inline void *phys_to_virt(unsigned long address) /** * DOC: ioremap() and ioremap_*() variants * - * If you have an IOMMU your architecture is expected to have both ioremap() - * and iounmap() implemented otherwise the asm-generic helpers will provide a - * direct mapping. + * Architectures with an MMU are expected to provide ioremap() and iounmap() + * themselves. For NOMMU architectures we provide a default nop-op + * implementation that expect that the physical address used for MMIO are + * already marked as uncached, and can be used as kernel virtual addresses. * - * There are ioremap_*() call variants, if you have no IOMMU we naturally will - * default to direct mapping for all of them, you can override these defaults. - * If you have an IOMMU you are highly encouraged to provide your own - * ioremap variant implementation as there currently is no safe architecture - * agnostic default. To avoid possible improper behaviour default asm-generic - * ioremap_*() variants all return NULL when an IOMMU is available. If you've - * defined your own ioremap_*() variant you must then declare your own - * ioremap_*() variant as defined to itself to avoid the default NULL return. + * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes + * for specific drivers if the architecture choses to implement them. If they + * are not implemented we fall back to plain ioremap. */ #ifndef CONFIG_MMU - -/* - * Change "struct page" to physical address. - * - * This implementation is for the no-MMU case only... if you have an MMU - * you'll need to provide your own definitions. - */ - #ifndef ioremap #define ioremap ioremap static inline void __iomem *ioremap(phys_addr_t offset, size_t size) @@ -954,14 +942,13 @@ static inline void __iomem *ioremap(phys_addr_t offset, size_t size) #ifndef iounmap #define iounmap iounmap - static inline void iounmap(void __iomem *addr) { } #endif #endif /* CONFIG_MMU */ + #ifndef ioremap_nocache -void __iomem *ioremap(phys_addr_t phys_addr, size_t size); #define ioremap_nocache ioremap_nocache static inline void __iomem *ioremap_nocache(phys_addr_t offset, size_t size) {
All MMU-enabled ports have a non-trivial ioremap and should thus provide the prototype for their implementation instead of providing a generic one unless a different symbol is not defined. Note that this only affects sparc32 nds32 as all others do provide their own version. Also update the kerneldoc comments in asm-generic/io.h to explain the situation around the default ioremap* implementations correctly. Signed-off-by: Christoph Hellwig <hch@lst.de> --- arch/nds32/include/asm/io.h | 2 ++ arch/sparc/include/asm/io_32.h | 1 + include/asm-generic/io.h | 29 ++++++++--------------------- 3 files changed, 11 insertions(+), 21 deletions(-)