[PATCH net-next v12 00/11] net: mdio: realtek-rtl9300: Add RTL83xx support
Markus Stockhausen <[email protected]> Mon, 3 Aug 2026 19:18:42 +0200
| Newsgroups | org.kernel.vger.linux-devicetree,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
The Realtek Otto switch platform consists of four different series - RTL838x aka maple : 28 port 1G Switches - RTL839x aka cypress : 52 port 1G Switches - RTL930x aka longan : 28 port 1G/2.5G/10G Switches - RTL931x aka mango : 56 port 1G/2.5G/10G Switches While the MDIO hardware polling unit and its necessity for the MAC layer was always well known, no detailed documentation was available. For this series the MDIO bus was inspected with a logic analyzer for a better understanding how polling and kernel access interact on the bus. All this will be explained now in the driver comments. This patch series adds support for the RTL83xx devices. For this - Enhance device tree binding. - Add special handling for limitations enforced by hardware polling. These already have minor side effects on RTL93xx devices but are even more critical for the RTL83xx hardware. - Add RTL83xx coding. Signed-off-by: Markus Stockhausen <[email protected]> --- v11 -> v12: - v11 was sent with the wrong starting commit and with leftovers from v10. Sorry for that and thanks to Jeremy. - Allow to support devices that as of now only need C22 read/write helpers. This avoids to carry around unneeded C45 code for RTL83xx. The feature is implemented with an additional patch. With this drop RTL83xx C45 helpers. (Sashiko) v11: https://lore.kernel.org/netdev/[email protected]/ v11 Sashiko review faild v10 -> v11: - Fix typo in bindings patch. Cypress has only 52 ports. (Sashiko) - Drop "extend priv lifetime" patch this was too complex and produced even more Sashiko findings. Instead use suppress_bind_attrs to disable sysfs unbinding. (Sashiko) - Rename detach helper phy_detach_internal() to avoid confusion with unlocked helpers that start with two underscores. (Sashiko) - Clarify the reason for the unconditional notify_phy_detach() that Sashiko complained about. (Markus) - Explain that FIELD_PREP(RTL8390_PHY_CTRL_EXT_PAGE, 0x1ff) is taken over from SDK and no meaningful name can be given for 0x1ff. Just like RTL9300_PHY_CTRL_PARK_PAGE. (Sashiko). v10: https://lore.kernel.org/netdev/[email protected]/ v10 sashiko-nipa: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260731061400.78301-1-markus.stockhausen%40gmx.de v10 sashiko-gemini: https://sashiko.dev/#/patchset/20260731061400.78301-1-markus.stockhausen%40gmx.de v9 -> v10: - Run devm_add_action_or_reset() after devm_of_mdiobus_register(). Critical last minute flaw during v9 refactoring. (Sashiko) - Enclose page access into guard() during detach notification to avoid concurrency issues during teardown. (Sashiko) - Clarify that system suspend/resume ist not supported. Hardware polling will not need to take care about system power management. (Sashiko) - Add patch to reword Kconfig description. (Sashiko) - Remark: v9 was mislabeled as v8 v9: https://lore.kernel.org/netdev/[email protected]/ v9 Sashiko review: https://sashiko.dev/#/patchset/20260729160227.155613-1-markus.stockhausen%40gmx.de v8 -> v9: - Align polling documentation with sample. Instead of "read" it must be "write". (Sashiko) - If otto_emdio_init_polling() fails do not leave otto_emdio_probe() but jump to error label for cleanup. (Sashiko) - Bind cleanup action to the bus and not the controller. This was done wrong in v7. (Sashiko) - Clear Realtek C22 PHY tracking page during detach. This ensures that next PHY attachment does not work on wrong initial page. (Sashiko) - Explain that polling registers have different names for the devices to avoid AI confusion. (Sashiko) - Improve notify_phy_attach() and notify_phy_detach() documentation to better reflect under what conditions these callbacks run. (Sashiko) - The v8 lifetime increase rework changed an error message without explanation. Undo that change. (Sashiko) - Improve page tracking commit message. Explain that bus scan runs before Realtek PHY check and thus a delayed error handling is accepted for now. (Sashiko) - Explain that the driver implements c45 access for RTL838x and RTL839x for completeness. (Sashiko) - Replace kzalloc() by kzalloc_obj due to checkpatch. (Markus) - Use define for page register 31. (Sashiko) - Avoid duplicate pointer walk in otto_emdio_notify_phy_attach(). (Sashiko) - Drop unneded parenthesis for phy vendor check inside otto_emdio_notify_phy_attach(). (Sashiko) v8: https://lore.kernel.org/netdev/[email protected]/ v8 Sashiko review: https://sashiko.dev/#/patchset/20260727191559.19617-1-markus.stockhausen%40gmx.de v7 -> v8: - Add patch 4 to increase lifetime of controller->priv structure so it is available until the last bus is unregistered. This avoids a use-after-free if controller is unbound via sysfs. (Sashiko) v7: https://lore.kernel.org/netdev/[email protected]/ v7 Sashiko review: https://sashiko.dev/#/message/20260726071751.1359156-1-markus.stockhausen%40gmx.de v6 -> v7: - Drop phy_poll bitmap. It was used to detect asymmetrical attach() and detach() callbacks. With v6 callback refactoring this is now obsolete. (Sashiko) - Relocate notify_detach() callback directly behind phy_suspend() for better symmetry. To avoid further AI review complaints about missing LIFO compliance explain that phy_detach() even without the patch is not compliant. (Sashiko) v6: https://lore.kernel.org/netdev/[email protected]/ v6 Sashiko review: https://sashiko.dev/#/patchset/20260724055611.1008577-1-markus.stockhausen%40gmx.de v5 -> v6: - Adapt polling documentation with new findings after questions about consistency of 100MBit downspeed detection. (Andrew) - Add a clearer explanation to the page tracking commit and why it was chosen over a polling enabling/disabling solution. (Andrew) - Make bus notification symmetrical and respect LIFO order. For this add a __phy_detach() helper that avoids code duplication in the phy_attach_direct() error paths. Drop the mdio_bus_notified status bit. (Andrew, Sashiko) - Adapt notify_phy_attach()/notify_phy_detach() documentation to reflect above changes. - Drop lockdep_assert_held check from otto_emdio_set_port_polling() and remove lock handling during polling initialization. At that point in time the driver has exclusive access. (Andrew) - Drop polling check in otto_emdio_notify_phy_attach(). Notification is symmetrical now so there is no chance of double invocation. (Andrew) - Add Reviewed-by to "Increase MDIO timeout" patch (Andrew) v5: https://lore.kernel.org/netdev/[email protected]/ v5 Sashiko review: https://sashiko.dev/#/patchset/20260722062356.12291-1-markus.stockhausen%40gmx.de v4 -> v5: - Design bus notification symmetric so that notify_phy_detach is only invoked when notify_phy_attach succeeded. (Jakub) - Improve documentation of notification callbacks. (Jakub) v4: https://lore.kernel.org/netdev/[email protected]/ v4 Sashiko review: https://sashiko.dev/#/patchset/20260709064157.2865063-1-markus.stockhausen%40gmx.de v3 -> v4: - Add Acked-by for dt-bindings commit (Conor) - Test phy_poll bitfield under lock to avoid race. (Sashiko) - Fix whitespace in commit "configure hardware polling" (Markus) v3: https://lore.kernel.org/netdev/[email protected]/ v3 Sashiko review: https://sashiko.dev/#/patchset/20260705163532.2853959-1-markus.stockhausen%40gmx.de v2 -> v3: - Enhance documentation and make clear that the driver and not the kernel must handle the bus mess. (Andrew) - Block non-Realtek PHYs on C22 buses to avoid issues with driver internal register 31 handling. (Andrew, Chris) - Drop C45 over C22 patch. This would need a bus lock/unlock design. For all known hardware designs it is not needed. (Andrew) - Drop tune_polling() and init_polling() from private structure. It is not used in this series and only produces review bot questions. (Sashiko) - Sort patches for better logical consistency. (Markus) - Add device tree patch that was missed in v2. (Markus) v2: https://lore.kernel.org/netdev/[email protected]/ v2 Sashiko review: https://sashiko.dev/#/patchset/20260629152336.2239826-1-markus.stockhausen%40gmx.de v1 -> v2: - The polling activation logic was refactored. V1 simply activated polling after bus probing. Now a dedicated phydev/bus callback takes care of this and also handles deferred PHY probing. (Sashiko) - Run MMD prefix helper before register 31 (aka Realtek page register) handling. (Jakub's bot) - Always run MMD postfix - even if the c22 register access fails. This ensures that the MMD state machine stays consistent. Adapt the error handling inside the postfix function to not overwrite the real MDIO return code (Sashiko, Jakub's bot) - Drop unused RTL8390_PHY_CTRL_PARK_PAGE define. Like on RTL931x this field must not be set and thus can be ignored. (Sashiko) - Change title in device tree documentation. Because of this do NOT add the Reviewed-by of Krzysztof. (Jakub's bot) - Fix wrong use of RTL839x in commit message of patch "c45 over c22 mitigation". RTL930x was wrongly named RTL839x in the list of good devices. (Markus) - Fix typos (e.g. c22 over c45) in polling documentation (Jakub's bot) v1: https://lore.kernel.org/netdev/[email protected]/ v1 Sashiko review: https://sashiko.dev/#/patchset/[email protected] Daniel Golle (1): net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen (10): dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series net: mdio: realtek-rtl9300: Add polling documentation net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes net: mdio: realtek-rtl9300: Configure hardware polling during probing net: mdio: realtek-rtl9300: Add page tracking net: mdio: realtek-rtl9300: Increase MDIO timeout net: mdio: realtek-rtl9300: Check for C45 support during setup net: mdio: realtek-rtl9300: Add support for RTL838x net: mdio: realtek-rtl9300: Add support for RTL839x net: mdio: reword MDIO_REALTEK_RTL9300 Kconfig .../bindings/net/realtek,rtl9301-mdio.yaml | 14 +- drivers/net/mdio/Kconfig | 4 +- drivers/net/mdio/mdio-realtek-rtl9300.c | 344 +++++++++++++++++- drivers/net/phy/phy_device.c | 180 ++++----- include/linux/phy.h | 18 + 5 files changed, 465 insertions(+), 95 deletions(-) -- 2.55.0