Commit 64a76b50 authored by Zhu Yi's avatar Zhu Yi Committed by John W. Linville

iwlwifi: allocated rx page accounting cleanup

In iwlwifi, priv->alloc_rxb_page is used to keep track of the Rx
pages allocated by the driver. This cleans up the page free routines
by introducing __iwl_free_pages/iwl_free_pages so that the accounting
is more accurate and less error prone. This also fixes two instances where
the counter was not updated.
Signed-off-by: default avatarZhu Yi <yi.zhu@intel.com>
Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d24deb25
...@@ -1835,8 +1835,7 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv) ...@@ -1835,8 +1835,7 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
rc = -EIO; rc = -EIO;
} }
priv->alloc_rxb_page--; iwl_free_pages(priv, cmd.reply_page);
free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
return rc; return rc;
} }
......
...@@ -1353,4 +1353,15 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch) ...@@ -1353,4 +1353,15 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0; return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
} }
static inline void __iwl_free_pages(struct iwl_priv *priv, struct page *page)
{
__free_pages(page, priv->hw_params.rx_page_order);
priv->alloc_rxb_page--;
}
static inline void iwl_free_pages(struct iwl_priv *priv, unsigned long page)
{
free_pages(page, priv->hw_params.rx_page_order);
priv->alloc_rxb_page--;
}
#endif /* __iwl_dev_h__ */ #endif /* __iwl_dev_h__ */
...@@ -234,7 +234,7 @@ cancel: ...@@ -234,7 +234,7 @@ cancel:
} }
fail: fail:
if (cmd->reply_page) { if (cmd->reply_page) {
free_pages(cmd->reply_page, priv->hw_params.rx_page_order); iwl_free_pages(priv, cmd->reply_page);
cmd->reply_page = 0; cmd->reply_page = 0;
} }
out: out:
......
...@@ -345,10 +345,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) ...@@ -345,10 +345,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
PAGE_SIZE << priv->hw_params.rx_page_order, PAGE_SIZE << priv->hw_params.rx_page_order,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
__free_pages(rxq->pool[i].page, __iwl_free_pages(priv, rxq->pool[i].page);
priv->hw_params.rx_page_order);
rxq->pool[i].page = NULL; rxq->pool[i].page = NULL;
priv->alloc_rxb_page--;
} }
} }
...@@ -416,9 +414,7 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) ...@@ -416,9 +414,7 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
PAGE_SIZE << priv->hw_params.rx_page_order, PAGE_SIZE << priv->hw_params.rx_page_order,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
priv->alloc_rxb_page--; __iwl_free_pages(priv, rxq->pool[i].page);
__free_pages(rxq->pool[i].page,
priv->hw_params.rx_page_order);
rxq->pool[i].page = NULL; rxq->pool[i].page = NULL;
} }
list_add_tail(&rxq->pool[i].list, &rxq->rx_used); list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
......
...@@ -144,8 +144,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) ...@@ -144,8 +144,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
clear_bit(STATUS_SCAN_HW, &priv->status); clear_bit(STATUS_SCAN_HW, &priv->status);
} }
priv->alloc_rxb_page--; iwl_free_pages(priv, cmd.reply_page);
free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
return ret; return ret;
} }
......
...@@ -164,9 +164,7 @@ int iwl_send_add_sta(struct iwl_priv *priv, ...@@ -164,9 +164,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
break; break;
} }
} }
iwl_free_pages(priv, cmd.reply_page);
priv->alloc_rxb_page--;
free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
return ret; return ret;
} }
...@@ -391,9 +389,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr, ...@@ -391,9 +389,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
break; break;
} }
} }
iwl_free_pages(priv, cmd.reply_page);
priv->alloc_rxb_page--;
free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
return ret; return ret;
} }
......
...@@ -812,7 +812,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, ...@@ -812,7 +812,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
break; break;
} }
free_pages(cmd.reply_page, priv->hw_params.rx_page_order); iwl_free_pages(priv, cmd.reply_page);
return rc; return rc;
} }
...@@ -1198,9 +1198,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) ...@@ -1198,9 +1198,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
PAGE_SIZE << priv->hw_params.rx_page_order, PAGE_SIZE << priv->hw_params.rx_page_order,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
priv->alloc_rxb_page--; __iwl_free_pages(priv, rxq->pool[i].page);
__free_pages(rxq->pool[i].page,
priv->hw_params.rx_page_order);
rxq->pool[i].page = NULL; rxq->pool[i].page = NULL;
} }
list_add_tail(&rxq->pool[i].list, &rxq->rx_used); list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
...@@ -1247,10 +1245,8 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx ...@@ -1247,10 +1245,8 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx
pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
PAGE_SIZE << priv->hw_params.rx_page_order, PAGE_SIZE << priv->hw_params.rx_page_order,
PCI_DMA_FROMDEVICE); PCI_DMA_FROMDEVICE);
__free_pages(rxq->pool[i].page, __iwl_free_pages(priv, rxq->pool[i].page);
priv->hw_params.rx_page_order);
rxq->pool[i].page = NULL; rxq->pool[i].page = NULL;
priv->alloc_rxb_page--;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment