iwlwifi: pcie: free IML DMA memory allocation
[ Upstream commit 310f60f53a86eba680d9bc20a371e13b06a5f903 ] In the case of gen3 devices with image loader (IML) support, we were leaking the IML DMA allocation and never freeing it. Fix that. 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.20210618105614.07e117dbedb7.I7bb9ebbe0617656986c2a598ea5e827b533bd3b9@changeid Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
78eadadff3
commit
b98ec6d8b3
@@ -126,7 +126,6 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
|
|||||||
struct iwl_prph_scratch *prph_scratch;
|
struct iwl_prph_scratch *prph_scratch;
|
||||||
struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl;
|
struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl;
|
||||||
struct iwl_prph_info *prph_info;
|
struct iwl_prph_info *prph_info;
|
||||||
void *iml_img;
|
|
||||||
u32 control_flags = 0;
|
u32 control_flags = 0;
|
||||||
int ret;
|
int ret;
|
||||||
int cmdq_size = max_t(u32, IWL_CMD_QUEUE_SIZE,
|
int cmdq_size = max_t(u32, IWL_CMD_QUEUE_SIZE,
|
||||||
@@ -234,14 +233,15 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
|
|||||||
trans_pcie->prph_scratch = prph_scratch;
|
trans_pcie->prph_scratch = prph_scratch;
|
||||||
|
|
||||||
/* Allocate IML */
|
/* Allocate IML */
|
||||||
iml_img = dma_alloc_coherent(trans->dev, trans->iml_len,
|
trans_pcie->iml = dma_alloc_coherent(trans->dev, trans->iml_len,
|
||||||
&trans_pcie->iml_dma_addr, GFP_KERNEL);
|
&trans_pcie->iml_dma_addr,
|
||||||
if (!iml_img) {
|
GFP_KERNEL);
|
||||||
|
if (!trans_pcie->iml) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_free_ctxt_info;
|
goto err_free_ctxt_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(iml_img, trans->iml, trans->iml_len);
|
memcpy(trans_pcie->iml, trans->iml, trans->iml_len);
|
||||||
|
|
||||||
iwl_enable_fw_load_int_ctx_info(trans);
|
iwl_enable_fw_load_int_ctx_info(trans);
|
||||||
|
|
||||||
@@ -290,6 +290,11 @@ void iwl_pcie_ctxt_info_gen3_free(struct iwl_trans *trans)
|
|||||||
trans_pcie->ctxt_info_dma_addr = 0;
|
trans_pcie->ctxt_info_dma_addr = 0;
|
||||||
trans_pcie->ctxt_info_gen3 = NULL;
|
trans_pcie->ctxt_info_gen3 = NULL;
|
||||||
|
|
||||||
|
dma_free_coherent(trans->dev, trans->iml_len, trans_pcie->iml,
|
||||||
|
trans_pcie->iml_dma_addr);
|
||||||
|
trans_pcie->iml_dma_addr = 0;
|
||||||
|
trans_pcie->iml = NULL;
|
||||||
|
|
||||||
iwl_pcie_ctxt_info_free_fw_img(trans);
|
iwl_pcie_ctxt_info_free_fw_img(trans);
|
||||||
|
|
||||||
dma_free_coherent(trans->dev, sizeof(*trans_pcie->prph_scratch),
|
dma_free_coherent(trans->dev, sizeof(*trans_pcie->prph_scratch),
|
||||||
|
@@ -336,6 +336,8 @@ struct cont_rec {
|
|||||||
* Context information addresses will be taken from here.
|
* Context information addresses will be taken from here.
|
||||||
* This is driver's local copy for keeping track of size and
|
* This is driver's local copy for keeping track of size and
|
||||||
* count for allocating and freeing the memory.
|
* count for allocating and freeing the memory.
|
||||||
|
* @iml: image loader image virtual address
|
||||||
|
* @iml_dma_addr: image loader image DMA address
|
||||||
* @trans: pointer to the generic transport area
|
* @trans: pointer to the generic transport area
|
||||||
* @scd_base_addr: scheduler sram base address in SRAM
|
* @scd_base_addr: scheduler sram base address in SRAM
|
||||||
* @kw: keep warm address
|
* @kw: keep warm address
|
||||||
@@ -388,6 +390,7 @@ struct iwl_trans_pcie {
|
|||||||
};
|
};
|
||||||
struct iwl_prph_info *prph_info;
|
struct iwl_prph_info *prph_info;
|
||||||
struct iwl_prph_scratch *prph_scratch;
|
struct iwl_prph_scratch *prph_scratch;
|
||||||
|
void *iml;
|
||||||
dma_addr_t ctxt_info_dma_addr;
|
dma_addr_t ctxt_info_dma_addr;
|
||||||
dma_addr_t prph_info_dma_addr;
|
dma_addr_t prph_info_dma_addr;
|
||||||
dma_addr_t prph_scratch_dma_addr;
|
dma_addr_t prph_scratch_dma_addr;
|
||||||
|
Reference in New Issue
Block a user