mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Ungerer <gerg@linux-m68k.org>
To: Daniel Palmer <daniel@0x0f.com>
Cc: geert@linux-m68k.org, christoph.plattner@gmx.at,
	linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org,
	arnd@kernel.org
Subject: Re: [RFC PATCH] m68k: nommu: Fix behaviour of io macros on non-CF
Date: Tue, 14 Apr 2026 22:18:32 +1000	[thread overview]
Message-ID: <ec4945ec-84fd-4462-b35d-79a04673107d@linux-m68k.org> (raw)
In-Reply-To: <20260404024658.2496519-1-daniel@0x0f.com>

Hi Daniel,

On 4/4/26 12:46, Daniel Palmer wrote:
> Currently for 68000 readl() and friends are broken in that they
> return the value from the bus as-is but should be reading a little
> endian value and swapping it to big endian.
> 
> This was found using virtio-mmio on a 68000 virt machine. virtio-mmio
> is little endian even if the emulated machine is big endian. This works
> for MMU m68k because the io macros do what is expected there, but if
> the kernel was built for nommu it breaks.
> 
> Potentially this will break some stuff for nommu non-CF m68k users
> but since there are probably 2 or 3 of us in the world I think we
> can work it out.
> 
> Suggested-by: Arnd Bergmann <arnd@kernel.org>
> Link: https://lore.kernel.org/lkml/ada73dc9-edf5-458c-8849-9f9db23ff304@app.fastmail.com/
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
> ---
>   arch/m68k/include/asm/io_no.h | 9 ---------
>   1 file changed, 9 deletions(-)
> 
> diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
> index 516371d5587a..c39db8798ef2 100644
> --- a/arch/m68k/include/asm/io_no.h
> +++ b/arch/m68k/include/asm/io_no.h
> @@ -96,15 +96,6 @@ static inline void writel(u32 value, volatile void __iomem *addr)
>   		__raw_writel(swab32(value), addr);
>   }
>   
> -#else
> -
> -#define readb __raw_readb
> -#define readw __raw_readw
> -#define readl __raw_readl
> -#define writeb __raw_writeb
> -#define writew __raw_writew
> -#define writel __raw_writel
> -
>   #endif /* IOMEMBASE */
>   
>   #if defined(CONFIG_PCI)

This change, in this form at least, breaks most of the non-MMU ColdFire targets.
Try compiling any of m5208evb, m5249evb, m5272c3, m5275evb, m5307c3 or
m5407c3 defconfigs and you get build failures. Targets that do not have
a PCI bus and so do not define IOMEMBASE will fail, which is most of them.

Maybe something like this might be better. I think this ends up giving you the
same result for 68000 nommu targets.

diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 516371d5587a..b335fd4a18e9 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -33,7 +33,6 @@
  #include <asm/byteorder.h>
  #include <asm/coldfire.h>
  #include <asm/mcfsim.h>
-#endif /* CONFIG_COLDFIRE */
  
  #if defined(IOMEMBASE)
  /*
@@ -126,6 +125,7 @@ static inline void writel(u32 value, volatile void __iomem *addr)
  #define PCI_IOBASE     ((void __iomem *) PCI_IO_PA)
  #define PCI_SPACE_LIMIT        PCI_IO_MASK
  #endif /* CONFIG_PCI */
+#endif /* CONFIG_COLDFIRE */
  
  #include <asm/kmap.h>
  #include <asm/virtconvert.h>


Regards
Greg


  parent reply	other threads:[~2026-04-14 12:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-04  2:46 Daniel Palmer
2026-04-13 16:52 ` Arnd Bergmann
2026-04-14  7:14   ` Geert Uytterhoeven
2026-04-14 12:18 ` Greg Ungerer [this message]
2026-04-14 12:55   ` Daniel Palmer
2026-04-14 13:24     ` Arnd Bergmann
2026-04-15 13:52       ` Greg Ungerer
2026-04-15 14:54         ` Arnd Bergmann
2026-04-17 14:11           ` Greg Ungerer
2026-04-17 16:36             ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec4945ec-84fd-4462-b35d-79a04673107d@linux-m68k.org \
    --to=gerg@linux-m68k.org \
    --cc=arnd@kernel.org \
    --cc=christoph.plattner@gmx.at \
    --cc=daniel@0x0f.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®