mac80211: rt2x00: backport accepted and pending patches from upstream
[openwrt/staging/mkresin.git] / package / kernel / mac80211 / patches / rt2x00 / 024-rt2800mmio-fetch-tx-status-changes.patch
1 From f6a9618198e190a2ba09ce3f0aa8e9ee1763bd38 Mon Sep 17 00:00:00 2001
2 From: Stanislaw Gruszka <sgruszka@redhat.com>
3 Date: Sat, 9 Feb 2019 12:08:34 +0100
4 Subject: [PATCH 24/28] rt2800mmio: fetch tx status changes
5
6 Prepare to use rt2800mmio_fetch_txstatus() in concurrent manner and drop
7 return value since is not longer needed.
8
9 Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
10 ---
11 drivers/net/wireless/ralink/rt2x00/rt2800mmio.c | 17 +++++++++--------
12 1 file changed, 9 insertions(+), 8 deletions(-)
13
14 --- a/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
15 +++ b/drivers/net/wireless/ralink/rt2x00/rt2800mmio.c
16 @@ -255,12 +255,12 @@ void rt2800mmio_autowake_tasklet(unsigne
17 }
18 EXPORT_SYMBOL_GPL(rt2800mmio_autowake_tasklet);
19
20 -static bool rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev)
21 +static void rt2800mmio_fetch_txstatus(struct rt2x00_dev *rt2x00dev)
22 {
23 u32 status;
24 - bool more = false;
25 + unsigned long flags;
26
27 - /* FIXEME: rewrite this comment
28 + /*
29 * The TX_FIFO_STATUS interrupt needs special care. We should
30 * read TX_STA_FIFO but we should do it immediately as otherwise
31 * the register can overflow and we would lose status reports.
32 @@ -271,20 +271,21 @@ static bool rt2800mmio_fetch_txstatus(st
33 * because we can schedule the tasklet multiple times (when the
34 * interrupt fires again during tx status processing).
35 *
36 - * txstatus tasklet is called with INT_SOURCE_CSR_TX_FIFO_STATUS
37 - * disabled so have only one producer and one consumer - we don't
38 - * need to lock the kfifo.
39 + * We also read statuses from tx status timeout timer, use
40 + * lock to prevent concurent writes to fifo.
41 */
42 +
43 + spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags);
44 +
45 while (!kfifo_is_full(&rt2x00dev->txstatus_fifo)) {
46 status = rt2x00mmio_register_read(rt2x00dev, TX_STA_FIFO);
47 if (!rt2x00_get_field32(status, TX_STA_FIFO_VALID))
48 break;
49
50 kfifo_put(&rt2x00dev->txstatus_fifo, status);
51 - more = true;
52 }
53
54 - return more;
55 + spin_unlock_irqrestore(&rt2x00dev->irqmask_lock, flags);
56 }
57
58 void rt2800mmio_txstatus_tasklet(unsigned long data)