more lock
authorChuanhong Guo <gch981213@gmail.com>
Sun, 2 Aug 2020 05:00:57 +0000 (13:00 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Sat, 19 Sep 2020 13:55:20 +0000 (21:55 +0800)
target/linux/generic/files/drivers/net/phy/ar8216.c

index ef71b94bd04cfd535d131f9831799ff41cfdaebf..7c0745c8a6bfe1845f41f88295824070ab2059c2 100644 (file)
@@ -224,6 +224,7 @@ ar8xxx_mii_read32(struct ar8xxx_priv *priv, int phy_id, int regnum)
 {
        struct mii_bus *bus = priv->mii_bus;
        u16 lo, hi;
+       lockdep_assert_held(&priv->reg_mutex);
 
        lo = bus->read(bus, phy_id, regnum);
        hi = bus->read(bus, phy_id, regnum + 1);
@@ -236,6 +237,7 @@ ar8xxx_mii_write32(struct ar8xxx_priv *priv, int phy_id, int regnum, u32 val)
 {
        struct mii_bus *bus = priv->mii_bus;
        u16 lo, hi;
+       lockdep_assert_held(&priv->reg_mutex);
 
        lo = val & 0xffff;
        hi = (u16) (val >> 16);
@@ -472,7 +474,10 @@ ar8216_read_port_link(struct ar8xxx_priv *priv, int port,
 
        memset(link, '\0', sizeof(*link));
 
+       mutex_lock(&priv->reg_mutex);
        status = priv->chip->read_port_status(priv, port);
+       mutex_unlock(&priv->reg_mutex);
+       cond_resched();
 
        link->aneg = !!(status & AR8216_PORT_STATUS_LINK_AUTO);
        if (link->aneg) {
@@ -496,8 +501,11 @@ ar8216_read_port_link(struct ar8xxx_priv *priv, int port,
        link->tx_flow = !!(status & AR8216_PORT_STATUS_TXFLOW);
        link->rx_flow = !!(status & AR8216_PORT_STATUS_RXFLOW);
 
-       if (link->aneg && link->duplex && priv->chip->read_port_eee_status)
+       if (link->aneg && link->duplex && priv->chip->read_port_eee_status) {
+               mutex_lock(&priv->reg_mutex);
                link->eee = priv->chip->read_port_eee_status(priv, port);
+               mutex_unlock(&priv->reg_mutex);
+       }
 
        speed = (status & AR8216_PORT_STATUS_SPEED) >>
                 AR8216_PORT_STATUS_SPEED_S;