* [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
* [PATCH net-next 01/14] net: stmmac: remove broken PCS code
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
@ 2025-10-15 14:20 ` 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)
` (13 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Changing the netif_carrier_*() state behind phylink's back has always
been prohibited because it messes up with phylinks state tracking, and
means that phylink no longer guarantees to call the mac_link_down()
and mac_link_up() methods at the appropriate times. This was later
documented in the sfp-phylink network driver conversion guide.
stmmac was converted to phylink in 2019, but nothing was done with the
"PCS" code. Since then, apart from the updates as part of phylink
development, nothing has happened with stmmac to improve its use of
phylink, or even to address this point.
A couple of years ago, a has_integrated_pcs boolean was added by Bart,
which later became the STMMAC_FLAG_HAS_INTEGRATED_PCS flag, to avoid
manipulating the netif_carrier_*() state. This flag is mis-named,
because whenever the stmmac is synthesized for its native SGMII, TBI
or RTBI interfaces, it has an "integrated PCS". This boolean/flag
actually means "ignore the status from the integrated PCS".
Discussing with Bart, the reasons for this are lost to the winds of
time (which is why we should always document the reasons in the commit
message.)
RGMII also has in-band status, and the dwmac cores and stmmac code
supports this but with one bug that saves the day.
When dwmac cores are synthesised for RGMII only, they do not contain
an integrated PCS, and so priv->dma_cap.pcs is clear, which prevents
(incorrectly) the "RGMII PCS" being used, meaning we don't read the
in-band status. However, a core synthesised for RGMII and also SGMII,
TBI or RTBI will have this capability bit set, thus making these
code paths reachable.
The Jetson Xavier NX uses RGMII mode to talk to its PHY, and removing
the incorrect check for priv->dma_cap.pcs reveals the theortical issue
with netif_carrier_*() manipulation is real:
dwc-eth-dwmac 2490000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
dwc-eth-dwmac 2490000.ethernet eth0: PHY [stmmac-0:00] driver [RTL8211F Gigabit Ethernet] (irq=141)
dwc-eth-dwmac 2490000.ethernet eth0: No Safety Features support found
dwc-eth-dwmac 2490000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
dwc-eth-dwmac 2490000.ethernet eth0: registered PTP clock
dwc-eth-dwmac 2490000.ethernet eth0: configuring for phy/rgmii-id link mode
8021q: adding VLAN 0 to HW filter on device eth0
dwc-eth-dwmac 2490000.ethernet eth0: Adding VLAN ID 0 is not supported
Link is Up - 1000/Full
Link is Down
Link is Up - 1000/Full
This looks good until one realises that the phylink "Link" status
messages are missing, even when the RJ45 cable is reconnected. Nothing
one can do results in the interface working. The interrupt handler
(which prints those "Link is" messages) always wins over phylink's
resolve worker, meaning phylink never calls the mac_link_up() nor
mac_link_down() methods.
eth0 also sees no traffic received, and is unable to obtain a DHCP
address:
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group defa
ult qlen 1000
link/ether e6:d3:6a:e6:92:de brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
27686 149 0 0 0 0
With the STMMAC_FLAG_HAS_INTEGRATED_PCS flag set, which disables the
netif_carrier_*() manipulation then stmmac works normally:
dwc-eth-dwmac 2490000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
dwc-eth-dwmac 2490000.ethernet eth0: PHY [stmmac-0:00] driver [RTL8211F Gigabit Ethernet] (irq=141)
dwc-eth-dwmac 2490000.ethernet eth0: No Safety Features support found
dwc-eth-dwmac 2490000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
dwc-eth-dwmac 2490000.ethernet eth0: registered PTP clock
dwc-eth-dwmac 2490000.ethernet eth0: configuring for phy/rgmii-id link mode
8021q: adding VLAN 0 to HW filter on device eth0
dwc-eth-dwmac 2490000.ethernet eth0: Adding VLAN ID 0 is not supported
Link is Up - 1000/Full
dwc-eth-dwmac 2490000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
and packets can be transferred.
This clearly shows that when priv->hw->pcs is set, but
STMMAC_FLAG_HAS_INTEGRATED_PCS is clear, the driver reliably fails.
Discovering whether a platform falls into this is impossible as
parsing all the dtsi and dts files to find out which use the stmmac
driver, whether any of them use RGMII or SGMII and also depends
whether an external interface is being used. The kernel likely
doesn't contain all dts files either.
The only driver that sets this flag uses the qcom,sa8775p-ethqos
compatible, and uses SGMII or 2500BASE-X.
but these are saved from this problem by the incorrect check for
priv->dma_cap.pcs.
So, we have to assume that for every other platform that uses SGMII
with stmmac is using an external PCS.
Moreover, ethtool output can be incorrect. With the full-duplex link
negotiated, ethtool reports:
Speed: 1000Mb/s
Duplex: Half
because with dwmac4, the full-duplex bit is in bit 16 of the status,
priv->xstats.pcs_duplex becomes BIT(16) for full duplex, but the
ethtool ksettings duplex member is u8 - so becomes zero. Moreover,
the supported, advertised and link partner modes are all "not
reported".
Finally, ksettings_set() won't be able to set the advertisement on
a PHY if this PCS code is activated, which is incorrect when SGMII
is used with a PHY.
Thus, remove:
1. the incorrect netif_carrier_*() manipulation.
2. the broken ethtool ksettings code.
Given that all uses of STMMAC_FLAG_HAS_INTEGRATED_PCS are now gone,
remove the flag from stmmac.h and dwmac-qcom-ethqos.c.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../stmicro/stmmac/dwmac-qcom-ethqos.c | 4 --
.../ethernet/stmicro/stmmac/stmmac_ethtool.c | 55 -------------------
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 9 ---
include/linux/stmmac.h | 1 -
4 files changed, 69 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index d8fd4d8f6ced..f62825220cf7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -96,7 +96,6 @@ struct ethqos_emac_driver_data {
bool rgmii_config_loopback_en;
bool has_emac_ge_3;
const char *link_clk_name;
- bool has_integrated_pcs;
u32 dma_addr_width;
struct dwmac4_addrs dwmac4_addrs;
bool needs_sgmii_loopback;
@@ -282,7 +281,6 @@ static const struct ethqos_emac_driver_data emac_v4_0_0_data = {
.rgmii_config_loopback_en = false,
.has_emac_ge_3 = true,
.link_clk_name = "phyaux",
- .has_integrated_pcs = true,
.needs_sgmii_loopback = true,
.dma_addr_width = 36,
.dwmac4_addrs = {
@@ -856,8 +854,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
plat_dat->flags |= STMMAC_FLAG_TSO_EN;
if (of_device_is_compatible(np, "qcom,qcs404-ethqos"))
plat_dat->flags |= STMMAC_FLAG_RX_CLK_RUNS_IN_LPI;
- if (data->has_integrated_pcs)
- plat_dat->flags |= STMMAC_FLAG_HAS_INTEGRATED_PCS;
if (data->dma_addr_width)
plat_dat->host_dma_width = data->dma_addr_width;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index 39fa1ec92f82..d89662b48087 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -322,47 +322,6 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,
{
struct stmmac_priv *priv = netdev_priv(dev);
- if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) &&
- (priv->hw->pcs & STMMAC_PCS_RGMII ||
- priv->hw->pcs & STMMAC_PCS_SGMII)) {
- u32 supported, advertising, lp_advertising;
-
- if (!priv->xstats.pcs_link) {
- cmd->base.speed = SPEED_UNKNOWN;
- cmd->base.duplex = DUPLEX_UNKNOWN;
- return 0;
- }
- cmd->base.duplex = priv->xstats.pcs_duplex;
-
- cmd->base.speed = priv->xstats.pcs_speed;
-
- /* Encoding of PSE bits is defined in 802.3z, 37.2.1.4 */
-
- ethtool_convert_link_mode_to_legacy_u32(
- &supported, cmd->link_modes.supported);
- ethtool_convert_link_mode_to_legacy_u32(
- &advertising, cmd->link_modes.advertising);
- ethtool_convert_link_mode_to_legacy_u32(
- &lp_advertising, cmd->link_modes.lp_advertising);
-
- /* Reg49[3] always set because ANE is always supported */
- cmd->base.autoneg = ADVERTISED_Autoneg;
- supported |= SUPPORTED_Autoneg;
- advertising |= ADVERTISED_Autoneg;
- lp_advertising |= ADVERTISED_Autoneg;
-
- cmd->base.port = PORT_OTHER;
-
- ethtool_convert_legacy_u32_to_link_mode(
- cmd->link_modes.supported, supported);
- ethtool_convert_legacy_u32_to_link_mode(
- cmd->link_modes.advertising, advertising);
- ethtool_convert_legacy_u32_to_link_mode(
- cmd->link_modes.lp_advertising, lp_advertising);
-
- return 0;
- }
-
return phylink_ethtool_ksettings_get(priv->phylink, cmd);
}
@@ -372,20 +331,6 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
{
struct stmmac_priv *priv = netdev_priv(dev);
- if (!(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS) &&
- (priv->hw->pcs & STMMAC_PCS_RGMII ||
- priv->hw->pcs & STMMAC_PCS_SGMII)) {
- /* Only support ANE */
- if (cmd->base.autoneg != AUTONEG_ENABLE)
- return -EINVAL;
-
- mutex_lock(&priv->lock);
- stmmac_pcs_ctrl_ane(priv, 1, priv->hw->ps, 0);
- mutex_unlock(&priv->lock);
-
- return 0;
- }
-
return phylink_ethtool_ksettings_set(priv->phylink, cmd);
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 650d75b73e0b..87a9d36f47a9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6000,15 +6000,6 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv)
for (queue = 0; queue < queues_count; queue++)
stmmac_host_mtl_irq_status(priv, priv->hw, queue);
- /* PCS link status */
- if (priv->hw->pcs &&
- !(priv->plat->flags & STMMAC_FLAG_HAS_INTEGRATED_PCS)) {
- if (priv->xstats.pcs_link)
- netif_carrier_on(priv->dev);
- else
- netif_carrier_off(priv->dev);
- }
-
stmmac_timestamp_interrupt(priv, priv);
}
}
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index fa1318bac06c..99022620457a 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -171,7 +171,6 @@ struct dwmac4_addrs {
u32 mtl_low_cred_offset;
};
-#define STMMAC_FLAG_HAS_INTEGRATED_PCS BIT(0)
#define STMMAC_FLAG_SPH_DISABLE BIT(1)
#define STMMAC_FLAG_USE_PHY_WOL BIT(2)
#define STMMAC_FLAG_HAS_SUN8I BIT(3)
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 02/14] net: stmmac: remove xstats.pcs_* members
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 14:20 ` 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)
` (12 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
As a result of the previous commit, the pcs_link, pcs_duplex and
pcs_speed members are not used outside of the interrupt handling code,
and are only used to print their status using the misleading "Link is"
messages that bear no relation to the actual status of the link.
Remove the printing of these messages, these members, and the code
that decodes them from the hardware.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 3 --
.../ethernet/stmicro/stmmac/dwmac1000_core.c | 28 +------------------
.../net/ethernet/stmicro/stmmac/dwmac4_core.c | 28 +------------------
3 files changed, 2 insertions(+), 57 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 8f34c9ad457f..33aeac5666f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -192,9 +192,6 @@ struct stmmac_extra_stats {
unsigned long irq_pcs_ane_n;
unsigned long irq_pcs_link_n;
unsigned long irq_rgmii_n;
- unsigned long pcs_link;
- unsigned long pcs_duplex;
- unsigned long pcs_speed;
/* debug register */
unsigned long mtl_tx_status_fifo_full;
unsigned long mtl_tx_fifo_not_empty;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index fe776ddf6889..2c5ee59c3208 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -266,34 +266,8 @@ static void dwmac1000_pmt(struct mac_device_info *hw, unsigned long mode)
/* RGMII or SMII interface */
static void dwmac1000_rgsmii(void __iomem *ioaddr, struct stmmac_extra_stats *x)
{
- u32 status;
-
- status = readl(ioaddr + GMAC_RGSMIIIS);
+ readl(ioaddr + GMAC_RGSMIIIS);
x->irq_rgmii_n++;
-
- /* Check the link status */
- if (status & GMAC_RGSMIIIS_LNKSTS) {
- int speed_value;
-
- x->pcs_link = 1;
-
- speed_value = ((status & GMAC_RGSMIIIS_SPEED) >>
- GMAC_RGSMIIIS_SPEED_SHIFT);
- if (speed_value == GMAC_RGSMIIIS_SPEED_125)
- x->pcs_speed = SPEED_1000;
- else if (speed_value == GMAC_RGSMIIIS_SPEED_25)
- x->pcs_speed = SPEED_100;
- else
- x->pcs_speed = SPEED_10;
-
- x->pcs_duplex = (status & GMAC_RGSMIIIS_LNKMOD_MASK);
-
- pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed,
- x->pcs_duplex ? "Full" : "Half");
- } else {
- x->pcs_link = 0;
- pr_info("Link is Down\n");
- }
}
static int dwmac1000_irq_status(struct mac_device_info *hw,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index d85bc0bb5c3c..8a19df7b0577 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -592,34 +592,8 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral,
/* RGMII or SMII interface */
static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
{
- u32 status;
-
- status = readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS);
+ readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS);
x->irq_rgmii_n++;
-
- /* Check the link status */
- if (status & GMAC_PHYIF_CTRLSTATUS_LNKSTS) {
- int speed_value;
-
- x->pcs_link = 1;
-
- speed_value = ((status & GMAC_PHYIF_CTRLSTATUS_SPEED) >>
- GMAC_PHYIF_CTRLSTATUS_SPEED_SHIFT);
- if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_125)
- x->pcs_speed = SPEED_1000;
- else if (speed_value == GMAC_PHYIF_CTRLSTATUS_SPEED_25)
- x->pcs_speed = SPEED_100;
- else
- x->pcs_speed = SPEED_10;
-
- x->pcs_duplex = (status & GMAC_PHYIF_CTRLSTATUS_LNKMOD);
-
- pr_info("Link is Up - %d/%s\n", (int)x->pcs_speed,
- x->pcs_duplex ? "Full" : "Half");
- } else {
- x->pcs_link = 0;
- pr_info("Link is Down\n");
- }
}
static int dwmac4_irq_mtl_status(struct stmmac_priv *priv,
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling
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 14:20 ` [PATCH net-next 02/14] net: stmmac: remove xstats.pcs_* members Russell King (Oracle)
@ 2025-10-15 14:20 ` Russell King (Oracle)
2025-10-15 20:47 ` Andrew Lunn
2025-10-15 21:35 ` Andrew Lunn
2025-10-15 14:20 ` [PATCH net-next 04/14] net: stmmac: remove PCS "mode" pause handling Russell King (Oracle)
` (11 subsequent siblings)
14 siblings, 2 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Now that the only use for the interrupt is to clear it and increment a
statistic counter (which is not that relevant anymore) remove all this
code and ensure that the interrupt remains disabled to avoid a stuck
interrupt.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 6 +++---
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 10 ----------
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 3 +--
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 ---------
4 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
index 0c011a47d5a3..8f3002d9de78 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
@@ -38,10 +38,10 @@
#define GMAC_INT_DISABLE_PCSAN BIT(2)
#define GMAC_INT_DISABLE_PMT BIT(3)
#define GMAC_INT_DISABLE_TIMESTAMP BIT(9)
-#define GMAC_INT_DISABLE_PCS (GMAC_INT_DISABLE_RGMII | \
- GMAC_INT_DISABLE_PCSLINK | \
+#define GMAC_INT_DISABLE_PCS (GMAC_INT_DISABLE_PCSLINK | \
GMAC_INT_DISABLE_PCSAN)
-#define GMAC_INT_DEFAULT_MASK (GMAC_INT_DISABLE_TIMESTAMP | \
+#define GMAC_INT_DEFAULT_MASK (GMAC_INT_DISABLE_RGMII | \
+ GMAC_INT_DISABLE_TIMESTAMP | \
GMAC_INT_DISABLE_PCS)
/* PMT Control and Status */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 2c5ee59c3208..654331b411f4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -263,13 +263,6 @@ static void dwmac1000_pmt(struct mac_device_info *hw, unsigned long mode)
writel(pmt, ioaddr + GMAC_PMT);
}
-/* RGMII or SMII interface */
-static void dwmac1000_rgsmii(void __iomem *ioaddr, struct stmmac_extra_stats *x)
-{
- readl(ioaddr + GMAC_RGSMIIIS);
- x->irq_rgmii_n++;
-}
-
static int dwmac1000_irq_status(struct mac_device_info *hw,
struct stmmac_extra_stats *x)
{
@@ -311,9 +304,6 @@ static int dwmac1000_irq_status(struct mac_device_info *hw,
dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x);
- if (intr_status & PCS_RGSMIIIS_IRQ)
- dwmac1000_rgsmii(ioaddr, x);
-
return ret;
}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 3dec1a264cf6..6dd84b6544cc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -106,8 +106,7 @@
#define GMAC_INT_LPI_EN BIT(5)
#define GMAC_INT_TSIE BIT(12)
-#define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_RGSMIIS | GMAC_INT_PCS_LINK | \
- GMAC_INT_PCS_ANE)
+#define GMAC_PCS_IRQ_DEFAULT (GMAC_INT_PCS_LINK | GMAC_INT_PCS_ANE)
#define GMAC_INT_DEFAULT_ENABLE (GMAC_INT_PMT_EN | GMAC_INT_LPI_EN | \
GMAC_INT_TSIE)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 8a19df7b0577..bff4c371c1d2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -589,13 +589,6 @@ static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral,
dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback);
}
-/* RGMII or SMII interface */
-static void dwmac4_phystatus(void __iomem *ioaddr, struct stmmac_extra_stats *x)
-{
- readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS);
- x->irq_rgmii_n++;
-}
-
static int dwmac4_irq_mtl_status(struct stmmac_priv *priv,
struct mac_device_info *hw, u32 chan)
{
@@ -667,8 +660,6 @@ static int dwmac4_irq_status(struct mac_device_info *hw,
}
dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x);
- if (intr_status & PCS_RGSMIIIS_IRQ)
- dwmac4_phystatus(ioaddr, x);
return ret;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 04/14] net: stmmac: remove PCS "mode" pause handling
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (2 preceding siblings ...)
2025-10-15 14:20 ` [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling Russell King (Oracle)
@ 2025-10-15 14:20 ` 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)
` (10 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Remove the "we always autoneg pause" forcing when the stmmac driver
decides that a "PCS" is present, which blocks passing the ethtool
pause calls to phylink when using SGMII mode.
This prevents the pause results being reported when a PHY is attached
using SGMII mode, or the pause settings being changed in SGMII mode.
There is no reason to prevent this.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index d89662b48087..c60cd948311e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -424,11 +424,7 @@ stmmac_get_pauseparam(struct net_device *netdev,
{
struct stmmac_priv *priv = netdev_priv(netdev);
- if (priv->hw->pcs) {
- pause->autoneg = 1;
- } else {
- phylink_ethtool_get_pauseparam(priv->phylink, pause);
- }
+ phylink_ethtool_get_pauseparam(priv->phylink, pause);
}
static int
@@ -437,12 +433,7 @@ stmmac_set_pauseparam(struct net_device *netdev,
{
struct stmmac_priv *priv = netdev_priv(netdev);
- if (priv->hw->pcs) {
- pause->autoneg = 1;
- return 0;
- } else {
- return phylink_ethtool_set_pauseparam(priv->phylink, pause);
- }
+ return phylink_ethtool_set_pauseparam(priv->phylink, pause);
}
static u64 stmmac_get_rx_normal_irq_n(struct stmmac_priv *priv, int q)
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 05/14] net: stmmac: remove unused PCS loopback support
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (3 preceding siblings ...)
2025-10-15 14:20 ` [PATCH net-next 04/14] net: stmmac: remove PCS "mode" pause handling Russell King (Oracle)
@ 2025-10-15 14:20 ` 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)
` (9 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Nothing calls stmmac_pcs_ctrl_ane() with the "loopback" argument set to
anything except zero, so this serves no useful purpose. Remove the
argument to reduce the code complexity.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 4 ++--
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 5 ++---
drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 ++--
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h | 6 +-----
6 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index f62825220cf7..32244217d952 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -622,7 +622,7 @@ static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed)
static void ethqos_pcs_set_inband(struct stmmac_priv *priv, bool enable)
{
- stmmac_pcs_ctrl_ane(priv, enable, 0, 0);
+ stmmac_pcs_ctrl_ane(priv, enable, 0);
}
/* On interface toggle MAC registers gets reset.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 654331b411f4..5c653be3d453 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -358,9 +358,9 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw)
}
static void dwmac1000_ctrl_ane(struct stmmac_priv *priv, bool ane,
- bool srgmi_ral, bool loopback)
+ bool srgmi_ral)
{
- dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback);
+ dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral);
}
static void dwmac1000_debug(struct stmmac_priv *priv, void __iomem *ioaddr,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index bff4c371c1d2..21e4461db937 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -583,10 +583,9 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
}
}
-static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral,
- bool loopback)
+static void dwmac4_ctrl_ane(struct stmmac_priv *priv, bool ane, bool srgmi_ral)
{
- dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral, loopback);
+ dwmac_ctrl_ane(priv->ioaddr, GMAC_PCS_BASE, ane, srgmi_ral);
}
static int dwmac4_irq_mtl_status(struct stmmac_priv *priv,
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 14dbe0685997..7796f5f3c96f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -374,8 +374,8 @@ struct stmmac_ops {
struct stmmac_extra_stats *x, u32 rx_queues,
u32 tx_queues);
/* PCS calls */
- void (*pcs_ctrl_ane)(struct stmmac_priv *priv, bool ane, bool srgmi_ral,
- bool loopback);
+ void (*pcs_ctrl_ane)(struct stmmac_priv *priv, bool ane,
+ bool srgmi_ral);
/* Safety Features */
int (*safety_feat_config)(void __iomem *ioaddr, unsigned int asp,
struct stmmac_safety_feature_cfg *safety_cfg);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 87a9d36f47a9..6252e30ff82d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3493,7 +3493,7 @@ static int stmmac_hw_setup(struct net_device *dev)
}
if (priv->hw->pcs)
- stmmac_pcs_ctrl_ane(priv, 1, priv->hw->ps, 0);
+ stmmac_pcs_ctrl_ane(priv, 1, priv->hw->ps);
/* set TX and RX rings length */
stmmac_set_rings_length(priv);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index 4a684c97dfae..5778f5b2f313 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -82,13 +82,12 @@ static inline void dwmac_pcs_isr(void __iomem *ioaddr, u32 reg,
* @reg: Base address of the AN Control Register.
* @ane: to enable the auto-negotiation
* @srgmi_ral: to manage MAC-2-MAC SGMII connections.
- * @loopback: to cause the PHY to loopback tx data into rx path.
* Description: this is the main function to configure the AN control register
* and init the ANE, select loopback (usually for debugging purpose) and
* configure SGMII RAL.
*/
static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane,
- bool srgmi_ral, bool loopback)
+ bool srgmi_ral)
{
u32 value = readl(ioaddr + GMAC_AN_CTRL(reg));
@@ -104,9 +103,6 @@ static inline void dwmac_ctrl_ane(void __iomem *ioaddr, u32 reg, bool ane,
if (srgmi_ral)
value |= GMAC_AN_CTRL_SGMRAL;
- if (loopback)
- value |= GMAC_AN_CTRL_ELE;
-
writel(value, ioaddr + GMAC_AN_CTRL(reg));
}
#endif /* __STMMAC_PCS_H__ */
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 06/14] net: stmmac: remove hw->ps xxx_core_init() hardware setup
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (4 preceding siblings ...)
2025-10-15 14:20 ` [PATCH net-next 05/14] net: stmmac: remove unused PCS loopback support Russell King (Oracle)
@ 2025-10-15 14:20 ` Russell King (Oracle)
2025-10-15 14:20 ` [PATCH net-next 07/14] net: stmmac: remove RGMII "pcs" mode Russell King (Oracle)
` (8 subsequent siblings)
14 siblings, 0 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
After a lot of digging, it seems that the oddly named hw->ps member is
all about configuring the core for reverse SGMII. This member is set to
one of 0, SPEED_10, SPEED_100 or SPEED_1000 depending on
priv->plat->mac_port_sel_speed. On DT systems, this comes from the
"snps,ps-speed" DT property.
When set to a non-zero value, it:
1. Configures the MAC at initialisation time to operate at a specific
speed. However, this will be overwritten by mac_link_up() when the
link comes up (e.g. with the fixed-link parameters.)
Note that dwxgmac2 wants to also support SPEED_2500 and SPEED_10000,
but both these values are impossible.
2. It _incorrectly_ enables the transmitter (GMAC_CONFIG_TE) which
makes no sense, rather than enabling the "transmit configuration"
bit (GMAC_CONFIG_TC). Likely a typo.
3. It configures the SGMII rate adapter layer to retrieve its speed
setting from the MAC configuration register rather than the PHY.
There are two ways forward here:
a) fixing (2) so that we set GMAC_CONFIG_TC. However, we have platform
that set the "snps,ps-speed" property and that work today. Fixing
this will cause the RGMII, SGMII or SMII inband configuration to be
transmitted, which will be a functional change which could cause a
regression.
b) ripping out (1) and (2) as they are ineffective. This also has the
possibility of regressions, but the patch author believes this risk
is much lower than (a).
Therefore, this commit takes the approach in (b).
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../ethernet/stmicro/stmmac/dwmac1000_core.c | 23 +++--------------
.../net/ethernet/stmicro/stmmac/dwmac4_core.c | 24 +++---------------
.../ethernet/stmicro/stmmac/dwxgmac2_core.c | 25 ++-----------------
3 files changed, 8 insertions(+), 64 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index 5c653be3d453..d35db8958be1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -26,35 +26,18 @@ static void dwmac1000_core_init(struct mac_device_info *hw,
struct net_device *dev)
{
void __iomem *ioaddr = hw->pcsr;
- u32 value = readl(ioaddr + GMAC_CONTROL);
int mtu = dev->mtu;
+ u32 value;
/* Configure GMAC core */
- value |= GMAC_CORE_INIT;
+ value = readl(ioaddr + GMAC_CONTROL);
if (mtu > 1500)
value |= GMAC_CONTROL_2K;
if (mtu > 2000)
value |= GMAC_CONTROL_JE;
- if (hw->ps) {
- value |= GMAC_CONTROL_TE;
-
- value &= ~hw->link.speed_mask;
- switch (hw->ps) {
- case SPEED_1000:
- value |= hw->link.speed1000;
- break;
- case SPEED_100:
- value |= hw->link.speed100;
- break;
- case SPEED_10:
- value |= hw->link.speed10;
- break;
- }
- }
-
- writel(value, ioaddr + GMAC_CONTROL);
+ writel(value | GMAC_CORE_INIT, ioaddr + GMAC_CONTROL);
/* Mask GMAC interrupts */
value = GMAC_INT_DEFAULT_MASK;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 21e4461db937..d855ab6b9145 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -27,29 +27,11 @@ static void dwmac4_core_init(struct mac_device_info *hw,
{
struct stmmac_priv *priv = netdev_priv(dev);
void __iomem *ioaddr = hw->pcsr;
- u32 value = readl(ioaddr + GMAC_CONFIG);
unsigned long clk_rate;
+ u32 value;
- value |= GMAC_CORE_INIT;
-
- if (hw->ps) {
- value |= GMAC_CONFIG_TE;
-
- value &= hw->link.speed_mask;
- switch (hw->ps) {
- case SPEED_1000:
- value |= hw->link.speed1000;
- break;
- case SPEED_100:
- value |= hw->link.speed100;
- break;
- case SPEED_10:
- value |= hw->link.speed10;
- break;
- }
- }
-
- writel(value, ioaddr + GMAC_CONFIG);
+ value = readl(ioaddr + GMAC_CONFIG);
+ writel(value | GMAC_CORE_INIT, ioaddr + GMAC_CONFIG);
/* Configure LPI 1us counter to number of CSR clock ticks in 1us - 1 */
clk_rate = clk_get_rate(priv->plat->stmmac_clk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
index 00e929bf280b..0430af27da40 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -23,29 +23,8 @@ static void dwxgmac2_core_init(struct mac_device_info *hw,
tx = readl(ioaddr + XGMAC_TX_CONFIG);
rx = readl(ioaddr + XGMAC_RX_CONFIG);
- tx |= XGMAC_CORE_INIT_TX;
- rx |= XGMAC_CORE_INIT_RX;
-
- if (hw->ps) {
- tx |= XGMAC_CONFIG_TE;
- tx &= ~hw->link.speed_mask;
-
- switch (hw->ps) {
- case SPEED_10000:
- tx |= hw->link.xgmii.speed10000;
- break;
- case SPEED_2500:
- tx |= hw->link.speed2500;
- break;
- case SPEED_1000:
- default:
- tx |= hw->link.speed1000;
- break;
- }
- }
-
- writel(tx, ioaddr + XGMAC_TX_CONFIG);
- writel(rx, ioaddr + XGMAC_RX_CONFIG);
+ writel(tx | XGMAC_CORE_INIT_TX, ioaddr + XGMAC_TX_CONFIG);
+ writel(rx | XGMAC_CORE_INIT_RX, ioaddr + XGMAC_RX_CONFIG);
writel(XGMAC_INT_DEFAULT_EN, ioaddr + XGMAC_INT_EN);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 07/14] net: stmmac: remove RGMII "pcs" mode
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (5 preceding siblings ...)
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 ` 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)
` (7 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Remove the RGMII "pcs" code in stmmac_check_pcs_mode() due to:
1) This should never have been conditional on a PCS being present, as
when a core is synthesised using only RGMII, the PCS won't be present
and priv->dma_cap.pcs will be false. Only multi-interface cores which
have a PCS present would have detected RGMII.
2) STMMAC_PCS_RGMII has no effect since the broken netif_carrier and
ethtool code was removed.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 1 -
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++-----------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 33aeac5666f4..ed5e207ffdba 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -270,7 +270,6 @@ struct stmmac_safety_stats {
#define FLOW_AUTO (FLOW_TX | FLOW_RX)
/* PCS defines */
-#define STMMAC_PCS_RGMII (1 << 0)
#define STMMAC_PCS_SGMII (1 << 1)
#define SF_DMA_MODE 1 /* DMA STORE-AND-FORWARD Operation Mode */
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6252e30ff82d..d440b1c2b7ff 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1087,17 +1087,9 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
{
int interface = priv->plat->phy_interface;
- if (priv->dma_cap.pcs) {
- if ((interface == PHY_INTERFACE_MODE_RGMII) ||
- (interface == PHY_INTERFACE_MODE_RGMII_ID) ||
- (interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
- (interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
- netdev_dbg(priv->dev, "PCS RGMII support enabled\n");
- priv->hw->pcs = STMMAC_PCS_RGMII;
- } else if (interface == PHY_INTERFACE_MODE_SGMII) {
- netdev_dbg(priv->dev, "PCS SGMII support enabled\n");
- priv->hw->pcs = STMMAC_PCS_SGMII;
- }
+ if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) {
+ netdev_dbg(priv->dev, "PCS SGMII support enabled\n");
+ priv->hw->pcs = STMMAC_PCS_SGMII;
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 08/14] net: stmmac: move reverse-"pcs" mode setup to stmmac_check_pcs_mode()
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (6 preceding siblings ...)
2025-10-15 14:20 ` [PATCH net-next 07/14] net: stmmac: remove RGMII "pcs" mode Russell King (Oracle)
@ 2025-10-15 14:20 ` 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)
` (6 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
The broken reverse-mode, selected by snps,ps-speed, is configured when
the platform provides a valid port speed and a PCS is being used.
Both these remain constant after the driver has probed, so the software
state doesn't need to be re-initialised each time stmmac_hw_setup() is
called (which is called at open and resume time.)
Move the software setup of reverse-mode to stmmac_check_pcs_mode()
which is called from the driver probe function.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d440b1c2b7ff..013a2f3684c7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1091,6 +1091,19 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
netdev_dbg(priv->dev, "PCS SGMII support enabled\n");
priv->hw->pcs = STMMAC_PCS_SGMII;
}
+
+ /* PS and related bits will be programmed according to the speed */
+ if (priv->hw->pcs) {
+ int speed = priv->plat->mac_port_sel_speed;
+
+ if ((speed == SPEED_10) || (speed == SPEED_100) ||
+ (speed == SPEED_1000)) {
+ priv->hw->ps = speed;
+ } else {
+ dev_warn(priv->device, "invalid port speed\n");
+ priv->hw->ps = 0;
+ }
+ }
}
/**
@@ -3435,19 +3448,6 @@ static int stmmac_hw_setup(struct net_device *dev)
stmmac_set_umac_addr(priv, priv->hw, dev->dev_addr, 0);
phylink_rx_clk_stop_unblock(priv->phylink);
- /* PS and related bits will be programmed according to the speed */
- if (priv->hw->pcs) {
- int speed = priv->plat->mac_port_sel_speed;
-
- if ((speed == SPEED_10) || (speed == SPEED_100) ||
- (speed == SPEED_1000)) {
- priv->hw->ps = speed;
- } else {
- dev_warn(priv->device, "invalid port speed\n");
- priv->hw->ps = 0;
- }
- }
-
/* Initialize the MAC Core */
stmmac_core_init(priv, priv->hw, dev);
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 09/14] net: stmmac: simplify stmmac_check_pcs_mode()
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (7 preceding siblings ...)
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 14:20 ` 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)
` (5 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
Now that we only support one mode, simplify stmmac_check_pcs_mode().
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 013a2f3684c7..611197cfa34f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1086,22 +1086,23 @@ static const struct phylink_mac_ops stmmac_phylink_mac_ops = {
static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
{
int interface = priv->plat->phy_interface;
+ int speed = priv->plat->mac_port_sel_speed;
if (priv->dma_cap.pcs && interface == PHY_INTERFACE_MODE_SGMII) {
netdev_dbg(priv->dev, "PCS SGMII support enabled\n");
priv->hw->pcs = STMMAC_PCS_SGMII;
- }
-
- /* PS and related bits will be programmed according to the speed */
- if (priv->hw->pcs) {
- int speed = priv->plat->mac_port_sel_speed;
- if ((speed == SPEED_10) || (speed == SPEED_100) ||
- (speed == SPEED_1000)) {
+ switch (speed) {
+ case SPEED_10:
+ case SPEED_100:
+ case SPEED_1000:
priv->hw->ps = speed;
- } else {
+ break;
+
+ default:
dev_warn(priv->device, "invalid port speed\n");
priv->hw->ps = 0;
+ break;
}
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 10/14] net: stmmac: hw->ps becomes hw->reverse_sgmii_enable
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (8 preceding siblings ...)
2025-10-15 14:20 ` [PATCH net-next 09/14] net: stmmac: simplify stmmac_check_pcs_mode() Russell King (Oracle)
@ 2025-10-15 14:20 ` 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)
` (4 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
After a lot of digging, it seems that the oddly named hw->ps member
is all about setting the core into reverse SGMII speed. When set to
a non-zero value, it:
1. Configures the MAC at initialisation time to operate at a specific
speed.
2. It _incorrectly_ enables the transmitter (GMAC_CONFIG_TE) which
makes no sense, rather than enabling the "transmit configuration"
bit (GMAC_CONFIG_TC).
3. It configures the SGMII rate adapter layer to retrieve its speed
setting from the MAC configuration register rather than the PHY.
In the previous commit, we removed (1) and (2) as phylink overwrites
the configuration set at that step.
Thus, the only functional aspect is (3), which is a boolean operation.
This means there is no need to store the actual speed, and just have a
boolean flag.
Convert the priv->ps member to a boolean, and rename it to
priv->reverse_sgmii_enable to make it more understandable.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index ed5e207ffdba..fee7021246b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -599,13 +599,13 @@ struct mac_device_info {
unsigned int mcast_bits_log2;
unsigned int rx_csum;
unsigned int pcs;
- unsigned int ps;
unsigned int xlgmac;
unsigned int num_vlan;
u32 vlan_filter[32];
bool vlan_fail_q_en;
u8 vlan_fail_q;
bool hw_vlan_en;
+ bool reverse_sgmii_enable;
};
struct stmmac_rx_routing {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 611197cfa34f..8f08366c25a4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1096,12 +1096,12 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
case SPEED_10:
case SPEED_100:
case SPEED_1000:
- priv->hw->ps = speed;
+ priv->hw->reverse_sgmii_enable = true;
break;
default:
dev_warn(priv->device, "invalid port speed\n");
- priv->hw->ps = 0;
+ priv->hw->reverse_sgmii_enable = false;
break;
}
}
@@ -3486,7 +3486,7 @@ static int stmmac_hw_setup(struct net_device *dev)
}
if (priv->hw->pcs)
- stmmac_pcs_ctrl_ane(priv, 1, priv->hw->ps);
+ stmmac_pcs_ctrl_ane(priv, 1, priv->hw->reverse_sgmii_enable);
/* set TX and RX rings length */
stmmac_set_rings_length(priv);
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (9 preceding siblings ...)
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 14:20 ` Russell King (Oracle)
2025-10-15 21:00 ` Andrew Lunn
2025-10-15 21:26 ` Andrew Lunn
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)
` (3 subsequent siblings)
14 siblings, 2 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
SGMII mode does not require port-speed to be specified; this only
switches SGMII to use the MAC configuration register speed settings
and the actual value is irrelevant when the link comes up.
As it seems the intention was to support "reverse SGMII" with this
setting, but the code didn't actually configure that due to a typo,
the warning and bad DT binding documentation has led people to
specify snps,ps-speed in their DT files inappropriately.
If mac_port_sel_speed is zero, then don't complain that the speed
is invalid, as this means we're using "normal" SGMII.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 8f08366c25a4..79d09b40dbcc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1101,6 +1101,8 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
default:
dev_warn(priv->device, "invalid port speed\n");
+ fallthrough;
+ case 0:
priv->hw->reverse_sgmii_enable = false;
break;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 12/14] net: stmmac: only call stmmac_pcs_ctrl_ane() for integrated SGMII PCS
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (10 preceding siblings ...)
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 14:20 ` 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)
` (2 subsequent siblings)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:20 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
The internal PCS registers only exist if the core is synthesized with
SGMII, TBI or RTBI support. They have no relevance for RGMII.
However, priv->hw->pcs contains a STMMAC_PCS_RGMII flag, which is set
if a PCS has been synthesized but we are operating in RGMII mode. As
the register has no effect for RGMII, there is no point calling
stmmac_pcs_ctrl_ane() in this case. Add a comment describing this
and make it conditional on STMMAC_PCS_SGMII.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 79d09b40dbcc..c3633baf5180 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3487,7 +3487,11 @@ static int stmmac_hw_setup(struct net_device *dev)
}
}
- if (priv->hw->pcs)
+ /* The PCS control register is only relevant for SGMII, TBI and RTBI
+ * modes. We no longer support TBI or RTBI, so only configure this
+ * register when operating in SGMII mode with the integrated PCS.
+ */
+ if (priv->hw->pcs & STMMAC_PCS_SGMII)
stmmac_pcs_ctrl_ane(priv, 1, priv->hw->reverse_sgmii_enable);
/* set TX and RX rings length */
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 13/14] net: stmmac: provide PCS initialisation hook
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (11 preceding siblings ...)
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 14:21 ` Russell King (Oracle)
2025-10-15 21:11 ` Andrew Lunn
2025-10-15 14:21 ` [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support Russell King (Oracle)
2025-10-15 15:10 ` [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:21 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
dwmac cores provide a feature bit to indicate when the PCS block is
present, but features are only read after the core's setup() function
has been called, meaning we can't decide whether to initialise the
integrated PCS in the setup function. Provide a new MAC core hook
for PCS initialisation, which will be called after the feature
registers have been read.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/hwif.h | 4 ++++
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index 7796f5f3c96f..82cfb6bec334 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -313,6 +313,8 @@ enum stmmac_lpi_mode {
/* Helpers to program the MAC core */
struct stmmac_ops {
+ /* Initialise any PCS instances */
+ int (*pcs_init)(struct stmmac_priv *priv);
/* MAC core initialization */
void (*core_init)(struct mac_device_info *hw, struct net_device *dev);
/* Update MAC capabilities */
@@ -413,6 +415,8 @@ struct stmmac_ops {
u32 pclass);
};
+#define stmmac_mac_pcs_init(__priv) \
+ stmmac_do_callback(__priv, mac, pcs_init, __priv)
#define stmmac_core_init(__priv, __args...) \
stmmac_do_void_callback(__priv, mac, core_init, __args)
#define stmmac_mac_update_caps(__priv) \
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c3633baf5180..35cd881b3496 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -7238,6 +7238,13 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
"Enable RX Mitigation via HW Watchdog Timer\n");
}
+ /* Unimplemented PCS init (as indicated by stmmac_do_callback()
+ * perversely returning -EINVAL) is non-fatal.
+ */
+ ret = stmmac_mac_pcs_init(priv);
+ if (ret != -EINVAL)
+ return ret;
+
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (12 preceding siblings ...)
2025-10-15 14:21 ` [PATCH net-next 13/14] net: stmmac: provide PCS initialisation hook Russell King (Oracle)
@ 2025-10-15 14:21 ` Russell King (Oracle)
2025-10-15 21:31 ` Andrew Lunn
2025-10-15 15:10 ` [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 14:21 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
Now that stmmac's PCS support is much more simple - just a matter of
configuring the control register - the basic conversion to phylink PCS
support becomes straight forward.
Create the infrastructure to setup a phylink_pcs instance for the
integrated PCS:
- add a struct stmmac_pcs to encapsulate the phylink_pcs structure,
pointer to stmmac_priv, and the core-specific base address of the PCS
registers.
- modify stmmac_priv and stmmac_mac_select_pcs() to return the embedded
phylink_pcs structure when setup and STMMAC_PCS_SGMII is in use, and
move the comment from stmmac_hw_setup() to here.
- create stmmac_pcs.c, which contains the phylink_pcs_ops structure, a
dummy .pcs_get_state() method which always reports link-down, and
.pcs_config() method, moving the call to stmmac_pcs_ctrl_ane() here,
but without indirecting through the dwmac specific core code.
This will ensure that the PCS control register is configured to the
same settings as before, but will now happen when the netdev is opened
or reusmed rather than only during probe time. However, this will be
before the .fix_mac_speed() method is called, which is critical for the
behaviour in dwmac-qcom-ethqos's ethqos_configure_sgmii() function to
be maintained.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +-
.../ethernet/stmicro/stmmac/dwmac1000_core.c | 9 ++++
.../net/ethernet/stmicro/stmmac/dwmac4_core.c | 11 +++++
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 4 ++
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++---
.../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 47 +++++++++++++++++++
.../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 17 +++++++
7 files changed, 97 insertions(+), 8 deletions(-)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 51e068e26ce4..11c0ba2ccdb1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -7,7 +7,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \
stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \
stmmac_xdp.o stmmac_est.o stmmac_fpe.o stmmac_vlan.o \
- $(stmmac-y)
+ stmmac_pcs.o $(stmmac-y)
stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index d35db8958be1..571e48362444 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -22,6 +22,14 @@
#include "stmmac_ptp.h"
#include "dwmac1000.h"
+static int dwmac1000_pcs_init(struct stmmac_priv *priv)
+{
+ if (!priv->dma_cap.pcs)
+ return 0;
+
+ return stmmac_integrated_pcs_init(priv, GMAC_PCS_BASE);
+}
+
static void dwmac1000_core_init(struct mac_device_info *hw,
struct net_device *dev)
{
@@ -435,6 +443,7 @@ static void dwmac1000_set_mac_loopback(void __iomem *ioaddr, bool enable)
}
const struct stmmac_ops dwmac1000_ops = {
+ .pcs_init = dwmac1000_pcs_init,
.core_init = dwmac1000_core_init,
.set_mac = stmmac_set_mac,
.rx_ipc = dwmac1000_rx_ipc_enable,
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index d855ab6b9145..0b785389b7ef 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -22,6 +22,14 @@
#include "dwmac4.h"
#include "dwmac5.h"
+static int dwmac4_pcs_init(struct stmmac_priv *priv)
+{
+ if (!priv->dma_cap.pcs)
+ return 0;
+
+ return stmmac_integrated_pcs_init(priv, GMAC_PCS_BASE);
+}
+
static void dwmac4_core_init(struct mac_device_info *hw,
struct net_device *dev)
{
@@ -875,6 +883,7 @@ static int dwmac4_config_l4_filter(struct mac_device_info *hw, u32 filter_no,
}
const struct stmmac_ops dwmac4_ops = {
+ .pcs_init = dwmac4_pcs_init,
.core_init = dwmac4_core_init,
.update_caps = dwmac4_update_caps,
.set_mac = stmmac_set_mac,
@@ -909,6 +918,7 @@ const struct stmmac_ops dwmac4_ops = {
};
const struct stmmac_ops dwmac410_ops = {
+ .pcs_init = dwmac4_pcs_init,
.core_init = dwmac4_core_init,
.update_caps = dwmac4_update_caps,
.set_mac = stmmac_dwmac4_set_mac,
@@ -945,6 +955,7 @@ const struct stmmac_ops dwmac410_ops = {
};
const struct stmmac_ops dwmac510_ops = {
+ .pcs_init = dwmac4_pcs_init,
.core_init = dwmac4_core_init,
.update_caps = dwmac4_update_caps,
.set_mac = stmmac_dwmac4_set_mac,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 7ca5477be390..34f62993a4da 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -25,6 +25,8 @@
#include <net/xdp.h>
#include <uapi/linux/bpf.h>
+struct stmmac_pcs;
+
struct stmmac_resources {
void __iomem *addr;
u8 mac[ETH_ALEN];
@@ -273,6 +275,8 @@ struct stmmac_priv {
unsigned int pause_time;
struct mii_bus *mii;
+ struct stmmac_pcs *integrated_pcs;
+
struct phylink_config phylink_config;
struct phylink *phylink;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 35cd881b3496..b2c23ace49b6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -46,6 +46,7 @@
#include "stmmac_ptp.h"
#include "stmmac_fpe.h"
#include "stmmac.h"
+#include "stmmac_pcs.h"
#include "stmmac_xdp.h"
#include <linux/reset.h>
#include <linux/of_mdio.h>
@@ -850,6 +851,13 @@ static struct phylink_pcs *stmmac_mac_select_pcs(struct phylink_config *config,
return pcs;
}
+ /* The PCS control register is only relevant for SGMII, TBI and RTBI
+ * modes. We no longer support TBI or RTBI, so only configure this
+ * register when operating in SGMII mode with the integrated PCS.
+ */
+ if (priv->hw->pcs & STMMAC_PCS_SGMII && priv->integrated_pcs)
+ return &priv->integrated_pcs->pcs;
+
return NULL;
}
@@ -3487,13 +3495,6 @@ static int stmmac_hw_setup(struct net_device *dev)
}
}
- /* The PCS control register is only relevant for SGMII, TBI and RTBI
- * modes. We no longer support TBI or RTBI, so only configure this
- * register when operating in SGMII mode with the integrated PCS.
- */
- if (priv->hw->pcs & STMMAC_PCS_SGMII)
- stmmac_pcs_ctrl_ane(priv, 1, priv->hw->reverse_sgmii_enable);
-
/* set TX and RX rings length */
stmmac_set_rings_length(priv);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
new file mode 100644
index 000000000000..50ea51d7a1cc
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include "stmmac.h"
+#include "stmmac_pcs.h"
+
+static void dwmac_integrated_pcs_get_state(struct phylink_pcs *pcs,
+ unsigned int neg_mode,
+ struct phylink_link_state *state)
+{
+ state->link = false;
+}
+
+static int dwmac_integrated_pcs_config(struct phylink_pcs *pcs,
+ unsigned int neg_mode,
+ phy_interface_t interface,
+ const unsigned long *advertising,
+ bool permit_pause_to_mac)
+{
+ struct stmmac_pcs *spcs = phylink_pcs_to_stmmac_pcs(pcs);
+
+ dwmac_ctrl_ane(spcs->base, 0, 1, spcs->priv->hw->reverse_sgmii_enable);
+
+ return 0;
+}
+
+static const struct phylink_pcs_ops dwmac_integrated_pcs_ops = {
+ .pcs_get_state = dwmac_integrated_pcs_get_state,
+ .pcs_config = dwmac_integrated_pcs_config,
+};
+
+int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset)
+{
+ struct stmmac_pcs *spcs;
+
+ spcs = devm_kzalloc(priv->device, sizeof(*spcs), GFP_KERNEL);
+ if (!spcs)
+ return -ENOMEM;
+
+ spcs->priv = priv;
+ spcs->base = priv->ioaddr + offset;
+ spcs->pcs.ops = &dwmac_integrated_pcs_ops;
+
+ __set_bit(PHY_INTERFACE_MODE_SGMII, spcs->pcs.supported_interfaces);
+
+ priv->integrated_pcs = spcs;
+
+ return 0;
+}
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
index 5778f5b2f313..64397ac8ecab 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h
@@ -9,6 +9,7 @@
#ifndef __STMMAC_PCS_H__
#define __STMMAC_PCS_H__
+#include <linux/phylink.h>
#include <linux/slab.h>
#include <linux/io.h>
#include "common.h"
@@ -46,6 +47,22 @@
#define GMAC_ANE_RFE_SHIFT 12
#define GMAC_ANE_ACK BIT(14)
+struct stmmac_priv;
+
+struct stmmac_pcs {
+ struct stmmac_priv *priv;
+ void __iomem *base;
+ struct phylink_pcs pcs;
+};
+
+static inline struct stmmac_pcs *
+phylink_pcs_to_stmmac_pcs(struct phylink_pcs *pcs)
+{
+ return container_of(pcs, struct stmmac_pcs, pcs);
+}
+
+int stmmac_integrated_pcs_init(struct stmmac_priv *priv, unsigned int offset);
+
/**
* dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR
* @ioaddr: IO registers pointer
--
2.47.3
^ permalink raw reply related [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 00/14] net: stmmac: phylink PCS conversion
2025-10-15 14:19 [PATCH net-next 00/14] net: stmmac: phylink PCS conversion Russell King (Oracle)
` (13 preceding siblings ...)
2025-10-15 14:21 ` [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support Russell King (Oracle)
@ 2025-10-15 15:10 ` Russell King (Oracle)
2025-10-16 7:44 ` Maxime Chevallier
14 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 15:10 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
On Wed, Oct 15, 2025 at 03:19:25PM +0100, Russell King (Oracle) wrote:
> 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.
I've just noticed I sent out RFC v2.. completely forgot about that,
sorry. This is a subset of RFC v2, but with patches 13 and 14
reversed.
--
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
* Re: [PATCH net-next 01/14] net: stmmac: remove broken PCS code
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:44 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:02PM +0100, Russell King (Oracle) wrote:
> Changing the netif_carrier_*() state behind phylink's back has always
> been prohibited because it messes up with phylinks state tracking, and
> means that phylink no longer guarantees to call the mac_link_down()
> and mac_link_up() methods at the appropriate times. This was later
> documented in the sfp-phylink network driver conversion guide.
>
> stmmac was converted to phylink in 2019, but nothing was done with the
> "PCS" code. Since then, apart from the updates as part of phylink
> development, nothing has happened with stmmac to improve its use of
> phylink, or even to address this point.
>
> A couple of years ago, a has_integrated_pcs boolean was added by Bart,
> which later became the STMMAC_FLAG_HAS_INTEGRATED_PCS flag, to avoid
> manipulating the netif_carrier_*() state. This flag is mis-named,
> because whenever the stmmac is synthesized for its native SGMII, TBI
> or RTBI interfaces, it has an "integrated PCS". This boolean/flag
> actually means "ignore the status from the integrated PCS".
>
> Discussing with Bart, the reasons for this are lost to the winds of
> time (which is why we should always document the reasons in the commit
> message.)
>
> RGMII also has in-band status, and the dwmac cores and stmmac code
> supports this but with one bug that saves the day.
>
> When dwmac cores are synthesised for RGMII only, they do not contain
> an integrated PCS, and so priv->dma_cap.pcs is clear, which prevents
> (incorrectly) the "RGMII PCS" being used, meaning we don't read the
> in-band status. However, a core synthesised for RGMII and also SGMII,
> TBI or RTBI will have this capability bit set, thus making these
> code paths reachable.
>
> The Jetson Xavier NX uses RGMII mode to talk to its PHY, and removing
> the incorrect check for priv->dma_cap.pcs reveals the theortical issue
> with netif_carrier_*() manipulation is real:
>
> dwc-eth-dwmac 2490000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
> dwc-eth-dwmac 2490000.ethernet eth0: PHY [stmmac-0:00] driver [RTL8211F Gigabit Ethernet] (irq=141)
> dwc-eth-dwmac 2490000.ethernet eth0: No Safety Features support found
> dwc-eth-dwmac 2490000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
> dwc-eth-dwmac 2490000.ethernet eth0: registered PTP clock
> dwc-eth-dwmac 2490000.ethernet eth0: configuring for phy/rgmii-id link mode
> 8021q: adding VLAN 0 to HW filter on device eth0
> dwc-eth-dwmac 2490000.ethernet eth0: Adding VLAN ID 0 is not supported
> Link is Up - 1000/Full
> Link is Down
> Link is Up - 1000/Full
>
> This looks good until one realises that the phylink "Link" status
> messages are missing, even when the RJ45 cable is reconnected. Nothing
> one can do results in the interface working. The interrupt handler
> (which prints those "Link is" messages) always wins over phylink's
> resolve worker, meaning phylink never calls the mac_link_up() nor
> mac_link_down() methods.
>
> eth0 also sees no traffic received, and is unable to obtain a DHCP
> address:
>
> 3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group defa
> ult qlen 1000
> link/ether e6:d3:6a:e6:92:de brd ff:ff:ff:ff:ff:ff
> RX: bytes packets errors dropped overrun mcast
> 0 0 0 0 0 0
> TX: bytes packets errors dropped carrier collsns
> 27686 149 0 0 0 0
>
> With the STMMAC_FLAG_HAS_INTEGRATED_PCS flag set, which disables the
> netif_carrier_*() manipulation then stmmac works normally:
>
> dwc-eth-dwmac 2490000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
> dwc-eth-dwmac 2490000.ethernet eth0: PHY [stmmac-0:00] driver [RTL8211F Gigabit Ethernet] (irq=141)
> dwc-eth-dwmac 2490000.ethernet eth0: No Safety Features support found
> dwc-eth-dwmac 2490000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
> dwc-eth-dwmac 2490000.ethernet eth0: registered PTP clock
> dwc-eth-dwmac 2490000.ethernet eth0: configuring for phy/rgmii-id link mode
> 8021q: adding VLAN 0 to HW filter on device eth0
> dwc-eth-dwmac 2490000.ethernet eth0: Adding VLAN ID 0 is not supported
> Link is Up - 1000/Full
> dwc-eth-dwmac 2490000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
>
> and packets can be transferred.
>
> This clearly shows that when priv->hw->pcs is set, but
> STMMAC_FLAG_HAS_INTEGRATED_PCS is clear, the driver reliably fails.
>
> Discovering whether a platform falls into this is impossible as
> parsing all the dtsi and dts files to find out which use the stmmac
> driver, whether any of them use RGMII or SGMII and also depends
> whether an external interface is being used. The kernel likely
> doesn't contain all dts files either.
>
> The only driver that sets this flag uses the qcom,sa8775p-ethqos
> compatible, and uses SGMII or 2500BASE-X.
>
> but these are saved from this problem by the incorrect check for
> priv->dma_cap.pcs.
>
> So, we have to assume that for every other platform that uses SGMII
> with stmmac is using an external PCS.
>
> Moreover, ethtool output can be incorrect. With the full-duplex link
> negotiated, ethtool reports:
>
> Speed: 1000Mb/s
> Duplex: Half
>
> because with dwmac4, the full-duplex bit is in bit 16 of the status,
> priv->xstats.pcs_duplex becomes BIT(16) for full duplex, but the
> ethtool ksettings duplex member is u8 - so becomes zero. Moreover,
> the supported, advertised and link partner modes are all "not
> reported".
>
> Finally, ksettings_set() won't be able to set the advertisement on
> a PHY if this PCS code is activated, which is incorrect when SGMII
> is used with a PHY.
>
> Thus, remove:
> 1. the incorrect netif_carrier_*() manipulation.
> 2. the broken ethtool ksettings code.
>
> Given that all uses of STMMAC_FLAG_HAS_INTEGRATED_PCS are now gone,
> remove the flag from stmmac.h and dwmac-qcom-ethqos.c.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 02/14] net: stmmac: remove xstats.pcs_* members
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:45 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:07PM +0100, Russell King (Oracle) wrote:
> As a result of the previous commit, the pcs_link, pcs_duplex and
> pcs_speed members are not used outside of the interrupt handling code,
> and are only used to print their status using the misleading "Link is"
> messages that bear no relation to the actual status of the link.
>
> Remove the printing of these messages, these members, and the code
> that decodes them from the hardware.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling
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
1 sibling, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:47 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:12PM +0100, Russell King (Oracle) wrote:
> Now that the only use for the interrupt is to clear it and increment a
> statistic counter (which is not that relevant anymore) remove all this
> code and ensure that the interrupt remains disabled to avoid a stuck
> interrupt.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 04/14] net: stmmac: remove PCS "mode" pause handling
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:48 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:17PM +0100, Russell King (Oracle) wrote:
> Remove the "we always autoneg pause" forcing when the stmmac driver
> decides that a "PCS" is present, which blocks passing the ethtool
> pause calls to phylink when using SGMII mode.
>
> This prevents the pause results being reported when a PHY is attached
> using SGMII mode, or the pause settings being changed in SGMII mode.
> There is no reason to prevent this.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 05/14] net: stmmac: remove unused PCS loopback support
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:50 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:22PM +0100, Russell King (Oracle) wrote:
> Nothing calls stmmac_pcs_ctrl_ane() with the "loopback" argument set to
> anything except zero, so this serves no useful purpose. Remove the
> argument to reduce the code complexity.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 07/14] net: stmmac: remove RGMII "pcs" mode
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:53 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:33PM +0100, Russell King (Oracle) wrote:
> Remove the RGMII "pcs" code in stmmac_check_pcs_mode() due to:
>
> 1) This should never have been conditional on a PCS being present, as
> when a core is synthesised using only RGMII, the PCS won't be present
> and priv->dma_cap.pcs will be false. Only multi-interface cores which
> have a PCS present would have detected RGMII.
>
> 2) STMMAC_PCS_RGMII has no effect since the broken netif_carrier and
> ethtool code was removed.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 08/14] net: stmmac: move reverse-"pcs" mode setup to stmmac_check_pcs_mode()
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:55 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:38PM +0100, Russell King (Oracle) wrote:
> The broken reverse-mode, selected by snps,ps-speed, is configured when
> the platform provides a valid port speed and a PCS is being used.
>
> Both these remain constant after the driver has probed, so the software
> state doesn't need to be re-initialised each time stmmac_hw_setup() is
> called (which is called at open and resume time.)
>
> Move the software setup of reverse-mode to stmmac_check_pcs_mode()
> which is called from the driver probe function.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 09/14] net: stmmac: simplify stmmac_check_pcs_mode()
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:56 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:43PM +0100, Russell King (Oracle) wrote:
> Now that we only support one mode, simplify stmmac_check_pcs_mode().
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 10/14] net: stmmac: hw->ps becomes hw->reverse_sgmii_enable
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 20:57 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:48PM +0100, Russell King (Oracle) wrote:
> After a lot of digging, it seems that the oddly named hw->ps member
> is all about setting the core into reverse SGMII speed. When set to
> a non-zero value, it:
>
> 1. Configures the MAC at initialisation time to operate at a specific
> speed.
> 2. It _incorrectly_ enables the transmitter (GMAC_CONFIG_TE) which
> makes no sense, rather than enabling the "transmit configuration"
> bit (GMAC_CONFIG_TC).
> 3. It configures the SGMII rate adapter layer to retrieve its speed
> setting from the MAC configuration register rather than the PHY.
>
> In the previous commit, we removed (1) and (2) as phylink overwrites
> the configuration set at that step.
>
> Thus, the only functional aspect is (3), which is a boolean operation.
> This means there is no need to store the actual speed, and just have a
> boolean flag.
>
> Convert the priv->ps member to a boolean, and rename it to
> priv->reverse_sgmii_enable to make it more understandable.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
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
1 sibling, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:00 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:53PM +0100, Russell King (Oracle) wrote:
> SGMII mode does not require port-speed to be specified; this only
> switches SGMII to use the MAC configuration register speed settings
> and the actual value is irrelevant when the link comes up.
>
> As it seems the intention was to support "reverse SGMII" with this
> setting, but the code didn't actually configure that due to a typo,
> the warning and bad DT binding documentation has led people to
> specify snps,ps-speed in their DT files inappropriately.
>
> If mac_port_sel_speed is zero, then don't complain that the speed
> is invalid, as this means we're using "normal" SGMII.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 12/14] net: stmmac: only call stmmac_pcs_ctrl_ane() for integrated SGMII PCS
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
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:01 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:59PM +0100, Russell King (Oracle) wrote:
> The internal PCS registers only exist if the core is synthesized with
> SGMII, TBI or RTBI support. They have no relevance for RGMII.
>
> However, priv->hw->pcs contains a STMMAC_PCS_RGMII flag, which is set
> if a PCS has been synthesized but we are operating in RGMII mode. As
> the register has no effect for RGMII, there is no point calling
> stmmac_pcs_ctrl_ane() in this case. Add a comment describing this
> and make it conditional on STMMAC_PCS_SGMII.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 13/14] net: stmmac: provide PCS initialisation hook
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)
0 siblings, 1 reply; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:11 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
> + /* Unimplemented PCS init (as indicated by stmmac_do_callback()
> + * perversely returning -EINVAL) is non-fatal.
> + */
> + ret = stmmac_mac_pcs_init(priv);
> + if (ret != -EINVAL)
> + return ret;
Oh, that's ugly.
Looking back at
commit 42de047d60bc5d87e369c36115058b9dacc5683c
Author: Jose Abreu <Jose.Abreu@synopsys.com>
Date: Mon Apr 16 16:08:12 2018 +0100
net: stmmac: Switch stmmac_desc_ops to generic HW Interface Helpers
which added this, i don't actually see a user of the returned EINVAL.
EOPNOTSUPP would of been better. But changing it now will need quite a
bit of review work :-(
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
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)
1 sibling, 1 reply; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:26 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:53PM +0100, Russell King (Oracle) wrote:
> SGMII mode does not require port-speed to be specified; this only
> switches SGMII to use the MAC configuration register speed settings
> and the actual value is irrelevant when the link comes up.
>
> As it seems the intention was to support "reverse SGMII" with this
> setting, but the code didn't actually configure that due to a typo,
> the warning and bad DT binding documentation has led people to
> specify snps,ps-speed in their DT files inappropriately.
I know you hit the patch limit. Do you have a patch in the next series
which updates the binding?
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support
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)
0 siblings, 1 reply; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:31 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
> - create stmmac_pcs.c, which contains the phylink_pcs_ops structure, a
> dummy .pcs_get_state() method which always reports link-down
I've not followed the PCS code too closely. Why always report link
down? Why is a dummy method needed?
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 13/14] net: stmmac: provide PCS initialisation hook
2025-10-15 21:11 ` Andrew Lunn
@ 2025-10-15 21:32 ` Russell King (Oracle)
0 siblings, 0 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 21:32 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 11:11:22PM +0200, Andrew Lunn wrote:
> > + /* Unimplemented PCS init (as indicated by stmmac_do_callback()
> > + * perversely returning -EINVAL) is non-fatal.
> > + */
> > + ret = stmmac_mac_pcs_init(priv);
> > + if (ret != -EINVAL)
> > + return ret;
>
> Oh, that's ugly.
Yes, I completely agree, and...
> which added this, i don't actually see a user of the returned EINVAL.
> EOPNOTSUPP would of been better. But changing it now will need quite a
> bit of review work :-(
Yes. Maybe at some point in the future it can be addressed - it will
become an issue if we end up with an implementation of these methods
that returns -EINVAL to really mean failure.
However, it's a non-zero chunk of work to go through every single
caller of numerous methods to make the change. It may be possible to
introduce a new base-helper that returns -EOPNOTSUPP and switch
groups of methods... but given my present backlog, it's not something
I'm going to rush to do!
--
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
* Re: [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling
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)
1 sibling, 1 reply; 40+ messages in thread
From: Andrew Lunn @ 2025-10-15 21:35 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 03:20:12PM +0100, Russell King (Oracle) wrote:
> Now that the only use for the interrupt is to clear it and increment a
> statistic counter (which is not that relevant anymore) remove all this
> code and ensure that the interrupt remains disabled to avoid a stuck
> interrupt.
Will this interrupt come back later, as part of the PCS? Or will the
PCS be polled?
This leaves this counter unused, as you said. It does not look trivial
to remove it, it is part of the statistics ABI. But if the interrupt
comes back in a later patch, this counter could also be brought back
to life?
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
2025-10-15 21:26 ` Andrew Lunn
@ 2025-10-15 21:48 ` Russell King (Oracle)
2025-10-16 13:03 ` Andrew Lunn
0 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 21:48 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 11:26:03PM +0200, Andrew Lunn wrote:
> On Wed, Oct 15, 2025 at 03:20:53PM +0100, Russell King (Oracle) wrote:
> > SGMII mode does not require port-speed to be specified; this only
> > switches SGMII to use the MAC configuration register speed settings
> > and the actual value is irrelevant when the link comes up.
> >
> > As it seems the intention was to support "reverse SGMII" with this
> > setting, but the code didn't actually configure that due to a typo,
> > the warning and bad DT binding documentation has led people to
> > specify snps,ps-speed in their DT files inappropriately.
>
> I know you hit the patch limit. Do you have a patch in the next series
> which updates the binding?
I don't at present, and I'm not sure what the point of updating it
would actually be, because this is another thing that's just broken.
The purpose of this property is to allow DT to specify the operating
speed of the link when acting as if it were a PHY on the end of a
SGMII (or RGMII) link using in-band signalling. However, because the
code mixes up GMAC_CONTROL_TE instead of GMAC_CONTROL_TC, when this
is set, the _transmit enable_ is set, rather than the _transmit
configuration_ bit, meaning the core doesn't actually send the
inband status as if it were a PHY.
So, the whole thing is pointless, it's never worked from what I can
see, and lastly... this property should not even be specifying a
speed at all, because that's what we have the fixed-link stuff for.
At best, this should have triggered a discussion about PHY
interface modes such as reverse-SGMII and reverse-RGMII that we've
recently had where the MAC is acting as if it were a PHY.
We can't get rid of it because doing so would break existing DTS
files. We can't fix it to work, because given the vagueness of the
current definition, people have added this property even when they
do not want to be operating in reverse mode.
Hence, I would like this property a slow and painful^h^h^hfree death.
Maybe mark the property deprecated, and remove all explanation of it
apart from stating that it's obsolete after this patch series has
been merged and we've proven that it's never been useful.
IMHO, it's a property that should never have existed.
--
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
* Re: [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support
2025-10-15 21:31 ` Andrew Lunn
@ 2025-10-15 21:57 ` Russell King (Oracle)
2025-10-16 13:05 ` Andrew Lunn
0 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 21:57 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 11:31:37PM +0200, Andrew Lunn wrote:
> > - create stmmac_pcs.c, which contains the phylink_pcs_ops structure, a
> > dummy .pcs_get_state() method which always reports link-down
>
> I've not followed the PCS code too closely. Why always report link
> down? Why is a dummy method needed?
If phylink is put into inband mode, and a PCS is supplied to phylink
where this method left NULL, the kernel will oops.
As the code stands today in mainline, if phylink were to be put into
inband mode with the integrated PCS, then there will be no phylink PCS,
and so phylink_mac_pcs_get_state() will fall into the "else" path of:
pcs = pl->pcs;
if (pcs)
pcs->ops->pcs_get_state(pcs, pl->pcs_neg_mode, state);
else
state->link = 0;
and force the link down.
So, adding this method keeps the status quo - not oopsing the kernel
and not allowing the link to come up. No unintended behavioural
change in this regard from how it would behave today. :)
--
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
* Re: [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling
2025-10-15 21:35 ` Andrew Lunn
@ 2025-10-15 22:12 ` Russell King (Oracle)
2025-10-16 13:07 ` Andrew Lunn
0 siblings, 1 reply; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-15 22:12 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 11:35:40PM +0200, Andrew Lunn wrote:
> On Wed, Oct 15, 2025 at 03:20:12PM +0100, Russell King (Oracle) wrote:
> > Now that the only use for the interrupt is to clear it and increment a
> > statistic counter (which is not that relevant anymore) remove all this
> > code and ensure that the interrupt remains disabled to avoid a stuck
> > interrupt.
>
> Will this interrupt come back later, as part of the PCS? Or will the
> PCS be polled?
It depends whether it has any users - given the scrappy nature of all
this, and the fact it's never been properly implemented, I need to
hear from the platform glue people to really know what's going on.
Right now, all I'm doing is removing loads of code that has been proven
to be broken, and re-implementing what is left in a way that will work
for people who are using the internal PCS (in other words, where the
STMMAC_FLAG_HAS_INTEGRATED_PCS was set which disabled much of the
broken code anyway.)
> This leaves this counter unused, as you said. It does not look trivial
> to remove it, it is part of the statistics ABI. But if the interrupt
> comes back in a later patch, this counter could also be brought back
> to life?
Sadly, it's not quite unused - see dwmac-sun8i.c:
if (v & EMAC_RGMII_STA_INT)
x->irq_rgmii_n++;
This is more than glue, but is almost an entire core implementation as
well - the original commit introducing it says:
The dwmac-sun8i is a heavy hacked version of stmmac hardware by
allwinner.
In fact the only common part is the descriptor management and the first
register function.
So, rather than remove the statistic entirely, as I'm not touching this
hacked version, I decided to keep the statistic counter as there is
still something using it.
--
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
* Re: [PATCH net-next 00/14] net: stmmac: phylink PCS conversion
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
0 siblings, 0 replies; 40+ messages in thread
From: Maxime Chevallier @ 2025-10-16 7:44 UTC (permalink / raw)
To: Russell King (Oracle), 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 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
Hi Russell,
On 15/10/2025 17:10, Russell King (Oracle) wrote:
> On Wed, Oct 15, 2025 at 03:19:25PM +0100, Russell King (Oracle) wrote:
>> 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.
>
> I've just noticed I sent out RFC v2.. completely forgot about that,
> sorry
:( I don't know if you saw my reply to it then...
To quote :
"
I tested that series on socfpga with :
- 1 instance using RGMII, w/ a ksz9031 PHY, and it works well,
traffic flows, ethtool seems to report correct data
- 1 instance that has the Lynx PCS (DMA_HW_FEATURE[30:28] == 0)
This also works perfectly, switching between SGMII/1000BaseX dynamically
by hotswapping SFP modules works well, no regression found at a first glance.
"
All the boards I have that have a flavour of stmmac don't seem to have the
internal PCS, are you still interested in some testing , just
for non-regression ?
This is a subset of RFC v2, but with patches 13 and 14
> reversed.
>
Maxime
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
2025-10-15 21:48 ` Russell King (Oracle)
@ 2025-10-16 13:03 ` Andrew Lunn
2025-10-16 13:51 ` Russell King (Oracle)
0 siblings, 1 reply; 40+ messages in thread
From: Andrew Lunn @ 2025-10-16 13:03 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
> I don't at present, and I'm not sure what the point of updating it
> would actually be, because this is another thing that's just broken.
> Hence, I would like this property a slow and painful^h^h^hfree death.
> Maybe mark the property deprecated, and remove all explanation of it
> apart from stating that it's obsolete after this patch series has
> been merged and we've proven that it's never been useful.
And this is what i was thinking. At least mark it deprecated. If you
want to remove the documentation late, i'm fine with that as well.
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 14/14] net: stmmac: convert to phylink PCS support
2025-10-15 21:57 ` Russell King (Oracle)
@ 2025-10-16 13:05 ` Andrew Lunn
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-16 13:05 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
On Wed, Oct 15, 2025 at 10:57:08PM +0100, Russell King (Oracle) wrote:
> On Wed, Oct 15, 2025 at 11:31:37PM +0200, Andrew Lunn wrote:
> > > - create stmmac_pcs.c, which contains the phylink_pcs_ops structure, a
> > > dummy .pcs_get_state() method which always reports link-down
> >
> > I've not followed the PCS code too closely. Why always report link
> > down? Why is a dummy method needed?
>
> If phylink is put into inband mode, and a PCS is supplied to phylink
> where this method left NULL, the kernel will oops.
>
> As the code stands today in mainline, if phylink were to be put into
> inband mode with the integrated PCS, then there will be no phylink PCS,
> and so phylink_mac_pcs_get_state() will fall into the "else" path of:
>
> pcs = pl->pcs;
> if (pcs)
> pcs->ops->pcs_get_state(pcs, pl->pcs_neg_mode, state);
> else
> state->link = 0;
>
> and force the link down.
>
> So, adding this method keeps the status quo - not oopsing the kernel
> and not allowing the link to come up. No unintended behavioural
> change in this regard from how it would behave today. :)
O.K. Maybe some of this text could be added to the commit message?
Thanks
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 03/14] net: stmmac: remove SGMII/RGMII/SMII interrupt handling
2025-10-15 22:12 ` Russell King (Oracle)
@ 2025-10-16 13:07 ` Andrew Lunn
0 siblings, 0 replies; 40+ messages in thread
From: Andrew Lunn @ 2025-10-16 13:07 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, 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
> Sadly, it's not quite unused - see dwmac-sun8i.c:
>
> if (v & EMAC_RGMII_STA_INT)
> x->irq_rgmii_n++;
Ah, i missed that. So yes, it needs to stay.
Thanks
Andrew
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: [PATCH net-next 11/14] net: stmmac: do not require snps,ps-speed for SGMII
2025-10-16 13:03 ` Andrew Lunn
@ 2025-10-16 13:51 ` Russell King (Oracle)
0 siblings, 0 replies; 40+ messages in thread
From: Russell King (Oracle) @ 2025-10-16 13:51 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiner Kallweit, 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
On Thu, Oct 16, 2025 at 03:03:34PM +0200, Andrew Lunn wrote:
> > I don't at present, and I'm not sure what the point of updating it
> > would actually be, because this is another thing that's just broken.
>
> > Hence, I would like this property a slow and painful^h^h^hfree death.
> > Maybe mark the property deprecated, and remove all explanation of it
> > apart from stating that it's obsolete after this patch series has
> > been merged and we've proven that it's never been useful.
>
> And this is what i was thinking. At least mark it deprecated. If you
> want to remove the documentation late, i'm fine with that as well.
It's rather premature to do this - this series doesn't change anything
in the way that snps,ps-speed behaves.
Setting this still:
1. sets the SGMII rate adapter to take its speed configuration from the
MAC control register rather than the in-band config.
2. enables the exchange of the SGMII in-band config.
What it doesn't do, and has never done, is to ensure that the in-band
config that is sent contains the speed and duplex information for the
SGMII link partner due to a repeated typo in the individual core sub-
drivers.
I'm not intending removing this until we have a different way to
specify it, e.g. PHY_INTERFACE_MODE_REVSGMII, but that is currently
looking unlikely. However, with PHY_INTERFACE_MODE_REVSGMII, we would
need to make the change (fix the typo bug) to publish the correct
in-band config.
I think a bit more thought is needed before going down that path,
because if we're publishing the config, is it a fixed-link. That's
something that we need to sort out in the PHY_INTERFACE_MODE_REVSGMII
discussions... if we're still going with it.
So, right now what happens here entirely depends on stuff we have
yet to make decisions on, and so marking it deprecated now is too
early.
--
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).