Netdev List
 help / color / mirror / Atom feed
* [PATCH net v1 1/1] net: phylink: keep initial advertising settings
@ 2026-11-04 12:55 Thilo Zirnstein
  2026-11-06 13:51 ` Andrew Lunn
  2026-11-08 13:16 ` netdev-bot+sashiko
  0 siblings, 2 replies; 5+ messages in thread
From: Thilo Zirnstein @ 2026-11-04 12:55 UTC (permalink / raw)
  To: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Thilo Zirnstein

If the net device is phylink based,
consists of a mac with a phy connected and the
mac driver does add the phy while the ndo_open callback,
initial advertising settings of the link may be overwritten
during phylink_bringup_phy.

The mode of action is as follows:

* The link was not up yet - no phy connected
* the user configures the advertisement of the interface
* the mac driver delegates the call to phylink_ethtool_ksettings_set
    * here we are not configuring the phy - it does not exist yet
* the user set up the interface
* the mac drivers calls phylink_connect_phy
    * calls phylink_bringup_phy
        * overwrites advertisement with
            * linkmode_copy(config.advertising, phy->advertising);
            * linkmode_copy(pl->link_config.advertising,
                config.advertising);

Connecting the phy while ndo_open callback seems to be a common pattern,
affected drivers are:

* macb
* r8169
* stmmac
* tn40xx

The advertising settings can be kept by using the intersection
of the phylink advert bits and the phy advert bits.

This was observed and tested on a
Xilinx Zyqnmp system with builtin macb ethernet interface.

Fixes: 9525ae83959b ("phylink: add phylink infrastructure")
Signed-off-by: Thilo Zirnstein <thi.zirnstein@gmail.com>
---
 drivers/net/phy/phylink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e885da1c2831..145f181bc9d3 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2320,6 +2320,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
 	pl->phy_state.duplex = DUPLEX_UNKNOWN;
 	pl->phy_state.rate_matching = RATE_MATCH_NONE;
 	linkmode_copy(pl->supported, supported);
+	linkmode_and(config.advertising, config.advertising, pl->link_config.advertising);
 	linkmode_copy(pl->link_config.advertising, config.advertising);

 	/* Restrict the phy advertisement according to the MAC support. */
--
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* Re: [PATCH net v1 1/1] net: phylink: keep initial advertising settings
@ 2026-11-09  9:58 Anandu Padinhare
  0 siblings, 0 replies; 5+ messages in thread
From: Anandu Padinhare @ 2026-11-09  9:58 UTC (permalink / raw)
  To: Thilo Zirnstein, linux@armlinux.org.uk, andrew@lunn.ch,
	hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com
  Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org

On Wed, Nov 04, 2026 at 01:55:09PM +0100, Thilo Zirnstein wrote:
> Connecting the phy while ndo_open callback seems to be a common pattern,
> affected drivers are:
>
> * macb
> * r8169
> * stmmac
> * tn40xx

Hi Thilo,

Results from an ADSP-SC598 board (stmmac, RGMII, TI DP83867 PHY) with
a 6.18-based kernel, with and without this patch.

1. The case in the commit message is fixed, with both the dp83867 and
   the generic PHY driver:

     ip link set eth0 down
     ethtool -s eth0 speed 100 duplex full autoneg on
     ip link set eth0 up

   Without the patch the link comes up at 1000 Mb/s; with it, at
   100 Mb/s.

2. In that same case the pause bits are lost: with the patch the link
   comes up with flow control off; without it, pause stays on. Same
   with both PHY drivers. While the interface is down, ethtool shows
   no advertised modes and no pause, before and after the
   "ethtool -s" (phylink_ethtool_ksettings_get() reports none when no
   PHY is attached), and the AND then drops the pause bits the PHY
   advertises.

3. Sashiko's sequences (a) and (b) both reproduce with the dp83867
   driver:

   (a) advertise 100baseT/Full while up, ifdown/ifup: 100 Mb/s.
       advertise 10/100/1000baseT/Full while up: 1000 Mb/s.
       ifdown/ifup: back to 100 Mb/s, advertising only 100baseT/Full.

   (b) continuing, advertise 1000baseT/Full while up: 1000 Mb/s.
       ifdown/ifup: "Advertised link modes: Not reported", and the
       link stays down (NO-CARRIER).

   Without the patch, both keep the last setting: (a) comes back at
   1000 Mb/s, and (b) at 1000 Mb/s with 1000baseT/Full advertised.

Happy to test a v2 on this board.

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

end of thread, other threads:[~2026-11-09  9:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 12:55 [PATCH net v1 1/1] net: phylink: keep initial advertising settings Thilo Zirnstein
2026-11-06 13:51 ` Andrew Lunn
2026-11-06 21:21   ` Thilo Zirnstein
2026-11-08 13:16 ` netdev-bot+sashiko
  -- strict thread matches above, loose matches on Subject: below --
2026-11-09  9:58 Anandu Padinhare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox