From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: Daniel Palmer <daniel@0x0f.com>
Cc: angelo@kernel-space.org, bmeng.cn@gmail.com, laurent@vivier.eu,
u-boot@lists.denx.de
Subject: Re: [RFC PATCH 2/3] virtio: mmio: endian *fixes* *HACK*
Date: Fri, 3 Apr 2026 03:43:27 +0800 [thread overview]
Message-ID: <ac7G35VDs5TV4GCP@google.com> (raw)
In-Reply-To: <CAFr9PXn3abM6DcbfJBBbokBtQ02XrfK66jVtjCGo8+_V-mtkzw@mail.gmail.com>
Hi Daniel,
On Sat, Mar 14, 2026 at 05:53:17PM +0900, Daniel Palmer wrote:
> Hi all,
>
> On Tue, 10 Mar 2026 at 23:01, Daniel Palmer <daniel@thingy.jp> wrote:
> >
> > From: Daniel Palmer <daniel@0x0f.com>
> >
> > This is an attempt to *fix* virtio mmio on the QEMU m68k virt machine.
> > As far as I can tell all of the registers in the virtio mmio regions
> > should be little endian so after reading them they need to be converted
> > to big endian for the code to work on them? other parts of the code
> > are also doing endian conversion so I'm not sure.
> >
> > Or QEMU is incorrectly giving big endian register values?
> > ---
>
> I have a patch for this in my Linux tree too so I sent that:
> https://lore.kernel.org/lkml/20260314030612.1949420-1-daniel@thingy.jp/T/#mab66837bb90c30916fd0fc066245bdeb9918e96c
> It would seem our versions of readl(), writel() etc are broken. For
> Linux the nommu versions are broken, for u-boot it seems they are all
> broken. By broken I mean they should be expecting a little endian
> value from the access and then converting to the CPU endian. (I think)
>
Sorry for the late reply.
So it sounds like we have to fix all the broken readl/writel() in both
Linux and U-Boot first.
For U-Boot, I think we need the following fix? (totally untested yet)
diff --git a/arch/m68k/include/asm/io.h b/arch/m68k/include/asm/io.h
index 35ad4a1c044..0106a57a03e 100644
--- a/arch/m68k/include/asm/io.h
+++ b/arch/m68k/include/asm/io.h
@@ -31,10 +31,10 @@
#define writew(b,addr) ((*(volatile u16 *) (addr)) = (b))
#define writel(b,addr) ((*(volatile u32 *) (addr)) = (b))
#else
-#define readw(addr) in_be16((volatile u16 *)(addr))
-#define readl(addr) in_be32((volatile u32 *)(addr))
-#define writew(b,addr) out_be16((volatile u16 *)(addr),(b))
-#define writel(b,addr) out_be32((volatile u32 *)(addr),(b))
+#define readw(addr) in_le16((volatile u16 *)(addr))
+#define readl(addr) in_le32((volatile u32 *)(addr))
+#define writew(b,addr) out_le16((volatile u16 *)(addr),(b))
+#define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
#endif
/*
Regards,
Kuan-Wei
next prev parent reply other threads:[~2026-04-03 4:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 13:59 [RFC PATCH 0/3] Add virtio-mmio support to m68k virt machine Daniel Palmer
2026-03-10 13:59 ` [RFC PATCH 1/3] virtio: mmio: Allow instantiation via platform data Daniel Palmer
2026-03-10 13:59 ` [RFC PATCH 2/3] virtio: mmio: endian *fixes* *HACK* Daniel Palmer
2026-03-14 8:53 ` Daniel Palmer
2026-04-02 19:43 ` Kuan-Wei Chiu [this message]
2026-04-04 1:49 ` Daniel Palmer
2026-03-10 13:59 ` [RFC PATCH 3/3] board: qemu: m68k: Create virtio mmio instances Daniel Palmer
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=ac7G35VDs5TV4GCP@google.com \
--to=visitorckw@gmail.com \
--cc=angelo@kernel-space.org \
--cc=bmeng.cn@gmail.com \
--cc=daniel@0x0f.com \
--cc=laurent@vivier.eu \
--cc=u-boot@lists.denx.de \
/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