]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iwlwifi: pcie: free RBs during configure
authorJohannes Berg <johannes.berg@intel.com>
Mon, 2 Aug 2021 14:09:38 +0000 (17:09 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:42:18 +0000 (13:42 +0200)
[ Upstream commit 6ac5720086c8b176794eb74c5cc09f8b79017f38 ]

When switching op-modes, or more generally when reconfiguring,
we might switch the RB size. In _iwl_pcie_rx_init() we have a
comment saying we must free all RBs since we might switch the
size, but this is actually too late: the switch has been done
and we'll free the buffers with the wrong size.

Fix this by always freeing the buffers, if any, at the start
of configure, instead of only after the size may have changed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210802170640.42d7c93279c4.I07f74e65aab0e3d965a81206fcb289dc92d74878@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
drivers/net/wireless/intel/iwlwifi/pcie/trans.c

index fb8491412be44423c7d22a0f16e4595b54b87917..586c4104edf228940a57dffbf0d302f3dcc098ea 100644 (file)
@@ -487,6 +487,9 @@ void iwl_pcie_free_rbs_pool(struct iwl_trans *trans)
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        int i;
 
+       if (!trans_pcie->rx_pool)
+               return;
+
        for (i = 0; i < RX_POOL_SIZE(trans_pcie->num_rx_bufs); i++) {
                if (!trans_pcie->rx_pool[i].page)
                        continue;
@@ -1093,7 +1096,7 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
        INIT_LIST_HEAD(&rba->rbd_empty);
        spin_unlock_bh(&rba->lock);
 
-       /* free all first - we might be reconfigured for a different size */
+       /* free all first - we overwrite everything here */
        iwl_pcie_free_rbs_pool(trans);
 
        for (i = 0; i < RX_QUEUE_SIZE; i++)
index 239bc177a3e5c7b9324a29519bc761b338d6de37..a7a495dbf64db334e1f1fd1ccc3c22579b15c65b 100644 (file)
@@ -1866,6 +1866,9 @@ static void iwl_trans_pcie_configure(struct iwl_trans *trans,
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 
+       /* free all first - we might be reconfigured for a different size */
+       iwl_pcie_free_rbs_pool(trans);
+
        trans->txqs.cmd.q_id = trans_cfg->cmd_queue;
        trans->txqs.cmd.fifo = trans_cfg->cmd_fifo;
        trans->txqs.cmd.wdg_timeout = trans_cfg->cmd_q_wdg_timeout;