Skip to content

rtl8261n: bugfixes and patch updates - #20392

Closed
balika011 wants to merge 9 commits into
openwrt:mainfrom
balika011:rtl930x_rtk8261n
Closed

balika011 wants to merge 9 commits into
openwrt:mainfrom
balika011:rtl930x_rtk8261n

Conversation

@balika011

@balika011 balika011 commented Oct 12, 2025 •

Copy link
Copy Markdown
Contributor

The current driver is buggy, but for some unknown reason still works with MTK devices.
On realtek rtl93xx switches it doesn't work however.
The current workaround is: we turn on the phys from uboot and keep them on.

These changes fixes the issue, we don't need to turn on the phys from uboot anymore.

Note:
There isn't much code here that stops these phys being added to CONFIG_REALTEK_PHY driver,
should we merge them?

@github-actions github-actions Bot added the kernel pull request/issue with Linux kernel related changes label Oct 12, 2025
@balika011

Copy link
Copy Markdown
Contributor Author

@jonasjelonek @Djfe @andrewjlamarche @ecsv I would love to have some input here. What should we do about that?

@namidairo

Copy link
Copy Markdown
Contributor

The author/sign-off has the same issue as mentioned in #20337 so you may want to take a look at your git config?

@willmo

willmo commented Oct 13, 2025 •

Copy link
Copy Markdown
Contributor

FWIW for those working on this PHY, I found a newer version of the SDK driver in this TP-Link GPL tarball, at qca_95xx_12_2/qca/src/linux-5.4/drivers/net/phy/rtk/. There is also a U-Boot driver at qca_95xx_12_2/qca/src/u-boot-2016/drivers/net/ipq_common/.

I believe that tarball is for this router, which is based on Qualcomm IPQ9574, so it's neither Realtek nor Mediatek.

I haven't gone spelunking through other such tarballs.

@balika011

balika011 commented Oct 13, 2025 •

Copy link
Copy Markdown
Contributor Author

FWIW for those working on this PHY, no idea if this helps, but I found what appears to be a newer version of the SDK driver in this TP-Link GPL tarball: https://static.tp-link.com/upload/gpl-code/2025/202505/20250527/GPL_Archer_BE550v2.6_BE9300v2.6.tar.gz , at qca_95xx_12_2/qca/src/linux-5.4/drivers/net/phy/rtk/. There also seems to be a U-Boot driver at qca_95xx_12_2/qca/src/u-boot-2016/drivers/net/ipq_common/.

nice, i used the one that can be found in dms1250 source and compared to the "core" binary in the stock firmware. it's a 1:1 match

tp-link refuses to share the source code for tl-st5008

@Djfe

Djfe commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

mentioning @Ansuel because he is involved with the MTK side of things (for code like pnswap)

@balika011

Copy link
Copy Markdown
Contributor Author

I did a lot of work on converting patches to the form used by mtk/qc.
i found a few differences compared to the mtk.
however they don't seem to matter at all in reality

i think what actually fixed it is the use of genphy_c45_pma_suspend / genphy_c45_pma_resume

the source code linked by @willmo also contains a fix in rtk_phylib_mmd_write, that's used by the functions in these drivers

i have to do some more testing

@willmo

willmo commented Oct 13, 2025 •

Copy link
Copy Markdown
Contributor

I do wonder if the newer SDK's patches (and/or other updates) will help with devices like W1700K in #17869 though. (Certainly there are a lot of updates to the patches compared to what's currently in main.) I haven't had time to try though.

@Djfe

Djfe commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

I just noticed that the PR as well as a few of the commits spell it RTK instead of RTL. You might want to correct that during the next rebase :)

This reverts commit b77fa45.

Signed-off-by: Balázs Triszka <[email protected]>
@balika011 balika011 changed the title rtk8261n: add rtl93xx specific patches rtk8261n: bugfixes and patch updates Oct 13, 2025
@balika011 balika011 changed the title rtk8261n: bugfixes and patch updates rtl8261n: bugfixes and patch updates Oct 13, 2025
there were a lot of code that's not needed for Linux
remove them

Signed-off-by: Balázs Triszka <[email protected]>
comes from Archer BE550 source drop

Signed-off-by: Balázs Triszka <[email protected]>
same as ddb0cd2 but for RX line

Signed-off-by: Balázs Triszka <[email protected]>
these functions are identical as the ones inplemented here therefor dedundant
(after rtk_phylib_mmd_write bugfix...)

Signed-off-by: Balázs Triszka <[email protected]>
comes from Archer BE550 source drop

Signed-off-by: Balázs Triszka <[email protected]>
comes from Archer BE550 source drop

