RE: [PATCH net-next v1 1/3] r8169: make PHY OCP access safe in atomic context

From: Javen

Date: Tue Nov 10 2026 - 05:57:04 EST


>
>On Mon, Nov 09, 2026 at 10:30:20AM +0800, javen wrote:
>> From: Javen Xu <javen_xu@xxxxxxxxxxxxxx>
>>
>> r8168_phy_ocp_read() and r8168_phy_ocp_write() wait for the GPHY_OCP
>> handshake with rtl_loop_wait(), which may sleep (fsleep(25)). Upcoming
>> PTP support for RTL8127A accesses the PTP block through the same PHY
>> OCP interface from atomic context (spinlock held, NAPI RX path), and
>> concurrently with phylib MDIO accesses.
>>
>> Busy-wait for the handshake with readl_poll_timeout_atomic() instead,
>> keeping the previous maximum wait time of 250us, and serialize the
>> GPHY_OCP register accesses with a new spinlock.
>
>There are many drivers which need to access PHY registers via blocking MDIO
>accesses. Why is this driver different?

In v1, RX timestamp was read in rtl_rx(), i.e. in NAPI context and tx is in ndo_start_xmit. Since neither of those fast-paths can sleep, I had to export the raw PHY OCP accessors and wrap them in a spinlock.

I will try to move all the code to phy driver and all accesses will use phy_read_mmd()/phy_write_mmd() and will be serialized by a mutex.

Thanks,
Javen

>
> Andrew