wil6210: prevent usage of tx ring 0 for eDMA
authorMaya Erez <merez@codeaurora.org>
Thu, 23 Aug 2018 11:47:10 +0000 (14:47 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:45:29 +0000 (18:45 +0100)
[ Upstream commit df2b53884a5a454bf441ca78e5b57307262c73f4 ]

In enhanced DMA ring 0 is used for RX ring, hence TX ring 0
is an unused element in ring_tx and ring2cid_tid arrays.
Initialize ring2cid_tid CID to WIL6210_MAX_CID to prevent a false
match of CID 0.
Go over the ring_tx and ring2cid_tid from wil_get_min_tx_ring_id
and on to prevent access to index 0 in eDMA.

Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/txrx.c

index d186b68..920cb23 100644 (file)
@@ -223,6 +223,7 @@ __acquires(&sta->tid_rx_lock) __releases(&sta->tid_rx_lock)
        struct net_device *ndev = vif_to_ndev(vif);
        struct wireless_dev *wdev = vif_to_wdev(vif);
        struct wil_sta_info *sta = &wil->sta[cid];
+       int min_ring_id = wil_get_min_tx_ring_id(wil);
 
        might_sleep();
        wil_dbg_misc(wil, "disconnect_cid: CID %d, MID %d, status %d\n",
@@ -273,7 +274,7 @@ __acquires(&sta->tid_rx_lock) __releases(&sta->tid_rx_lock)
        memset(sta->tid_crypto_rx, 0, sizeof(sta->tid_crypto_rx));
        memset(&sta->group_crypto_rx, 0, sizeof(sta->group_crypto_rx));
        /* release vrings */
-       for (i = 0; i < ARRAY_SIZE(wil->ring_tx); i++) {
+       for (i = min_ring_id; i < ARRAY_SIZE(wil->ring_tx); i++) {
                if (wil->ring2cid_tid[i][0] == cid)
                        wil_ring_fini_tx(wil, i);
        }
@@ -604,8 +605,10 @@ int wil_priv_init(struct wil6210_priv *wil)
                wil->sta[i].mid = U8_MAX;
        }
 
-       for (i = 0; i < WIL6210_MAX_TX_RINGS; i++)
+       for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
                spin_lock_init(&wil->ring_tx_data[i].lock);
+               wil->ring2cid_tid[i][0] = WIL6210_MAX_CID;
+       }
 
        mutex_init(&wil->mutex);
        mutex_init(&wil->vif_mutex);
index 25a65ca..73cdf54 100644 (file)
@@ -77,8 +77,9 @@ bool wil_is_tx_idle(struct wil6210_priv *wil)
 {
        int i;
        unsigned long data_comp_to;
+       int min_ring_id = wil_get_min_tx_ring_id(wil);
 
-       for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
+       for (i = min_ring_id; i < WIL6210_MAX_TX_RINGS; i++) {
                struct wil_ring *vring = &wil->ring_tx[i];
                int vring_index = vring - wil->ring_tx;
                struct wil_ring_tx_data *txdata =
@@ -1945,6 +1946,7 @@ static inline void __wil_update_net_queues(struct wil6210_priv *wil,
                                           bool check_stop)
 {
        int i;
+       int min_ring_id = wil_get_min_tx_ring_id(wil);
 
        if (unlikely(!vif))
                return;
@@ -1977,7 +1979,7 @@ static inline void __wil_update_net_queues(struct wil6210_priv *wil,
                return;
 
        /* check wake */
-       for (i = 0; i < WIL6210_MAX_TX_RINGS; i++) {
+       for (i = min_ring_id; i < WIL6210_MAX_TX_RINGS; i++) {
                struct wil_ring *cur_ring = &wil->ring_tx[i];
                struct wil_ring_tx_data  *txdata = &wil->ring_tx_data[i];