Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[deliverable/linux.git] / drivers / net / wireless / b43 / main.c
index 80b688441ffe83eb06901e42c24b92fe07215cb3..e789792a36bc468f88d688f984c299a78927424c 100644 (file)
@@ -390,7 +390,7 @@ static inline void b43_shm_control_word(struct b43_wldev *dev,
        b43_write32(dev, B43_MMIO_SHM_CONTROL, control);
 }
 
-u32 __b43_shm_read32(struct b43_wldev *dev, u16 routing, u16 offset)
+u32 b43_shm_read32(struct b43_wldev *dev, u16 routing, u16 offset)
 {
        u32 ret;
 
@@ -413,20 +413,7 @@ out:
        return ret;
 }
 
-u32 b43_shm_read32(struct b43_wldev *dev, u16 routing, u16 offset)
-{
-       struct b43_wl *wl = dev->wl;
-       unsigned long flags;
-       u32 ret;
-
-       spin_lock_irqsave(&wl->shm_lock, flags);
-       ret = __b43_shm_read32(dev, routing, offset);
-       spin_unlock_irqrestore(&wl->shm_lock, flags);
-
-       return ret;
-}
-
-u16 __b43_shm_read16(struct b43_wldev *dev, u16 routing, u16 offset)
+u16 b43_shm_read16(struct b43_wldev *dev, u16 routing, u16 offset)
 {
        u16 ret;
 
@@ -447,20 +434,7 @@ out:
        return ret;
 }
 
-u16 b43_shm_read16(struct b43_wldev *dev, u16 routing, u16 offset)
-{
-       struct b43_wl *wl = dev->wl;
-       unsigned long flags;
-       u16 ret;
-
-       spin_lock_irqsave(&wl->shm_lock, flags);
-       ret = __b43_shm_read16(dev, routing, offset);
-       spin_unlock_irqrestore(&wl->shm_lock, flags);
-
-       return ret;
-}
-
-void __b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value)
+void b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value)
 {
        if (routing == B43_SHM_SHARED) {
                B43_WARN_ON(offset & 0x0001);
@@ -480,17 +454,7 @@ void __b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value
        b43_write32(dev, B43_MMIO_SHM_DATA, value);
 }
 
-void b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value)
-{
-       struct b43_wl *wl = dev->wl;
-       unsigned long flags;
-
-       spin_lock_irqsave(&wl->shm_lock, flags);
-       __b43_shm_write32(dev, routing, offset, value);
-       spin_unlock_irqrestore(&wl->shm_lock, flags);
-}
-
-void __b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value)
+void b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value)
 {
        if (routing == B43_SHM_SHARED) {
                B43_WARN_ON(offset & 0x0001);
@@ -506,16 +470,6 @@ void __b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value
        b43_write16(dev, B43_MMIO_SHM_DATA, value);
 }
 
-void b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value)
-{
-       struct b43_wl *wl = dev->wl;
-       unsigned long flags;
-
-       spin_lock_irqsave(&wl->shm_lock, flags);
-       __b43_shm_write16(dev, routing, offset, value);
-       spin_unlock_irqrestore(&wl->shm_lock, flags);
-}
-
 /* Read HostFlags */
 u64 b43_hf_read(struct b43_wldev *dev)
 {
@@ -690,7 +644,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)
 {
-       struct b43_wl *wl = dev->wl;
        struct b43_phy *phy = &dev->phy;
        unsigned int i, max_loop;
        u16 value;
@@ -710,8 +663,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
                buffer[0] = 0x000B846E;
        }
 
-       write_lock_irq(&wl->tx_lock);
-
        for (i = 0; i < 5; i++)
                b43_ram_write(dev, i * 4, buffer[i]);
 
@@ -767,8 +718,6 @@ void b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on)
        }
        if (phy->radio_ver == 0x2050 && phy->radio_rev <= 0x5)
                b43_radio_write16(dev, 0x0051, 0x0037);
