netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/14] net: stmmac: phylink PCS conversion
@ 2025-10-15 14:19 Russell King (Oracle)
  2025-10-15 14:20 ` [PATCH net-next 01/14] net: stmmac: remove broken PCS code Russell King (Oracle)
                   ` (14 more replies)
  0 siblings, 15 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:19 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Abhishek Chauhan, Alexandre Torgue, Alexis Lothore, Andrew Lunn,
	Boon Khai Ng, Choong Yong Liang, Daniel Machon, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Faizal Rahim,
	Furong Xu, Inochi Amaoto, Jacob Keller, Jakub Kicinski,
	Jan Petrous (OSS), Jisheng Zhang, Kees Cook, Kunihiko Hayashi,
	Lad Prabhakar, Ley Foon Tan, linux-arm-kernel, linux-arm-msm,
	linux-stm32, Matthew Gerlach, Maxime Chevallier, Maxime Coquelin,
	Michal Swiatkowski, netdev, Oleksij Rempel, Paolo Abeni,
	Rohan G Thomas, Shenwei Wang, Simon Horman, Song Yoong Siang,
	Swathi K S, Tiezhu Yang, Vinod Koul, Vladimir Oltean,
	Vladimir Oltean, Yu-Chun Lin

This series is radical - it takes the brave step of ripping out much of
the existing PCS support code and throwing it all away.

I have discussed the introduction of the STMMAC_FLAG_HAS_INTEGRATED_PCS
flag with Bartosz Golaszewski, and the conclusion I came to is that
this is to workaround the breakage that I've been going on about
concerning the phylink conversion for the last five or six years.

The problem is that the stmmac PCS code manipulates the netif carrier
state, which confuses phylink.

There is a way of testing this out on the Jetson Xavier NX platform as
the "PCS" code paths can be exercised while in RGMII mode - because
RGMII also has in-band status and the status register is shared with
SGMII. Testing this out confirms my long held theory: the interrupt
handler manipulates the netif carrier state before phylink gets a
look-in, which means that the mac_link_up() and mac_link_down() methods
are never called, resulting in the device being non-functional.

Moreover, on dwmac4 cores, ethtool reports incorrect information -
despite having a full-duplex link, ethtool reports that it is
half-dupex.

Thus, this code is completely broken - anyone using it will not have
a functional platform, and thus it doesn't deserve to live any longer,
especially as it's a thorn in phylink.

Rip all this out, leaving just the bare bones initialisation in place.

However, this is not the last of what's broken. We have this hw->ps
integer which is really not descriptive, and the DT property from
which it comes from does little to help understand what's going on.
Putting all the clues together:

- early configuration of the GMAC configuration register for the
  speed.
- setting the SGMII rate adapter layer to take its speed from the
  GMAC configuration register.

Lastly, setting the transmit enable (TE) bit, which is a typo that puts
the nail in the coffin of this code. It should be the transmit
configuration (TC) bit. Given that when the link comes up, phylink
will call mac_link_up() which will overwrite the speed in the GMAC
configuration register, the only part of this that is functional is
changing where the SGMII rate adapter layer gets its speed from,
which is a boolean.

From what I've found so far, everyone who sets the snps,ps-speed
property which configures this mode also configures a fixed link,
so the pre-configuration is unnecessary - the link will come up
anyway.

So, this series rips that out the preconfiguration as well, and
replaces hw->ps with a boolean hw->reverse_sgmii_enable flag.

We then move the sole PCS configuration into a phylink_pcs instance,
which configures the PCS control register in the same way as is done
during the probe function.

Thus, we end up with much easier and simpler conversion to phylink PCS
than previous attempts.

Even so, this still results in inband mode always being enabled at the
moment in the new .pcs_config() method to reflect what the probe
function was doing. The next stage will be to change that to allow
phylink to correctly configure the PCS. This needs fixing to allow
platform glue maintainers who are currently blocked to progress.

Please note, however, that this has not been tested with any SGMII
platform.

I've tried to get as many people into the Cc list with get_maintainers,
I hope that's sufficient to get enough eyeballs on this.

