From: "Markus Stockhausen" <markus.stockhausen@gmx.de>
To: "'Andrew Lunn'" <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, <chris.packham@alliedtelesis.co.nz>,
<daniel@makrotopia.org>,
"'Jonas Jelonek'" <jonas.jelonek@protonmail.ch>
Subject: Realtek Otto PHY hardware polling
Date: Sat, 6 Jun 2026 18:48:37 +0200 [thread overview]
Message-ID: <02d001dcf5d4$540aad50$fc2007f0$@gmx.de> (raw)
Hi Andrew,
> Von: Andrew Lunn <andrew@lunn.ch>
> Gesendet: Dienstag, 2. Juni 2026 22:30
> An: Markus Stockhausen <markus.stockhausen@gmx.de>
> Betreff: Re: [PATCH net-next 6/8] net: mdio: realtek-rtl9300: relocate
topology setup
>
> > The hardware polling in these devices is very important for the DSA
> > driver. Especially as a port can be either PHY or SerDes driven. Some
> > MAC operations simply do not work if a wrong state is reported.
>
> And you will get the wrong state if the timing of the poll is in the
> middle of the PHY driver swapping the page to read/write something.
>
> I've not looked at what PHYs you plan to support, but code like
>
>
https://elixir.bootlin.com/linux/v7.0.10/source/drivers/net/phy/realtek/real
tek_main.c#L907
>
> could be called every 50ms to blink the LEDs. That changes the page,
> writes a register, and then changes back to the original page. If the
> HW polling happens in the middle of that, it will read from the wrong
> place. If that HW poll actually changes the page, without restoring
> it, the write made in that function could go to the wrong page.
>
> So, in order to be able to use the Linux PHY drivers, you need to
> ensure the Linux PHY drivers has exclusive access to the bus when it
> needs it.
Thank you for the journey we are on together. Today I took a a lot of
time to get a better picture of this. First of all the hardware polling
is tightly coupled with the MDIO bus access. So by design the software
access to the PHYs is automatically synchronized with the polling.
Basically there is no need to disable/enable polling for an access.
We are running OpenWrt with polling enabled all the time without
major issues.
As advised I hammered the bus of the RTL9300 with several
access patterns over a few hours. I took the upstream driver that
writes directly to the PHY and does not cache the page like downstream
. So even more stress and chances of wrong pages on the PHY.
No issue occured.
While doing so I checked the Realtek SDK regarding enabling and
disabling of hardware polling. What I found [1]:
- enabling/disabling polling is more often in RTL838x and RTL839x
- It is only used for special functions (fiber, EEE, hard reset, SerDes
calibration).
- Usage is mostly for the RTL8218B / RTL8214FC PHY
- And another twist: RTL839x can only configure polling for all ports
at once with a global flag.
From the not yet ported SDK code snippets I read today, I'm even
more convinced that we only need some sort of controlled polling
enabling/disabling for specific access sequences.
That said and from over a year of downstream driver evolution I can
only say that in its current form it fits our needs. I'm even unsure if
this is only some kind of safety for engeneering samples or older
chip revisions. So I will try to stay with the lockless approach as long as
possible and only use it during bus setup when the PHYs are probed
and spooky initialization sequences are running.
Will give this another test on the RTL83xx when upstreaming that code.
Once again thank you and best regards.
Markus
[1]
https://github.com/reyalo/Realtek/blob/31ad7755468e4b72cd9473b4a545513de8288
f47/sources/rtk-dms1250/src/hal/mac/miim_common_drv.c#L1054
reply other threads:[~2026-06-06 16:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='02d001dcf5d4$540aad50$fc2007f0$@gmx.de' \
--to=markus.stockhausen@gmx.de \
--cc=andrew@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=daniel@makrotopia.org \
--cc=jonas.jelonek@protonmail.ch \
--cc=netdev@vger.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