iwlwifi: move bc_pool to a common trans header
authorMordechay Goodstein <mordechay.goodstein@intel.com>
Thu, 24 Sep 2020 13:23:35 +0000 (16:23 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 1 Oct 2020 18:56:46 +0000 (21:56 +0300)
The bc_pool code is not directly related to the PCIe transport,
so move the structures it uses to the common iwl-trans.h header.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.f6469c62665d.Id920f1ae8f70886b66a98956a6412726d29a9481@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-trans.c
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c

index 4a61ab56d728b9d10d694747867e44d27f66e4d6..105776b397922ffd65bcc42dcd76e6034be2182a 100644 (file)
@@ -66,6 +66,7 @@
 #include "iwl-trans.h"
 #include "iwl-drv.h"
 #include "iwl-fh.h"
+#include <linux/dmapool.h>
 
 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
                                  struct device *dev,
@@ -110,6 +111,22 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
        trans->ops = ops;
        trans->num_rx_queues = 1;
 
+       if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
+               trans->txqs.bc_tbl_size = sizeof(struct iwl_gen3_bc_tbl);
+       else
+               trans->txqs.bc_tbl_size = sizeof(struct iwlagn_scd_bc_tbl);
+       /*
+        * For gen2 devices, we use a single allocation for each byte-count
+        * table, but they're pretty small (1k) so use a DMA pool that we
+        * allocate here.
+        */
+       if (trans->trans_cfg->gen2) {
+               trans->txqs.bc_pool = dmam_pool_create("iwlwifi:bc", dev,
+                                                      trans->txqs.bc_tbl_size,
+                                                      256, 0);
+               if (!trans->txqs.bc_pool)
+                       return NULL;
+       }
        snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name),
                 "iwl_cmd_pool:%s", dev_name(trans->dev));
        trans->dev_cmd_pool =
index d17eafe31e41a3beef2f6f6750d8752b5a67dbd7..dbcd89e9546b9e27b473770982d41845fd76b140 100644 (file)
@@ -914,6 +914,8 @@ struct iwl_trans_txqs {
        unsigned long queue_used[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)];
        unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_TVQM_QUEUES)];
        struct iwl_txq *txq[IWL_MAX_TVQM_QUEUES];
+       struct dma_pool *bc_pool;
+       size_t bc_tbl_size;
        struct {
                u8 fifo;
                u8 q_id;
index 55808ba10d27b998ce40e08c6779a8edd9973d88..032e858ce7a38ff5d683c4567542eb7dc1aa2350 100644 (file)
@@ -451,7 +451,6 @@ struct iwl_trans_pcie {
        u32 scd_base_addr;
        struct iwl_dma_ptr scd_bc_tbls;
        struct iwl_dma_ptr kw;
-       struct dma_pool *bc_pool;
 
        struct iwl_txq *txq_memory;
 
index 43adb664636644983de57a61d8e0bab39edc21be..354ec140f4487c35c462ce59f2d7a06a9cade06c 100644 (file)
@@ -3649,24 +3649,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
 
        init_waitqueue_head(&trans_pcie->sx_waitq);
 
-       /*
-        * For gen2 devices, we use a single allocation for each byte-count
-        * table, but they're pretty small (1k) so use a DMA pool that we
-        * allocate here.
-        */
-       if (cfg_trans->gen2) {
-               size_t bc_tbl_size;
-
-               if (cfg_trans->device_family >= IWL_DEVICE_FAMILY_AX210)
-                       bc_tbl_size = sizeof(struct iwl_gen3_bc_tbl);
-               else
-                       bc_tbl_size = sizeof(struct iwlagn_scd_bc_tbl);
-
-               trans_pcie->bc_pool = dmam_pool_create("iwlwifi:bc", &pdev->dev,
-                                                      bc_tbl_size, 256, 0);
-               if (!trans_pcie->bc_pool)
-                       goto out_no_pci;
-       }
 
        if (trans_pcie->msix_enabled) {
                ret = iwl_pcie_init_msix_handler(pdev, trans_pcie);
index 606bef2ecc7b26f7059616975c384f38c8b78adf..8b2275bf301cfb1ae9aea987063e5df17042d68b 100644 (file)
@@ -1225,7 +1225,7 @@ void iwl_pcie_gen2_txq_free_memory(struct iwl_trans *trans,
 
        kfree(txq->entries);
        if (txq->bc_tbl.addr)
-               dma_pool_free(trans_pcie->bc_pool, txq->bc_tbl.addr,
+               dma_pool_free(trans->txqs.bc_pool, txq->bc_tbl.addr,
                              txq->bc_tbl.dma);
        kfree(txq);
 }
@@ -1273,18 +1273,14 @@ int iwl_trans_pcie_dyn_txq_alloc_dma(struct iwl_trans *trans,
                                     struct iwl_txq **intxq, int size,
                                     unsigned int timeout)
 {
-       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        size_t bc_tbl_size, bc_tbl_entries;
        struct iwl_txq *txq;
        int ret;
 
-       if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) {
-               bc_tbl_size = sizeof(struct iwl_gen3_bc_tbl);
-               bc_tbl_entries = bc_tbl_size / sizeof(u16);
-       } else {
-               bc_tbl_size = sizeof(struct iwlagn_scd_bc_tbl);
-               bc_tbl_entries = bc_tbl_size / sizeof(u16);
-       }
+       WARN_ON(!trans->txqs.bc_tbl_size);
+
+       bc_tbl_size = trans->txqs.bc_tbl_size;
+       bc_tbl_entries = bc_tbl_size / sizeof(u16);
 
        if (WARN_ON(size > bc_tbl_entries))
                return -EINVAL;
@@ -1293,7 +1289,7 @@ int iwl_trans_pcie_dyn_txq_alloc_dma(struct iwl_trans *trans,
        if (!txq)
                return -ENOMEM;
 
-       txq->bc_tbl.addr = dma_pool_alloc(trans_pcie->bc_pool, GFP_KERNEL,
+       txq->bc_tbl.addr = dma_pool_alloc(trans->txqs.bc_pool, GFP_KERNEL,
                                          &txq->bc_tbl.dma);
        if (!txq->bc_tbl.addr) {
                IWL_ERR(trans, "Scheduler BC Table allocation failed\n");