-
-       write_unlock_irq(&wl->tx_lock);
 }
 
 static void key_write(struct b43_wldev *dev,
@@ -2340,11 +2289,7 @@ static int b43_upload_microcode(struct b43_wldev *dev)
                        err = -ENODEV;
                        goto error;
                }
-               msleep_interruptible(50);
-               if (signal_pending(current)) {
-                       err = -EINTR;
-                       goto error;
-               }
+               msleep(50);
        }
        b43_read32(dev, B43_MMIO_GEN_IRQ_REASON);       /* dummy read */
 
@@ -3098,46 +3043,52 @@ static int b43_rng_init(struct b43_wl *wl)
        return err;
 }
 
-static int b43_op_tx(struct ieee80211_hw *hw,
-                    struct sk_buff *skb)
+static void b43_tx_work(struct work_struct *work)
 {
-       struct b43_wl *wl = hw_to_b43_wl(hw);
-       struct b43_wldev *dev = wl->current_dev;
-       unsigned long flags;
-       int err;
+       struct b43_wl *wl = container_of(work, struct b43_wl, tx_work);
+       struct b43_wldev *dev;
+       struct sk_buff *skb;
+       int err = 0;
 
-       if (unlikely(skb->len < 2 + 2 + 6)) {
-               /* Too short, this can't be a valid frame. */
-               goto drop_packet;
+       mutex_lock(&wl->mutex);
+       dev = wl->current_dev;
+       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. */
-       read_lock_irqsave(&wl->tx_lock, flags);
+       while (skb_queue_len(&wl->tx_queue)) {
+               skb = skb_dequeue(&wl->tx_queue);
 
-       err = -ENODEV;
-       if (likely(b43_status(dev) >= B43_STAT_STARTED)) {
                if (b43_using_pio_transfers(dev))
                        err = b43_pio_tx(dev, skb);
                else
                        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))
-               goto drop_packet;
-       return NETDEV_TX_OK;
+static int b43_op_tx(struct ieee80211_hw *hw,
+                    struct sk_buff *skb)
+{
+       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;
 }
 
-/* Locking: wl->irq_lock */
 static void b43_qos_params_upload(struct b43_wldev *dev,
                                  const struct ieee80211_tx_queue_params *p,
                                  u16 shm_offset)
@@ -3146,6 +3097,9 @@ static void b43_qos_params_upload(struct b43_wldev *dev,
        int bslots, tmp;
        unsigned int i;
 
+       if (!dev->qos_enabled)
+               return;
+
        bslots = b43_read16(dev, B43_MMIO_RNG) & p->cw_min;
 
        memset(&params, 0, sizeof(params));
@@ -3191,6 +3145,9 @@ static void b43_qos_upload_all(struct b43_wldev *dev)
        struct b43_qos_params *params;
        unsigned int i;
 
+       if (!dev->qos_enabled)
+               return;
+
        BUILD_BUG_ON(ARRAY_SIZE(b43_qos_shm_offsets) !=
                     ARRAY_SIZE(wl->qos_params));
 
@@ -3250,6 +3207,16 @@ static void b43_qos_clear(struct b43_wl *wl)
 /* Initialize the core's QOS capabilities */
 static void b43_qos_init(struct b43_wldev *dev)
 {
+       if (!dev->qos_enabled) {
+               /* Disable QOS support. */
+               b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_EDCF);
+               b43_write16(dev, B43_MMIO_IFSCTL,
+                           b43_read16(dev, B43_MMIO_IFSCTL)
+                           & ~B43_MMIO_IFSCTL_USE_EDCF);
+               b43dbg(dev->wl, "QoS disabled\n");
+               return;
+       }
+
        /* Upload the current QOS parameters. */
        b43_qos_upload_all(dev);
 
@@ -3258,6 +3225,7 @@ static void b43_qos_init(struct b43_wldev *dev)
        b43_write16(dev, B43_MMIO_IFSCTL,
                    b43_read16(dev, B43_MMIO_IFSCTL)
                    | B43_MMIO_IFSCTL_USE_EDCF);
+       b43dbg(dev->wl, "QoS enabled\n");
 }
 
 static int b43_op_conf_tx(struct ieee80211_hw *hw, u16 _queue,
@@ -3686,18 +3654,12 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
        u8 algorithm;
        u8 index;
        int err;
-       unsigned long flags;
        static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
        if (modparam_nohwcrypt)
                return -ENOSPC; /* User disabled HW-crypto */
 
        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;
        err = -ENODEV;
@@ -3789,7 +3751,6 @@ out_unlock:
                       sta ? sta->addr : bcast_addr);
                b43_dump_keymemory(dev);
        }
-       write_unlock_irqrestore(&wl->tx_lock, flags);
        mutex_unlock(&wl->mutex);
 
        return err;
@@ -3846,9 +3807,10 @@ redo:
        if (!dev || b43_status(dev) < B43_STAT_STARTED)
                return dev;
 
-       /* Disable periodic work. Unlock to avoid deadlocks. */
+       /* Cancel work. Unlock to avoid deadlocks. */
        mutex_unlock(&wl->mutex);
        cancel_delayed_work_sync(&dev->periodic_work);
+       cancel_work_sync(&wl->tx_work);
        mutex_lock(&wl->mutex);
        dev = wl->current_dev;
        if (!dev || b43_status(dev) < B43_STAT_STARTED) {
@@ -3883,7 +3845,10 @@ redo:
        }
        B43_WARN_ON(b43_read32(dev, B43_MMIO_GEN_IRQ_MASK));
 
-       b43_pio_stop(dev);
+       /* Drain the TX queue */
+       while (skb_queue_len(&wl->tx_queue))
+               dev_kfree_skb(skb_dequeue(&wl->tx_queue));
+
        b43_mac_suspend(dev);
        free_irq(dev->dev->irq, dev);
        b43dbg(wl, "Wireless interface stopped\n");
@@ -4123,16 +4088,20 @@ static void b43_imcfglo_timeouts_workaround(struct b43_wldev *dev)
            bus->pcicore.dev->id.revision <= 5) {
                /* IMCFGLO timeouts workaround. */
                tmp = ssb_read32(dev->dev, SSB_IMCFGLO);
-               tmp &= ~SSB_IMCFGLO_REQTO;
-               tmp &= ~SSB_IMCFGLO_SERTO;
                switch (bus->bustype) {
                case SSB_BUSTYPE_PCI:
                case SSB_BUSTYPE_PCMCIA:
+                       tmp &= ~SSB_IMCFGLO_REQTO;
+                       tmp &= ~SSB_IMCFGLO_SERTO;
                        tmp |= 0x32;
                        break;
                case SSB_BUSTYPE_SSB:
+                       tmp &= ~SSB_IMCFGLO_REQTO;
+                       tmp &= ~SSB_IMCFGLO_SERTO;
                        tmp |= 0x53;
                        break;
+               default:
+                       break;
                }
                ssb_write32(dev->dev, SSB_IMCFGLO, tmp);
        }
@@ -4314,6 +4283,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
        if (!dev->suspend_in_progress)
                b43_rng_init(wl);
 
+       ieee80211_wake_queues(dev->wl->hw);
+
        b43_set_status(dev, B43_STAT_INITIALIZED);
 
        if (!dev->suspend_in_progress)
@@ -4866,14 +4837,14 @@ static int b43_wireless_init(struct ssb_device *dev)
 
        /* Initialize struct b43_wl */
        wl->hw = hw;
-       rwlock_init(&wl->tx_lock);
        spin_lock_init(&wl->leds_lock);
-       spin_lock_init(&wl->shm_lock);
        mutex_init(&wl->mutex);
        spin_lock_init(&wl->hardirq_lock);
        INIT_LIST_HEAD(&wl->devlist);
        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->tx_work, b43_tx_work);
+       skb_queue_head_init(&wl->tx_queue);
 
        ssb_set_devtypedata(dev, wl);
        b43info(wl, "Broadcom %04X WLAN found (core revision %u)\n",
This page took 0.030338 seconds and 5 git commands to generate.