The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Rustam Adilov <adilov@disroot.org>
To: markus.stockhausen@gmx.de
Cc: 'Chris Packham' <Chris.Packham@alliedtelesis.co.nz>,
	'Daniel Lezcano' <daniel.lezcano@kernel.org>,
	'Thomas Gleixner' <tglx@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: AW: AW: AW: [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes
Date: Fri, 15 May 2026 19:47:43 +0000	[thread overview]
Message-ID: <ff85cd56a1291c8cc9ff28f59b62652c@disroot.org> (raw)
In-Reply-To: <016d01dce49a$36b7bd60$a4273820$@gmx.de>

On 2026-05-15 18:39, markus.stockhausen@gmx.de wrote:
>> Von: Rustam Adilov <adilov@disroot.org> 
>> Gesendet: Freitag, 15. Mai 2026 20:21
>> An: markus.stockhausen@gmx.de
>> Betreff: Re: AW: AW: [PATCH] clocksource: rtl-otto: Change driver to use
> __raw reads and writes
>>
>> On 2026-05-15 17:18, markus.stockhausen@gmx.de wrote:
>> >> Von: Rustam Adilov <adilov@disroot.org> 
>> >> Gesendet: Freitag, 15. Mai 2026 16:33
>> >> An: markus.stockhausen@gmx.de
>> >> Betreff: Re: AW: [PATCH] clocksource: rtl-otto: Change driver to use
> __raw
>> > reads and writes
>> >> ...
>> >> > IIRC the current functions use memory barriers while the
>> >> > new ones do not. Timers are critical and cost me a lot
>> >> > of time in the past [1]. We nearly lost support for several
>> >> > devices last year. So I like to have at least some stability 
>> >> > confirmation from downstream.
>> >>
>> >> As far as i can see, if you untangle the the BUILDIO_MEM(l, u32) in [1]
>> >> you should see they do have barriers as denoted by barrier argument
> being
>> > set.
>> >> So that means, in MIPS, both readl/writel are the same as their __raw
>> > variants.
>> >> And both ioread32/iowrite32 are using readl/writel under the hood so...
>> > 
>> > Hi,
>> > 
>> > will the __relaxed functions serve your IO_SWAP scenario too?
>> > 
>> > Markus
>>
>> Not really because the readl_relaxed and readl appear to be both mapped to
> ioswabl
>> which changes behavior as per IO_SWAP config [1].
> 
> My two cents regarding the real issue behind this discussion. 
> I'm still convinced that CONFIG_SWAP_IO_SPACE is not the
> right way to get an USB driver working. Rewriting every other
> driver around that just feels wrong.

I mean, it is either this or hacking up the general usb reads and writes
functions with this atrociousness:

 static inline unsigned int ehci_readl(const struct ehci_hcd *ehci,
 		__u32 __iomem *regs)
 {
+#if defined(CONFIG_RTK_MIPS_SOC)
+	return (le32_to_cpu((*(volatile unsigned long *)(regs))));
+#else
 #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
 	return ehci_big_endian_mmio(ehci) ?
 		readl_be(regs) :
@@ -746,6 +749,7 @@
 #else
 	return readl(regs);
 #endif
+#endif
 }

 static inline void ehci_writel(const struct ehci_hcd *ehci,
 		const unsigned int val, __u32 __iomem *regs)
 {
+#if defined(CONFIG_RTK_MIPS_SOC)
+	((*(volatile unsigned long *)(regs))=cpu_to_le32(val));
+#else
 #ifdef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO
 	ehci_big_endian_mmio(ehci) ?
 		writel_be(val, regs) :
@@ -773,6 +780,7 @@
 	else
 		writel(val, regs);
 #endif
+#endif
 }

And i don't think anyone upstream is gonna be okay with it.
Obviously that's straight from Realtek code and we can slightly
improve it but the underlying issue is still gonna be there.

With all that, I believe CONFIG_SWAP_IO_SPACE is a good long term
solution to this endian mess and multiple big endian MIPS SoCs use
it too like Lantiq and Broadcom. The happy side effect is rewriting
existing drivers, which i'll call as a good thing personally.

> Coming back to this. If it produces the same assembler code
> for the big endian Realtek Otto platform then I'm ok with this.
> I expect an immediate downstream backport if it gets
> accepted upstream.
> 
> Markus

Best,
Rustam

      reply	other threads:[~2026-05-15 19:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 13:15 [PATCH] clocksource: rtl-otto: Change driver to use __raw reads and writes Rustam Adilov
2026-05-13 18:31 ` Rustam Adilov
2026-05-13 21:05   ` Chris Packham
2026-05-14 20:50     ` AW: " markus.stockhausen
2026-05-15 14:32       ` Rustam Adilov
2026-05-15 17:18         ` AW: " markus.stockhausen
2026-05-15 18:21           ` Rustam Adilov
2026-05-15 18:39             ` AW: " markus.stockhausen
2026-05-15 19:47               ` Rustam Adilov [this message]

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=ff85cd56a1291c8cc9ff28f59b62652c@disroot.org \
    --to=adilov@disroot.org \
    --cc=Chris.Packham@alliedtelesis.co.nz \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.stockhausen@gmx.de \
    --cc=tglx@kernel.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