Commit 381291b7 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

[TG3]: Fix nvram arbitration bugs.

The nvram arbitration rules were not strictly followed in a few places
and this could lead to reading corrupted values from the nvram.
Signed-off-by: default avatarMichael Chan <mchan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 65ab592d
...@@ -8533,6 +8533,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) ...@@ -8533,6 +8533,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
tp->tg3_flags |= TG3_FLAG_NVRAM; tp->tg3_flags |= TG3_FLAG_NVRAM;
tg3_nvram_lock(tp);
tg3_enable_nvram_access(tp); tg3_enable_nvram_access(tp);
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
...@@ -8543,6 +8544,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) ...@@ -8543,6 +8544,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
tg3_get_nvram_size(tp); tg3_get_nvram_size(tp);
tg3_disable_nvram_access(tp); tg3_disable_nvram_access(tp);
tg3_nvram_unlock(tp);
} else { } else {
tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
...@@ -8640,10 +8642,10 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val) ...@@ -8640,10 +8642,10 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
if (ret == 0) if (ret == 0)
*val = swab32(tr32(NVRAM_RDDATA)); *val = swab32(tr32(NVRAM_RDDATA));
tg3_nvram_unlock(tp);
tg3_disable_nvram_access(tp); tg3_disable_nvram_access(tp);
tg3_nvram_unlock(tp);
return ret; return ret;
} }
...@@ -8728,6 +8730,10 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len, ...@@ -8728,6 +8730,10 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
offset = offset + (pagesize - page_off); offset = offset + (pagesize - page_off);
/* Nvram lock released by tg3_nvram_read() above,
* so need to get it again.
*/
tg3_nvram_lock(tp);
tg3_enable_nvram_access(tp); tg3_enable_nvram_access(tp);
/* /*
......
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