mt76: mt76x02: remove irqsave/restore in locking for tx status fifo
authorFelix Fietkau <nbd@nbd.name>
Thu, 31 Jan 2019 21:38:28 +0000 (22:38 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 1 May 2019 11:03:59 +0000 (13:03 +0200)
Use a separate lock and spin_trylock to avoid disabling interrupts.
Should improve performance and latency

Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c

index cd37f44580baadb4fb4b28ee6a655b3a2cda33f7..9f103c2506db9cb18e49fb7e81a5d6bde2465f1d 100644 (file)
@@ -86,6 +86,7 @@ struct mt76x02_dev {
 
        u8 txdone_seq;
        DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
+       spinlock_t txstatus_fifo_lock;
 
        struct sk_buff *rx_head;
 
index 28851060aa0ff7783758be246f572c00adf195a2..c1f041e1a27995b759751a45d28474b1630e508d 100644 (file)
@@ -739,7 +739,6 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
 void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq)
 {
        struct mt76x02_tx_status stat = {};
-       unsigned long flags;
        u8 update = 1;
        bool ret;
 
@@ -749,9 +748,11 @@ void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq)
        trace_mac_txstat_poll(dev);
 
        while (!irq || !kfifo_is_full(&dev->txstatus_fifo)) {
-               spin_lock_irqsave(&dev->mt76.mmio.irq_lock, flags);
+               if (!spin_trylock(&dev->txstatus_fifo_lock))
+                       break;
+
                ret = mt76x02_mac_load_tx_status(dev, &stat);
-               spin_unlock_irqrestore(&dev->mt76.mmio.irq_lock, flags);
+               spin_unlock(&dev->txstatus_fifo_lock);
 
                if (!ret)
                        break;
index 87e14af7a93b45e345ca1fac5ddbbe978c90fa59..5bc1b901f8971b512ee852c145a388a867a1b26f 100644 (file)
@@ -201,6 +201,7 @@ int mt76x02_dma_init(struct mt76x02_dev *dev)
        tasklet_init(&dev->pre_tbtt_tasklet, mt76x02_pre_tbtt_tasklet,
                     (unsigned long)dev);
 
+       spin_lock_init(&dev->txstatus_fifo_lock);
        kfifo_init(&dev->txstatus_fifo, status_fifo, fifo_size);
 
        mt76_dma_attach(&dev->mt76);