wifi: iwlwifi: empty overflow queue during flush
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Sun, 22 Oct 2023 14:55:51 +0000 (17:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:03 +0000 (11:59 +0100)
[ Upstream commit 658939fc68d3241f9a0019e224cd7154438c23f2 ]

If a TX queue has no space for new TX frames, the driver will keep
these frames in the overflow queue, and during reclaim flow it
will retry to send the frames from that queue.
But if the reclaim flow was invoked from TX queue flush, we will also
TX these frames, which is wrong as we don't want to TX anything
after flush.
This might also cause assert 0x125F when removing the queue,
saying that the driver removes a non-empty queue
Fix this by TXing the overflow queue's frames only if we are
not in flush queue flow.

Fixes: a44509805895 ("iwlwifi: move reclaim flows to the queue file")
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20231022173519.caf06c8709d9.Ibf664ccb3f952e836f8fa461ea58fc08e5c46e88@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/intel/iwlwifi/dvm/tx.c
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
drivers/net/wireless/intel/iwlwifi/queue/tx.c
drivers/net/wireless/intel/iwlwifi/queue/tx.h

index 60a7b61d59aa33d43407f7b141fde4b3f8116707..ca1daec641c4fcc926887c0262a6a007972c8fbc 100644 (file)
@@ -3,6 +3,7 @@
  *
  * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved.
  * Copyright (C) 2019 Intel Corporation
+ * Copyright (C) 2023 Intel Corporation
  *****************************************************************************/
 
 #include <linux/kernel.h>
@@ -1169,7 +1170,7 @@ void iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb)
                        iwlagn_check_ratid_empty(priv, sta_id, tid);
                }
 
-               iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs);
+               iwl_trans_reclaim(priv->trans, txq_id, ssn, &skbs, false);
 
                freed = 0;
 
@@ -1315,7 +1316,7 @@ void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
         * block-ack window (we assume that they've been successfully
         * transmitted ... if not, it's too late anyway). */
        iwl_trans_reclaim(priv->trans, scd_flow, ba_resp_scd_ssn,
-                         &reclaimed_skbs);
+                         &reclaimed_skbs, false);
 
        IWL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, "
                           "sta_id = %d\n",
index 1b3c976d19feb6c5e688d6b3450b9f2039f59704..168eda2132fb81b30698f5d14c1644c406926d51 100644 (file)
@@ -588,7 +588,7 @@ struct iwl_trans_ops {
        int (*tx)(struct iwl_trans *trans, struct sk_buff *skb,
                  struct iwl_device_tx_cmd *dev_cmd, int queue);
        void (*reclaim)(struct iwl_trans *trans, int queue, int ssn,
-                       struct sk_buff_head *skbs);
+                       struct sk_buff_head *skbs, bool is_flush);
 
        void (*set_q_ptrs)(struct iwl_trans *trans, int queue, int ptr);
 
@@ -1273,14 +1273,15 @@ static inline int iwl_trans_tx(struct iwl_trans *trans, struct sk_buff *skb,
 }
 
 static inline void iwl_trans_reclaim(struct iwl_trans *trans, int queue,
-                                    int ssn, struct sk_buff_head *skbs)
+                                    int ssn, struct sk_buff_head *skbs,
+                                    bool is_flush)
 {
        if (WARN_ON_ONCE(trans->state != IWL_TRANS_FW_ALIVE)) {
                IWL_ERR(trans, "%s bad state = %d\n", __func__, trans->state);
                return;
        }
 
-       trans->ops->reclaim(trans, queue, ssn, skbs);
+       trans->ops->reclaim(trans, queue, ssn, skbs, is_flush);
 }
 
 static inline void iwl_trans_set_q_ptrs(struct iwl_trans *trans, int queue,
index bf241f9128fd92f9d708ed3c0bed3cd763a557e4..2ede69132fee9c6a54ba55f0d82d2f5e8da2ed66 100644 (file)
@@ -1599,7 +1599,7 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
        seq_ctl = le16_to_cpu(tx_resp->seq_ctl);
 
        /* we can free until ssn % q.n_bd not inclusive */
-       iwl_trans_reclaim(mvm->trans, txq_id, ssn, &skbs);
+       iwl_trans_reclaim(mvm->trans, txq_id, ssn, &skbs, false);
 
        while (!skb_queue_empty(&skbs)) {
                struct sk_buff *skb = __skb_dequeue(&skbs);
@@ -1951,7 +1951,7 @@ static void iwl_mvm_tx_reclaim(struct iwl_mvm *mvm, int sta_id, int tid,
         * block-ack window (we assume that they've been successfully
         * transmitted ... if not, it's too late anyway).
         */
-       iwl_trans_reclaim(mvm->trans, txq, index, &reclaimed_skbs);
+       iwl_trans_reclaim(mvm->trans, txq, index, &reclaimed_skbs, is_flush);
 
        skb_queue_walk(&reclaimed_skbs, skb) {
                struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
index 340240b8954f6a4786d1efe70da315475019bb23..ca74b1b63cac159cc335feef25edaad6471690c8 100644 (file)
@@ -1575,7 +1575,7 @@ void iwl_txq_progress(struct iwl_txq *txq)
 
 /* Frees buffers until index _not_ inclusive */
 void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
-                    struct sk_buff_head *skbs)
+                    struct sk_buff_head *skbs, bool is_flush)
 {
        struct iwl_txq *txq = trans->txqs.txq[txq_id];
        int tfd_num, read_ptr, last_to_free;
@@ -1650,9 +1650,11 @@ void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
        if (iwl_txq_space(trans, txq) > txq->low_mark &&
            test_bit(txq_id, trans->txqs.queue_stopped)) {
                struct sk_buff_head overflow_skbs;
+               struct sk_buff *skb;
 
                __skb_queue_head_init(&overflow_skbs);
-               skb_queue_splice_init(&txq->overflow_q, &overflow_skbs);
+               skb_queue_splice_init(&txq->overflow_q,
+                                     is_flush ? skbs : &overflow_skbs);
 
                /*
                 * We are going to transmit from the overflow queue.
@@ -1672,8 +1674,7 @@ void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
                 */
                spin_unlock_bh(&txq->lock);
 
-               while (!skb_queue_empty(&overflow_skbs)) {
-                       struct sk_buff *skb = __skb_dequeue(&overflow_skbs);
+               while ((skb = __skb_dequeue(&overflow_skbs))) {
                        struct iwl_device_tx_cmd *dev_cmd_ptr;
 
                        dev_cmd_ptr = *(void **)((u8 *)skb->cb +
index b7d3808588bfbc038b9dc8a6a4f7ec00bbd2ea30..4c09bc1930fa14307ed99525921435b7f5b3de64 100644 (file)
@@ -179,7 +179,7 @@ void iwl_txq_gen1_update_byte_cnt_tbl(struct iwl_trans *trans,
                                      struct iwl_txq *txq, u16 byte_cnt,
                                      int num_tbs);
 void iwl_txq_reclaim(struct iwl_trans *trans, int txq_id, int ssn,
-                    struct sk_buff_head *skbs);
+                    struct sk_buff_head *skbs, bool is_flush);
 void iwl_txq_set_q_ptrs(struct iwl_trans *trans, int txq_id, int ptr);
 void iwl_trans_txq_freeze_timer(struct iwl_trans *trans, unsigned long txqs,
                                bool freeze);