1 From 91a5340db0526b7263bc8da14b120ea3129b5f28 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Sat, 9 Feb 2019 12:08:31 +0100
4 Subject: [PATCH 21/28] rt2800: partially restore old mmio txstatus behaviour
6 Do not disable txstatus interrupt and add quota of processed tx statuses in
7 one tasklet. Quota is needed to allow to fed device with new frames during
8 processing of tx statuses.
10 Patch fixes about 15% performance degradation on some scenarios coused by
11 0b0d556e0ebb ("rt2800mmio: use txdone/txstatus routines from lib").
13 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
15 .../net/wireless/ralink/rt2x00/rt2800lib.c | 4 +--
16 .../net/wireless/ralink/rt2x00/rt2800lib.h | 2 +-
17 .../net/wireless/ralink/rt2x00/rt2800mmio.c | 30 +++++--------------
18 .../net/wireless/ralink/rt2x00/rt2800usb.c | 2 +-
19 4 files changed, 12 insertions(+), 26 deletions(-)
21 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
22 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
23 @@ -1100,7 +1100,7 @@ void rt2800_txdone_entry(struct queue_en
25 EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
27 -void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
28 +void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota)
30 struct data_queue *queue;
31 struct queue_entry *entry;
32 @@ -1108,7 +1108,7 @@ void rt2800_txdone(struct rt2x00_dev *rt
36 - while (kfifo_get(&rt2x00dev->txstatus_fifo, ®)) {
37 + while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, ®)) {
39 * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is
40 * guaranteed to be one of the TX QIDs .
41 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
42 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.h
43 @@ -195,7 +195,7 @@ void rt2800_process_rxwi(struct queue_en
45 void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
47 -void rt2800_txdone(struct rt2x00_dev *rt2x00dev);
48 +void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota);
49 void rt2800_txdone_nostatus(struct rt2x00_dev *rt2x00dev);
50 bool rt2800_txstatus_timeout(struct rt2x00_dev *rt2x00dev);
52 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
53 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
54 @@ -255,20 +255,6 @@ void rt2800mmio_autowake_tasklet(unsigne
56 EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet);
58 -static void rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev)
60 - bool timeout = false;
62 - while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) ||
63 - (timeout = rt2800_txstatus_timeout(rt2x00dev))) {
65 - rt2800_txdone(rt2x00dev);
68 - rt2800_txdone_nostatus(rt2x00dev);
72 static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev)
75 @@ -305,14 +291,11 @@ void rt2800mmio_txstatus_tasklet(unsigne
77 struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
80 - rt2800mmio_txdone(rt2x00dev);
81 + rt2800_txdone(rt2x00dev, 16);
83 - } while (rt2800mmio_fetch_txstatus(rt2x00dev));
84 + if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo))
85 + tasklet_schedule(&rt2x00dev->txstatus_tasklet);
87 - if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
88 - rt2800mmio_enable_interrupt(rt2x00dev,
89 - INT_SOURCE_CSR_TX_FIFO_STATUS);
91 EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet);
93 @@ -339,8 +322,10 @@ irqreturn_t rt2800mmio_interrupt(int irq
96 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_TX_FIFO_STATUS)) {
97 + rt2x00_set_field32(&mask, INT_MASK_CSR_TX_FIFO_STATUS, 1);
98 rt2800mmio_fetch_txstatus(rt2x00dev);
99 - tasklet_schedule(&rt2x00dev->txstatus_tasklet);
100 + if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo))
101 + tasklet_schedule(&rt2x00dev->txstatus_tasklet);
104 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT))
105 @@ -500,7 +485,8 @@ void rt2800mmio_flush_queue(struct data_
108 tasklet_disable(&rt2x00dev->txstatus_tasklet);
109 - rt2800mmio_txdone(rt2x00dev);
110 + rt2800_txdone(rt2x00dev, UINT_MAX);
111 + rt2800_txdone_nostatus(rt2x00dev);
112 tasklet_enable(&rt2x00dev->txstatus_tasklet);
115 --- a/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
116 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800usb.c
117 @@ -480,7 +480,7 @@ static void rt2800usb_work_txdone(struct
118 while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) ||
119 rt2800_txstatus_timeout(rt2x00dev)) {
121 - rt2800_txdone(rt2x00dev);
122 + rt2800_txdone(rt2x00dev, UINT_MAX);
124 rt2800_txdone_nostatus(rt2x00dev);