diff options
author | Brian Norris <briannorris@chromium.org> | 2017-03-10 20:39:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-30 03:41:26 -0400 |
commit | cb6e07ba5878959d5ebb6189e6e11cc335d914b6 (patch) | |
tree | 385dcf91cadb69f2b9e71e89620e7d5b8f8e6a6e /drivers/net | |
parent | 35ef543eb372811d9090cbc4de0d5f86e6d2f787 (diff) |
mwifiex: pcie: don't leak DMA buffers when removing
commit 4e841d3eb9294ce4137fdb5d0a88f1bceab9c212 upstream.
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: 4c5dae59d2e9 ("mwifiex: add PCIe function level reset support")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/marvell/mwifiex/pcie.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 3c3c4f197da8..7a310c491ea5 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c | |||
@@ -2700,6 +2700,21 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) | |||
2700 | schedule_work(&pcie_work); | 2700 | schedule_work(&pcie_work); |
2701 | } | 2701 | } |
2702 | 2702 | ||
2703 | static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) | ||
2704 | { | ||
2705 | struct pcie_service_card *card = adapter->card; | ||
2706 | const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; | ||
2707 | |||
2708 | if (reg->sleep_cookie) | ||
2709 | mwifiex_pcie_delete_sleep_cookie_buf(adapter); | ||
2710 | |||
2711 | mwifiex_pcie_delete_cmdrsp_buf(adapter); | ||
2712 | mwifiex_pcie_delete_evtbd_ring(adapter); | ||
2713 | mwifiex_pcie_delete_rxbd_ring(adapter); | ||
2714 | mwifiex_pcie_delete_txbd_ring(adapter); | ||
2715 | card->cmdrsp_buf = NULL; | ||
2716 | } | ||
2717 | |||
2703 | /* | 2718 | /* |
2704 | * This function initializes the PCI-E host memory space, WCB rings, etc. | 2719 | * This function initializes the PCI-E host memory space, WCB rings, etc. |
2705 | * | 2720 | * |
@@ -2812,13 +2827,6 @@ err_enable_dev: | |||
2812 | 2827 | ||
2813 | /* | 2828 | /* |
2814 | * This function cleans up the allocated card buffers. | 2829 | * This function cleans up the allocated card buffers. |
2815 | * | ||
2816 | * The following are freed by this function - | ||
2817 | * - TXBD ring buffers | ||
2818 | * - RXBD ring buffers | ||
2819 | * - Event BD ring buffers | ||
2820 | * - Command response ring buffer | ||
2821 | * - Sleep cookie buffer | ||
2822 | */ | 2830 | */ |
2823 | static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) | 2831 | static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) |
2824 | { | 2832 | { |
@@ -2834,6 +2842,8 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) | |||
2834 | "Failed to write driver not-ready signature\n"); | 2842 | "Failed to write driver not-ready signature\n"); |
2835 | } | 2843 | } |
2836 | 2844 | ||
2845 | mwifiex_pcie_free_buffers(adapter); | ||
2846 | |||
2837 | if (pdev) { | 2847 | if (pdev) { |
2838 | pci_iounmap(pdev, card->pci_mmap); | 2848 | pci_iounmap(pdev, card->pci_mmap); |
2839 | pci_iounmap(pdev, card->pci_mmap1); | 2849 | pci_iounmap(pdev, card->pci_mmap1); |
@@ -3080,10 +3090,7 @@ err_cre_txbd: | |||
3080 | pci_iounmap(pdev, card->pci_mmap1); | 3090 | pci_iounmap(pdev, card->pci_mmap1); |
3081 | } | 3091 | } |
3082 | 3092 | ||
3083 | /* This function cleans up the PCI-E host memory space. | 3093 | /* This function cleans up the PCI-E host memory space. */ |
3084 | * Some code is extracted from mwifiex_unregister_dev() | ||
3085 | * | ||
3086 | */ | ||
3087 | static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) | 3094 | static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) |
3088 | { | 3095 | { |
3089 | struct pcie_service_card *card = adapter->card; | 3096 | struct pcie_service_card *card = adapter->card; |
@@ -3095,16 +3102,8 @@ static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) | |||
3095 | adapter->seq_num = 0; | 3102 | adapter->seq_num = 0; |
3096 | adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K; | 3103 | adapter->tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K; |
3097 | 3104 | ||
3098 | if (card) { | 3105 | if (card) |
3099 | if (reg->sleep_cookie) | 3106 | mwifiex_pcie_free_buffers(adapter); |
3100 | mwifiex_pcie_delete_sleep_cookie_buf(adapter); | ||
3101 | |||
3102 | mwifiex_pcie_delete_cmdrsp_buf(adapter); | ||
3103 | mwifiex_pcie_delete_evtbd_ring(adapter); | ||
3104 | mwifiex_pcie_delete_rxbd_ring(adapter); | ||
3105 | mwifiex_pcie_delete_txbd_ring(adapter); | ||
3106 | card->cmdrsp_buf = NULL; | ||
3107 | } | ||
3108 | 3107 | ||
3109 | return; | 3108 | return; |
3110 | } | 3109 | } |