Commit 77b483f1 authored by Matt Carlson's avatar Matt Carlson Committed by David S. Miller

tg3: Add APE register access locking

If the driver resets the chip while the APE is performing a register
access, that register access will never complete and the APE will hang
indefinitely.  To prevent this race condition, the driver must acquire
an APE mutex before resetting the chip.  The APE will not attempt a
register access until it acquires this lock.
Signed-off-by: default avatarMatt Carlson <mcarlson@broadcom.com>
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c6153b5b
...@@ -536,6 +536,7 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum) ...@@ -536,6 +536,7 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum)
return 0; return 0;
switch (locknum) { switch (locknum) {
case TG3_APE_LOCK_GRC:
case TG3_APE_LOCK_MEM: case TG3_APE_LOCK_MEM:
break; break;
default: default:
...@@ -573,6 +574,7 @@ static void tg3_ape_unlock(struct tg3 *tp, int locknum) ...@@ -573,6 +574,7 @@ static void tg3_ape_unlock(struct tg3 *tp, int locknum)
return; return;
switch (locknum) { switch (locknum) {
case TG3_APE_LOCK_GRC:
case TG3_APE_LOCK_MEM: case TG3_APE_LOCK_MEM:
break; break;
default: default:
...@@ -5760,6 +5762,8 @@ static int tg3_chip_reset(struct tg3 *tp) ...@@ -5760,6 +5762,8 @@ static int tg3_chip_reset(struct tg3 *tp)
tg3_mdio_stop(tp); tg3_mdio_stop(tp);
tg3_ape_lock(tp, TG3_APE_LOCK_GRC);
/* No matching tg3_nvram_unlock() after this because /* No matching tg3_nvram_unlock() after this because
* chip reset below will undo the nvram lock. * chip reset below will undo the nvram lock.
*/ */
...@@ -5914,6 +5918,8 @@ static int tg3_chip_reset(struct tg3 *tp) ...@@ -5914,6 +5918,8 @@ static int tg3_chip_reset(struct tg3 *tp)
tg3_mdio_start(tp); tg3_mdio_start(tp);
tg3_ape_unlock(tp, TG3_APE_LOCK_GRC);
err = tg3_poll_fw(tp); err = tg3_poll_fw(tp);
if (err) if (err)
return err; return err;
......
...@@ -1889,6 +1889,7 @@ ...@@ -1889,6 +1889,7 @@
#define APE_EVENT_STATUS_EVENT_PENDING 0x80000000 #define APE_EVENT_STATUS_EVENT_PENDING 0x80000000
/* APE convenience enumerations. */ /* APE convenience enumerations. */
#define TG3_APE_LOCK_GRC 1
#define TG3_APE_LOCK_MEM 4 #define TG3_APE_LOCK_MEM 4
#define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10 #define TG3_EEPROM_SB_F1R2_MBA_OFF 0x10
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment