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.
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 for your comments!
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 | 40 +++-------------------------- arch/m68k/include/asm/io_no.h | 12 --------- arch/m68k/include/asm/kmap.h | 7 ++++- drivers/input/keyboard/hilkbd.c | 4 +-- drivers/net/ethernet/8390/mac8390.c | 20 +++++++-------- 6 files changed, 28 insertions(+), 62 deletions(-)
Signature · 12 lines
2.17.1
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 TorvaldsGeert Uytterhoeven
maintainerPATCH 1/5 m68k/io: Add missing ioremap define guards, fix typo
- Add missing define guard for ioremap_wt(),
- Fix typo s/ioremap_fillcache/ioremap_fullcache/,
- Add define guard for iounmap() for consistency with other architectures.
--- arch/m68k/include/asm/kmap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/m68k/include/asm/kmap.h +3 -1
@@ -16,6 +16,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 +34,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
Greg Ungerer
maintainerRe: [PATCH 1/5] m68k/io: Add missing ioremap define guards, fix typo
Hi Geert,
Quoted 7 lines · Geert Uytterhoeven
- Add missing define guard for
ioremap_wt(),
- Fix typo s/ioremap_fillcache/ioremap_fullcache/,
- Add define guard foriounmap()for consistency with other architectures.Fixes 9746882f547d2f00 ("m68k: group io mapping definitions and functions")Signed-off-by Geert Uytterhoeven <[email protected]>
If I build for the m5475evb defconfig then I get warnings like this:
CC init/main.o
In file included from ./include/asm-generic/io.h:19:0,
from ./arch/m68k/include/asm/io_no.h:147,
from ./arch/m68k/include/asm/io.h:3,
from ./include/linux/bio.h:28,
from ./include/linux/blkdev.h:21,
from init/main.c:80:./include/asm-generic/iomap.h:79:0: warning: "ioremap_wt" redefined
#define ioremap_wt ioremap_nocache
^
In file included from ./arch/m68k/include/asm/io_no.h:145:0,
from ./arch/m68k/include/asm/io.h:3,
from ./include/linux/bio.h:28,
from ./include/linux/blkdev.h:21,
from init/main.c:80:./arch/m68k/include/asm/kmap.h:37:0: note: this is the location of the previous definition
#define ioremap_wt ioremap_wt
^
Regards
Greg
Quoted 33 lines
--- arch/m68k/include/asm/kmap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/m68k/include/asm/kmap.h +3
-1@@ -16,6 +16,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 +34,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) {
Geert Uytterhoeven
maintainerRe: [PATCH 1/5] m68k/io: Add missing ioremap define guards, fix typo
Hi Greg,
Quoted 22 lines · Greg Ungerer
Quoted 7 lines · Geert Uytterhoeven
- Add missing define guard for
ioremap_wt(),
- Fix typo s/ioremap_fillcache/ioremap_fullcache/,
- Add define guard foriounmap()for consistency with other architectures.Fixes 9746882f547d2f00 ("m68k: group io mapping definitions and functions")Signed-off-by Geert Uytterhoeven <[email protected]>If I build for the m5475evb defconfig then I get warnings like this:
CC
init/main.o
In file included from./include/asm-generic/io.h:19:0,from ./arch/m68k/include/asm/io_no.h:147, from ./arch/m68k/include/asm/io.h:3, from ./include/linux/bio.h:28, from ./include/linux/blkdev.h:21, from init/main.c:80:
./include/asm-generic/iomap.h:79:0: warning: "ioremap_wt" redefined
#defineioremap_wtioremap_nocache
^
In file included from./arch/m68k/include/asm/io_no.h:145:0,
Quoted 7 lines
from ./arch/m68k/include/asm/io.h:3, from ./include/linux/bio.h:28, from ./include/linux/blkdev.h:21, from init/main.c:80:
./arch/m68k/include/asm/kmap.h:37:0: note: this is the location of the previous definition
#defineioremap_wtioremap_wt
^
Thanks, I did some m68knommu compile tests, but didn't see this warning, which happens for Coldfire+MMU only.
The issue is that there are two ways to declare an architecture has ioremap_wt():
1. By defining ioremap_wt,
2. By defining ARCH_HAS_IOREMAP_WT.
1 is done in arch/m68k/include/asm/kmap.h.
2 is done in arch/m68k/include/asm/io_mm.h. Moving that to kmap.h fixes the warning. Will send an update shortly.
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
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.
--- 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
Re: [PATCH 2/5] net: mac8390: Use standard memcpy_{from,to}io()
From: Geert Uytterhoeven <[email protected]>
Date: Mon, 2 Jul 2018 15:35:29 +0200
Quoted 7 lines
The mac8390 driver defines its own variants of
memcpy_fromio()andmemcpy_toio(), using similar implementations, but different function signatures.Remove the custom definitions of
memcpy_fromio()andmemcpy_toio(), and adjust all callers to the standard signatures.
Quoted 6 lines
Signed-off-by Geert Uytterhoeven <[email protected]>---
This is a dependency for "m68k: Move mem*io define guards to <asm/kmap.h>".Untested on real hardware, assembler output compared.
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>".
--- 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
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()".
--- 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
@@ -48,18 +48,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.
--- 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__
@@ -369,40 +369,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))
@@ -444,4 +410,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
Greg Ungerer
maintainerHi 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 5 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.
Thanks for your comments!
I like it alot. If we can just fix up the warnings caused by patch number 1 I am more than happy to ack.
Regards
Greg
Quoted 15 lines
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 | 40 +++-------------------------- arch/m68k/include/asm/io_no.h | 12 --------- arch/m68k/include/asm/kmap.h | 7 ++++- drivers/input/keyboard/hilkbd.c | 4 +-- drivers/net/ethernet/8390/mac8390.c | 20 +++++++-------- 6 files changed, 28 insertions(+), 62 deletions(-)