Skip to contentSkip to conversation

m68k: IO Fixes and Cleanups

PATCH In review Geert Uytterhoeven 3 participants 10 messages Jul 2, 2018 – Jul 3, 2018

Subsystems (7)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

cover 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 Torvalds
author maintainer
#1 lore raw

PATCH 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.

Fixes 9746882f547d2f00 ("m68k: group io mapping definitions and functions")
---
 arch/m68k/include/asm/kmap.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/m68k/include/asm/kmap.h +3 -1
index 84b8333db8ad1987..bf1026def698f21f 100644
@@ -16,6 +16,7 @@
  */
 extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
 			       int cacheflag);
+#define iounmap iounmap
 extern 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_wt
 static 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_fullcache
 static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
 					      unsigned long size)
 {
Signature · 1 line
2.17.1
author maintainer
#4 lore raw

PATCH 2/5 net: mac8390: Use standard memcpy_{from,to}io()

In reply to Geert Uytterhoeven

The 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
index b6d735bf80117e27..342ae08ec3c29832 100644
@@ -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
author maintainer
#6 lore raw

PATCH 3/5 Input: hilkbd - Add casts to HP9000/300 I/O accessors

In reply to 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.

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
index a4e404aaf64bdb82..5c7afdec192c139b 100644
@@ -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
author maintainer
#7 lore raw

PATCH 4/5 m68k/io: Move mem*io define guards to <asm/kmap.h>

In reply to Geert Uytterhoeven

The 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
index 83a0a6d449f44bdd..c207428fae5953e7 100644
@@ -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
index bf1026def698f21f..dd4a365bf463d3cf 100644
@@ -48,18 +48,21 @@ static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
 	return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
 }
 
+#define memset_io memset_io
 static inline void memset_io(volatile void __iomem *addr, unsigned char val,
 			     int count)
 {
 	__builtin_memset((void __force *) addr, val, count);
 }
 
+#define memcpy_fromio memcpy_fromio
 static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
 				 int count)
 {
 	__builtin_memcpy(dst, (void __force *) src, count);
 }
 
+#define memcpy_toio memcpy_toio
 static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
 			       int count)
 {
Signature · 1 line
2.17.1
author maintainer
#8 lore raw

PATCH 5/5 m68k/io: Switch mmu variant to <asm-generic/io.h>

In reply to Geert Uytterhoeven

The 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
index ca2849afb0877339..aabe6420ead2a599 100644
@@ -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
index fe485f4f5fac4d92..49ced111e6db0324 100644
@@ -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
index c207428fae5953e7..0498192e1d983292 100644
@@ -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
maintainer Acked-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] net: mac8390: Use standard memcpy_{from,to}io()

In reply to Geert Uytterhoeven

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() 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.

Quoted 6 lines

---
This is a dependency for "m68k: Move mem*io define guards to <asm/kmap.h>".

Untested on real hardware, assembler output compared.

maintainer
#2 lore raw

Re: [PATCH 1/5] m68k/io: Add missing ioremap define guards, fix typo

In reply to Geert Uytterhoeven

Hi Geert,

Quoted 7 lines · Geert Uytterhoeven

- Add missing define guard for ioremap_wt(),
- Fix typo s/ioremap_fillcache/ioremap_fullcache/,
- Add define guard for iounmap() for consistency with other architectures.

Fixes 9746882f547d2f00 ("m68k: group io mapping definitions and functions")

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
index 84b8333db8ad1987..bf1026def698f21f 100644
@@ -16,6 +16,7 @@
   */
  extern void __iomem *__ioremap(unsigned long physaddr, unsigned long size,
  			       int cacheflag);
+#define iounmap iounmap
  extern 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_wt
  static 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_fullcache
  static inline void __iomem *ioremap_fullcache(unsigned long physaddr,
  					      unsigned long size)
  {
maintainer
#9 lore raw
In reply to Geert Uytterhoeven

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 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(-)
author maintainer
#3 lore raw

Re: [PATCH 1/5] m68k/io: Add missing ioremap define guards, fix typo

In reply to Greg Ungerer

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 for iounmap() for consistency with other architectures.

Fixes 9746882f547d2f00 ("m68k: group io mapping definitions and functions")

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,

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
#define ioremap_wt ioremap_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