net: bcmgenet: synchronize EXT_RGMII_OOB_CTRL access

commit d85cf67a33 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: afe3f907d2 ("net: bcmgenet: power on MII block for all MII modes")
Cc: stable@vger.kernel.org
Signed-off-by: Doug Berger <opendmb@gmail.com>
Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Doug Berger 2024-04-25 15:27:19 -07:00 committed by Greg Kroah-Hartman
parent ef31b4647e
commit 8b3845de02

View File

@ -2,7 +2,7 @@
/* /*
* Broadcom GENET MDIO routines * Broadcom GENET MDIO routines
* *
* Copyright (c) 2014-2017 Broadcom * Copyright (c) 2014-2024 Broadcom
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
@ -274,6 +274,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
* block for the interface to work, unconditionally clear the * block for the interface to work, unconditionally clear the
* Out-of-band disable since we do not need it. * Out-of-band disable since we do not need it.
*/ */
mutex_lock(&phydev->lock);
reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL); reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
reg &= ~OOB_DISABLE; reg &= ~OOB_DISABLE;
if (priv->ext_phy) { if (priv->ext_phy) {
@ -285,6 +286,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
reg |= RGMII_MODE_EN; reg |= RGMII_MODE_EN;
} }
bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL); bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
mutex_unlock(&phydev->lock);
if (init) if (init)
dev_info(kdev, "configuring instance for %s\n", phy_name); dev_info(kdev, "configuring instance for %s\n", phy_name);