Commit 7d4b0394 authored by Larry Finger's avatar Larry Finger Committed by John W. Linville

[PATCH] bcm43xx-softmac: Init, shutdown and restart fixes

This fixes various bugs in the init and shutdown code
that would lead to lockups and crashes.
Signed-Off-By: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 34fa0e31
...@@ -519,6 +519,7 @@ static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm) ...@@ -519,6 +519,7 @@ static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm)
return -EBUSY; return -EBUSY;
} }
bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL); bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_MASK); /* flush */
spin_unlock_irqrestore(&bcm->irq_lock, flags); spin_unlock_irqrestore(&bcm->irq_lock, flags);
bcm43xx_synchronize_irq(bcm); bcm43xx_synchronize_irq(bcm);
...@@ -3150,6 +3151,7 @@ static void bcm43xx_periodic_work_handler(void *d) ...@@ -3150,6 +3151,7 @@ static void bcm43xx_periodic_work_handler(void *d)
/* Periodic work will take a long time, so we want it to /* Periodic work will take a long time, so we want it to
* be preemtible. * be preemtible.
*/ */
mutex_lock(&bcm->mutex);
netif_stop_queue(bcm->net_dev); netif_stop_queue(bcm->net_dev);
synchronize_net(); synchronize_net();
spin_lock_irqsave(&bcm->irq_lock, flags); spin_lock_irqsave(&bcm->irq_lock, flags);
...@@ -3158,7 +3160,6 @@ static void bcm43xx_periodic_work_handler(void *d) ...@@ -3158,7 +3160,6 @@ static void bcm43xx_periodic_work_handler(void *d)
bcm43xx_pio_freeze_txqueues(bcm); bcm43xx_pio_freeze_txqueues(bcm);
savedirqs = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL); savedirqs = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
spin_unlock_irqrestore(&bcm->irq_lock, flags); spin_unlock_irqrestore(&bcm->irq_lock, flags);
mutex_lock(&bcm->mutex);
bcm43xx_synchronize_irq(bcm); bcm43xx_synchronize_irq(bcm);
} else { } else {
/* Periodic work should take short time, so we want low /* Periodic work should take short time, so we want low
...@@ -3172,13 +3173,11 @@ static void bcm43xx_periodic_work_handler(void *d) ...@@ -3172,13 +3173,11 @@ static void bcm43xx_periodic_work_handler(void *d)
if (badness > BADNESS_LIMIT) { if (badness > BADNESS_LIMIT) {
spin_lock_irqsave(&bcm->irq_lock, flags); spin_lock_irqsave(&bcm->irq_lock, flags);
if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) {
tasklet_enable(&bcm->isr_tasklet); tasklet_enable(&bcm->isr_tasklet);
bcm43xx_interrupt_enable(bcm, savedirqs); bcm43xx_interrupt_enable(bcm, savedirqs);
if (bcm43xx_using_pio(bcm)) if (bcm43xx_using_pio(bcm))
bcm43xx_pio_thaw_txqueues(bcm); bcm43xx_pio_thaw_txqueues(bcm);
bcm43xx_mac_enable(bcm); bcm43xx_mac_enable(bcm);
}
netif_wake_queue(bcm->net_dev); netif_wake_queue(bcm->net_dev);
} }
mmiowb(); mmiowb();
...@@ -3186,12 +3185,12 @@ static void bcm43xx_periodic_work_handler(void *d) ...@@ -3186,12 +3185,12 @@ static void bcm43xx_periodic_work_handler(void *d)
mutex_unlock(&bcm->mutex); mutex_unlock(&bcm->mutex);
} }
static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm) void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
{ {
cancel_rearming_delayed_work(&bcm->periodic_work); cancel_rearming_delayed_work(&bcm->periodic_work);
} }
static void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm) void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
{ {
struct work_struct *work = &(bcm->periodic_work); struct work_struct *work = &(bcm->periodic_work);
...@@ -3539,11 +3538,10 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm) ...@@ -3539,11 +3538,10 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
err = bcm43xx_select_wireless_core(bcm, -1); err = bcm43xx_select_wireless_core(bcm, -1);
if (err) if (err)
goto err_crystal_off; goto err_crystal_off;
bcm43xx_periodic_tasks_setup(bcm);
err = bcm43xx_sysfs_register(bcm); err = bcm43xx_sysfs_register(bcm);
if (err) if (err)
goto err_wlshutdown; goto err_wlshutdown;
bcm43xx_periodic_tasks_setup(bcm);
err = bcm43xx_rng_init(bcm); err = bcm43xx_rng_init(bcm);
if (err) if (err)
goto err_sysfs_unreg; goto err_sysfs_unreg;
...@@ -3969,6 +3967,7 @@ static int bcm43xx_net_stop(struct net_device *net_dev) ...@@ -3969,6 +3967,7 @@ static int bcm43xx_net_stop(struct net_device *net_dev)
err = bcm43xx_disable_interrupts_sync(bcm); err = bcm43xx_disable_interrupts_sync(bcm);
assert(!err); assert(!err);
bcm43xx_free_board(bcm); bcm43xx_free_board(bcm);
flush_scheduled_work();
return 0; return 0;
} }
...@@ -4119,11 +4118,16 @@ static void bcm43xx_chip_reset(void *_bcm) ...@@ -4119,11 +4118,16 @@ static void bcm43xx_chip_reset(void *_bcm)
{ {
struct bcm43xx_private *bcm = _bcm; struct bcm43xx_private *bcm = _bcm;
struct bcm43xx_phyinfo *phy; struct bcm43xx_phyinfo *phy;
int err; int err = -ENODEV;
mutex_lock(&(bcm)->mutex); mutex_lock(&(bcm)->mutex);
if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
bcm43xx_periodic_tasks_delete(bcm);
phy = bcm43xx_current_phy(bcm); phy = bcm43xx_current_phy(bcm);
err = bcm43xx_select_wireless_core(bcm, phy->type); err = bcm43xx_select_wireless_core(bcm, phy->type);
if (!err)
bcm43xx_periodic_tasks_setup(bcm);
}
mutex_unlock(&(bcm)->mutex); mutex_unlock(&(bcm)->mutex);
printk(KERN_ERR PFX "Controller restart%s\n", printk(KERN_ERR PFX "Controller restart%s\n",
...@@ -4132,11 +4136,12 @@ static void bcm43xx_chip_reset(void *_bcm) ...@@ -4132,11 +4136,12 @@ static void bcm43xx_chip_reset(void *_bcm)
/* Hard-reset the chip. /* Hard-reset the chip.
* This can be called from interrupt or process context. * This can be called from interrupt or process context.
* bcm->irq_lock must be locked.
*/ */
void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason) void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
{ {
assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED); if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
bcm43xx_set_status(bcm, BCM43xx_STAT_RESTARTING); return;
printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason); printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm); INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm);
schedule_work(&bcm->restart_work); schedule_work(&bcm->restart_work);
......
...@@ -141,6 +141,9 @@ void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy); ...@@ -141,6 +141,9 @@ void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy);
void bcm43xx_mac_suspend(struct bcm43xx_private *bcm); void bcm43xx_mac_suspend(struct bcm43xx_private *bcm);
void bcm43xx_mac_enable(struct bcm43xx_private *bcm); void bcm43xx_mac_enable(struct bcm43xx_private *bcm);
void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm);
void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm);
void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason); void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason);
int bcm43xx_sprom_read(struct bcm43xx_private *bcm, u16 *sprom); int bcm43xx_sprom_read(struct bcm43xx_private *bcm, u16 *sprom);
......
...@@ -333,8 +333,11 @@ static ssize_t bcm43xx_attr_phymode_store(struct device *dev, ...@@ -333,8 +333,11 @@ static ssize_t bcm43xx_attr_phymode_store(struct device *dev,
goto out; goto out;
} }
bcm43xx_periodic_tasks_delete(bcm);
mutex_lock(&(bcm)->mutex); mutex_lock(&(bcm)->mutex);
err = bcm43xx_select_wireless_core(bcm, phytype); err = bcm43xx_select_wireless_core(bcm, phytype);
if (!err)
bcm43xx_periodic_tasks_setup(bcm);
mutex_unlock(&(bcm)->mutex); mutex_unlock(&(bcm)->mutex);
if (err == -ESRCH) if (err == -ESRCH)
err = -ENODEV; err = -ENODEV;
......
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