Skip to content

Commit

Permalink
tg3: Fix link check in tg3_adjust_link
Browse files Browse the repository at this point in the history
The tg3 driver tried to detect link changes by comparing the tg3 local
active_speed member with SPEED_UNKNOWN (or formerly SPEED_INVALID).
This check is not correct, since phylib will never set its speed member
to either of these two values.  The code only appeared to work because
tg3 initializes active_speed to SPEED_INVALID during tg3_init_one.  This
patch introduces a new "old_link" tg3 member and then compares the
phy_device's link member against it to detect link state changes.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Matt Carlson authored and David S. Miller committed Feb 23, 2012
1 parent 9f6f9af commit 34655ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/broadcom/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,13 +1819,13 @@ static void tg3_adjust_link(struct net_device *dev)
(6 << TX_LENGTHS_IPG_SHIFT) |
(32 << TX_LENGTHS_SLOT_TIME_SHIFT)));

if ((phydev->link && tp->link_config.active_speed == SPEED_UNKNOWN) ||
(!phydev->link && tp->link_config.active_speed != SPEED_UNKNOWN) ||
if (phydev->link != tp->old_link ||
phydev->speed != tp->link_config.active_speed ||
phydev->duplex != tp->link_config.active_duplex ||
oldflowctrl != tp->link_config.active_flowctrl)
linkmesg = 1;

tp->old_link = phydev->link;
tp->link_config.active_speed = phydev->speed;
tp->link_config.active_duplex = phydev->duplex;

Expand Down Expand Up @@ -13352,6 +13352,8 @@ static void __devinit tg3_phy_init_link_config(struct tg3 *tp)
tp->link_config.autoneg = AUTONEG_ENABLE;
tp->link_config.active_speed = SPEED_UNKNOWN;
tp->link_config.active_duplex = DUPLEX_UNKNOWN;

tp->old_link = -1;
}

static int __devinit tg3_phy_probe(struct tg3 *tp)
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/tg3.h
Original file line number Diff line number Diff line change
Expand Up @@ -3064,6 +3064,7 @@ struct tg3 {

struct mii_bus *mdio_bus;
int mdio_irq[PHY_MAX_ADDR];
int old_link;

u8 phy_addr;

Expand Down

0 comments on commit 34655ad

Please sign in to comment.