m68k: IO Fixes and Cleanups
Subsystems (7)
Geert Uytterhoeven
maintainercover m68k: IO Fixes and Cleanups
Hi all,
This patch series contains fixes and cleanups for I/O accessors on m68k platforms (with MMU).
The first patch contains small fixes without any dependencies. Patches 2 and 3 make small adjustments to drivers that are dependencies for further cleanup.
Patch 4 and 5 complete the cleanup.
Changes compared to v1:
- Move ARCH_HAS_IOREMAP_WT to fix "ioremap_wt redefined" warnings with
m5475evb defconfig,
- Add Acked-by.
Given the dependencies, I think it's easiest if the respective maintainers would provide their Acked-by, so all patches can go in through the m68k tree.
Thanks!
Geert Uytterhoeven (5):
m68k/io: Add missing ioremap define guards, fix typo
net: mac8390: Use standard memcpy_{from,to}io()
Input: hilkbd - Add casts to HP9000/300 I/O accessors m68k/io: Move mem*io define guards to <asm/kmap.h> m68k/io: Switch mmu variant to <asm-generic/io.h>
arch/m68k/include/asm/io.h | 7 +++++ arch/m68k/include/asm/io_mm.h | 42 +++-------------------------- arch/m68k/include/asm/io_no.h | 12 --------- arch/m68k/include/asm/kmap.h | 9 ++++++- drivers/input/keyboard/hilkbd.c | 4 +-- drivers/net/ethernet/8390/mac8390.c | 20 +++++++------- 6 files changed, 30 insertions(+), 64 deletions(-)
Signature · 5 lines
2.17.1
Gr{oetje,eeting}s,
GeertGeert Uytterhoeven
maintainerPATCH 1/5 m68k/io: Add missing ioremap define guards, fix typo
- Add missing define guard for ioremap_wt(),
- Move ARCH_HAS_IOREMAP_WT from <asm/io_mm.h> to <asm/kmap.h>, as it is applicable to Coldfire with MMU, too,
- Fix typo s/ioremap_fillcache/ioremap_fullcache/,
- Add define guard for iounmap() for consistency with other architectures.
---
v2:
- Move ARCH_HAS_IOREMAP_WT to fix "ioremap_wt redefined" warnings with
m5475evb defconfig. --- arch/m68k/include/asm/io_mm.h | 2 -- arch/m68k/include/asm/kmap.h | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/m68k/include/asm/io_mm.h +0 -2
@@ -21,8 +21,6 @@#ifdef __KERNEL__ -#define ARCH_HAS_IOREMAP_WT -#include <linux/compiler.h> #include <asm/raw_io.h> #include <asm/virtconvert.h>
arch/m68k/include/asm/kmap.h +5 -1
@@ -4,6 +4,8 @@#ifdef CONFIG_MMU +#define ARCH_HAS_IOREMAP_WT +/* Values for nocacheflag and cmode */ #define IOMAP_FULL_CACHING 0#define IOMAP_NOCACHE_SER 1
@@ -16,6 +18,7 @@*/ 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);
@@ -33,13 +36,14 @@ static inline void __iomem *ioremap_nocache(unsigned long physaddr, }#define ioremap_uc ioremap_nocache +#define ioremap_wt ioremap_wtstatic inline void __iomem *ioremap_wt (unsigned long physaddr,unsigned long size) {return __ioremap (physaddr, size,IOMAP_WRITETHROUGH ); } -#define ioremap_fillcache ioremap_fullcache +#define ioremap_fullcache ioremap_fullcachestatic inline void __iomem *ioremap_fullcache (unsigned long physaddr,unsigned long size) {
Signature · 1 line
2.17.1
Geert Uytterhoeven
maintainerPATCH 2/5 net: mac8390: Use standard memcpy_{from,to}io()
In reply to Geert UytterhoevenThe mac8390 driver defines its own variants of memcpy_fromio() and memcpy_toio(), using similar implementations, but different function signatures.
Remove the custom definitions of memcpy_fromio() and memcpy_toio(), and adjust all callers to the standard signatures.
---
This is a dependency for "m68k: Move mem*io define guards to <asm/kmap.h>".
Untested on real hardware, assembler output compared.
v2:
- Add Acked-by.
--- drivers/net/ethernet/8390/mac8390.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/8390/mac8390.c +10 -10
@@ -153,9 +153,6 @@ static void dayna_block_input(struct net_device *dev, int count,static void dayna_block_output (struct net_device *dev,int count,const unsigned char *buf,int start_page); -#define memcpy_fromio (a, b, c) memcpy((a), (void *)(b), (c)) -#define memcpy_toio (a, b, c) memcpy((void *)(a), (b), (c)) -#define memcmp_withio (a, b, c) memcmp((a), (void *)(b), (c))/* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
@@ -239,7 +236,7 @@ static enum mac8390_access mac8390_testio(unsigned long membase)unsigned long outdata =0xA5A0B5B0 ;unsigned long indata =0x00000000 ;/* Try writing 32 bits */ -memcpy_toio (membase, &outdata,4 ); +memcpy_toio ((void __iomem *)membase, &outdata,4 );/* Now compare them */ if (memcmp_withio (&outdata, membase,4 ) ==0 )return ACCESS_32 ;
@@ -711,7 +708,7 @@ static void sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) {unsigned long hdr_start = (ring_page -WD_START_PG )<<8 ; -memcpy_fromio (hdr, dev->mem_start + hdr_start,4 ); +memcpy_fromio (hdr, (void __iomem *)dev->mem_start + hdr_start,4 );/* Fix endianness */ hdr->count =swab16 (hdr->count); }
@@ -725,13 +722,16 @@ static void sane_block_input(struct net_device *dev, int count,if (xfer_start + count > ei_status.rmem_end) {/* We must wrap the input move. */ int semi_count = ei_status.rmem_end - xfer_start; -memcpy_fromio (skb->data, dev->mem_start + xfer_base, +memcpy_fromio (skb->data, + (void __iomem *)dev->mem_start + xfer_base, semi_count); count -= semi_count; -memcpy_fromio (skb->data + semi_count, ei_status.rmem_start, - count); +memcpy_fromio (skb->data + semi_count, + (void __iomem *)ei_status.rmem_start, count); }else { -memcpy_fromio (skb->data, dev->mem_start + xfer_base, count); +memcpy_fromio (skb->data, + (void __iomem *)dev->mem_start + xfer_base, + count); } }
@@ -740,7 +740,7 @@ static void sane_block_output(struct net_device *dev, int count, {long shmem = (start_page -WD_START_PG )<<8 ; -memcpy_toio (dev->mem_start + shmem, buf, count); +memcpy_toio ((void __iomem *)dev->mem_start + shmem, buf, count); }/* dayna block input/output */
Signature · 1 line
2.17.1
Geert Uytterhoeven
maintainerPATCH 3/5 Input: hilkbd - Add casts to HP9000/300 I/O accessors
In reply to Geert UytterhoevenInternally, hilkbd uses "unsigned long" I/O addresses everywhere. This works fine as:
- On PA-RISC, hilkbd uses the gsc_{read,write}b() I/O accessors, which take "unsigned long" addresses,
- On m68k, hilkbd uses {read,write}b(), which are currently mapped to {in,out}_8(), and convert the passed addresses to pointers internally.
However, the asm-generic version of {read,write}b() does not perform such conversions, and requires passing pointers instead. Hence add casts to prepare for switching m68k to the asm-generic version.
---
This is a dependency for "m68k/io: Switch mmu variant to <asm-generic/io.h>".
v2:
- No changes.
--- drivers/input/keyboard/hilkbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/keyboard/hilkbd.c +2 -2
@@ -57,8 +57,8 @@ MODULE_LICENSE("GPL v2");#define HIL_DATA 0x1#define HIL_CMD 0x3#define HIL_IRQ 2 -#define hil_readb (p) readb(p) -#define hil_writeb (v,p) writeb((v),(p)) +#define hil_readb (p) readb((const volatile void __iomem *)(p)) +#define hil_writeb (v, p) writeb((v), (volatile void __iomem *)(p))#else #error "HIL is not supported on this platform"
Signature · 1 line
2.17.1
Re: [PATCH 3/5] Input: hilkbd - Add casts to HP9000/300 I/O accessors
Quoted 8 lines · Geert Uytterhoeven
Internally, hilkbd uses "unsigned long" I/O addresses everywhere. This works fine as:
- On PA-RISC, hilkbd uses the gsc_{read,write}b() I/O accessors, which take "unsigned long" addresses,
- On m68k, hilkbd uses {read,write}b(), which are currently mapped to {in,out}_8(), and convert the passed addresses to pointers internally.
Quoted 5 lines
However, the asm-generic version of {read,write}b() does not perform such conversions, and requires passing pointers instead. Hence add casts to prepare for switching m68k to the asm-generic version.
Signed-off-by Geert Uytterhoeven <[email protected]>
Quoted 28 lines
---
This is a dependency for "m68k/io: Switch mmu variant to <asm-generic/io.h>".v2:
- No changes.--- drivers/input/keyboard/hilkbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/input/keyboard/hilkbd.c +2
-2@@ -57,8 +57,8 @@ MODULE_LICENSE("GPL v2");#define HIL_DATA 0x1#define HIL_CMD 0x3#define HIL_IRQ 2 -#define hil_readb (p) readb(p) -#define hil_writeb (v,p) writeb((v),(p)) +#define hil_readb (p) readb((const volatile void __iomem *)(p)) +#define hil_writeb (v, p) writeb((v), (volatile void __iomem *)(p))#else #error "HIL is not supported on this platform"Signature · 1 line
2.17.1
Signature · 1 line
Dmitry
Geert Uytterhoeven
maintainerPATCH 4/5 m68k/io: Move mem*io define guards to <asm/kmap.h>
In reply to Geert UytterhoevenThe mem*io define guards are applicable to all users of <asm/kmap.h>. Hence move them, and drop the #ifdef.
---
To avoid redefined warnings, this depends on "net: mac8390: Use standard memcpy_{from,to}io()".
v2:
- No changes.
--- arch/m68k/include/asm/io_no.h | 11 ----------- arch/m68k/include/asm/kmap.h | 3 +++ 2 files changed, 3 insertions(+), 11 deletions(-)
arch/m68k/include/asm/io_no.h +0 -11
@@ -131,17 +131,6 @@ static inline void writel(u32 value, volatile void __iomem *addr)#define PCI_SPACE_LIMIT PCI_IO_MASK#endif /* CONFIG_PCI */ -/* -* These are defined in kmap.h as static inline functions. To maintain -* previous behavior we put these define guards here so io_mm.h doesn't -* see them. -*/ -#ifdef CONFIG_MMU -#define memset_io memset_io -#define memcpy_fromio memcpy_fromio -#define memcpy_toio memcpy_toio -#endif -#include <asm/kmap.h> #include <asm/virtconvert.h> #include <asm-generic/io.h>
arch/m68k/include/asm/kmap.h +3 -0
@@ -50,18 +50,21 @@ static inline void __iomem *ioremap_fullcache(unsigned long physaddr,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) {__builtin_memset ((void __force *) addr, val, count); } +#define memcpy_fromio memcpy_fromiostatic inline void memcpy_fromio (void *dst,const volatile void __iomem *src,int count) {__builtin_memcpy (dst, (void __force *) src, count); } +#define memcpy_toio memcpy_toiostatic inline void memcpy_toio (volatile void __iomem *dst,const void *src,int count) {
Signature · 1 line
2.17.1
Geert Uytterhoeven
maintainerPATCH 5/5 m68k/io: Switch mmu variant to <asm-generic/io.h>
In reply to Geert UytterhoevenThe dummy functions defined in <asm/io_mm.h> can be provided by <asm-generic/io.h>.
As nommu already uses <asm-generic/io.h>, move its inclusion to <asm/io.h>, and add/adjust include guards where appropriate.
This gets rid of lots of "statement with no effect" and "unused variable" warnings when compile-testing.
---
v2:
- No changes.
--- arch/m68k/include/asm/io.h | 7 ++++++ arch/m68k/include/asm/io_mm.h | 40 +++-------------------------------- arch/m68k/include/asm/io_no.h | 1 - 3 files changed, 10 insertions(+), 38 deletions(-)
arch/m68k/include/asm/io.h +7 -0
@@ -1,6 +1,13 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _M68K_IO_H +#define _M68K_IO_H +#if defined(__uClinux__) || defined(CONFIG_COLDFIRE )#include <asm/io_no.h> #else #include <asm/io_mm.h> #endif + +#include <asm-generic/io.h> + +#endif /* _M68K_IO_H */
arch/m68k/include/asm/io_mm.h +3 -37
@@ -16,8 +16,8 @@* isa_readX(),isa_writeX() are for ISA memory */ -#ifndef _IO_H -#define _IO_H +#ifndef _M68K_IO_MM_H +#define _M68K_IO_MM_H#ifdef __KERNEL__
@@ -367,40 +367,6 @@ static inline void isa_delay(void)#define writew (val, addr) out_le16((addr), (val))#endif /* CONFIG_ATARI_ROM_ISA */ -#if !defined(CONFIG_ISA ) && !defined(CONFIG_ATARI_ROM_ISA ) -/* -* We need to define dummy functions for GENERIC_IOMAP support. -*/ -#define inb (port) 0xff -#define inb_p (port) 0xff -#define outb (val,port) ((void)0) -#define outb_p (val,port) ((void)0) -#define inw (port) 0xffff -#define inw_p (port) 0xffff -#define outw (val,port) ((void)0) -#define outw_p (val,port) ((void)0) -#define inl (port) 0xffffffffUL -#define inl_p (port) 0xffffffffUL -#define outl (val,port) ((void)0) -#define outl_p (val,port) ((void)0) - -#define insb (port,buf,nr) ((void)0) -#define outsb (port,buf,nr) ((void)0) -#define insw (port,buf,nr) ((void)0) -#define outsw (port,buf,nr) ((void)0) -#define insl (port,buf,nr) ((void)0) -#define outsl (port,buf,nr) ((void)0) - -/* -* These should be valid on any ioremap()ed region -*/ -#define readb (addr) in_8(addr) -#define writeb (val,addr) out_8((addr),(val)) -#define readw (addr) in_le16(addr) -#define writew (val,addr) out_le16((addr),(val)) - -#endif /* !CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */ -#define readl (addr) in_le32(addr)#define writel (val,addr) out_le32((addr),(val))
@@ -442,4 +408,4 @@ static inline void isa_delay(void)#define writew_relaxed (b, addr) writew(b, addr)#define writel_relaxed (b, addr) writel(b, addr) -#endif /* _IO_H */ +#endif /* _M68K_IO_MM_H */
arch/m68k/include/asm/io_no.h +0 -1
@@ -133,6 +133,5 @@ static inline void writel(u32 value, volatile void __iomem *addr)#include <asm/kmap.h> #include <asm/virtconvert.h> -#include <asm-generic/io.h> #endif /* _M68KNOMMU_IO_H */
Signature · 1 line
2.17.1
Hi Geert,
Quoted 10 lines · Geert Uytterhoeven
Hi all,
This patch series contains fixes and cleanups for I/O accessors on m68k platforms (with MMU).
The first patch contains small fixes without any dependencies. Patches 2 and 3 make small adjustments to drivers that are dependencies for further cleanup.
Patch 4 and 5 complete the cleanup.
Quoted 8 lines
Changes compared to v1:
- MoveARCH_HAS_IOREMAP_WTto fix "ioremap_wtredefined" warnings withm5475evb defconfig,- Add Acked-by.
Given the dependencies, I think it's easiest if the respective maintainers would provide their Acked-by, so all patches can go in through the m68k tree.
Retested on ColdFire 5475, looks good.
For the whole series:
Regards
Greg
Quoted 17 lines
Thanks!
Geert Uytterhoeven (5):
m68k/io: Add missing ioremap define guards, fix typo
net: mac8390: Use standard memcpy_{from,to}io()
Input: hilkbd - Add casts to HP9000/300 I/O accessors m68k/io: Move mem*io define guards to <asm/kmap.h> m68k/io: Switch mmu variant to <asm-generic/io.h>arch/m68k/include/asm/io.h | 7 +++++ arch/m68k/include/asm/io_mm.h | 42 +++-------------------------- arch/m68k/include/asm/io_no.h | 12 --------- arch/m68k/include/asm/kmap.h | 9 ++++++- drivers/input/keyboard/hilkbd.c | 4 +-- drivers/net/ethernet/8390/mac8390.c | 20 +++++++------- 6 files changed, 30 insertions(+), 64 deletions(-)
Quoted 14 lines · Greg Ungerer
Quoted 13 lines · Geert Uytterhoeven
This patch series contains fixes and cleanups for I/O accessors on m68k platforms (with MMU).
The first patch contains small fixes without any dependencies. Patches 2 and 3 make small adjustments to drivers that are dependencies for further cleanup.
Patch 4 and 5 complete the cleanup.Changes compared to v1:
- MoveARCH_HAS_IOREMAP_WTto fix "ioremap_wtredefined" warnings withm5475evb defconfig,- Add Acked-by.
Quoted 8 lines
Quoted 3 lines
Given the dependencies, I think it's easiest if the respective maintainers would provide their Acked-by, so all patches can go in through the m68k tree.
Retested on ColdFire 5475, looks good.
For the whole series:Acked-by Greg Ungerer <[email protected]>
Thanks, applied and queued for v4.19.
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