Changes since RFC:
- new patch (7) to remove RGMII "pcs" mode
- new patch (8) to move reverse "pcs" mode to stmmac_check_pcs_mode()
- new patch (9) to simplify the code moved in the previous patch
- new patch (10) to rename the confusing hw->ps to something more
  understandable.
- new patch (11) to shut up inappropriate complaints about
  "snps,ps-speed" being invalid.
- new patch (13) to add a MAC .pcs_init method, which will only be
  called when core has PCS present.
- modify patch 14 to use this new pcs_init method.

Despite getting a couple of responses to the RFC series posted in
September, I have had nothing testing this on hardware. I have tested
this on the Jetson Xavier NX, which included trial runs with enabling
the RGMII "pcs" mode, hence the new patches that rip out this mode. I
have come to the conclusion that the only way to get stmmac changes
tested is to get them merged into net-next, thereby forcing people to
have to run with them... and we'll deal with any fallout later.

 drivers/net/ethernet/stmicro/stmmac/Makefile       |  2 +-
 drivers/net/ethernet/stmicro/stmmac/common.h       |  5 +-
 .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c    |  6 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac1000.h    |  6 +-
 .../net/ethernet/stmicro/stmmac/dwmac1000_core.c   | 65 ++-------------------
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h       |  3 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c  | 66 ++-------------------
 .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    | 25 +-------
 drivers/net/ethernet/stmicro/stmmac/hwif.h         |  4 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  4 ++
 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c   | 68 +---------------------
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 24 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c   | 47 +++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h   | 23 ++++++--
 include/linux/stmmac.h                             |  1 -
 15 files changed, 104 insertions(+), 245 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2025-10-16 13:52 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
2025-10-15 14:20 ` [PATCH net-next 01/14] net: stmmac: remove broken PCS code Russell King (Oracle)
2025-10-15 20:44   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 02/14] net: stmmac: remove xstats.pcs_* members Russell King (Oracle)
2025-10-15 20:45   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling Russell King (Oracle)
2025-10-15 20:47   ` Andrew Lunn
2025-10-15 21:35   ` Andrew Lunn
2025-10-15 22:12     ` Russell King (Oracle)
2025-10-16 13:07       ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 04/14] net: stmmac: remove PCS "mode" pause handling Russell King (Oracle)
2025-10-15 20:48   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 05/14] net: stmmac: remove unused PCS loopback support Russell King (Oracle)
2025-10-15 20:50   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 06/14] net: stmmac: remove hw->ps xxx_core_init() hardware setup Russell King (Oracle)
2025-10-15 14:20 ` [PATCH net-next 07/14] net: stmmac: remove RGMII "pcs" mode Russell King (Oracle)
2025-10-15 20:53   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 08/14] net: stmmac: move reverse-"pcs" mode setup to stmmac_check_pcs_mode() Russell King (Oracle)
2025-10-15 20:55   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 09/14] net: stmmac: simplify stmmac_check_pcs_mode() Russell King (Oracle)
2025-10-15 20:56   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 10/14] net: stmmac: hw->ps becomes hw->reverse_sgmii_enable Russell King (Oracle)
2025-10-15 20:57   ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII Russell King (Oracle)
2025-10-15 21:00   ` Andrew Lunn
2025-10-15 21:26   ` Andrew Lunn
2025-10-15 21:48     ` Russell King (Oracle)
2025-10-16 13:03       ` Andrew Lunn
2025-10-16 13:51         ` Russell King (Oracle)
2025-10-15 14:20 ` [PATCH net-next 12/14] net: stmmac: only call stmmac_pcs_ctrl_ane() for integrated SGMII PCS Russell King (Oracle)
2025-10-15 21:01   ` Andrew Lunn
2025-10-15 14:21 ` [PATCH net-next 13/14] net: stmmac: provide PCS initialisation hook Russell King (Oracle)
2025-10-15 21:11   ` Andrew Lunn
2025-10-15 21:32     ` Russell King (Oracle)
2025-10-15 14:21 ` [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support Russell King (Oracle)
2025-10-15 21:31   ` Andrew Lunn
2025-10-15 21:57     ` Russell King (Oracle)
2025-10-16 13:05       ` Andrew Lunn
2025-10-15 15:10 ` [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
2025-10-16  7:44   ` Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).