6214ad30db05515957f62d37d6b79cbe80922f68
[openwrt/staging/nbd.git] /
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
5
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.
9
10 Patch fixes about 15% performance degradation on some scenarios coused by
11 0b0d556e0ebb ("rt2800mmio: use txdone/txstatus routines from lib").
12
13 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
14 ---
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(-)
20
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
24 }
25 EXPORT_SYMBOL_GPL(rt2800_txdone_entry);
26
27 -void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
28 +void rt2800_txdone(struct rt2x00_dev *rt2x00dev, unsigned int quota)
29 {
30 struct data_queue *queue;
31 struct queue_entry *entry;
32 @@ -1108,7 +1108,7 @@ void rt2800_txdone(struct rt2x00_dev *rt
33 u8 qid;
34 bool match;
35
36 - while (kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) {
37 + while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) {
38 /*
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
44
45 void rt2800_txdone_entry(struct queue_entry *entry, u32 status, __le32 *txwi,
46 bool match);
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);
51
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
55 }
56 EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet);
57
58 -static void rt2800mmio_txdone(struct rt2x00_dev *rt2x00dev)
59 -{
60 - bool timeout = false;
61 -
62 - while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) ||
63 - (timeout = rt2800_txstatus_timeout(rt2x00dev))) {
64 -
65 - rt2800_txdone(rt2x00dev);
66 -
67 - if (timeout)
68 - rt2800_txdone_nostatus(rt2x00dev);
69 - }
70 -}
71 -
72 static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev)
73 {
74 u32 status;
75 @@ -305,14 +291,11 @@ void rt2800mmio_txstatus_tasklet(unsigne
76 {
77 struct rt2x00_dev *rt2x00dev = (struct rt2x00_dev *)data;
78
79 - do {
80 - rt2800mmio_txdone(rt2x00dev);
81 + rt2800_txdone(rt2x00dev, 16);
82
83 - } while (rt2800mmio_fetch_txstatus(rt2x00dev));
84 + if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo))
85 + tasklet_schedule(&rt2x00dev->txstatus_tasklet);
86
87 - if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
88 - rt2800mmio_enable_interrupt(rt2x00dev,
89 - INT_SOURCE_CSR_TX_FIFO_STATUS);
90 }
91 EXPORT_SYMBOL_GPL(rt2800mmio_txstatus_tasklet);
92
93 @@ -339,8 +322,10 @@ irqreturn_t rt2800mmio_interrupt(int irq
94 mask = ~reg;
95
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);
102 }
103
104 if (rt2x00_get_field32(reg, INT_SOURCE_CSR_PRE_TBTT))
105 @@ -500,7 +485,8 @@ void rt2800mmio_flush_queue(struct data_
106 */
107 if (tx_queue) {
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);
113 }
114
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)) {
120
121 - rt2800_txdone(rt2x00dev);
122 + rt2800_txdone(rt2x00dev, UINT_MAX);
123
124 rt2800_txdone_nostatus(rt2x00dev);
125