2018-07-09 09:33:22

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 0/5] 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(-)

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


2018-07-09 09:32:21

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 4/5] m68k/io: Move mem*io define guards to <asm/kmap.h>

The mem*io define guards are applicable to all users of <asm/kmap.h>.
Hence move them, and drop the #ifdef.

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
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(-)

diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 83a0a6d449f44bdd..c207428fae5953e7 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -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>
diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h
index 608e12f058a7cd7d..aac7f045f7f0aa85 100644
--- a/arch/m68k/include/asm/kmap.h
+++ b/arch/m68k/include/asm/kmap.h
@@ -50,18 +50,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)
{
--
2.17.1


2018-07-09 09:32:34

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 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.

Fixes: 9746882f547d2f00 ("m68k: group io mapping definitions and functions")
Signed-off-by: Geert Uytterhoeven <[email protected]>
---
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(-)

diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index fe485f4f5fac4d92..7e518303786c2d65 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -21,8 +21,6 @@

#ifdef __KERNEL__

-#define ARCH_HAS_IOREMAP_WT
-
#include <linux/compiler.h>
#include <asm/raw_io.h>
#include <asm/virtconvert.h>
diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h
index 84b8333db8ad1987..608e12f058a7cd7d 100644
--- a/arch/m68k/include/asm/kmap.h
+++ b/arch/m68k/include/asm/kmap.h
@@ -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 iounmap
extern 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_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)
{
--
2.17.1


2018-07-09 09:33:05

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 5/5] m68k/io: Switch mmu variant to <asm-generic/io.h>

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.

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
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(-)

diff --git a/arch/m68k/include/asm/io.h b/arch/m68k/include/asm/io.h
index ca2849afb0877339..aabe6420ead2a599 100644
--- a/arch/m68k/include/asm/io.h
+++ b/arch/m68k/include/asm/io.h
@@ -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 */
diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index 7e518303786c2d65..782b78f8a04890b3 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -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 */
diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index c207428fae5953e7..0498192e1d983292 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -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 */
--
2.17.1


2018-07-09 09:33:06

by Geert Uytterhoeven

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

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.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Acked-by: David S. Miller <[email protected]>
---
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(-)

diff --git a/drivers/net/ethernet/8390/mac8390.c b/drivers/net/ethernet/8390/mac8390.c
index b6d735bf80117e27..342ae08ec3c29832 100644
--- a/drivers/net/ethernet/8390/mac8390.c
+++ b/drivers/net/ethernet/8390/mac8390.c
@@ -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 */
--
2.17.1


2018-07-09 09:33:27

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 3/5] Input: hilkbd - Add casts to HP9000/300 I/O accessors

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.

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
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(-)

diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index a4e404aaf64bdb82..5c7afdec192c139b 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -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"
--
2.17.1


2018-07-10 01:49:23

by Greg Ungerer

[permalink] [raw]
Subject: Re: [PATCH 0/5] m68k: IO Fixes and Cleanups

Hi Geert,

On 09/07/18 19:30, Geert Uytterhoeven wrote:
> 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.

Retested on ColdFire 5475, looks good.
For the whole series:

Acked-by: Greg Ungerer <[email protected]>

Regards
Greg



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

2018-07-16 12:24:13

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 3/5] Input: hilkbd - Add casts to HP9000/300 I/O accessors

On Mon, Jul 09, 2018 at 11:30:38AM +0200, Geert Uytterhoeven wrote:
> 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.
>
> Signed-off-by: Geert Uytterhoeven <[email protected]>

Acked-by: Dmitry Torokhov <[email protected]>

> ---
> 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(-)
>
> diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
> index a4e404aaf64bdb82..5c7afdec192c139b 100644
> --- a/drivers/input/keyboard/hilkbd.c
> +++ b/drivers/input/keyboard/hilkbd.c
> @@ -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"
> --
> 2.17.1
>

--
Dmitry

2018-07-18 11:39:12

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 0/5] m68k: IO Fixes and Cleanups

On Tue, Jul 10, 2018 at 3:48 AM Greg Ungerer <[email protected]> wrote:
> On 09/07/18 19:30, Geert Uytterhoeven wrote:
> > 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.
>
> 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

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