diff options
author | Michael Buesch <mb@bu3sch.de> | 2008-04-25 13:29:08 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-01 17:38:18 -0400 |
commit | 21a75d7788f4e29b6c6d28e08f9f0310c4de828d (patch) | |
tree | fa61a2ca42bbc98c28a760630e39f8f3c781d6f2 /drivers/net/wireless | |
parent | c2a3b233450d5bc426c063ea2d8a74351db29ea4 (diff) |
b43: Fix some TX/RX locking issues
This fixes some TX/RX related locking issues.
With this patch applied, some of the PHY transmission errors are fixed.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/b43/b43.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/main.c | 43 |
2 files changed, 33 insertions, 14 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index eff2a158a411..37783cdd301a 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -691,6 +691,10 @@ struct b43_wl { | |||
691 | 691 | ||
692 | struct mutex mutex; | 692 | struct mutex mutex; |
693 | spinlock_t irq_lock; | 693 | spinlock_t irq_lock; |
694 | /* R/W lock for data transmission. | ||
695 | * Transmissions on 2+ queues can run concurrently, but somebody else | ||
696 | * might sync with TX by write_lock_irqsave()'ing. */ | ||
697 | rwlock_t tx_lock; | ||
694 | /* Lock for LEDs access. */ | 698 | /* Lock for LEDs access. */ |
695 | spinlock_t leds_lock; | 699 | spinlock_t leds_lock; |
696 | /* Lock for SHM access. */ | 700 | /* Lock for SHM access. */ |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 6c7db9a1a466..8fdba9415c04 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -729,6 +729,7 @@ static void b43_synchronize_irq(struct b43_wldev *dev) | |||
729 | */ | 729 | */ |
730 | void b43_dummy_transmission(struct b43_wldev *dev) | 730 | void b43_dummy_transmission(struct b43_wldev *dev) |
731 | { | 731 | { |
732 | struct b43_wl *wl = dev->wl; | ||
732 | struct b43_phy *phy = &dev->phy; | 733 | struct b43_phy *phy = &dev->phy; |
733 | unsigned int i, max_loop; | 734 | unsigned int i, max_loop; |
734 | u16 value; | 735 | u16 value; |
@@ -755,6 +756,9 @@ void b43_dummy_transmission(struct b43_wldev *dev) | |||
755 | return; | 756 | return; |
756 | } | 757 | } |
757 | 758 | ||
759 | spin_lock_irq(&wl->irq_lock); | ||
760 | write_lock(&wl->tx_lock); | ||
761 | |||
758 | for (i = 0; i < 5; i++) | 762 | for (i = 0; i < 5; i++) |
759 | b43_ram_write(dev, i * 4, buffer[i]); | 763 | b43_ram_write(dev, i * 4, buffer[i]); |
760 | 764 | ||
@@ -795,6 +799,9 @@ void b43_dummy_transmission(struct b43_wldev *dev) | |||
795 | } | 799 | } |
796 | if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) | 800 | if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) |
797 | b43_radio_write16(dev, 0x0051, 0x0037); | 801 | b43_radio_write16(dev, 0x0051, 0x0037); |
802 | |||
803 | write_unlock(&wl->tx_lock); | ||
804 | spin_unlock_irq(&wl->irq_lock); | ||
798 | } | 805 | } |
799 | 806 | ||
800 | static void key_write(struct b43_wldev *dev, | 807 | static void key_write(struct b43_wldev *dev, |
@@ -2840,24 +2847,31 @@ static int b43_op_tx(struct ieee80211_hw *hw, | |||
2840 | { | 2847 | { |
2841 | struct b43_wl *wl = hw_to_b43_wl(hw); | 2848 | struct b43_wl *wl = hw_to_b43_wl(hw); |
2842 | struct b43_wldev *dev = wl->current_dev; | 2849 | struct b43_wldev *dev = wl->current_dev; |
2843 | int err = -ENODEV; | 2850 | unsigned long flags; |
2851 | int err; | ||
2844 | 2852 | ||
2845 | if (unlikely(skb->len < 2 + 2 + 6)) { | 2853 | if (unlikely(skb->len < 2 + 2 + 6)) { |
2846 | /* Too short, this can't be a valid frame. */ | 2854 | /* Too short, this can't be a valid frame. */ |
2847 | return -EINVAL; | 2855 | dev_kfree_skb_any(skb); |
2856 | return NETDEV_TX_OK; | ||
2848 | } | 2857 | } |
2849 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); | 2858 | B43_WARN_ON(skb_shinfo(skb)->nr_frags); |
2850 | |||
2851 | if (unlikely(!dev)) | 2859 | if (unlikely(!dev)) |
2852 | goto out; | 2860 | return NETDEV_TX_BUSY; |
2853 | if (unlikely(b43_status(dev) < B43_STAT_STARTED)) | 2861 | |
2854 | goto out; | 2862 | /* Transmissions on seperate queues can run concurrently. */ |
2855 | /* TX is done without a global lock. */ | 2863 | read_lock_irqsave(&wl->tx_lock, flags); |
2856 | if (b43_using_pio_transfers(dev)) | 2864 | |
2857 | err = b43_pio_tx(dev, skb, ctl); | 2865 | err = -ENODEV; |
2858 | else | 2866 | if (likely(b43_status(dev) >= B43_STAT_STARTED)) { |
2859 | err = b43_dma_tx(dev, skb, ctl); | 2867 | if (b43_using_pio_transfers(dev)) |
2860 | out: | 2868 | err = b43_pio_tx(dev, skb, ctl); |
2869 | else | ||
2870 | err = b43_dma_tx(dev, skb, ctl); | ||
2871 | } | ||
2872 | |||
2873 | read_unlock_irqrestore(&wl->tx_lock, flags); | ||
2874 | |||
2861 | if (unlikely(err)) | 2875 | if (unlikely(err)) |
2862 | return NETDEV_TX_BUSY; | 2876 | return NETDEV_TX_BUSY; |
2863 | return NETDEV_TX_OK; | 2877 | return NETDEV_TX_OK; |
@@ -3476,7 +3490,9 @@ static void b43_wireless_core_stop(struct b43_wldev *dev) | |||
3476 | spin_unlock_irqrestore(&wl->irq_lock, flags); | 3490 | spin_unlock_irqrestore(&wl->irq_lock, flags); |
3477 | b43_synchronize_irq(dev); | 3491 | b43_synchronize_irq(dev); |
3478 | 3492 | ||
3493 | write_lock_irqsave(&wl->tx_lock, flags); | ||
3479 | b43_set_status(dev, B43_STAT_INITIALIZED); | 3494 | b43_set_status(dev, B43_STAT_INITIALIZED); |
3495 | write_unlock_irqrestore(&wl->tx_lock, flags); | ||
3480 | 3496 | ||
3481 | b43_pio_stop(dev); | 3497 | b43_pio_stop(dev); |
3482 | mutex_unlock(&wl->mutex); | 3498 | mutex_unlock(&wl->mutex); |
@@ -3485,8 +3501,6 @@ static void b43_wireless_core_stop(struct b43_wldev *dev) | |||
3485 | cancel_delayed_work_sync(&dev->periodic_work); | 3501 | cancel_delayed_work_sync(&dev->periodic_work); |
3486 | mutex_lock(&wl->mutex); | 3502 | mutex_lock(&wl->mutex); |
3487 | 3503 | ||
3488 | ieee80211_stop_queues(wl->hw); //FIXME this could cause a deadlock, as mac80211 seems buggy. | ||
3489 | |||
3490 | b43_mac_suspend(dev); | 3504 | b43_mac_suspend(dev); |
3491 | free_irq(dev->dev->irq, dev); | 3505 | free_irq(dev->dev->irq, dev); |
3492 | b43dbg(wl, "Wireless interface stopped\n"); | 3506 | b43dbg(wl, "Wireless interface stopped\n"); |
@@ -4498,6 +4512,7 @@ static int b43_wireless_init(struct ssb_device *dev) | |||
4498 | memset(wl, 0, sizeof(*wl)); | 4512 | memset(wl, 0, sizeof(*wl)); |
4499 | wl->hw = hw; | 4513 | wl->hw = hw; |
4500 | spin_lock_init(&wl->irq_lock); | 4514 | spin_lock_init(&wl->irq_lock); |
4515 | rwlock_init(&wl->tx_lock); | ||
4501 | spin_lock_init(&wl->leds_lock); | 4516 | spin_lock_init(&wl->leds_lock); |
4502 | spin_lock_init(&wl->shm_lock); | 4517 | spin_lock_init(&wl->shm_lock); |
4503 | mutex_init(&wl->mutex); | 4518 | mutex_init(&wl->mutex); |