Commit f5d40eed authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

b43: Remove TX spinlock

This removes the TX spinlock and defers TX to a workqueue to allow
locking wl->mutex instead and to allow sleeping for register accesses.
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Tested-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 36dbd954
...@@ -683,6 +683,11 @@ struct b43_wl { ...@@ -683,6 +683,11 @@ struct b43_wl {
* This is scheduled when we determine that the actual TX output * This is scheduled when we determine that the actual TX output
* power doesn't match what we want. */ * power doesn't match what we want. */
struct work_struct txpower_adjust_work; struct work_struct txpower_adjust_work;
/* Packet transmit work */
struct work_struct tx_work;
/* Queue of packets to be transmitted. */
struct sk_buff_head tx_queue;
}; };
/* The type of the firmware file. */ /* The type of the firmware file. */
......
...@@ -690,7 +690,6 @@ static void b43_short_slot_timing_disable(struct b43_wldev *dev) ...@@ -690,7 +690,6 @@ static void b43_short_slot_timing_disable(struct b43_wldev *dev)
*/ */
void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on) void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
{ {
struct b43_wl *wl = dev->wl;
struct b43_phy *phy = &dev->phy; struct b43_phy *phy = &dev->phy;
unsigned int i, max_loop; unsigned int i, max_loop;
u16 value; u16 value;
...@@ -710,8 +709,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on) ...@@ -710,8 +709,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
buffer[0] = 0x000B846E; buffer[0] = 0x000B846E;
} }
write_lock_irq(&wl->tx_lock);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
b43_ram_write(dev, i * 4, buffer[i]); b43_ram_write(dev, i * 4, buffer[i]);
...@@ -767,8 +764,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on) ...@@ -767,8 +764,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
} }
if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5) if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5)
b43_radio_write16(dev, 0x0051, 0x0037); b43_radio_write16(dev, 0x0051, 0x0037);
write_unlock_irq(&wl->tx_lock);
} }
static void key_write(struct b43_wldev *dev, static void key_write(struct b43_wldev *dev,
...@@ -3098,42 +3093,49 @@ static int b43_rng_init(struct b43_wl *wl) ...@@ -3098,42 +3093,49 @@ static int b43_rng_init(struct b43_wl *wl)
return err; return err;
} }
static int b43_op_tx(struct ieee80211_hw *hw, static void b43_tx_work(struct work_struct *work)
struct sk_buff *skb)
{ {
struct b43_wl *wl = hw_to_b43_wl(hw); struct b43_wl *wl = container_of(work, struct b43_wl, tx_work);
struct b43_wldev *dev = wl->current_dev; struct b43_wldev *dev;
unsigned long flags; struct sk_buff *skb;
int err; int err = 0;
if (unlikely(skb->len < 2 + 2 + 6)) { mutex_lock(&wl->mutex);
/* Too short, this can't be a valid frame. */ dev = wl->current_dev;
goto drop_packet; if (unlikely(!dev || b43_status(dev) < B43_STAT_STARTED)) {
mutex_unlock(&wl->mutex);
return;
} }
B43_WARN_ON(skb_shinfo(skb)->nr_frags);
if (unlikely(!dev))
goto drop_packet;
/* Transmissions on seperate queues can run concurrently. */ while (skb_queue_len(&wl->tx_queue)) {
read_lock_irqsave(&wl->tx_lock, flags); skb = skb_dequeue(&wl->tx_queue);
err = -ENODEV;
if (likely(b43_status(dev) >= B43_STAT_STARTED)) {
if (b43_using_pio_transfers(dev)) if (b43_using_pio_transfers(dev))
err = b43_pio_tx(dev, skb); err = b43_pio_tx(dev, skb);
else else
err = b43_dma_tx(dev, skb); err = b43_dma_tx(dev, skb);
if (unlikely(err))
dev_kfree_skb(skb); /* Drop it */
} }
read_unlock_irqrestore(&wl->tx_lock, flags); mutex_unlock(&wl->mutex);
}
if (unlikely(err)) static int b43_op_tx(struct ieee80211_hw *hw,
goto drop_packet; struct sk_buff *skb)
return NETDEV_TX_OK; {
struct b43_wl *wl = hw_to_b43_wl(hw);
if (unlikely(skb->len < 2 + 2 + 6)) {
/* Too short, this can't be a valid frame. */
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
}
B43_WARN_ON(skb_shinfo(skb)->nr_frags);
skb_queue_tail(&wl->tx_queue, skb);
ieee80211_queue_work(wl->hw, &wl->tx_work);
drop_packet:
/* We can not transmit this packet. Drop it. */
dev_kfree_skb_any(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -3686,18 +3688,12 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -3686,18 +3688,12 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
u8 algorithm; u8 algorithm;
u8 index; u8 index;
int err; int err;
unsigned long flags;
static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
if (modparam_nohwcrypt) if (modparam_nohwcrypt)
return -ENOSPC; /* User disabled HW-crypto */ return -ENOSPC; /* User disabled HW-crypto */
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
write_lock_irqsave(&wl->tx_lock, flags);
/* mutex -> Every config operation must take it.
* tx_lock -> We modify the dev->key array, which is accessed
* in the TX handler.
*/
dev = wl->current_dev; dev = wl->current_dev;
err = -ENODEV; err = -ENODEV;
...@@ -3789,7 +3785,6 @@ out_unlock: ...@@ -3789,7 +3785,6 @@ out_unlock:
sta ? sta->addr : bcast_addr); sta ? sta->addr : bcast_addr);
b43_dump_keymemory(dev); b43_dump_keymemory(dev);
} }
write_unlock_irqrestore(&wl->tx_lock, flags);
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
return err; return err;
...@@ -3846,9 +3841,10 @@ redo: ...@@ -3846,9 +3841,10 @@ redo:
if (!dev || b43_status(dev) < B43_STAT_STARTED) if (!dev || b43_status(dev) < B43_STAT_STARTED)
return dev; return dev;
/* Disable periodic work. Unlock to avoid deadlocks. */ /* Cancel work. Unlock to avoid deadlocks. */
mutex_unlock(&wl->mutex); mutex_unlock(&wl->mutex);
cancel_delayed_work_sync(&dev->periodic_work); cancel_delayed_work_sync(&dev->periodic_work);
cancel_work_sync(&wl->tx_work);
mutex_lock(&wl->mutex); mutex_lock(&wl->mutex);
dev = wl->current_dev; dev = wl->current_dev;
if (!dev || b43_status(dev) < B43_STAT_STARTED) { if (!dev || b43_status(dev) < B43_STAT_STARTED) {
...@@ -3883,6 +3879,10 @@ redo: ...@@ -3883,6 +3879,10 @@ redo:
} }
B43_WARN_ON(b43_read32(dev, B43_MMIO_GEN_IRQ_MASK)); B43_WARN_ON(b43_read32(dev, B43_MMIO_GEN_IRQ_MASK));
/* Drain the TX queue */
while (skb_queue_len(&wl->tx_queue))
dev_kfree_skb(skb_dequeue(&wl->tx_queue));
b43_pio_stop(dev); b43_pio_stop(dev);
b43_mac_suspend(dev); b43_mac_suspend(dev);
free_irq(dev->dev->irq, dev); free_irq(dev->dev->irq, dev);
...@@ -4866,7 +4866,6 @@ static int b43_wireless_init(struct ssb_device *dev) ...@@ -4866,7 +4866,6 @@ static int b43_wireless_init(struct ssb_device *dev)
/* Initialize struct b43_wl */ /* Initialize struct b43_wl */
wl->hw = hw; wl->hw = hw;
rwlock_init(&wl->tx_lock);
spin_lock_init(&wl->leds_lock); spin_lock_init(&wl->leds_lock);
spin_lock_init(&wl->shm_lock); spin_lock_init(&wl->shm_lock);
mutex_init(&wl->mutex); mutex_init(&wl->mutex);
...@@ -4874,6 +4873,8 @@ static int b43_wireless_init(struct ssb_device *dev) ...@@ -4874,6 +4873,8 @@ static int b43_wireless_init(struct ssb_device *dev)
INIT_LIST_HEAD(&wl->devlist); INIT_LIST_HEAD(&wl->devlist);
INIT_WORK(&wl->beacon_update_trigger, b43_beacon_update_trigger_work); INIT_WORK(&wl->beacon_update_trigger, b43_beacon_update_trigger_work);
INIT_WORK(&wl->txpower_adjust_work, b43_phy_txpower_adjust_work); INIT_WORK(&wl->txpower_adjust_work, b43_phy_txpower_adjust_work);
INIT_WORK(&wl->tx_work, b43_tx_work);
skb_queue_head_init(&wl->tx_queue);
ssb_set_devtypedata(dev, wl); ssb_set_devtypedata(dev, wl);
b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n", b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n",
......
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