Signed-off-by: Balázs Triszka <[email protected]>
prints the actual phy name during config init

Signed-off-by: Balázs Triszka <[email protected]>
@balika011

Copy link
Copy Markdown
Contributor Author

@namidairo @willmo @Djfe @Ansuel this should be ready to merge

@OpenWRT-fanboy

Copy link
Copy Markdown

apply rtk serdes patches based on device property flag wouldn't build. Needed to revert that one.

drivers/net/phy/rtl8261n/phy_rtl826xb_patch.c:662:33: error: 'phydev' undeclared (first use in this function) 662 | struct rtk_phy_priv *priv = phydev->priv; | ^~~~~~

some rtk devices, like TL-ST5008 doesn't need that patch, infact breaks it

Signed-off-by: Balázs Triszka <[email protected]>
@balika011

Copy link
Copy Markdown
Contributor Author

apply rtk serdes patches based on device property flag wouldn't build. Needed to revert that one.

drivers/net/phy/rtl8261n/phy_rtl826xb_patch.c:662:33: error: 'phydev' undeclared (first use in this function) 662 | struct rtk_phy_priv *priv = phydev->priv; | ^~~~~~

woops fixed it. somehow i didn't add the last change of mine

@plappermaul

Copy link
Copy Markdown
Contributor

Added the Realtek specific parts of the BE550 GPL to https://github.com/plappermaul/realtek-doc

