Skip to content

Commit

Permalink
net: phy: fix write to mii-ctrl1000 register
Browse files Browse the repository at this point in the history
When userspace writes to the MII_ADVERTISE register, we update phylib's
advertising mask and trigger a renegotiation.  However, writing to the
MII_CTRL1000 register, which contains the gigabit advertisement, does
neither.  This can lead to phylib's copy of the advertisement becoming
de-synced with the values in the PHY register set, which can result in
incorrect negotiation resolution.

Fixes: 5502b21 ("net: phy: use phy_resolve_aneg_linkmode in genphy_read_status")
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: Russell King <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Russell King authored and davem330 committed Oct 5, 2019
1 parent 2d819d2 commit 4cf6c57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/phy/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
val);
change_autoneg = true;
break;
case MII_CTRL1000:
mii_ctrl1000_mod_linkmode_adv_t(phydev->advertising,
val);
change_autoneg = true;
break;
default:
/* do nothing */
break;
Expand Down
9 changes: 9 additions & 0 deletions include/linux/mii.h
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ static inline void mii_lpa_mod_linkmode_lpa_t(unsigned long *lp_advertising,
lp_advertising, lpa & LPA_LPACK);
}

static inline void mii_ctrl1000_mod_linkmode_adv_t(unsigned long *advertising,
u32 ctrl1000)
{
linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, advertising,
ctrl1000 & ADVERTISE_1000HALF);
linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, advertising,
ctrl1000 & ADVERTISE_1000FULL);
}

/**
* linkmode_adv_to_lcl_adv_t
* @advertising:pointer to linkmode advertising
Expand Down

0 comments on commit 4cf6c57

Please sign in to comment.