Skip to content

Commit 4e841d3

Browse files
computersforpeaceKalle Valo
authored andcommitted
mwifiex: pcie: don't leak DMA buffers when removing
When PCIe FLR support was added, much of the remove/release code for PCIe was migrated to ->down_dev(), but ->down_dev() is never called for device removal. Let's refactor the cleanup to be done in both cases. Also, drop the comments above mwifiex_cleanup_pcie(), because they were clearly wrong, and it's better to have clear and obvious code than to detail the code steps in comments anyway. Fixes: 4c5dae5 ("mwifiex: add PCIe function level reset support") Cc: <[email protected]> Signed-off-by: Brian Norris <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 9a3fcf9 commit 4e841d3

File tree

1 file changed

+19
-19
lines changed
  • drivers/net/wireless/marvell/mwifiex

1 file changed

+19
-19
lines changed

drivers/net/wireless/marvell/mwifiex/pcie.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,21 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
27392739
schedule_work(&card->work);
27402740
}
27412741

2742+
static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
2743+
{
2744+
struct pcie_service_card *card = adapter->card;
2745+
const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
2746+
2747+
if (reg->sleep_cookie)
2748+
mwifiex_pcie_delete_sleep_cookie_buf(adapter);
2749+
2750+
mwifiex_pcie_delete_cmdrsp_buf(adapter);
2751+
mwifiex_pcie_delete_evtbd_ring(adapter);
2752+
mwifiex_pcie_delete_rxbd_ring(adapter);
2753+
mwifiex_pcie_delete_txbd_ring(adapter);
2754+
card->cmdrsp_buf = NULL;
2755+
}
2756+
27422757
/*
27432758
* This function initializes the PCI-E host memory space, WCB rings, etc.
27442759
*
@@ -2850,13 +2865,6 @@ static int mwifiex_init_pcie(struct mwifiex_adapter *adapter)
28502865

28512866
/*
28522867
* This function cleans up the allocated card buffers.
2853-
*
2854-
* The following are freed by this function -
2855-
* - TXBD ring buffers
2856-
* - RXBD ring buffers
2857-
* - Event BD ring buffers
2858-
* - Command response ring buffer
2859-
* - Sleep cookie buffer
28602868
*/
28612869
static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter)
28622870
{
@@ -2875,6 +2883,8 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter)
28752883
"Failed to write driver not-ready signature\n");
28762884
}
28772885

2886+
mwifiex_pcie_free_buffers(adapter);
2887+
28782888
if (pdev) {
28792889
pci_iounmap(pdev, card->pci_mmap);
28802890
pci_iounmap(pdev, card->pci_mmap1);
@@ -3126,10 +3136,7 @@ static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter)
31263136
pci_iounmap(pdev, card->pci_mmap1);
31273137
}
31283138

3129-
/* This function cleans up the PCI-E host memory space.
3130-
* Some code is extracted from mwifiex_unregister_dev()
3131-
*
3132-
*/
3139+
/* This function cleans up the PCI-E host memory space. */
31333140
static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter)
31343141
{
31353142
struct pcie_service_card *card = adapter->card;
@@ -3140,14 +3147,7 @@ static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter)
31403147

31413148
adapter->seq_num = 0;
31423149

3143-
if (reg->sleep_cookie)
3144-
mwifiex_pcie_delete_sleep_cookie_buf(adapter);
3145-
3146-
mwifiex_pcie_delete_cmdrsp_buf(adapter);
3147-
mwifiex_pcie_delete_evtbd_ring(adapter);
3148-
mwifiex_pcie_delete_rxbd_ring(adapter);
3149-
mwifiex_pcie_delete_txbd_ring(adapter);
3150-
card->cmdrsp_buf = NULL;
3150+
mwifiex_pcie_free_buffers(adapter);
31513151
}
31523152

31533153
static struct mwifiex_if_ops pcie_ops = {

0 commit comments

Comments
 (0)