tg3: Fix 'scheduling while atomic' errors

This patch fixes the 'scheduling while atomic' errors introduced by
commit 12dac0756d357325b107fe6ec24921ec38661839 ("tg3: adapt tg3 to
use reworked PCI PM code").

The first hunk of the patch removes an unnecessary
tg3_set_power_state() call. The chip will already be in the D0 state
either due to a chip reset or through a previous call to
tg3_set_power_state().

The second hunk of the patch moves the tg3_set_power_state() call
outside the critical section guarded by tg3_full_lock() and
tg3_full_unlock() functions. The power state of the device is and
should be outside the lock's domain and all other
tg3_set_power_state() calls support this.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Matt Carlson and committed by David S. Miller 2f751b67 cc6533e9

+4 -16
+4 -16
drivers/net/tg3.c
··· 7687 */ 7688 static int tg3_init_hw(struct tg3 *tp, int reset_phy) 7689 { 7690 - int err; 7691 - 7692 - /* Force the chip into D0. */ 7693 - err = tg3_set_power_state(tp, PCI_D0); 7694 - if (err) 7695 - goto out; 7696 - 7697 tg3_switch_clocks(tp); 7698 7699 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); 7700 7701 - err = tg3_reset_hw(tp, reset_phy); 7702 - 7703 - out: 7704 - return err; 7705 } 7706 7707 #define TG3_STAT_ADD32(PSTAT, REG) \ ··· 8006 8007 netif_carrier_off(tp->dev); 8008 8009 - tg3_full_lock(tp, 0); 8010 - 8011 err = tg3_set_power_state(tp, PCI_D0); 8012 - if (err) { 8013 - tg3_full_unlock(tp); 8014 return err; 8015 - } 8016 8017 tg3_disable_ints(tp); 8018 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
··· 7687 */ 7688 static int tg3_init_hw(struct tg3 *tp, int reset_phy) 7689 { 7690 tg3_switch_clocks(tp); 7691 7692 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); 7693 7694 + return tg3_reset_hw(tp, reset_phy); 7695 } 7696 7697 #define TG3_STAT_ADD32(PSTAT, REG) \ ··· 8016 8017 netif_carrier_off(tp->dev); 8018 8019 err = tg3_set_power_state(tp, PCI_D0); 8020 + if (err) 8021 return err; 8022 + 8023 + tg3_full_lock(tp, 0); 8024 8025 tg3_disable_ints(tp); 8026 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;