mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javen <javen_xu@realsil.com.cn>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "hkallweit1@gmail.com" <hkallweit1@gmail.com>,
	"nic_swsd@realtek.com" <nic_swsd@realtek.com>,
	"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"horms@kernel.org" <horms@kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH net-next v1 1/3] r8169: make PHY OCP access safe in atomic context
Date: Tue, 10 Nov 2026 09:58:22 +0000	[thread overview]
Message-ID: <b986c9c9f4b1407b99f62975885b73e6@realsil.com.cn> (raw)
In-Reply-To: <7791e7b5-fdc8-4c8c-ab5b-dcc7d7a6506a@lunn.ch>

>
>On Mon, Nov 09, 2026 at 10:30:20AM +0800, javen wrote:
>> From: Javen Xu <javen_xu@realsil.com.cn>
>>
>> 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

  reply	other threads:[~2026-11-10  9:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09  2:30 [PATCH net-next v1 0/3] r8169: add PTP support for RTL8127a javen
2026-11-09  2:30 ` [PATCH net-next v1 1/3] r8169: make PHY OCP access safe in atomic context javen
2026-11-09 20:47   ` Andrew Lunn
2026-11-10  9:58     ` Javen [this message]
2026-11-09  2:30 ` [PATCH net-next v1 2/3] r8169: add PTP hardware clock support for RTL8127a javen
2026-11-09 20:51   ` Andrew Lunn
2026-11-09  2:30 ` [PATCH net-next v1 3/3] r8169: add hardware timestamping " javen

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=b986c9c9f4b1407b99f62975885b73e6@realsil.com.cn \
    --to=javen_xu@realsil.com.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    /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

all inboxes | Powered by JetHome®