Re: [PATCH v12 2/5] tty: goldfish: introduce gf_ioread32()/gf_iowrite32()

From: Arnd Bergmann
Date: Wed Jan 26 2022 - 09:15:44 EST


On Wed, Jan 26, 2022 at 2:41 PM Greg KH <greg@xxxxxxxxx> wrote:
>
> On Fri, Jan 21, 2022 at 09:07:35PM +0100, Laurent Vivier wrote:
> > Revert
> > commit da31de35cd2f ("tty: goldfish: use __raw_writel()/__raw_readl()")
>
> Why?
>
> > and define gf_ioread32()/gf_iowrite32() to be able to use accessors
> > defined by the architecture.
>
> What does this do?

The reverted commit was an incorrect workaround for an old qemu bug:

The goldfish devices are apparently defined as "native" endianness,
which in qemu is whatever the architecture maintainers thought it should
be at the time (little-endian on arm, big-endian on powerpc, board
specific on mips, etc.) but independent of what kernel is actually running
on the machine if the CPU supports both.

m68k in qemu picked big-endian here, which is the opposite of what
the kernel driver does, presumably because that is the endianness of
the CPU itself.

Since we can't fix qemu any more, and runtime detection doesn't work
on machines without devicetree, having a sane default (whatever the
driver used to do) and an architecture specific override for those that
got it wrong is probably our best option.

Arnd