* [PATCH net-next v1] net: phy: realtek: improve firmware write speed
@ 2026-09-10 2:49 javen
2026-09-10 12:25 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: javen @ 2026-09-10 2:49 UTC (permalink / raw)
To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
freddy_gu, nb, maxime.chevallier
Cc: netdev, linux-kernel, daniel, vladimir.oltean, Javen Xu
From: Javen Xu <javen_xu@realsil.com.cn>
Firmware execution routine unconditionally uses phy_modify_mmd() for
all OP_WRITE entries which introduces an unnecessary read transaction
when updating an entire 16-bit register. So we optimize this by
checking bitmask boundaries. Use phy_write_mmd() directly to speed up
firmware loading process.
Signed-off-by: Javen Xu <javen_xu@realsil.com.cn>
---
drivers/net/phy/realtek/realtek_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index 27e31a799e2c..97b0b67b9900 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -548,8 +548,12 @@ static int rtl8261x_fw_execute_entry(struct phy_device *phydev,
switch (entry->type) {
case OP_WRITE:
- ret = phy_modify_mmd(phydev, dev, addr,
- GENMASK(msb, lsb), (value << lsb) & GENMASK(msb, lsb));
+ if (msb != 15 || lsb != 0)
+ ret = phy_modify_mmd(phydev, dev, addr, GENMASK(msb, lsb),
+ (value << lsb) & GENMASK(msb, lsb));
+ else
+ ret = phy_write_mmd(phydev, dev, addr, value);
+
if (ret)
return ret;
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net-next v1] net: phy: realtek: improve firmware write speed
2026-09-10 2:49 [PATCH net-next v1] net: phy: realtek: improve firmware write speed javen
@ 2026-09-10 12:25 ` Andrew Lunn
2026-09-11 5:51 ` Javen
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2026-09-10 12:25 UTC (permalink / raw)
To: javen
Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, freddy_gu, nb,
maxime.chevallier, netdev, linux-kernel, daniel, vladimir.oltean
On Thu, Sep 10, 2026 at 10:49:26AM +0800, javen wrote:
> From: Javen Xu <javen_xu@realsil.com.cn>
>
> Firmware execution routine unconditionally uses phy_modify_mmd() for
> all OP_WRITE entries which introduces an unnecessary read transaction
> when updating an entire 16-bit register. So we optimize this by
> checking bitmask boundaries. Use phy_write_mmd() directly to speed up
> firmware loading process.
For optimisations, it is normal to include some benchmark numbers to
show how big a change it made. Is the added complexity worth the
change?
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next v1] net: phy: realtek: improve firmware write speed
2026-09-10 12:25 ` Andrew Lunn
@ 2026-09-11 5:51 ` Javen
2026-09-11 7:33 ` Nicolai Buchwitz
0 siblings, 1 reply; 5+ messages in thread
From: Javen @ 2026-09-11 5:51 UTC (permalink / raw)
To: Andrew Lunn
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
顾晓军, nb@tipi-net.de,
maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, daniel@makrotopia.org,
vladimir.oltean@nxp.com
>
>On Thu, Sep 10, 2026 at 10:49:26AM +0800, javen wrote:
>> From: Javen Xu <javen_xu@realsil.com.cn>
>>
>> Firmware execution routine unconditionally uses phy_modify_mmd() for
>> all OP_WRITE entries which introduces an unnecessary read transaction
>> when updating an entire 16-bit register. So we optimize this by
>> checking bitmask boundaries. Use phy_write_mmd() directly to speed up
>> firmware loading process.
>
>For optimisations, it is normal to include some benchmark numbers to show
>how big a change it made. Is the added complexity worth the change?
>
I traced the actual MDC/MDIO hardware transactions during firmware loading process. Here are the benchmark numbers:
- Unpatched : about 28,000 MDIO transactions.
- Patched: about 9,600 MDIO transactions.
This results in a 65% reduction in MDIO traffic.
Thanks,
Javen
> Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v1] net: phy: realtek: improve firmware write speed
2026-09-11 5:51 ` Javen
@ 2026-09-11 7:33 ` Nicolai Buchwitz
2026-09-11 9:38 ` Javen
0 siblings, 1 reply; 5+ messages in thread
From: Nicolai Buchwitz @ 2026-09-11 7:33 UTC (permalink / raw)
To: Javen
Cc: Andrew Lunn, hkallweit1, linux, davem, edumazet, kuba, pabeni,
顾晓军, maxime.chevallier, netdev, linux-kernel,
daniel, vladimir.oltean
Hi Javen
On 11.9.2026 07:51, Javen wrote:
>>
>> On Thu, Sep 10, 2026 at 10:49:26AM +0800, javen wrote:
>>> From: Javen Xu <javen_xu@realsil.com.cn>
>>>
>>> Firmware execution routine unconditionally uses phy_modify_mmd() for
>>> all OP_WRITE entries which introduces an unnecessary read transaction
>>> when updating an entire 16-bit register. So we optimize this by
>>> checking bitmask boundaries. Use phy_write_mmd() directly to speed up
>>> firmware loading process.
>>
>> For optimisations, it is normal to include some benchmark numbers to
>> show
>> how big a change it made. Is the added complexity worth the change?
>>
>
> I traced the actual MDC/MDIO hardware transactions during firmware
> loading process. Here are the benchmark numbers:
>
> - Unpatched : about 28,000 MDIO transactions.
> - Patched: about 9,600 MDIO transactions.
>
> This results in a 65% reduction in MDIO traffic.
Can you please add these numbers to the commit?
The patch itself looks fine and also compiles cleanly on my machine.
So with the number added, I'd be happy to R-b.
>
> Thanks,
> Javen
>
>> Andrew
Thanks,
Nicolai
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next v1] net: phy: realtek: improve firmware write speed
2026-09-11 7:33 ` Nicolai Buchwitz
@ 2026-09-11 9:38 ` Javen
0 siblings, 0 replies; 5+ messages in thread
From: Javen @ 2026-09-11 9:38 UTC (permalink / raw)
To: Nicolai Buchwitz
Cc: Andrew Lunn, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, 顾晓军,
maxime.chevallier@bootlin.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, daniel@makrotopia.org,
vladimir.oltean@nxp.com
>
>
>Hi Javen
>
>On 11.9.2026 07:51, Javen wrote:
>>>
>>> On Thu, Sep 10, 2026 at 10:49:26AM +0800, javen wrote:
>>>> From: Javen Xu <javen_xu@realsil.com.cn>
>>>>
>>>> Firmware execution routine unconditionally uses phy_modify_mmd() for
>>>> all OP_WRITE entries which introduces an unnecessary read
>>>> transaction when updating an entire 16-bit register. So we optimize
>>>> this by checking bitmask boundaries. Use phy_write_mmd() directly to
>>>> speed up firmware loading process.
>>>
>>> For optimisations, it is normal to include some benchmark numbers to
>>> show how big a change it made. Is the added complexity worth the
>>> change?
>>>
>>
>> I traced the actual MDC/MDIO hardware transactions during firmware
>> loading process. Here are the benchmark numbers:
>>
>> - Unpatched : about 28,000 MDIO transactions.
>> - Patched: about 9,600 MDIO transactions.
>>
>> This results in a 65% reduction in MDIO traffic.
>
>Can you please add these numbers to the commit?
>
>The patch itself looks fine and also compiles cleanly on my machine.
>So with the number added, I'd be happy to R-b.
>
Hi Nicolai,
Thanks for the review and testing.
I will add these benchmark numbers to the commit message and send out a v2 patch.
Thanks,
Javen
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-11 9:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-10 2:49 [PATCH net-next v1] net: phy: realtek: improve firmware write speed javen
2026-09-10 12:25 ` Andrew Lunn
2026-09-11 5:51 ` Javen
2026-09-11 7:33 ` Nicolai Buchwitz
2026-09-11 9:38 ` Javen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox