diff options
Diffstat (limited to 'drivers/net/wireless/bcm43xx/bcm43xx_main.c')
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_main.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c index bad3452ea893..a1b783813d8e 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c | |||
@@ -746,7 +746,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom) | |||
746 | if (err) | 746 | if (err) |
747 | goto err_ctlreg; | 747 | goto err_ctlreg; |
748 | spromctl |= 0x10; /* SPROM WRITE enable. */ | 748 | spromctl |= 0x10; /* SPROM WRITE enable. */ |
749 | bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); | 749 | err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); |
750 | if (err) | 750 | if (err) |
751 | goto err_ctlreg; | 751 | goto err_ctlreg; |
752 | /* We must burn lots of CPU cycles here, but that does not | 752 | /* We must burn lots of CPU cycles here, but that does not |
@@ -768,7 +768,7 @@ int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom) | |||
768 | mdelay(20); | 768 | mdelay(20); |
769 | } | 769 | } |
770 | spromctl &= ~0x10; /* SPROM WRITE enable. */ | 770 | spromctl &= ~0x10; /* SPROM WRITE enable. */ |
771 | bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); | 771 | err = bcm43xx_pci_write_config32(bcm, BCM43xx_PCICFG_SPROMCTL, spromctl); |
772 | if (err) | 772 | if (err) |
773 | goto err_ctlreg; | 773 | goto err_ctlreg; |
774 | mdelay(500); | 774 | mdelay(500); |
@@ -1463,6 +1463,23 @@ static void handle_irq_transmit_status(struct bcm43xx_private *bcm) | |||
1463 | } | 1463 | } |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | static void drain_txstatus_queue(struct bcm43xx_private *bcm) | ||
1467 | { | ||
1468 | u32 dummy; | ||
1469 | |||
1470 | if (bcm->current_core->rev < 5) | ||
1471 | return; | ||
1472 | /* Read all entries from the microcode TXstatus FIFO | ||
1473 | * and throw them away. | ||
1474 | */ | ||
1475 | while (1) { | ||
1476 | dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0); | ||
1477 | if (!dummy) | ||
1478 | break; | ||
1479 | dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_1); | ||
1480 | } | ||
1481 | } | ||
1482 | |||
1466 | static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) | 1483 | static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm) |
1467 | { | 1484 | { |
1468 | bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F); | 1485 | bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F); |
@@ -2925,10 +2942,13 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm, | |||
2925 | bcm43xx_write16(bcm, 0x043C, 0x000C); | 2942 | bcm43xx_write16(bcm, 0x043C, 0x000C); |
2926 | 2943 | ||
2927 | if (active_wlcore) { | 2944 | if (active_wlcore) { |
2928 | if (bcm43xx_using_pio(bcm)) | 2945 | if (bcm43xx_using_pio(bcm)) { |
2929 | err = bcm43xx_pio_init(bcm); | 2946 | err = bcm43xx_pio_init(bcm); |
2930 | else | 2947 | } else { |
2931 | err = bcm43xx_dma_init(bcm); | 2948 | err = bcm43xx_dma_init(bcm); |
2949 | if (err == -ENOSYS) | ||
2950 | err = bcm43xx_pio_init(bcm); | ||
2951 | } | ||
2932 | if (err) | 2952 | if (err) |
2933 | goto err_chip_cleanup; | 2953 | goto err_chip_cleanup; |
2934 | } | 2954 | } |
@@ -3160,17 +3180,30 @@ static int estimate_periodic_work_badness(unsigned int state) | |||
3160 | static void bcm43xx_periodic_work_handler(void *d) | 3180 | static void bcm43xx_periodic_work_handler(void *d) |
3161 | { | 3181 | { |
3162 | struct bcm43xx_private *bcm = d; | 3182 | struct bcm43xx_private *bcm = d; |
3183 | struct net_device *net_dev = bcm->net_dev; | ||
3163 | unsigned long flags; | 3184 | unsigned long flags; |
3164 | u32 savedirqs = 0; | 3185 | u32 savedirqs = 0; |
3165 | int badness; | 3186 | int badness; |
3187 | unsigned long orig_trans_start = 0; | ||
3166 | 3188 | ||
3189 | mutex_lock(&bcm->mutex); | ||
3167 | badness = estimate_periodic_work_badness(bcm->periodic_state); | 3190 | badness = estimate_periodic_work_badness(bcm->periodic_state); |
3168 | if (badness > BADNESS_LIMIT) { | 3191 | if (badness > BADNESS_LIMIT) { |
3169 | /* Periodic work will take a long time, so we want it to | 3192 | /* Periodic work will take a long time, so we want it to |
3170 | * be preemtible. | 3193 | * be preemtible. |
3171 | */ | 3194 | */ |
3172 | mutex_lock(&bcm->mutex); | 3195 | |
3173 | netif_tx_disable(bcm->net_dev); | 3196 | netif_tx_lock_bh(net_dev); |
3197 | /* We must fake a started transmission here, as we are going to | ||
3198 | * disable TX. If we wouldn't fake a TX, it would be possible to | ||
3199 | * trigger the netdev watchdog, if the last real TX is already | ||
3200 | * some time on the past (slightly less than 5secs) | ||
3201 | */ | ||
3202 | orig_trans_start = net_dev->trans_start; | ||
3203 | net_dev->trans_start = jiffies; | ||
3204 | netif_stop_queue(net_dev); | ||
3205 | netif_tx_unlock_bh(net_dev); | ||
3206 | |||
3174 | spin_lock_irqsave(&bcm->irq_lock, flags); | 3207 | spin_lock_irqsave(&bcm->irq_lock, flags); |
3175 | bcm43xx_mac_suspend(bcm); | 3208 | bcm43xx_mac_suspend(bcm); |
3176 | if (bcm43xx_using_pio(bcm)) | 3209 | if (bcm43xx_using_pio(bcm)) |
@@ -3182,7 +3215,6 @@ static void bcm43xx_periodic_work_handler(void *d) | |||
3182 | /* Periodic work should take short time, so we want low | 3215 | /* Periodic work should take short time, so we want low |
3183 | * locking overhead. | 3216 | * locking overhead. |
3184 | */ | 3217 | */ |
3185 | mutex_lock(&bcm->mutex); | ||
3186 | spin_lock_irqsave(&bcm->irq_lock, flags); | 3218 | spin_lock_irqsave(&bcm->irq_lock, flags); |
3187 | } | 3219 | } |
3188 | 3220 | ||
@@ -3196,6 +3228,7 @@ static void bcm43xx_periodic_work_handler(void *d) | |||
3196 | bcm43xx_pio_thaw_txqueues(bcm); | 3228 | bcm43xx_pio_thaw_txqueues(bcm); |
3197 | bcm43xx_mac_enable(bcm); | 3229 | bcm43xx_mac_enable(bcm); |
3198 | netif_wake_queue(bcm->net_dev); | 3230 | netif_wake_queue(bcm->net_dev); |
3231 | net_dev->trans_start = orig_trans_start; | ||
3199 | } | 3232 | } |
3200 | mmiowb(); | 3233 | mmiowb(); |
3201 | spin_unlock_irqrestore(&bcm->irq_lock, flags); | 3234 | spin_unlock_irqrestore(&bcm->irq_lock, flags); |
@@ -3516,6 +3549,7 @@ int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm, | |||
3516 | bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); | 3549 | bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); |
3517 | bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); | 3550 | bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); |
3518 | bcm43xx_security_init(bcm); | 3551 | bcm43xx_security_init(bcm); |
3552 | drain_txstatus_queue(bcm); | ||
3519 | ieee80211softmac_start(bcm->net_dev); | 3553 | ieee80211softmac_start(bcm->net_dev); |
3520 | 3554 | ||
3521 | /* Let's go! Be careful after enabling the IRQs. | 3555 | /* Let's go! Be careful after enabling the IRQs. |
@@ -3993,8 +4027,6 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm, | |||
3993 | struct net_device *net_dev, | 4027 | struct net_device *net_dev, |
3994 | struct pci_dev *pci_dev) | 4028 | struct pci_dev *pci_dev) |
3995 | { | 4029 | { |
3996 | int err; | ||
3997 | |||
3998 | bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT); | 4030 | bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT); |
3999 | bcm->ieee = netdev_priv(net_dev); | 4031 | bcm->ieee = netdev_priv(net_dev); |
4000 | bcm->softmac = ieee80211_priv(net_dev); | 4032 | bcm->softmac = ieee80211_priv(net_dev); |
@@ -4012,22 +4044,8 @@ static int bcm43xx_init_private(struct bcm43xx_private *bcm, | |||
4012 | (void (*)(unsigned long))bcm43xx_interrupt_tasklet, | 4044 | (void (*)(unsigned long))bcm43xx_interrupt_tasklet, |
4013 | (unsigned long)bcm); | 4045 | (unsigned long)bcm); |
4014 | tasklet_disable_nosync(&bcm->isr_tasklet); | 4046 | tasklet_disable_nosync(&bcm->isr_tasklet); |
4015 | if (modparam_pio) { | 4047 | if (modparam_pio) |
4016 | bcm->__using_pio = 1; | 4048 | bcm->__using_pio = 1; |
4017 | } else { | ||
4018 | err = pci_set_dma_mask(pci_dev, DMA_30BIT_MASK); | ||
4019 | err |= pci_set_consistent_dma_mask(pci_dev, DMA_30BIT_MASK); | ||
4020 | if (err) { | ||
4021 | #ifdef CONFIG_BCM43XX_PIO | ||
4022 | printk(KERN_WARNING PFX "DMA not supported. Falling back to PIO.\n"); | ||
4023 | bcm->__using_pio = 1; | ||
4024 | #else | ||
4025 | printk(KERN_ERR PFX "FATAL: DMA not supported and PIO not configured. " | ||
4026 | "Recompile the driver with PIO support, please.\n"); | ||
4027 | return -ENODEV; | ||
4028 | #endif /* CONFIG_BCM43XX_PIO */ | ||
4029 | } | ||
4030 | } | ||
4031 | bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; | 4049 | bcm->rts_threshold = BCM43xx_DEFAULT_RTS_THRESHOLD; |
4032 | 4050 | ||
4033 | /* default to sw encryption for now */ | 4051 | /* default to sw encryption for now */ |
@@ -4208,7 +4226,11 @@ static int bcm43xx_resume(struct pci_dev *pdev) | |||
4208 | dprintk(KERN_INFO PFX "Resuming...\n"); | 4226 | dprintk(KERN_INFO PFX "Resuming...\n"); |
4209 | 4227 | ||
4210 | pci_set_power_state(pdev, 0); | 4228 | pci_set_power_state(pdev, 0); |
4211 | pci_enable_device(pdev); | 4229 | err = pci_enable_device(pdev); |
4230 | if (err) { | ||
4231 | printk(KERN_ERR PFX "Failure with pci_enable_device!\n"); | ||
4232 | return err; | ||
4233 | } | ||
4212 | pci_restore_state(pdev); | 4234 | pci_restore_state(pdev); |
4213 | 4235 | ||
4214 | bcm43xx_chipset_attach(bcm); | 4236 | bcm43xx_chipset_attach(bcm); |