Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: at803x: disable WOL at probe

Before 7beecaf7d507b ("net: phy: at803x: improve the WOL feature") patch
"at803x_get_wol" implementation used AT803X_INTR_ENABLE_WOL value to set
WAKE_MAGIC flag, and now AT803X_WOL_EN value is used for the same purpose.
The problem here is that the values of these two bits are different after
hardware reset: AT803X_INTR_ENABLE_WOL=0 after hardware reset, but
AT803X_WOL_EN=1. So now, if called right after boot, "at803x_get_wol" will
set WAKE_MAGIC flag, even if WOL function is not enabled by calling
"at803x_set_wol" function. The patch disables WOL function on probe thus
the behavior is consistent.

Fixes: 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Link: https://lore.kernel.org/r/20220527084935.235274-1-viorel.suman@oss.nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Viorel Suman and committed by
Jakub Kicinski
d7cd5e06 3a2cd89b

+22 -11
+22 -11
drivers/net/phy/at803x.c
··· 433 433 static int at803x_set_wol(struct phy_device *phydev, 434 434 struct ethtool_wolinfo *wol) 435 435 { 436 - struct net_device *ndev = phydev->attached_dev; 437 - const u8 *mac; 438 436 int ret, irq_enabled; 439 - unsigned int i; 440 - static const unsigned int offsets[] = { 441 - AT803X_LOC_MAC_ADDR_32_47_OFFSET, 442 - AT803X_LOC_MAC_ADDR_16_31_OFFSET, 443 - AT803X_LOC_MAC_ADDR_0_15_OFFSET, 444 - }; 445 - 446 - if (!ndev) 447 - return -ENODEV; 448 437 449 438 if (wol->wolopts & WAKE_MAGIC) { 439 + struct net_device *ndev = phydev->attached_dev; 440 + const u8 *mac; 441 + unsigned int i; 442 + static const unsigned int offsets[] = { 443 + AT803X_LOC_MAC_ADDR_32_47_OFFSET, 444 + AT803X_LOC_MAC_ADDR_16_31_OFFSET, 445 + AT803X_LOC_MAC_ADDR_0_15_OFFSET, 446 + }; 447 + 448 + if (!ndev) 449 + return -ENODEV; 450 + 450 451 mac = (const u8 *) ndev->dev_addr; 451 452 452 453 if (!is_valid_ether_addr(mac)) ··· 858 857 if (phydev->drv->phy_id == ATH8031_PHY_ID) { 859 858 int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); 860 859 int mode_cfg; 860 + struct ethtool_wolinfo wol = { 861 + .wolopts = 0, 862 + }; 861 863 862 864 if (ccr < 0) 863 865 goto err; ··· 875 871 case AT803X_MODE_CFG_FX100_RGMII_75OHM: 876 872 priv->is_fiber = true; 877 873 break; 874 + } 875 + 876 + /* Disable WOL by default */ 877 + ret = at803x_set_wol(phydev, &wol); 878 + if (ret < 0) { 879 + phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret); 880 + goto err; 878 881 } 879 882 } 880 883