Commit 8f5f7487 authored by Doug Berger's avatar Doug Berger Committed by sanglipeng1
Browse files

net: bcmgenet: synchronize EXT_RGMII_OOB_CTRL access

stable inclusion
from stable-v5.10.218
commit b8d75bb01c560db69e63015b76617444a929f306
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAX0QZ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b8d75bb01c560db69e63015b76617444a929f306



--------------------------------

commit d85cf67a339685beae1d0aee27b7f61da95455be upstream.

The EXT_RGMII_OOB_CTRL register can be written from different
contexts. It is predominantly written from the adjust_link
handler which is synchronized by the phydev->lock, but can
also be written from a different context when configuring the
mii in bcmgenet_mii_config().

The chances of contention are quite low, but it is conceivable
that adjust_link could occur during resume when WoL is enabled
so use the phydev->lock synchronizer in bcmgenet_mii_config()
to be sure.

Fixes: afe3f907 ("net: bcmgenet: power on MII block for all MII modes")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
Acked-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent 8fdc9eaf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -264,6 +264,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
	 * block for the interface to work
	 */
	if (priv->ext_phy) {
		mutex_lock(&phydev->lock);
		reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
		reg &= ~ID_MODE_DIS;
		reg |= id_mode_dis;
@@ -272,6 +273,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
		else
			reg |= RGMII_MODE_EN;
		bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
		mutex_unlock(&phydev->lock);
	}

	if (init)