priv->phytype = (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N) ? (RTK_PHYLIB_RTL8261N) : (RTK_PHYLIB_RTL8264B);
if (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N)
{
data = phy_read_mmd(phydev, 30, 0x103);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd make all instances of this MDIO_MMD_VEND1 instead of 30 going forward, and replace similarly for current usages of 6/7/30/31.

@balika011 balika011 Oct 14, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will send in a pr from this branch: https://github.com/balika011/openwrt_tplink_realtek/tree/rtl8261n_clean
will be fixed there, but that is a bigger change, so i want to send a separate pr for that

@willmo

willmo commented Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Added the Realtek specific parts of the BE550 GPL to https://github.com/plappermaul/realtek-doc

FWIW I also found an intermediate version of the RTK driver for RTL8261N et al. (older than from BE550 but newer than in main here) in the Archer BE5000 GPL tarball at mtk798x/openwrt-21.02/target/linux/linux-5.4.281/drivers/net/phy/rtk/, and (off-topic for this PR) another U-Boot driver for RTL8251B in the Deco BE65 Pro tarball, which is very similar to the one from BE550 except that it adds files rtl8251b_mdio.{c,h}.

edit: And a somewhat different RTK driver for RTL8226B in the Deco WB7200 tarball at package/kernel/rtl8367s/src/rtl8221b/. edit 2: Hmm, maybe it's nearly the same as what @plappermaul already had, sorry, I might have gotten confused there.

That's probably all the spelunking I can manage for now. Note that I didn't systematically check all TP-Link GPL tarballs but rather tried to check most of the WiFi 7-ish APs that appeared to have Realtek PHYs (or at least not Aquantia PHYs) and preferably with GPL tarballs uploaded in 2024 or 2025.

@kirdesde

Copy link
Copy Markdown

Thanks for taking care of this.

Tested on: TP-Link BE450 (Mediatek MT7988d, RTL8261N, Device Support PR pending #20398)

@balika011

Copy link
Copy Markdown
Contributor Author

Thanks for taking care of this.

Tested on: TP-Link BE450 (Mediatek MT7988d, RTL8261N, Device Support PR pending #20398)

can you test this branch please: https://github.com/balika011/openwrt_tplink_realtek/tree/rtl8261n_clean

@kirdesde

Copy link
Copy Markdown

Thanks for taking care of this.

Tested on: TP-Link BE450 (Mediatek MT7988d, RTL8261N, Device Support PR pending #20398)

Thanks for taking care of this.
Tested on: TP-Link BE450 (Mediatek MT7988d, RTL8261N, Device Support PR pending #20398)

can you test this branch please: https://github.com/balika011/openwrt_tplink_realtek/tree/rtl8261n_clean

Sure.

A build from that branch doesn't seem to work reliable (in terms of the 8261n)
Only if I power cycle the device the 8261n is working.

After a reboot the 8216n gets only a 1gbps link (after a huge delay, link partner is 5gbps capable) and no traffic flow.

A build from your PR is working fine even after a reboot.

Logs:

[ 12.313312] Realtek RTL8261N/8261BE/8251L mdio-bus:00: rtkphy_config_init:176 [RTL8261BE] phy_id: 0x1CCAF3 PHYAD:0 swap_tx: 0 swap_rx: 0 [ 12.355924] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[0] patch_type:14 [ 12.364885] Realtek RTL8261N/8261BE/8251L mdio-bus:00: [phy_patch_rtl826xb_flow] flow0 [ 12.381974] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[1] patch_type:6 [ 12.400057] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[2] patch_type:7 [ 12.418571] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[3] patch_type:8 [ 12.527496] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[4] patch_type:5 [ 12.582172] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[5] patch_type:4 [ 12.592142] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[6] patch_type:12 [ 12.617760] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[7] patch_type:15 [ 12.626751] Realtek RTL8261N/8261BE/8251L mdio-bus:00: [phy_patch_rtl826xb_flow] flow1 [ 12.656564] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[8] patch_type:16 [ 12.665535] Realtek RTL8261N/8261BE/8251L mdio-bus:00: [phy_patch_rtl826xb_flow] flow2 [ 12.684838] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[9] patch_type:9 [ 12.714077] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[10] patch_type:10 [ 12.723675] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[11] patch_type:11 [ 12.734957] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[12] patch_type:1 [ 12.745683] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[13] patch_type:2 [ 12.771993] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[14] patch_type:3 [ 12.781208] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[15] patch_type:13 [ 13.808860] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[16] patch_type:17 [ 13.817965] Realtek RTL8261N/8261BE/8251L mdio-bus:00: [phy_patch_rtl826xb_flow] flow3 [ 13.826407] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[17] patch_type:18 [ 13.835456] Realtek RTL8261N/8261BE/8251L mdio-bus:00: [phy_patch_rtl826xb_flow] flow4 [ 13.843370] Realtek RTL8261N/8261BE/8251L mdio-bus:00: phy_patch: pPatchDb->table[18] patch_type:0 [ 13.853379] mtk_soc_eth 15100000.ethernet eth2: PHY [mdio-bus:00] driver [Realtek RTL8261N/8261BE/8251L] (irq=POLL) [ 13.863806] mtk_soc_eth 15100000.ethernet eth2: configuring for phy/usxgmii link mode [ 13.885534] br-lan: port 1(eth2) entered blocking state [ 13.890769] br-lan: port 1(eth2) entered disabled state [ 13.896087] mtk_soc_eth 15100000.ethernet eth2: entered allmulticast mode [ 13.903056] mtk_soc_eth 15100000.ethernet eth2: entered promiscuous mode [ 42.006386] mtk_soc_eth 15100000.ethernet eth2: Link is Up - 1Gbps/Full - flow control rx/tx [ 42.006415] br-lan: port 1(eth2) entered blocking state [ 42.020063] br-lan: port 1(eth2) entered forwarding state

hurrian added a commit to hurrian/openwrt-w1700k that referenced this pull request Oct 18, 2025
Add support for the `RTL8261N` NBASE-T PHY to the Gemtek W1700K.

Depends: openwrt#20392 (rtl8261n: bugfixes and patch updates)
Signed-off-by: Kenneth Kasilag <[email protected]>
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Oct 18, 2025
…emtek W1700K

Based on disassembly of the OEM driver, and from logic analyzer measurement, the
UXSGMII HSO/HSI lines need to be polarity swapped.

Depends: openwrt#20392 (rtl8261n: bugfixes and patch updates)
Signed-off-by: Richard Huynh <[email protected]>
Signed-off-by: Kenneth Kasilag <[email protected]>
hurrian added a commit to hurrian/openwrt-w1700k that referenced this pull request Oct 18, 2025
Add support for the `RTL8261N` NBASE-T PHY to the Gemtek W1700K.

Depends: openwrt#20392 (rtl8261n: bugfixes and patch updates)
Signed-off-by: Kenneth Kasilag <[email protected]>
hurrian pushed a commit to hurrian/openwrt-w1700k that referenced this pull request Oct 18, 2025
…emtek W1700K

Based on disassembly of the OEM driver, and from logic analyzer measurement, the
UXSGMII HSO/HSI lines need to be polarity swapped.

Depends: openwrt#20392 (rtl8261n: bugfixes and patch updates)
Signed-off-by: Richard Huynh <[email protected]>
Signed-off-by: Kenneth Kasilag <[email protected]>
@hurrian

hurrian commented Oct 18, 2025

Copy link
Copy Markdown
Contributor

Tested this branch to work on Gemtek W1700K.

As for rtl8261n_clean - I get the same issue as above, negotiates to 1Gb after a long delay and no traffic passes.

Tested-by: Kenneth Kasilag [email protected]

@balika011

Copy link
Copy Markdown
Contributor Author

superseded by #20450

@Djfe

Djfe commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

feel free to close this pr since you yourself superseded it :)

@balika011 balika011 closed this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel pull request/issue with Linux kernel related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants