iwlwifi: fw: use helper to determine whether to dump paging
authorSara Sharon <sara.sharon@intel.com>
Mon, 30 Jul 2018 08:06:09 +0000 (11:06 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Sun, 11 Nov 2018 09:06:23 +0000 (11:06 +0200)
Logic is there twice, and we'll need a third place
soon for ini dumping. In addition move the dumping
to a function, also to enable reuse.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/dbg.c
drivers/net/wireless/intel/iwlwifi/fw/dbg.h

index aebdf43..58a9800 100644 (file)
@@ -639,6 +639,32 @@ out:
        return fifo_len;
 }
 
+static void iwl_dump_paging(struct iwl_fw_runtime *fwrt,
+                           struct iwl_fw_error_dump_data **data)
+{
+       int i;
+
+       IWL_DEBUG_INFO(fwrt, "WRT paging dump\n");
+       for (i = 1; i < fwrt->num_of_paging_blk + 1; i++) {
+               struct iwl_fw_error_dump_paging *paging;
+               struct page *pages =
+                       fwrt->fw_paging_db[i].fw_paging_block;
+               dma_addr_t addr = fwrt->fw_paging_db[i].fw_paging_phys;
+
+               (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING);
+               (*data)->len = cpu_to_le32(sizeof(*paging) +
+                                            PAGING_BLOCK_SIZE);
+               paging =  (void *)(*data)->data;
+               paging->index = cpu_to_le32(i);
+               dma_sync_single_for_cpu(fwrt->trans->dev, addr,
+                                       PAGING_BLOCK_SIZE,
+                                       DMA_BIDIRECTIONAL);
+               memcpy(paging->data, page_address(pages),
+                      PAGING_BLOCK_SIZE);
+               (*data) = iwl_fw_error_next_data(*data);
+       }
+}
+
 static struct iwl_fw_error_dump_file *
 _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
                   struct iwl_fw_dump_ptrs *fw_error_dump)
@@ -707,10 +733,7 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
        }
 
        /* Make room for fw's virtual image pages, if it exists */
-       if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) &&
-           !fwrt->trans->cfg->gen2 &&
-           fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size &&
-           fwrt->fw_paging_db[0].fw_paging_block)
+       if (iwl_fw_dbg_is_paging_enabled(fwrt))
                file_len += fwrt->num_of_paging_blk *
                        (sizeof(*dump_data) +
                         sizeof(struct iwl_fw_error_dump_paging) +
@@ -860,30 +883,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
        }
 
        /* Dump fw's virtual image */
-       if (iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) &&
-           !fwrt->trans->cfg->gen2 &&
-           fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size &&
-           fwrt->fw_paging_db[0].fw_paging_block) {
-               IWL_DEBUG_INFO(fwrt, "WRT paging dump\n");
-               for (i = 1; i < fwrt->num_of_paging_blk + 1; i++) {
-                       struct iwl_fw_error_dump_paging *paging;
-                       struct page *pages =
-                               fwrt->fw_paging_db[i].fw_paging_block;
-                       dma_addr_t addr = fwrt->fw_paging_db[i].fw_paging_phys;
-
-                       dump_data->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PAGING);
-                       dump_data->len = cpu_to_le32(sizeof(*paging) +
-                                                    PAGING_BLOCK_SIZE);
-                       paging = (void *)dump_data->data;
-                       paging->index = cpu_to_le32(i);
-                       dma_sync_single_for_cpu(fwrt->trans->dev, addr,
-                                               PAGING_BLOCK_SIZE,
-                                               DMA_BIDIRECTIONAL);
-                       memcpy(paging->data, page_address(pages),
-                              PAGING_BLOCK_SIZE);
-                       dump_data = iwl_fw_error_next_data(dump_data);
-               }
-       }
+       if (iwl_fw_dbg_is_paging_enabled(fwrt))
+               iwl_dump_paging(fwrt, &dump_data);
 
        if (prph_len) {
                iwl_dump_prph(fwrt->trans, &dump_data,
index 0d5169c..4a5fa05 100644 (file)
@@ -322,6 +322,14 @@ static inline bool iwl_fw_dbg_is_d3_debug_enabled(struct iwl_fw_runtime *fwrt)
                iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_D3_DEBUG_DATA);
 }
 
+static inline bool iwl_fw_dbg_is_paging_enabled(struct iwl_fw_runtime *fwrt)
+{
+       return iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) &&
+               !fwrt->trans->cfg->gen2 &&
+               fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size &&
+               fwrt->fw_paging_db[0].fw_paging_block;
+}
+
 void iwl_fw_dbg_read_d3_debug_data(struct iwl_fw_runtime *fwrt);
 
 static inline void iwl_fw_flush_dump(struct iwl_fw_runtime *fwrt)