lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210214010405.32019-3-michael@walle.cc>
Date:   Sun, 14 Feb 2021 02:04:05 +0100
From:   Michael Walle <michael@...le.cc>
To:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Michael Walle <michael@...le.cc>
Subject: [PATCH net-next 2/2] net: phy: at803x: use proper locking in at803x_aneg_done()

at803x_aneg_done() checks if auto-negotiation is completed on the SGMII
side. This doesn't take the mdio bus lock and the page switching is
open-coded. Now that we have proper page support, just use
phy_read_paged(). Also use phydev->interface to check if we have an
SGMII link instead of reading the mode register and be a bit more
precise on the warning message.

Signed-off-by: Michael Walle <michael@...le.cc>
---
 drivers/net/phy/at803x.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index a3aa10f14638..8abaea7ae6bd 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -756,32 +756,27 @@ static void at803x_link_change_notify(struct phy_device *phydev)
 
 static int at803x_aneg_done(struct phy_device *phydev)
 {
-	int ccr;
-
-	int aneg_done = genphy_aneg_done(phydev);
-	if (aneg_done != BMSR_ANEGCOMPLETE)
-		return aneg_done;
+	int ret, val;
 
-	/*
-	 * in SGMII mode, if copper side autoneg is successful,
-	 * also check SGMII side autoneg result
-	 */
-	ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
-	if ((ccr & AT803X_MODE_CFG_MASK) != AT803X_MODE_CFG_SGMII)
-		return aneg_done;
 
-	/* switch to SGMII/fiber page */
-	phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr & ~AT803X_BT_BX_REG_SEL);
+	ret = genphy_aneg_done(phydev);
 
-	/* check if the SGMII link is OK. */
-	if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) {
-		phydev_warn(phydev, "803x_aneg_done: SGMII link is not ok\n");
-		aneg_done = 0;
+	/* In SGMII mode, if copper side autoneg is successful, also check
+	 * SGMII side autoneg result.
+	 */
+	if (phydev->interface == PHY_INTERFACE_MODE_SGMII &&
+	    ret == BMSR_ANEGCOMPLETE) {
+		val = phy_read_paged(phydev, AT803X_FIBER_PAGE, AT803X_PSSR);
+		if (val < 0)
+			return val;
+
+		if (!(val & AT803X_PSSR_MR_AN_COMPLETE)) {
+			phydev_warn(phydev, "SGMII autoneg isn't completed\n");
+			return 0;
+		}
 	}
-	/* switch back to copper page */
-	phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL);
 
-	return aneg_done;
+	return ret;
 }
 
 static int at803x_read_status(struct phy_device *phydev)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