generic ioremap (and lots of cleanups)
Subsystems (22)
Hi all,
the last patches in this series add a generic ioremap implementation, and switch our 3 most recent and thus most tidy architeture ports over to use it. With a little work and an additional arch hook or two the implementation should be able to eventually cover more than half of our ports.
The patches before that clean up various lose ends in the ioremap and iounmap implementations.
A git tree is also available here:
git://git.infradead.org/users/hch/misc.git generic-ioremap
Gitweb:
http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/generic-ioremap
PATCH 1/26 mtd/maps/pxa2xx: use ioremap_cache insted of ioremap_cached
pxa2xx-flash is the only user of ioremap_cached, which is an alias for ioremap_cache anyway.
--- drivers/mtd/maps/pxa2xx-flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/maps/pxa2xx-flash.c +1 -2
@@ -68,8 +68,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev) info->map.name);return -ENOMEM ; } - info->map.cached = -ioremap_cached (info->map.phys, info->map.size); + info->map.cached =ioremap_cache (info->map.phys, info->map.size);if (!info->map.cached)printk (KERN_WARNING "Failed to ioremap cached %s\n" , info->map.name);
Signature · 1 line
2.20.1
Re: [PATCH 01/26] mtd/maps/pxa2xx: use ioremap_cache insted of ioremap_cached
Mtd maintainers, can you pick this one up for 5.4?
Quoted 30 lines · Christoph Hellwig
pxa2xx-flash is the only user of
ioremap_cached, which is an alias forioremap_cacheanyway.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/mtd/maps/pxa2xx-flash.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/mtd/maps/pxa2xx-flash.c +1
-2@@ -68,8 +68,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev) info->map.name);return -ENOMEM ; } - info->map.cached = -ioremap_cached (info->map.phys, info->map.size); + info->map.cached =ioremap_cache (info->map.phys, info->map.size);if (!info->map.cached)printk (KERN_WARNING "Failed to ioremap cached %s\n" , info->map.name);Signature · 7 lines
2.20.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
---end quoted text---
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 01/26] mtd/maps/pxa2xx: use ioremap_cache insted of ioremap_cached
Quoted 2 lines · Christoph Hellwig
Mtd maintainers, can you pick this one up for 5.4?
Sure. Queued for 5.4
Signature · 6 lines
Thanks, //richard ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/26 arm, unicore32: remove ioremap_cached
In reply to Christoph HellwigNo users of ioremap_cached are left, remove it.
--- arch/arm/include/asm/io.h | 6 ------ arch/arm/mm/ioremap.c | 4 ---- arch/arm/mm/mmu.c | 2 +- arch/arm/mm/nommu.c | 4 ---- arch/unicore32/include/asm/io.h | 4 +--- arch/unicore32/mm/ioremap.c | 8 -------- 6 files changed, 2 insertions(+), 26 deletions(-)
arch/arm/include/asm/io.h +0 -6
@@ -400,12 +400,6 @@ void __iomem *ioremap(resource_size_t res_cookie, size_t size);void __iomem *ioremap_cache (resource_size_t res_cookie,size_t size);#define ioremap_cache ioremap_cache -/* -* Do not use ioremap_cached in new code. Provided for the benefit of -* the pxa2xx-flash MTD driver only. -*/ -void __iomem *ioremap_cached (resource_size_t res_cookie,size_t size); -void __iomem *ioremap_wc (resource_size_t res_cookie,size_t size);#define ioremap_wc ioremap_wc#define ioremap_wt ioremap_wc
arch/arm/mm/ioremap.c +0 -4
@@ -382,15 +382,11 @@ void __iomem *ioremap(resource_size_t res_cookie, size_t size)EXPORT_SYMBOL (ioremap);void __iomem *ioremap_cache (resource_size_t res_cookie,size_t size) -__alias (ioremap_cached); - -void __iomem *ioremap_cached (resource_size_t res_cookie,size_t size) {return arch_ioremap_caller (res_cookie, size,MT_DEVICE_CACHED ,__builtin_return_address (0 )); }EXPORT_SYMBOL (ioremap_cache); -EXPORT_SYMBOL (ioremap_cached);void __iomem *ioremap_wc (resource_size_t res_cookie,size_t size) {
arch/arm/mm/mmu.c +1 -1
@@ -259,7 +259,7 @@ static struct mem_type mem_types[] __ro_after_init = { .prot_sect = PROT_SECT_DEVICE, .domain = DOMAIN_IO, }, - [MT_DEVICE_CACHED] = { /* ioremap_cached */ + [MT_DEVICE_CACHED] = { /* ioremap_cache */ .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_CACHED, .prot_l1 = PMD_TYPE_TABLE, .prot_sect = PROT_SECT_DEVICE | PMD_SECT_WB,
arch/arm/mm/nommu.c +0 -4
@@ -206,15 +206,11 @@ void __iomem *ioremap(resource_size_t res_cookie, size_t size)EXPORT_SYMBOL (ioremap);void __iomem *ioremap_cache (resource_size_t res_cookie,size_t size) -__alias (ioremap_cached); - -void __iomem *ioremap_cached (resource_size_t res_cookie,size_t size) {return __arm_ioremap_caller (res_cookie, size,MT_DEVICE_CACHED ,__builtin_return_address (0 )); }EXPORT_SYMBOL (ioremap_cache); -EXPORT_SYMBOL (ioremap_cached);void __iomem *ioremap_wc (resource_size_t res_cookie,size_t size) {
arch/unicore32/include/asm/io.h +1 -3
@@ -18,10 +18,9 @@#include <asm-generic/io.h> /* -* __uc32_ioremap and __uc32_ioremap_cached takes CPU physical address. +* __uc32_ioremap takes CPU physical address. */ extern void __iomem *__uc32_ioremap (unsigned long ,size_t ); -extern void __iomem *__uc32_ioremap_cached (unsigned long ,size_t );extern void __uc32_iounmap (volatile void __iomem *addr);/*
@@ -32,7 +31,6 @@ extern void __uc32_iounmap(volatile void __iomem *addr);* */ #define ioremap (cookie, size) __uc32_ioremap(cookie, size) -#define ioremap_cached (cookie, size) __uc32_ioremap_cached(cookie, size)#define ioremap_nocache (cookie, size) __uc32_ioremap(cookie, size)#define iounmap (cookie) __uc32_iounmap(cookie)
arch/unicore32/mm/ioremap.c +0 -8
@@ -220,14 +220,6 @@ __uc32_ioremap(unsigned long phys_addr, size_t size) }EXPORT_SYMBOL (__uc32_ioremap); -void __iomem * -__uc32_ioremap_cached (unsigned long phys_addr,size_t size) -{ -return __uc32_ioremap_caller (phys_addr, size,MT_DEVICE_CACHED , -__builtin_return_address (0 )); -} -EXPORT_SYMBOL (__uc32_ioremap_cached); -void __uc32_iounmap (volatile void __iomem *io_addr) {void *addr = (void *)(PAGE_MASK & (unsigned long )io_addr);
Signature · 1 line
2.20.1
PATCH 3/26 m68k, microblaze: remove ioremap_fullcache
In reply to Christoph HellwigNo callers of this function.
--- arch/m68k/include/asm/kmap.h | 7 ------- arch/microblaze/include/asm/io.h | 1 - 2 files changed, 8 deletions(-)
arch/m68k/include/asm/kmap.h +0 -7
@@ -43,13 +43,6 @@ static inline void __iomem *ioremap_wt(unsigned long physaddr,return __ioremap (physaddr, size,IOMAP_WRITETHROUGH ); } -#define ioremap_fullcache ioremap_fullcache -static inline void __iomem *ioremap_fullcache (unsigned long physaddr, -unsigned long size) -{ -return __ioremap (physaddr, size,IOMAP_FULL_CACHING ); -} -#define memset_io memset_iostatic inline void memset_io (volatile void __iomem *addr,unsigned char val,int count)
arch/microblaze/include/asm/io.h +0 -1
@@ -40,7 +40,6 @@ extern void iounmap(volatile void __iomem *addr);extern void __iomem *ioremap (phys_addr_t address,unsigned long size);#define ioremap_nocache (addr, size) ioremap((addr), (size)) -#define ioremap_fullcache (addr, size) ioremap((addr), (size))#define ioremap_wc (addr, size) ioremap((addr), (size))#define ioremap_wt (addr, size) ioremap((addr), (size))
Signature · 1 line
2.20.1
Re: [PATCH 03/26] m68k, microblaze: remove ioremap_fullcache
Quoted 5 lines · Christoph Hellwig
No callers of this function.
Signed-off-by Christoph Hellwig <[email protected]>arch/m68k/include/asm/kmap.h | 7 -------
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 03/26] m68k, microblaze: remove ioremap_fullcache
In reply to Christoph HellwigQuoted 32 lines · Christoph Hellwig
No callers of this function.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/m68k/include/asm/kmap.h | 7 ------- arch/microblaze/include/asm/io.h | 1 - 2 files changed, 8 deletions(-)arch/m68k/include/asm/kmap.h +0
-7@@ -43,13 +43,6 @@ static inline void __iomem *ioremap_wt(unsigned long physaddr,return __ioremap (physaddr, size,IOMAP_WRITETHROUGH ); } -#define ioremap_fullcache ioremap_fullcache -static inline void __iomem *ioremap_fullcache (unsigned long physaddr, -unsigned long size) -{ -return __ioremap (physaddr, size,IOMAP_FULL_CACHING ); -} -#define memset_io memset_iostatic inline void memset_io (volatile void __iomem *addr,unsigned char val,int count)arch/microblaze/include/asm/io.h +0
-0
arch/microblaze/include/asm/io.h extern void iounmap(volatile void __iomem *addr); · line 45
Quoted 7 lines
arch/microblaze/include/asm/io.h +0
-1@@ -40,7 +40,6 @@ extern void iounmap(volatile void __iomem *addr);extern void __iomem *ioremap (phys_addr_t address,unsigned long size);#define ioremap_nocache (addr, size) ioremap((addr), (size)) -#define ioremap_fullcache (addr, size) ioremap((addr), (size))#define ioremap_wc (addr, size) ioremap((addr), (size))#define ioremap_wt (addr, size) ioremap((addr), (size))
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 4/26 mips: remove ioremap_cachable
In reply to Christoph HellwigJust define ioremap_cache directly.
--- arch/mips/include/asm/io.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/mips/include/asm/io.h +3 -4
@@ -262,11 +262,11 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset,#define ioremap_uc ioremap_nocache/* -* ioremap_cachable - map bus memory into CPU space +* ioremap_cache - map bus memory into CPU space * @offset: bus address of the memory * @size: size of the resource to map * -* ioremap_nocache performs a platform specific sequence of operations to +* ioremap_cache performs a platform specific sequence of operations to * make bus memory CPU accessible via the readb/readw/readl/writeb/ * writew/writel functions and the other mmio helpers. The returned * address is not guaranteed to be usable directly as a virtual
@@ -276,9 +276,8 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset,* the CPU. Also enables full write-combining. Useful for some * memory-like regions on I/O busses. */ -#define ioremap_cachable (offset, size) \ +#define ioremap_cache (offset, size) \ __ioremap_mode((offset), (size), _page_cachable_default) -#define ioremap_cache ioremap_cachable/* * ioremap_wc - map bus memory into CPU space
Signature · 1 line
2.20.1
Re: [PATCH 04/26] mips: remove ioremap_cachable
Hi Christoph,
Quoted 3 lines · Christoph Hellwig
Just define
ioremap_cachedirectly.Signed-off-by Christoph Hellwig <[email protected]>
Thanks,
Paul
Quoted 36 lines
--- arch/mips/include/asm/io.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)arch/mips/include/asm/io.h +3
-4@@ -262,11 +262,11 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset,#define ioremap_uc ioremap_nocache/* -* ioremap_cachable - map bus memory into CPU space +* ioremap_cache - map bus memory into CPU space * @offset: bus address of the memory * @size: size of the resource to map * -* ioremap_nocache performs a platform specific sequence of operations to +* ioremap_cache performs a platform specific sequence of operations to * make bus memory CPU accessible via the readb/readw/readl/writeb/ * writew/writel functions and the other mmio helpers. The returned * address is not guaranteed to be usable directly as a virtual @@ -276,9 +276,8 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset,* the CPU. Also enables full write-combining. Useful for some * memory-like regions on I/O busses. */ -#define ioremap_cachable (offset, size) \ +#define ioremap_cache (offset, size) \ __ioremap_mode((offset), (size), _page_cachable_default) -#define ioremap_cache ioremap_cachable/* * ioremap_wc - map bus memory into CPU space Signature · 1 line
2.20.1
Re: [PATCH 04/26] mips: remove ioremap_cachable
Quoted 8 lines · Paul Burton
Hi Christoph,
Quoted 3 lines · Christoph Hellwig
Just define
ioremap_cachedirectly.Signed-off-by Christoph Hellwig <[email protected]>Acked-by Paul Burton <[email protected]>
Can you pick this patch up through the mips tree?
Paul Burton
AppliedRe: [PATCH 04/26] mips: remove ioremap_cachable
In reply to Christoph HellwigHello,
Quoted 1 line · Christoph Hellwig
Just define
ioremap_cachedirectly.
Applied to mips-next.
Quoted 5 lines
commit
60af0d94cc37
https://git.kernel.org/mips/c/60af0d94cc37Signed-off-by Christoph Hellwig <[email protected]>Signed-off-by Paul Burton <[email protected]>
Thanks,
Paul
[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]
PATCH 5/26 openrisc: map as uncached in ioremap
In reply to Christoph HellwigOpenrisc is the only architecture not mapping ioremap as uncached, which has been the default since the Linux 2.6.x days. Switch it over to implement uncached semantics by default.
--- arch/openrisc/include/asm/io.h | 20 +++----------------- arch/openrisc/include/asm/pgtable.h | 2 +- arch/openrisc/mm/ioremap.c | 8 ++++---- 3 files changed, 8 insertions(+), 22 deletions(-)
arch/openrisc/include/asm/io.h +3 -17
@@ -25,25 +25,11 @@#define PIO_OFFSET 0#define PIO_MASK 0 -#define ioremap_nocache ioremap_nocache +#define ioremap_nocache ioremap#include <asm-generic/io.h> #include <asm/pgtable.h> -extern void __iomem *__ioremap (phys_addr_t offset,unsigned long size, -pgprot_t prot); - -static inline void __iomem *ioremap (phys_addr_t offset,size_t size) -{ -return __ioremap (offset, size,PAGE_KERNEL ); -} - -/* #define _PAGE_CI 0x002 */ -static inline void __iomem *ioremap_nocache (phys_addr_t offset, -unsigned long size) -{ -return __ioremap (offset, size, -__pgprot (pgprot_val (PAGE_KERNEL ) | _PAGE_CI)); -} - +void __iomem *ioremap (phys_addr_t offset,unsigned long size);extern void iounmap (void *addr); +#endif
arch/openrisc/include/asm/pgtable.h +1 -1
@@ -97,7 +97,7 @@ extern void paging_init(void);/* Define some higher level generic page attributes. * * If you change _PAGE_CI definition be sure to change it in -* io.h for ioremap_nocache() too. +* io.h for ioremap() too. */ /*
arch/openrisc/mm/ioremap.c +4 -4
@@ -34,8 +34,7 @@ static unsigned int fixmaps_used __initdata;* have to convert them into an offset in a page-aligned mapping, but the * caller shouldn't need to know that small detail. */ -void __iomem *__ref -__ioremap (phys_addr_t addr,unsigned long size,pgprot_t prot) +void __iomem *__ref ioremap (phys_addr_t addr,unsigned long size) {phys_addr_t p;unsigned long v;
@@ -66,7 +65,8 @@ __ioremap(phys_addr_t addr, unsigned long size, pgprot_t prot) fixmaps_used += (size >>PAGE_SHIFT ); } -if (ioremap_page_range (v, v + size, p, prot)) { +if (ioremap_page_range (v, v + size, p, +__pgprot (pgprot_val (PAGE_KERNEL ) | _PAGE_CI))) {if (likely (mem_init_done))vfree (area->addr);else
@@ -76,7 +76,7 @@ __ioremap(phys_addr_t addr, unsigned long size, pgprot_t prot)return (void __iomem *)(offset + (char *)v); } -EXPORT_SYMBOL (__ioremap); +EXPORT_SYMBOL (ioremap);void iounmap (void *addr) {
Signature · 1 line
2.20.1
Re: [PATCH 05/26] openrisc: map as uncached in ioremap
Quoted 10 lines · Christoph Hellwig
Openrisc is the only architecture not mapping ioremap as uncached, which has been the default since the Linux 2.6.x days. Switch it over to implement uncached semantics by default.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/openrisc/include/asm/io.h | 20 +++----------------- arch/openrisc/include/asm/pgtable.h | 2 +- arch/openrisc/mm/ioremap.c | 8 ++++---- 3 files changed, 8 insertions(+), 22 deletions(-)
Thanks,
-Stafford
Re: [PATCH 05/26] openrisc: map as uncached in ioremap
Quoted 5 lines · Stafford Horne
Quoted 4 lines · Christoph Hellwig
Openrisc is the only architecture not mapping ioremap as uncached, which has been the default since the Linux 2.6.x days. Switch it over to implement uncached semantics by default.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>--- arch/openrisc/include/asm/io.h | 20 +++----------------- arch/openrisc/include/asm/pgtable.h | 2 +- arch/openrisc/mm/ioremap.c | 8 ++++---- 3 files changed, 8 insertions(+), 22 deletions(-)Acked-by Stafford Horne <[email protected]>
Can you send this one to Linus for 5.4? That would help with the possibility to remove ioremap_nocache after that.
Stafford Horne
maintainerRe: [PATCH 05/26] openrisc: map as uncached in ioremap
Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Stafford Horne
Quoted 10 lines · Christoph Hellwig
Openrisc is the only architecture not mapping ioremap as uncached, which has been the default since the Linux 2.6.x days. Switch it over to implement uncached semantics by default.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/openrisc/include/asm/io.h | 20 +++----------------- arch/openrisc/include/asm/pgtable.h | 2 +- arch/openrisc/mm/ioremap.c | 8 ++++---- 3 files changed, 8 insertions(+), 22 deletions(-)
Quoted 4 lines
Quoted 1 line
Acked-by Stafford Horne <[email protected]>Can you send this one to Linus for 5.4? That would help with the possibility to remove
ioremap_nocacheafter that.
Sure, I will pick this up.
-Stafford
PATCH 6/26 ia64: rename ioremap_nocache to ioremap_uc
In reply to Christoph HellwigOn ia64 ioremap_nocache fails if attributs don't match. Not other architectures does this, and we plan to get rid of ioremap_nocache. So get rid of the special semantics and define ioremap_nocache in terms of ioremap as no portable driver could rely on the behavior anyway.
However x86 implements ioremap_uc with a in a similar way as the ia64 version of ioremap_nocache, so implement that instead.
--- arch/ia64/include/asm/io.h | 6 +++--- arch/ia64/mm/ioremap.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/ia64/include/asm/io.h +3 -3
@@ -412,16 +412,16 @@ __writeq (unsigned long val, volatile void __iomem *addr)# ifdef __KERNEL__extern void __iomem *ioremap (unsigned long offset,unsigned long size); -extern void __iomem *ioremap_nocache (unsigned long offset,unsigned long size); +extern void __iomem *ioremap_uc (unsigned long offset,unsigned long size);extern void iounmap (volatile void __iomem *addr);static inline void __iomem *ioremap_cache (unsigned long phys_addr,unsigned long size) {return ioremap (phys_addr, size); }#define ioremap ioremap -#define ioremap_nocache ioremap_nocache +#define ioremap_nocache ioremap#define ioremap_cache ioremap_cache -#define ioremap_uc ioremap_nocache +#define ioremap_uc ioremap_uc#define iounmap iounmap/*
arch/ia64/mm/ioremap.c +2 -2
@@ -99,14 +99,14 @@ ioremap (unsigned long phys_addr, unsigned long size)EXPORT_SYMBOL (ioremap);void __iomem * -ioremap_nocache (unsigned long phys_addr,unsigned long size) +ioremap_uc (unsigned long phys_addr,unsigned long size) {if (kern_mem_attribute (phys_addr, size) &EFI_MEMORY_WB )return NULL ;return __ioremap_uc (phys_addr); } -EXPORT_SYMBOL (ioremap_nocache); +EXPORT_SYMBOL (ioremap_uc);void early_iounmap (volatile void __iomem *addr,unsigned long size)
Signature · 1 line
2.20.1
Re: [PATCH 06/26] ia64: rename ioremap_nocache to ioremap_uc
Hello!
Quoted 1 line · Christoph Hellwig
On ia64
ioremap_nocachefails if attributs don't match. Not other
Attributes. :-)
Quoted 6 lines
architectures does this, and we plan to get rid of
ioremap_nocache. So get rid of the special semantics and defineioremap_nocachein terms of ioremap as no portable driver could rely on the behavior anyway.However x86 implements
ioremap_ucwith a in a similar way as the ia64
"With a" not really needed?
Quoted 3 lines
version of
ioremap_nocache, so implement that instead.Signed-off-by Christoph Hellwig <[email protected]>
[...]
MBR, Sergei
PATCH 7/26 hexagon: clean up ioremap
In reply to Christoph HellwigUse ioremap as the main implemented function, and defined ioremap_nocache to it as a deprecated alias.
--- arch/hexagon/include/asm/io.h | 11 ++--------- arch/hexagon/kernel/hexagon_ksyms.c | 2 +- arch/hexagon/mm/ioremap.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)
arch/hexagon/include/asm/io.h +2 -9
@@ -171,16 +171,9 @@ static inline void writel(u32 data, volatile void __iomem *addr)#define writew_relaxed __raw_writew#define writel_relaxed __raw_writel -/* -* Need an mtype somewhere in here, for cache type deals? -* This is probably too long for an inline. -*/ -void __iomem *ioremap_nocache (unsigned long phys_addr,unsigned long size); +void __iomem *ioremap (unsigned long phys_addr,unsigned long size); +#define ioremap_nocache ioremap -static inline void __iomem *ioremap (unsigned long phys_addr,unsigned long size) -{ -return ioremap_nocache (phys_addr, size); -}static inline void iounmap (volatile void __iomem *addr) {
arch/hexagon/kernel/hexagon_ksyms.c +1 -1
@@ -20,7 +20,7 @@ EXPORT_SYMBOL(__vmgetie);EXPORT_SYMBOL (__vmsetie);EXPORT_SYMBOL (__vmyield);EXPORT_SYMBOL (empty_zero_page); -EXPORT_SYMBOL (ioremap_nocache); +EXPORT_SYMBOL (ioremap);EXPORT_SYMBOL (memcpy);EXPORT_SYMBOL (memset);
arch/hexagon/mm/ioremap.c +1 -1
@@ -9,7 +9,7 @@#include <linux/vmalloc.h> #include <linux/mm.h> -void __iomem *ioremap_nocache (unsigned long phys_addr,unsigned long size) +void __iomem *ioremap (unsigned long phys_addr,unsigned long size) {unsigned long last_addr, addr;unsigned long offset = phys_addr & ~PAGE_MASK ;
Signature · 1 line
2.20.1
PATCH 8/26 m68k: simplify ioremap_nocache
In reply to Christoph HellwigJust define ioremap_nocache to ioremap instead of duplicating the inline. Also defined ioremap_uc in terms of ioremap instead of the using a double indirection.
--- arch/m68k/include/asm/kmap.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/m68k/include/asm/kmap.h +2 -8
@@ -28,14 +28,8 @@ static inline void __iomem *ioremap(unsigned long physaddr, unsigned long size)return __ioremap (physaddr, size,IOMAP_NOCACHE_SER ); } -#define ioremap_nocache ioremap_nocache -static inline void __iomem *ioremap_nocache (unsigned long physaddr, -unsigned long size) -{ -return __ioremap (physaddr, size,IOMAP_NOCACHE_SER ); -} - -#define ioremap_uc ioremap_nocache +#define ioremap_nocache ioremap +#define ioremap_uc ioremap#define ioremap_wt ioremap_wtstatic inline void __iomem *ioremap_wt (unsigned long physaddr,unsigned long size)
Signature · 1 line
2.20.1
Re: [PATCH 08/26] m68k: simplify ioremap_nocache
Hi Christoph,
Quoted 5 lines · Christoph Hellwig
Just define
ioremap_nocacheto ioremap instead of duplicating the inline. Also definedioremap_ucin terms of ioremap instead of the using a double indirection.Signed-off-by Christoph Hellwig <[email protected]>
BTW, shouldn't we get rid of the sole user of ioremap_uc(), too? Seems to make a difference on x86 only, where it is "strongly uncached" (whatever that may mean ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 08/26] m68k: simplify ioremap_nocache
Quoted 3 lines · Geert Uytterhoeven
BTW, shouldn't we get rid of the sole user of
ioremap_uc(), too? Seems to make a difference on x86 only, where it is "strongly uncached" (whatever that may mean ;-)
Yes, we probably should. However that actually seems worth a discussion so I wanted to defer it until after this already huge series.
Another thing we can do after this series is to kill of ioremap_nocache.
Re: [PATCH 08/26] m68k: simplify ioremap_nocache
In reply to Geert UytterhoevenQuoted 10 lines · Geert Uytterhoeven
Hi Christoph,
Quoted 5 lines · Christoph Hellwig
Just define
ioremap_nocacheto ioremap instead of duplicating the inline. Also definedioremap_ucin terms of ioremap instead of the using a double indirection.Signed-off-by Christoph Hellwig <[email protected]>
Do you mind picking this up through the m68k tree?
Geert Uytterhoeven
maintainerRe: [PATCH 08/26] m68k: simplify ioremap_nocache
Hi Christoph,
Quoted 11 lines · Christoph Hellwig
Quoted 8 lines · Geert Uytterhoeven
Quoted 5 lines · Christoph Hellwig
Just define
ioremap_nocacheto ioremap instead of duplicating the inline. Also definedioremap_ucin terms of ioremap instead of the using a double indirection.Signed-off-by Christoph Hellwig <[email protected]>Do you mind picking this up through the m68k tree?
Sure. Applied and queued for v5.4.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 9/26 alpha: remove the unused __ioremap wrapper
In reply to Christoph HellwigNo need for the additional namespace pollution.
--- arch/alpha/include/asm/io.h | 6 ------ 1 file changed, 6 deletions(-)
arch/alpha/include/asm/io.h +0 -6
@@ -283,12 +283,6 @@ static inline void __iomem *ioremap(unsigned long port, unsigned long size)return IO_CONCAT (__IO_PREFIX,ioremap) (port, size); } -static inline void __iomem *__ioremap (unsigned long port,unsigned long size, -unsigned long flags) -{ -return ioremap (port, size); -} -static inline void __iomem *ioremap_nocache (unsigned long offset,unsigned long size) {
Signature · 1 line
2.20.1
PATCH 10/26 nios2: remove __ioremap
In reply to Christoph HellwigThe cacheflag argument to __ioremap is always 0, so just implement ioremap directly.
--- arch/nios2/include/asm/io.h | 20 ++++---------------- arch/nios2/mm/ioremap.c | 17 +++-------------- 2 files changed, 7 insertions(+), 30 deletions(-)
arch/nios2/include/asm/io.h +4 -16
@@ -25,29 +25,17 @@#define writew_relaxed (x, addr) writew(x, addr)#define writel_relaxed (x, addr) writel(x, addr) -extern void __iomem *__ioremap (unsigned long physaddr,unsigned long size, -unsigned long cacheflag); +void __iomem *ioremap (unsigned long physaddr,unsigned long size);extern void __iounmap (void __iomem *addr); -static inline void __iomem *ioremap (unsigned long physaddr,unsigned long size) -{ -return __ioremap (physaddr, size,0 ); -} - -static inline void __iomem *ioremap_nocache (unsigned long physaddr, -unsigned long size) -{ -return __ioremap (physaddr, size,0 ); -} -static inline void iounmap (void __iomem *addr) {__iounmap (addr); } -#define ioremap_nocache ioremap_nocache -#define ioremap_wc ioremap_nocache -#define ioremap_wt ioremap_nocache +#define ioremap_nocache ioremap +#define ioremap_wc ioremap +#define ioremap_wt ioremap/* Pages to physical address... */ #define page_to_phys (page) virt_to_phys(page_to_virt(page))
arch/nios2/mm/ioremap.c +3 -14
@@ -112,8 +112,7 @@ static int remap_area_pages(unsigned long address, unsigned long phys_addr,/* * Map some physical address range into the kernel address space. */ -void __iomem *__ioremap (unsigned long phys_addr,unsigned long size, -unsigned long cacheflag) +void __iomem *ioremap (unsigned long phys_addr,unsigned long size) {struct vm_struct *area;unsigned long offset;
@@ -139,15 +138,6 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,return NULL ; } -/* -* Map uncached objects in the low part of address space to -* CONFIG_NIOS2_IO_REGION_BASE -*/ -if (IS_MAPPABLE_UNCACHEABLE (phys_addr) && -IS_MAPPABLE_UNCACHEABLE (last_addr) && - !(cacheflag & _PAGE_CACHED)) -return (void __iomem *)(CONFIG_NIOS2_IO_REGION_BASE + phys_addr); -/* Mappings have to be page-aligned */ offset = phys_addr & ~PAGE_MASK ; phys_addr &=PAGE_MASK ;
@@ -158,14 +148,13 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,if (!area)return NULL ; addr = area->addr; -if (remap_area_pages ((unsigned long ) addr, phys_addr, size, - cacheflag)) { +if (remap_area_pages ((unsigned long ) addr, phys_addr, size,0 )) {vunmap (addr);return NULL ; }return (void __iomem *) (offset + (char *)addr); } -EXPORT_SYMBOL (__ioremap); +EXPORT_SYMBOL (ioremap);/* * __iounmap unmaps nearly everything, so be careful
Signature · 1 line
2.20.1
PATCH 11/26 parisc: remove __ioremap
In reply to Christoph Hellwig__ioremap is always called with the _PAGE_NO_CACHE, so fold the whole thing and rename it to ioremap. This allows allows to remove the special EISA quirk to force _PAGE_NO_CACHE.
--- arch/parisc/include/asm/io.h | 11 +---------- arch/parisc/mm/ioremap.c | 16 +++------------- 2 files changed, 4 insertions(+), 23 deletions(-)
arch/parisc/include/asm/io.h +1 -10
@@ -127,16 +127,7 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)/* * The standard PCI ioremap interfaces */ - -extern void __iomem *__ioremap (unsigned long offset,unsigned long size,unsigned long flags); - -/* Most machines react poorly to I/O-space being cacheable... Instead let's -* define ioremap() in terms of ioremap_nocache(). -*/ -static inline void __iomem *ioremap (unsigned long offset,unsigned long size) -{ -return __ioremap (offset, size, _PAGE_NO_CACHE); -} +void __iomem *ioremap (unsigned long offset,unsigned long size);#define ioremap_nocache (off, sz) ioremap((off), (sz))#define ioremap_wc ioremap_nocache#define ioremap_uc ioremap_nocache
arch/parisc/mm/ioremap.c +3 -13
@@ -25,23 +25,13 @@* have to convert them into an offset in a page-aligned mapping, but the * caller shouldn't need to know that small detail. */ -void __iomem *__ioremap (unsigned long phys_addr,unsigned long size,unsigned long flags) +void __iomem *ioremap (unsigned long phys_addr,unsigned long size) {void __iomem *addr;struct vm_struct *area;unsigned long offset, last_addr;pgprot_t pgprot; -#ifdef CONFIG_EISA -unsigned long end = phys_addr + size -1 ; -/* Support EISA addresses */ -if ((phys_addr >=0x00080000 && end <0x000fffff ) || - (phys_addr >=0x00500000 && end <0x03bfffff )) { - phys_addr |=F_EXTEND (0xfc000000 ); - flags |= _PAGE_NO_CACHE; - } -#endif -/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;if (!size || last_addr < phys_addr)
@@ -65,7 +55,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l } pgprot =__pgprot (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | - _PAGE_ACCESSED | flags); + _PAGE_ACCESSED | _PAGE_NO_CACHE);/* * Mappings have to be page-aligned
@@ -90,7 +80,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned lreturn (void __iomem *) (offset + (char __iomem *)addr); } -EXPORT_SYMBOL (__ioremap); +EXPORT_SYMBOL (ioremap);void iounmap (const volatile void __iomem *addr) {
Signature · 1 line
2.20.1
PATCH 12/26 x86: clean up ioremap
In reply to Christoph HellwigUse ioremap as the main implemented function, and defined ioremap_nocache to it as a deprecated alias.
--- arch/x86/include/asm/io.h | 8 ++------ arch/x86/mm/ioremap.c | 8 ++++---- arch/x86/mm/pageattr.c | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
arch/x86/include/asm/io.h +2 -6
@@ -180,8 +180,6 @@ static inline unsigned int isa_virt_to_bus(volatile void *address)* The default ioremap() behavior is non-cached; if you need something * else, you probably want one of the following. */ -extern void __iomem *ioremap_nocache (resource_size_t offset,unsigned long size); -#define ioremap_nocache ioremap_nocacheextern void __iomem *ioremap_uc (resource_size_t offset,unsigned long size);#define ioremap_uc ioremap_ucextern void __iomem *ioremap_cache (resource_size_t offset,unsigned long size);
@@ -205,11 +203,9 @@ extern void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long* If the area you are trying to map is a PCI BAR you should have a * look at pci_iomap(). */ -static inline void __iomem *ioremap (resource_size_t offset,unsigned long size) -{ -return ioremap_nocache (offset, size); -} +void __iomem *ioremap (resource_size_t offset,unsigned long size);#define ioremap ioremap +#define ioremap_nocache ioremapextern void iounmap (volatile void __iomem *addr);#define iounmap iounmap
arch/x86/mm/ioremap.c +4 -4
@@ -279,11 +279,11 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size, }/** -* ioremap_nocache - map bus memory into CPU space +* ioremap - map bus memory into CPU space * @phys_addr: bus address of the memory * @size: size of the resource to map * -* ioremap_nocache performs a platform specific sequence of operations to +* ioremap performs a platform specific sequence of operations to * make bus memory CPU accessible via the readb/readw/readl/writeb/ * writew/writel functions and the other mmio helpers. The returned * address is not guaranteed to be usable directly as a virtual
@@ -299,7 +299,7 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,* * Must be freed with iounmap. */ -void __iomem *ioremap_nocache (resource_size_t phys_addr,unsigned long size) +void __iomem *ioremap (resource_size_t phys_addr,unsigned long size) {/* * Ideally, this should be:
@@ -314,7 +314,7 @@ void __iomem *ioremap_nocache(resource_size_t phys_addr, unsigned long size)return __ioremap_caller (phys_addr, size, pcm,__builtin_return_address (0 ), false); } -EXPORT_SYMBOL (ioremap_nocache); +EXPORT_SYMBOL (ioremap);/** * ioremap_uc - map bus memory into CPU space as strongly uncachable
arch/x86/mm/pageattr.c +2 -2
@@ -1774,7 +1774,7 @@ static inline int cpa_clear_pages_array(struct page **pages, int numpages,int _set_memory_uc (unsigned long addr,int numpages) {/* -* for now UC MINUS. see comments in ioremap_nocache() +* for now UC MINUS. see comments in ioremap() * If you really need strong UC use ioremap_uc(), but note * that you cannot override IO areas with set_memory_*() as * these helpers cannot work with IO memory.
@@ -1789,7 +1789,7 @@ int set_memory_uc(unsigned long addr, int numpages)int ret;/* -* for now UC MINUS. see comments in ioremap_nocache() +* for now UC MINUS. see comments in ioremap() */ ret =reserve_memtype (__pa (addr),__pa (addr) + numpages *PAGE_SIZE , _PAGE_CACHE_MODE_UC_MINUS,NULL );
Signature · 1 line
2.20.1
Re: [PATCH 12/26] x86: clean up ioremap
Quoted 9 lines · Christoph Hellwig
Use ioremap as the main implemented function, and defined
ioremap_nocacheto it as a deprecated alias.Signed-off-by Christoph Hellwig <[email protected]>--- arch/x86/include/asm/io.h | 8 ++------ arch/x86/mm/ioremap.c | 8 ++++---- arch/x86/mm/pageattr.c | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)
Thanks,
Ingo
Re: [PATCH 12/26] x86: clean up ioremap
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Christoph Hellwig
Use ioremap as the main implemented function, and defined
ioremap_nocacheto it as a deprecated alias.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Christoph Hellwig <[email protected]>--- arch/x86/include/asm/io.h | 8 ++------ arch/x86/mm/ioremap.c | 8 ++++---- arch/x86/mm/pageattr.c | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-)Acked-by Ingo Molnar <[email protected]>
Can you pick it up through tip for 5.4? That way we can get most bits in through their maintainer trees, and then I'll resubmit the rest for the next merge window.
PATCH 13/26 xtensa: clean up ioremap
In reply to Christoph HellwigUse ioremap as the main implemented function, and defined ioremap_nocache to it as a deprecated alias.
--- arch/xtensa/include/asm/io.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/xtensa/include/asm/io.h +4 -10
@@ -31,8 +31,7 @@ void xtensa_iounmap(volatile void __iomem *addr);/* * Return the virtual address for the specified bus memory. */ -static inline void __iomem *ioremap_nocache (unsigned long offset, -unsigned long size) +static inline void __iomem *ioremap (unsigned long offset,unsigned long size) {if (offset >=XCHAL_KIO_PADDR && offset -XCHAL_KIO_PADDR <XCHAL_KIO_SIZE )
@@ -51,15 +50,10 @@ static inline void __iomem *ioremap_cache(unsigned long offset,return xtensa_ioremap_cache (offset, size); }#define ioremap_cache ioremap_cache -#define ioremap_nocache ioremap_nocache - -#define ioremap_wc ioremap_nocache -#define ioremap_wt ioremap_nocache -static inline void __iomem *ioremap (unsigned long offset,unsigned long size) -{ -return ioremap_nocache (offset, size); -} +#define ioremap_nocache ioremap +#define ioremap_wc ioremap +#define ioremap_wt ioremapstatic inline void iounmap (volatile void __iomem *addr) {
Signature · 1 line
2.20.1
PATCH 14/26 asm-generic: don't provide __ioremap
In reply to Christoph Hellwig__ioremap is not a kernel API, but used for helpers with differing semantics in arch code. We should not provide it in as-generic.
--- include/asm-generic/io.h | 9 --------- 1 file changed, 9 deletions(-)
include/asm-generic/io.h +0 -9
@@ -963,15 +963,6 @@ static inline void __iomem *ioremap(phys_addr_t offset, size_t size) }#endif -#ifndef __ioremap -#define __ioremap __ioremap -static inline void __iomem *__ioremap (phys_addr_t offset,size_t size, -unsigned long flags) -{ -return ioremap (offset, size); -} -#endif -#ifndef iounmap#define iounmap iounmap
Signature · 1 line
2.20.1
Re: [PATCH 14/26] asm-generic: don't provide __ioremap
Quoted 4 lines · Christoph Hellwig
__ioremapis not a kernel API, but used for helpers with differing semantics in arch code. We should not provide it in as-generic.Signed-off-by Christoph Hellwig <[email protected]>
- Paul
Re: [PATCH 14/26] asm-generic: don't provide __ioremap
Quoted 1 line · Paul Walmsley
This ack is superfluous since the patch doesn't touch arch/riscv; feel free to drop it
- Paul
PATCH 14/26 asm-generic: don't provide __ioremap
In reply to Paul WalmsleyArnd, can you consider this patch for asm-generic for 5.4? I don't think I'll be able to feed the actual generic ioremap implementation to Linus this merge window, but if we can get as many patches as possible in through their maintainer trees that would make my life much easier.
Arnd Bergmann
maintainerRe: [PATCH 14/26] asm-generic: don't provide __ioremap
Quoted 6 lines · Christoph Hellwig
Arnd, can you consider this patch for asm-generic for 5.4? I don't think I'll be able to feed the actual generic ioremap implementation to Linus this merge window, but if we can get as many patches as possible in through their maintainer trees that would make my life much easier.
Applied now, I missed it earlier when I was on vacation.
Arnd
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 14/26] asm-generic: don't provide __ioremap
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · Christoph Hellwig
Arnd, can you consider this patch for asm-generic for 5.4? I don't think I'll be able to feed the actual generic ioremap implementation to Linus this merge window, but if we can get as many patches as possible in through their maintainer trees that would make my life much easier.
Applied now, I missed it earlier when I was on vacation.
Thanks. I think the next two patches (15 and 16) should also be fine for the asm-generic tree for 5.4. For patch 17 I'd rather have all arch patches in first.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 15/26 asm-generic: ioremap_uc should behave the same with and without MMU
In reply to Christoph HellwigWhatever reason there is for the existence of ioremap_uc, and the fact that it returns NULL by default on architectures with an MMU applies equally to nommu architectures, so don't provide different defaults.
In practice the difference is meaningless as the only portable driver that uses ioremap_uc is atyfb which probably doesn't show up on nommu devices.
--- include/asm-generic/io.h | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
include/asm-generic/io.h +16 -20
@@ -935,18 +935,7 @@ static inline void *phys_to_virt(unsigned long address)* defined your own ioremap_*() variant you must then declare your own * ioremap_*() variant as defined to itself to avoid the default NULL return. */ - -#ifdef CONFIG_MMU - -#ifndef ioremap_uc -#define ioremap_uc ioremap_uc -static inline void __iomem *ioremap_uc (phys_addr_t offset,size_t size) -{ -return NULL ; -} -#endif - -#else /* !CONFIG_MMU */ +#ifndef CONFIG_MMU /* * Change "struct page" to physical address.
@@ -980,14 +969,6 @@ static inline void __iomem *ioremap_nocache(phys_addr_t offset, size_t size) }#endif -#ifndef ioremap_uc -#define ioremap_uc ioremap_uc -static inline void __iomem *ioremap_uc (phys_addr_t offset,size_t size) -{ -return ioremap_nocache (offset, size); -} -#endif -#ifndef ioremap_wc#define ioremap_wc ioremap_wcstatic inline void __iomem *ioremap_wc (phys_addr_t offset,size_t size)
@@ -1004,6 +985,21 @@ static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) }#endif +/* +* ioremap_uc is special in that we do require an explicit architecture +* implementation. In general you do now want to use this function in a +* driver and use plain ioremap, which is uncached by default. Similarly +* architectures should not implement it unless they have a very good +* reason. +*/ +#ifndef ioremap_uc +#define ioremap_uc ioremap_uc +static inline void __iomem *ioremap_uc (phys_addr_t offset,size_t size) +{ +return NULL ; +} +#endif +#ifdef CONFIG_HAS_IOPORT_MAP #ifndef CONFIG_GENERIC_IOMAP #ifndef ioport_map
Signature · 1 line
2.20.1
Re: [PATCH 15/26] asm-generic: ioremap_uc should behave the same with and without MMU
Quoted 9 lines · Christoph Hellwig
Whatever reason there is for the existence of
ioremap_uc, and the fact that it returns NULL by default on architectures with an MMU applies equally to nommu architectures, so don't provide different defaults.In practice the difference is meaningless as the only portable driver that uses
ioremap_ucis atyfb which probably doesn't show up on nommu devices.Signed-off-by Christoph Hellwig <[email protected]>
[ ... ]
Quoted 4 lines
include/asm-generic/io.h +0
-0
[ ... ]
include/asm-generic/io.h static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) · line 990
Quoted 7 lines
include/asm-generic/io.h +3
-0@@ -1004,6 +985,21 @@ static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) }#endif +/* +* ioremap_uc is special in that we do require an explicit architecture +* implementation. In general you do now want to use this function in a
^^^ not
include/asm-generic/io.h static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) · line 991
Quoted 1 line
include/asm-generic/io.h +1
-0+* driver and use plain ioremap, which is uncached by default. Similarly
^ instead
include/asm-generic/io.h static inline void __iomem *ioremap_wt(phys_addr_t offset, size_t size) · line 994
Quoted 3 lines
include/asm-generic/io.h +3
-0+* architectures should not implement it unless they have a very good +* reason. +*/
Looks like this mess is only needed on x86 with certain graphics drivers and conflicts between MTRR and page table-based MMU attributes.
- Paul
PATCH 16/26 asm-generic: don't provide ioremap for CONFIG_MMU
In reply to Christoph HellwigAll 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.
--- 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(-)
arch/nds32/include/asm/io.h +2 -0
@@ -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_writebstatic 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 */
arch/sparc/include/asm/io_32.h +1 -0
@@ -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);
include/asm-generic/io.h +8 -21
@@ -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 ioremapstatic 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_nocachestatic inline void __iomem *ioremap_nocache (phys_addr_t offset,size_t size) {
Signature · 1 line
2.20.1
Re: [PATCH 16/26] asm-generic: don't provide ioremap for CONFIG_MMU
Quoted 15 lines · Christoph Hellwig
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.hto explain the situation around the default ioremap* implementations correctly.Signed-off-by Christoph Hellwig <[email protected]>--- 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(-)
[ ... ]
Quoted 16 lines
include/asm-generic/io.h +4
-3@@ -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. *
include/asm-generic/io.h static inline void *phys_to_virt(unsigned long address) · line 931
Quoted 10 lines
include/asm-generic/io.h +2
-8-* 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
^^^ chooses
- Paul
PATCH 17/26 arch: rely on asm-generic/io.h for default ioremap_* definitions
In reply to Christoph HellwigVarious architectures that use asm-generic/io.h still defined their own default versions of ioremap_nocache, ioremap_wt and ioremap_wc that point back to plain ioremap directly or indirectly. Remove these definitions and rely on asm-generic/io.h instead. For this to work the backup ioremap_* defintions needs to be changed to purely cpp macros instea of inlines to cover for architectures like openrisc that only define ioremap after including <asm-generic/io.h>.
--- arch/arc/include/asm/io.h | 4 ---- arch/arm/include/asm/io.h | 1 - arch/arm64/include/asm/io.h | 2 -- arch/csky/include/asm/io.h | 4 ---- arch/ia64/include/asm/io.h | 1 - arch/microblaze/include/asm/io.h | 3 --- arch/nios2/include/asm/io.h | 4 ---- arch/openrisc/include/asm/io.h | 1 - arch/riscv/include/asm/io.h | 10 ---------- arch/s390/include/asm/io.h | 4 ---- arch/x86/include/asm/io.h | 1 - arch/xtensa/include/asm/io.h | 4 ---- include/asm-generic/io.h | 18 +++--------------- 13 files changed, 3 insertions(+), 54 deletions(-)
arch/arc/include/asm/io.h +0 -4
@@ -34,10 +34,6 @@ static inline void ioport_unmap(void __iomem *addr)extern void iounmap (const void __iomem *addr); -#define ioremap_nocache (phy, sz) ioremap(phy, sz) -#define ioremap_wc (phy, sz) ioremap(phy, sz) -#define ioremap_wt (phy, sz) ioremap(phy, sz) -/* * io{read,write}{16,32}be() macros */
arch/arm/include/asm/io.h +0 -1
@@ -392,7 +392,6 @@ static inline void memcpy_toio(volatile void __iomem *to, const void *from,*/ void __iomem *ioremap (resource_size_t res_cookie,size_t size);#define ioremap ioremap -#define ioremap_nocache ioremap/* * Do not use ioremap_cache for mapping memory. Use memremap instead.
arch/arm64/include/asm/io.h +0 -2
@@ -169,9 +169,7 @@ extern void __iounmap(volatile void __iomem *addr);extern void __iomem *ioremap_cache (phys_addr_t phys_addr,size_t size);#define ioremap (addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE)) -#define ioremap_nocache (addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))#define ioremap_wc (addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC)) -#define ioremap_wt (addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))#define iounmap __iounmap/*
arch/csky/include/asm/io.h +0 -4
@@ -40,10 +40,6 @@ extern int remap_area_pages(unsigned long address, phys_addr_t phys_addr,#define writel (v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); })#endif -#define ioremap_nocache (phy, sz) ioremap(phy, sz) -#define ioremap_wc ioremap_nocache -#define ioremap_wt ioremap_nocache -#include <asm-generic/io.h> #endif /* __ASM_CSKY_IO_H */
arch/ia64/include/asm/io.h +0 -1
@@ -419,7 +419,6 @@ static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned loreturn ioremap (phys_addr, size); }#define ioremap ioremap -#define ioremap_nocache ioremap#define ioremap_cache ioremap_cache#define ioremap_uc ioremap_uc#define iounmap iounmap
arch/microblaze/include/asm/io.h +0 -3
@@ -39,9 +39,6 @@ extern resource_size_t isa_mem_base;extern void iounmap (volatile void __iomem *addr);extern void __iomem *ioremap (phys_addr_t address,unsigned long size); -#define ioremap_nocache (addr, size) ioremap((addr), (size)) -#define ioremap_wc (addr, size) ioremap((addr), (size)) -#define ioremap_wt (addr, size) ioremap((addr), (size))#endif /* CONFIG_MMU */
arch/nios2/include/asm/io.h +0 -4
@@ -33,10 +33,6 @@ static inline void iounmap(void __iomem *addr)__iounmap (addr); } -#define ioremap_nocache ioremap -#define ioremap_wc ioremap -#define ioremap_wt ioremap -/* Pages to physical address... */ #define page_to_phys (page) virt_to_phys(page_to_virt(page))
arch/openrisc/include/asm/io.h +0 -1
@@ -25,7 +25,6 @@#define PIO_OFFSET 0#define PIO_MASK 0 -#define ioremap_nocache ioremap#include <asm-generic/io.h> #include <asm/pgtable.h>
arch/riscv/include/asm/io.h +0 -10
@@ -15,16 +15,6 @@#include <asm/mmiowb.h> extern void __iomem *ioremap (phys_addr_t offset,unsigned long size); - -/* -* The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't -* change the properties of memory regions. This should be fixed by the -* upcoming platform spec. -*/ -#define ioremap_nocache (addr, size) ioremap((addr), (size)) -#define ioremap_wc (addr, size) ioremap((addr), (size)) -#define ioremap_wt (addr, size) ioremap((addr), (size)) -extern void iounmap (volatile void __iomem *addr);/* Generic IO read/write. These perform native-endian accesses. */
arch/s390/include/asm/io.h +0 -4
@@ -26,10 +26,6 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);#define IO_SPACE_LIMIT 0 -#define ioremap_nocache (addr, size) ioremap(addr, size) -#define ioremap_wc ioremap_nocache -#define ioremap_wt ioremap_nocache -void __iomem *ioremap (unsigned long offset,unsigned long size);void iounmap (volatile void __iomem *addr);
arch/x86/include/asm/io.h +0 -1
@@ -205,7 +205,6 @@ extern void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long*/ void __iomem *ioremap (resource_size_t offset,unsigned long size);#define ioremap ioremap -#define ioremap_nocache ioremapextern void iounmap (volatile void __iomem *addr);#define iounmap iounmap
arch/xtensa/include/asm/io.h +0 -4
@@ -51,10 +51,6 @@ static inline void __iomem *ioremap_cache(unsigned long offset, }#define ioremap_cache ioremap_cache -#define ioremap_nocache ioremap -#define ioremap_wc ioremap -#define ioremap_wt ioremap -static inline void iounmap (volatile void __iomem *addr) {unsigned long va = (unsigned long ) addr;
include/asm-generic/io.h +3 -15
@@ -949,27 +949,15 @@ static inline void iounmap(void __iomem *addr)#endif /* CONFIG_MMU */ #ifndef ioremap_nocache -#define ioremap_nocache ioremap_nocache -static inline void __iomem *ioremap_nocache (phys_addr_t offset,size_t size) -{ -return ioremap (offset, size); -} +#define ioremap_nocache ioremap#endif #ifndef ioremap_wc -#define ioremap_wc ioremap_wc -static inline void __iomem *ioremap_wc (phys_addr_t offset,size_t size) -{ -return ioremap_nocache (offset, size); -} +#define ioremap_wc ioremap#endif #ifndef ioremap_wt -#define ioremap_wt ioremap_wt -static inline void __iomem *ioremap_wt (phys_addr_t offset,size_t size) -{ -return ioremap_nocache (offset, size); -} +#define ioremap_wt ioremap#endif /*
Signature · 1 line
2.20.1
Re: [PATCH 17/26] arch: rely on asm-generic/io.h for default ioremap_* definitions
Quoted 9 lines · Christoph Hellwig
Various architectures that use
asm-generic/io.hstill defined their own default versions ofioremap_nocache,ioremap_wtandioremap_wcthat point back to plain ioremap directly or indirectly. Remove these definitions and rely onasm-generic/io.hinstead. For this to work the backup ioremap_* defintions needs to be changed to purely cpp macros instea of inlines to cover for architectures like openrisc that only define ioremap after including <asm-generic/io.h>.Signed-off-by Christoph Hellwig <[email protected]>
- Paul
PATCH 18/26 m68k: rename __iounmap and mark it static
In reply to Christoph Hellwigm68k uses __iounmap as the name for an internal helper that is only used for some CPU types. Mark it static and give it a better name.
--- arch/m68k/include/asm/kmap.h | 1 - arch/m68k/mm/kmap.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/m68k/include/asm/kmap.h +0 -1
@@ -20,7 +20,6 @@ extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);#define iounmap iounmapextern void iounmap (void __iomem *addr); -extern void __iounmap (void *addr,unsigned long size);#define ioremap ioremapstatic inline void __iomem *ioremap (unsigned long physaddr,unsigned long size)
arch/m68k/mm/kmap.c +6 -3
@@ -52,6 +52,7 @@ static inline void free_io_area(void *addr)#define IO_SIZE (256*1024) +static void __free_io_area (void *addr,unsigned long size);static struct vm_struct *iolist;static struct vm_struct *get_io_area (unsigned long size)
@@ -90,7 +91,7 @@ static inline void free_io_area(void *addr)if (tmp->addr == addr) { *p = tmp->next;/* remove gap added in get_io_area() */ -__iounmap (tmp->addr, tmp->size -IO_SIZE ); +__free_io_area (tmp->addr, tmp->size -IO_SIZE );kfree (tmp);return ; }
@@ -249,12 +250,13 @@ void iounmap(void __iomem *addr) }EXPORT_SYMBOL (iounmap); +#ifndef CPU_M68040_OR_M68060_ONLY /* -* __iounmap unmaps nearly everything, so be careful +* __free_io_area unmaps nearly everything, so be careful * Currently it doesn't free pointer/page tables anymore but this * wasn't used anyway and might be added later. */ -void __iounmap (void *addr,unsigned long size) +static void __free_io_area (void *addr,unsigned long size) {unsigned long virtaddr = (unsigned long )addr;pgd_t *pgd_dir;
@@ -297,6 +299,7 @@ void __iounmap(void *addr, unsigned long size) flush_tlb_all(); } +#endif /* CPU_M68040_OR_M68060_ONLY */ /* * Set new cache mode for some kernel address space.
Signature · 1 line
2.20.1
Geert Uytterhoeven
maintainerRe: [PATCH 18/26] m68k: rename __iounmap and mark it static
Hi Christoph,
Quoted 4 lines · Christoph Hellwig
m68k uses
__iounmapas the name for an internal helper that is only used for some CPU types. Mark it static and give it a better name.Signed-off-by Christoph Hellwig <[email protected]>
Thanks for your patch!
Quoted 20 lines
arch/m68k/mm/kmap.c +2
-1@@ -52,6 +52,7 @@ static inline void free_io_area(void *addr)#define IO_SIZE (256*1024) +static void __free_io_area (void *addr,unsigned long size);static struct vm_struct *iolist;static struct vm_struct *get_io_area (unsigned long size)@@ -90,7 +91,7 @@ static inline void free_io_area(void *addr)if (tmp->addr == addr) { *p = tmp->next;/* remove gap added in get_io_area() */ -__iounmap (tmp->addr, tmp->size -IO_SIZE ); +__free_io_area (tmp->addr, tmp->size -IO_SIZE );kfree (tmp);return ; }
arch/m68k/mm/kmap.c void iounmap(void __iomem *addr) · line 253
Quoted 4 lines
arch/m68k/mm/kmap.c +1
-0@@ -249,12 +250,13 @@ void iounmap(void __iomem *addr) }EXPORT_SYMBOL (iounmap); +#ifndef CPU_M68040_OR_M68060_ONLY
Cant you move this block up, to avoid adding more #ifdef cluttery? The rest looks good to me.
Quoted 12 lines
arch/m68k/mm/kmap.c +2
-2/* -* __iounmap unmaps nearly everything, so be careful +* __free_io_area unmaps nearly everything, so be careful * Currently it doesn't free pointer/page tables anymore but this * wasn't used anyway and might be added later. */ -void __iounmap (void *addr,unsigned long size) +static void __free_io_area (void *addr,unsigned long size) {unsigned long virtaddr = (unsigned long )addr;pgd_t *pgd_dir;
arch/m68k/mm/kmap.c void __iounmap(void *addr, unsigned long size) · line 305
Quoted 7 lines
arch/m68k/mm/kmap.c +1
-0@@ -297,6 +299,7 @@ void __iounmap(void *addr, unsigned long size) flush_tlb_all(); } +#endif /* CPU_M68040_OR_M68060_ONLY */ /* * Set new cache mode for some kernel address space.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
PATCH 19/26 arm64: remove __iounmap
In reply to Christoph HellwigNo need to indirect iounmap for arm64.
--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
arch/arm64/include/asm/io.h +1 -2
@@ -165,12 +165,11 @@ extern void __memset_io(volatile void __iomem *, int, size_t);* I/O memory mapping functions. */ extern void __iomem *__ioremap (phys_addr_t phys_addr,size_t size,pgprot_t prot); -extern void __iounmap (volatile void __iomem *addr); +extern void iounmap (volatile void __iomem *addr);extern void __iomem *ioremap_cache (phys_addr_t phys_addr,size_t size);#define ioremap (addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))#define ioremap_wc (addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC)) -#define iounmap __iounmap/* * PCI configuration space mapping function.
arch/arm64/mm/ioremap.c +2 -2
@@ -69,7 +69,7 @@ void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot) }EXPORT_SYMBOL (__ioremap); -void __iounmap (volatile void __iomem *io_addr) +void iounmap (volatile void __iomem *io_addr) {unsigned long addr = (unsigned long )io_addr &PAGE_MASK ;
@@ -80,7 +80,7 @@ void __iounmap(volatile void __iomem *io_addr)if (is_vmalloc_addr ((void *)addr))vunmap ((void *)addr); } -EXPORT_SYMBOL (__iounmap); +EXPORT_SYMBOL (iounmap);void __iomem *ioremap_cache (phys_addr_t phys_addr,size_t size) {
Signature · 1 line
2.20.1
Re: [PATCH 19/26] arm64: remove __iounmap
Quoted 7 lines · Christoph Hellwig
No need to indirect iounmap for arm64.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
Not sure why we did it like this...
Will
Re: [PATCH 19/26] arm64: remove __iounmap
Quoted 9 lines · Will Deacon
Quoted 7 lines · Christoph Hellwig
No need to indirect iounmap for arm64.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
Quoted 3 lines
Not sure why we did it like this...
Acked-by Will Deacon <[email protected]>
Can you just pick this one up through the arm64 tree for 5.4?
Will Deacon
maintainerRe: [PATCH 19/26] arm64: remove __iounmap
Hi Christoph,
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Will Deacon
Quoted 7 lines · Christoph Hellwig
No need to indirect iounmap for arm64.
Signed-off-by Christoph Hellwig <[email protected]>--- arch/arm64/include/asm/io.h | 3 +-- arch/arm64/mm/ioremap.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 3 lines
Not sure why we did it like this...
Acked-by Will Deacon <[email protected]>Can you just pick this one up through the arm64 tree for 5.4?
Unfortunately, it doesn't apply because the tree you've based it on has removed ioremap_wt(). If you send a version based on mainline, I can queue it.
Cheers,
Will
PATCH 20/26 hexagon: remove __iounmap
In reply to Christoph HellwigNo need to indirect iounmap for hexagon.
--- arch/hexagon/include/asm/io.h | 7 +------ arch/hexagon/kernel/hexagon_ksyms.c | 2 +- arch/hexagon/mm/ioremap.c | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-)
arch/hexagon/include/asm/io.h +1 -6
@@ -27,7 +27,7 @@extern int remap_area_pages (unsigned long start,unsigned long phys_addr,unsigned long end,unsigned long flags); -extern void __iounmap (const volatile void __iomem *addr); +extern void iounmap (const volatile void __iomem *addr);/* Defined in lib/io.c, needed for smc91x driver. */ extern void __raw_readsw (const void __iomem *addr,void *data,int wordlen);
@@ -175,11 +175,6 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size);#define ioremap_nocache ioremap -static inline void iounmap (volatile void __iomem *addr) -{ -__iounmap (addr); -} -#define __raw_writel writel static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
arch/hexagon/kernel/hexagon_ksyms.c +1 -1
@@ -14,7 +14,7 @@EXPORT_SYMBOL (__clear_user_hexagon);EXPORT_SYMBOL (raw_copy_from_user);EXPORT_SYMBOL (raw_copy_to_user); -EXPORT_SYMBOL (__iounmap); +EXPORT_SYMBOL (iounmap);EXPORT_SYMBOL (__strnlen_user);EXPORT_SYMBOL (__vmgetie);EXPORT_SYMBOL (__vmsetie);
arch/hexagon/mm/ioremap.c +1 -1
@@ -38,7 +38,7 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size)return (void __iomem *) (offset + addr); } -void __iounmap (const volatile void __iomem *addr) +void iounmap (const volatile void __iomem *addr) {vunmap ((void *) ((unsigned long ) addr &PAGE_MASK )); }
Signature · 1 line
2.20.1
PATCH 21/26 nios2: remove __iounmap
In reply to Christoph HellwigNo need to indirect iounmap for nios2.
--- arch/nios2/include/asm/io.h | 7 +------ arch/nios2/mm/ioremap.c | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-)
arch/nios2/include/asm/io.h +1 -6
@@ -26,12 +26,7 @@#define writel_relaxed (x, addr) writel(x, addr)void __iomem *ioremap (unsigned long physaddr,unsigned long size); -extern void __iounmap (void __iomem *addr); - -static inline void iounmap (void __iomem *addr) -{ -__iounmap (addr); -} +void iounmap (void __iomem *addr);/* Pages to physical address... */ #define page_to_phys (page) virt_to_phys(page_to_virt(page))
arch/nios2/mm/ioremap.c +3 -3
@@ -157,11 +157,11 @@ void __iomem *ioremap(unsigned long phys_addr, unsigned long size)EXPORT_SYMBOL (ioremap);/* -* __iounmap unmaps nearly everything, so be careful +* iounmap unmaps nearly everything, so be careful * it doesn't free currently pointer/page tables anymore but it * wasn't used anyway and might be added later. */ -void __iounmap (void __iomem *addr) +void iounmap (void __iomem *addr) {struct vm_struct *p;
@@ -173,4 +173,4 @@ void __iounmap(void __iomem *addr)pr_err ("iounmap: bad address %p\n" , addr);kfree (p); } -EXPORT_SYMBOL (__iounmap); +EXPORT_SYMBOL (iounmap);
Signature · 1 line
2.20.1
PATCH 22/26 sh: remove __iounmap
In reply to Christoph HellwigNo need to indirect iounmap for sh.
--- arch/sh/include/asm/io.h | 9 ++------- arch/sh/mm/ioremap.c | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-)
arch/sh/include/asm/io.h +2 -7
@@ -267,7 +267,7 @@ unsigned long long poke_real_address_q(unsigned long long addr,#ifdef CONFIG_MMU void __iomem *__ioremap_caller (phys_addr_t offset,unsigned long size,pgprot_t prot,void *caller); -void __iounmap (void __iomem *addr); +void iounmap (void __iomem *addr);static inline void __iomem *__ioremap (phys_addr_t offset,unsigned long size,pgprot_t prot)
@@ -328,7 +328,7 @@ __ioremap_mode(phys_addr_t offset, unsigned long size, pgprot_t prot)#else #define __ioremap (offset, size, prot) ((void __iomem *)(offset))#define __ioremap_mode (offset, size, prot) ((void __iomem *)(offset)) -#define __iounmap (addr) do { } while (0) +#define iounmap (addr) do { } while (0)#endif /* CONFIG_MMU */ static inline void __iomem *ioremap (phys_addr_t offset,unsigned long size)
@@ -370,11 +370,6 @@ static inline int iounmap_fixed(void __iomem *addr) { return -EINVAL; }#define ioremap_nocache ioremap#define ioremap_uc ioremap -static inline void iounmap (void __iomem *addr) -{ -__iounmap (addr); -} -/* * Convert a physical pointer to a virtual kernel pointer for /dev/mem * access
arch/sh/mm/ioremap.c +2 -2
@@ -103,7 +103,7 @@ static inline int iomapping_nontranslatable(unsigned long offset)return 0 ; } -void __iounmap (void __iomem *addr) +void iounmap (void __iomem *addr) {unsigned long vaddr = (unsigned long __force )addr;struct vm_struct *p;
@@ -134,4 +134,4 @@ void __iounmap(void __iomem *addr)kfree (p); } -EXPORT_SYMBOL (__iounmap); +EXPORT_SYMBOL (iounmap);
Signature · 1 line
2.20.1
PATCH 23/26 lib: provide a simple generic ioremap implementation
In reply to Christoph HellwigA lot of architectures reuse the same simple ioremap implementation, so start lifting the most simple variant to lib/ioremap.c. It provides ioremap_prot and iounmap, plus a default ioremap that uses prot_noncached, although that can be overridden by asm/io.h.
--- include/asm-generic/io.h | 20 ++++++++++++++++---- lib/Kconfig | 3 +++ lib/ioremap.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-)
include/asm-generic/io.h +16 -4
@@ -923,9 +923,10 @@ static inline void *phys_to_virt(unsigned long address)* DOC: ioremap() and ioremap_*() variants * * 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. +* themselves or rely on GENERIC_IOREMAP. 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. * * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes * for specific drivers if the architecture choses to implement them. If they
@@ -946,7 +947,18 @@ static inline void iounmap(void __iomem *addr) { }#endif -#endif /* CONFIG_MMU */ +#elif defined(CONFIG_GENERIC_IOREMAP ) +#include <asm/pgtable.h> + +void __iomem *ioremap_prot (phys_addr_t addr,size_t size,unsigned long prot); +void iounmap (volatile void __iomem *addr); + +static inline void __iomem *ioremap (phys_addr_t addr,size_t size) +{ +/* _PAGE_IOREMAP needs to be supplied by the architecture */ +return ioremap_prot (addr, size, _PAGE_IOREMAP); +} +#endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ #ifndef ioremap_nocache#define ioremap_nocache ioremap
lib/Kconfig +3 -0
@@ -636,6 +636,9 @@ config STRING_SELFTEST endmenu +config GENERIC_IOREMAP + bool + config GENERIC_LIB_ASHLDI3 bool
lib/ioremap.c +39 -0
@@ -231,3 +231,42 @@ int ioremap_page_range(unsigned long addr,return err; } + +#ifdef CONFIG_GENERIC_IOREMAP +void __iomem *ioremap_prot (phys_addr_t addr,size_t size,unsigned long prot) +{ +unsigned long offset, vaddr; +phys_addr_t last_addr; +struct vm_struct *area; + +/* Disallow wrap-around or zero size */ + last_addr = addr + size -1 ; +if (!size || last_addr < addr) +return NULL ; + +/* Page-align mappings */ + offset = addr & (~PAGE_MASK ); + addr -= offset; + size =PAGE_ALIGN (size + offset); + + area =get_vm_area_caller (size,VM_IOREMAP , +__builtin_return_address (0 )); +if (!area) +return NULL ; + vaddr = (unsigned long )area->addr; + +if (ioremap_page_range (vaddr, vaddr + size, addr,__pgprot (prot))) { +free_vm_area (area); +return NULL ; + } + +return (void __iomem *)(vaddr + offset); +} +EXPORT_SYMBOL (ioremap_prot); + +void iounmap (volatile void __iomem *addr) +{ +vunmap ((void *)((unsigned long )addr &PAGE_MASK )); +} +EXPORT_SYMBOL (iounmap); +#endif /* CONFIG_GENERIC_IOREMAP */
Signature · 1 line
2.20.1
PATCH 24/26 riscv: use the generic ioremap code
In reply to Christoph HellwigUse the generic ioremap code instead of providing a local version. Note that this relies on the asm-generic no-op definition of pgprot_noncached.
--- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/io.h | 3 -- arch/riscv/include/asm/pgtable.h | 6 +++ arch/riscv/mm/Makefile | 1 - arch/riscv/mm/ioremap.c | 84 -------------------------------- 5 files changed, 7 insertions(+), 88 deletions(-) delete mode 100644 arch/riscv/mm/ioremap.c
arch/riscv/Kconfig +1 -0
@@ -30,6 +30,7 @@ config RISCV select GENERIC_STRNLEN_USER select GENERIC_SMP_IDLE_THREAD select GENERIC_ATOMIC64 if !64BIT + select GENERIC_IOREMAP select HAVE_ARCH_AUDITSYSCALL select HAVE_MEMBLOCK_NODE_MAP select HAVE_DMA_CONTIGUOUS
arch/riscv/include/asm/io.h +0 -3
@@ -14,9 +14,6 @@#include <linux/types.h> #include <asm/mmiowb.h> -extern void __iomem *ioremap (phys_addr_t offset,unsigned long size); -extern void iounmap (volatile void __iomem *addr); -/* Generic IO read/write. These perform native-endian accesses. */ #define __raw_writeb __raw_writebstatic inline void __raw_writeb (u8 val,volatile void __iomem *addr)
arch/riscv/include/asm/pgtable.h +6 -0
@@ -61,6 +61,12 @@#define PAGE_TABLE __pgprot(_PAGE_TABLE) +/* +* The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't +* change the properties of memory regions. +*/ +#define _PAGE_IOREMAP _PAGE_KERNEL +extern pgd_t swapper_pg_dir[];/* MAP_PRIVATE permissions: xwr (copy-on-write) */
arch/riscv/mm/Makefile +0 -1
@@ -8,7 +8,6 @@ endif obj-y += init.o obj-y += fault.o obj-y += extable.o -obj-y += ioremap.o obj-y += cacheflush.o obj-y += context.o obj-y += sifive_l2_cache.o
arch/riscv/mm/ioremap.c deleted +0 -84
84 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH 24/26] riscv: use the generic ioremap code
Quoted 5 lines · Christoph Hellwig
Use the generic ioremap code instead of providing a local version. Note that this relies on the asm-generic no-op definition of
pgprot_noncached.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 8 lines
--- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/io.h | 3 -- arch/riscv/include/asm/pgtable.h | 6 +++ arch/riscv/mm/Makefile | 1 - arch/riscv/mm/ioremap.c | 84 -------------------------------- 5 files changed, 7 insertions(+), 88 deletions(-) delete mode 100644 arch/riscv/mm/ioremap.c
- Paul
Re: [PATCH 24/26] riscv: use the generic ioremap code
Quoted 3 lines · Paul Walmsley
Can you also take a look at the patch adding the generic code?
PATCH 25/26 csky: use generic ioremap
In reply to Christoph HellwigUse the generic ioremap_prot and iounmap helpers.
--- arch/csky/Kconfig | 1 + arch/csky/include/asm/io.h | 7 ------ arch/csky/include/asm/pgtable.h | 4 ++++ arch/csky/mm/ioremap.c | 42 --------------------------------- 4 files changed, 5 insertions(+), 49 deletions(-)
arch/csky/Kconfig +1 -0
@@ -17,6 +17,7 @@ config CSKY select IRQ_DOMAIN select HANDLE_DOMAIN_IRQ select DW_APB_TIMER_OF + select GENERIC_IOREMAP select GENERIC_LIB_ASHLDI3 select GENERIC_LIB_ASHRDI3 select GENERIC_LIB_LSHRDI3
arch/csky/include/asm/io.h +0 -7
@@ -8,13 +8,6 @@#include <linux/types.h> #include <linux/version.h> -extern void __iomem *ioremap (phys_addr_t offset,size_t size); - -extern void iounmap (void *addr); - -extern int remap_area_pages (unsigned long address,phys_addr_t phys_addr, -size_t size,unsigned long flags); -/* * I/O memory access primitives. Reads are ordered relative to any * following Normal memory access. Writes are ordered relative to any prior
arch/csky/include/asm/pgtable.h +4 -0
@@ -86,6 +86,10 @@#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ _CACHE_CACHED) +#define _PAGE_IOREMAP \ + (_PAGE_PRESENT | __READABLE | __WRITEABLE | _PAGE_GLOBAL | \ + _CACHE_UNCACHED | _PAGE_SO) +#define __P000 PAGE_NONE#define __P001 PAGE_READONLY#define __P010 PAGE_COPY
arch/csky/mm/ioremap.c +0 -42
50 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 26/26 nds32: use generic ioremap
In reply to Christoph HellwigUse the generic ioremap_prot and iounmap helpers.
Note that the io.h include in pgtable.h had to be removed to not create an include loop. As far as I can tell there was no need for it to start with.
--- arch/nds32/Kconfig | 1 + arch/nds32/include/asm/io.h | 3 +- arch/nds32/include/asm/pgtable.h | 4 ++- arch/nds32/mm/Makefile | 3 +- arch/nds32/mm/ioremap.c | 62 -------------------------------- 5 files changed, 6 insertions(+), 67 deletions(-) delete mode 100644 arch/nds32/mm/ioremap.c
arch/nds32/Kconfig +1 -0
@@ -20,6 +20,7 @@ config NDS32 select GENERIC_CLOCKEVENTS select GENERIC_IRQ_CHIP select GENERIC_IRQ_SHOW + select GENERIC_IOREMAP select GENERIC_LIB_ASHLDI3 select GENERIC_LIB_ASHRDI3 select GENERIC_LIB_CMPDI2
arch/nds32/include/asm/io.h +1 -2
@@ -6,8 +6,6 @@#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_writebstatic inline void __raw_writeb (u8 val,volatile void __iomem *addr) {
@@ -80,6 +78,7 @@ static inline u32 __raw_readl(const volatile void __iomem *addr)#define writeb (v,c) ({ __iowmb(); writeb_relaxed((v),(c)); })#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 */
arch/nds32/include/asm/pgtable.h +3 -1
@@ -12,7 +12,6 @@#include <asm/nds32.h> #ifndef __ASSEMBLY__#include <asm/fixmap.h> -#include <asm/io.h> #include <nds32_intrinsic.h> #endif
@@ -130,6 +129,9 @@ extern void __pgd_error(const char *file, int line, unsigned long val);#define _PAGE_CACHE _PAGE_C_MEM_WB#endif +#define _PAGE_IOREMAP \ + (_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_G | _PAGE_C_DEV) +/* * + Level 1 descriptor (PMD) */
arch/nds32/mm/Makefile +1 -2
@@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y := extable.o tlb.o \ - fault.o init.o ioremap.o mmap.o \ +obj-y := extable.o tlb.o fault.o init.o mmap.o \ mm-nds32.o cacheflush.o proc.o obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o
arch/nds32/mm/ioremap.c deleted +0 -62
62 lines not on this page · raw message
Signature · 1 line
2.20.1