[PATCH net v1 1/1] net: phylink: keep initial advertising settings

From: Thilo Zirnstein

Date: Wed Nov 04 2026 - 07:57:37 EST


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@xxxxxxxxx>
---
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