Re: [RFC PATCH] m68k: nommu: Fix behaviour of io macros on non-CF

Geert Uytterhoeven <[email protected]>
Newsgroups org.kernel.vger.linux-m68k,org.kernel.vger.linux-kernel
Message-ID <CAMuHMdVj3YJowoYhxnW094MeAz4UX0CCC=d63N5SxTRAK2gw9w@mail.gmail.com>
Hi Arnd,

On Mon, 13 Apr 2026 at 18:52, Arnd Bergmann <[email protected]> wrote:
> On Sat, Apr 4, 2026, at 04: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 <[email protected]>
> > Link:
> > https://lore.kernel.org/lkml/[email protected]/
> > Signed-off-by: Daniel Palmer <[email protected]>
>
> Reviewed-by: Arnd Bergmann <[email protected]>
>
> It looks like the non-swapping readl() on nommu-m68k predates
> the git history, but apparently the coldfire version was fixed
> in 4d5303787627 ("m68k: fix read/write multi-byte IO for PCI
> on ColdFire") to behave like everything else, and dragonball
> appears does not support ISA or PCI buses, so it never used
> them.

Correct.  readl() and friends were introduced when it was deemed better
to use accessor functions instead of dereferencing volatile pointers
directly (which is what several m68k drivers are still doing), but
before it was decided that readl() is little endian for PCI everywhere
(there was no PCI on m68k at that point in time). And of course that
was long before the introduction of ioread32be()...

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.