blob: 062e34f4611da305687850cb645e5932e0ec77b0 [file] [log] [blame]
From 5e0d06a0c9b13e4e385289d3ebbc572f18966001 Mon Sep 17 00:00:00 2001
From: Avery Pennarun <apenwarr@gmail.com>
Date: Mon, 28 Apr 2014 03:38:31 -0400
Subject: [PATCH] ath10k: add some flags to make memory allocations try harder.
GFP_DMA should have a qualifier of either GFP_KERNEL or GFP_ATOMIC. With
neither, it neither waits nor has access to emergency memory, which means
maximizing its chance of disaster.
When allocating large memory areas, it can help to use __GFP_REPEAT, which
tries to free pages a few extra times.
And, because the current ath10k driver seems to be a little finicky about
memory allocation problems, let's just add __GFP_HIGH (to allow access to
the emergency pool) for all its allocations for now. It's probably best to
remove that eventually, but should be okay in the short term since we're
also expanding the size of our emergency pool (in a separate patch).
---
drivers/net/wireless/ath/ath10k/ce.c | 10 +++++-----
drivers/net/wireless/ath/ath10k/debug.c | 6 +++---
drivers/net/wireless/ath/ath10k/htt_rx.c | 6 +++---
drivers/net/wireless/ath/ath10k/htt_tx.c | 4 ++--
drivers/net/wireless/ath/ath10k/mac.c | 6 +++---
drivers/net/wireless/ath/ath10k/pci.c | 6 +++---
6 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/ce.c b/drivers/net/wireless/ath/ath10k/ce.c
index 1ad5c10..09d8235 100644
--- a/drivers/net/wireless/ath/ath10k/ce.c
+++ b/drivers/net/wireless/ath/ath10k/ce.c
@@ -923,7 +923,7 @@ ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
src_ring = kzalloc(sizeof(*src_ring) +
(nentries *
sizeof(*src_ring->per_transfer_context)),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (src_ring == NULL)
return ERR_PTR(-ENOMEM);
@@ -938,7 +938,7 @@ ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
dma_alloc_coherent(ar->dev,
(nentries * sizeof(struct ce_desc) +
CE_DESC_RING_ALIGN),
- &base_addr, GFP_KERNEL);
+ &base_addr, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!src_ring->base_addr_owner_space_unaligned) {
kfree(src_ring);
return ERR_PTR(-ENOMEM);
@@ -959,7 +959,7 @@ ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id,
*/
src_ring->shadow_base_unaligned =
kmalloc((nentries * sizeof(struct ce_desc) +
- CE_DESC_RING_ALIGN), GFP_KERNEL);
+ CE_DESC_RING_ALIGN), GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!src_ring->shadow_base_unaligned) {
dma_free_coherent(ar->dev,
(nentries * sizeof(struct ce_desc) +
@@ -990,7 +990,7 @@ ath10k_ce_alloc_dest_ring(struct ath10k *ar, unsigned int ce_id,
dest_ring = kzalloc(sizeof(*dest_ring) +
(nentries *
sizeof(*dest_ring->per_transfer_context)),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (dest_ring == NULL)
return ERR_PTR(-ENOMEM);
@@ -1005,7 +1005,7 @@ ath10k_ce_alloc_dest_ring(struct ath10k *ar, unsigned int ce_id,
dma_alloc_coherent(ar->dev,
(nentries * sizeof(struct ce_desc) +
CE_DESC_RING_ALIGN),
- &base_addr, GFP_KERNEL);
+ &base_addr, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!dest_ring->base_addr_owner_space_unaligned) {
kfree(dest_ring);
return ERR_PTR(-ENOMEM);
diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 0386550..a490ada 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -120,7 +120,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
ssize_t ret_cnt;
int i;
- buf = kzalloc(buf_len, GFP_KERNEL);
+ buf = kzalloc(buf_len, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!buf)
return -ENOMEM;
@@ -303,7 +303,7 @@ static ssize_t ath10k_read_fw_stats(struct file *file, char __user *user_buf,
if (ar->state != ATH10K_STATE_ON)
goto exit;
- buf = kzalloc(buf_len, GFP_KERNEL);
+ buf = kzalloc(buf_len, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!buf)
goto exit;
@@ -793,7 +793,7 @@ static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
struct ath10k *ar = file->private_data;
char *buf;
- buf = kzalloc(size, GFP_KERNEL);
+ buf = kzalloc(size, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (buf == NULL)
return -ENOMEM;
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
index f85a3cf..35f7e64 100644
--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
@@ -495,13 +495,13 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)
htt->rx_ring.netbufs_ring =
kmalloc(htt->rx_ring.size * sizeof(struct sk_buff *),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!htt->rx_ring.netbufs_ring)
goto err_netbuf;
vaddr = dma_alloc_coherent(htt->ar->dev,
(htt->rx_ring.size * sizeof(htt->rx_ring.paddrs_ring)),
- &paddr, GFP_DMA);
+ &paddr, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH|GFP_DMA);
if (!vaddr)
goto err_dma_ring;
@@ -510,7 +510,7 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)
vaddr = dma_alloc_coherent(htt->ar->dev,
sizeof(*htt->rx_ring.alloc_idx.vaddr),
- &paddr, GFP_DMA);
+ &paddr, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH|GFP_DMA);
if (!vaddr)
goto err_dma_idx;
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 7a3e2e4..c053400 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -97,13 +97,13 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt)
htt->max_num_pending_tx);
htt->pending_tx = kzalloc(sizeof(*htt->pending_tx) *
- htt->max_num_pending_tx, GFP_KERNEL);
+ htt->max_num_pending_tx, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!htt->pending_tx)
return -ENOMEM;
htt->used_msdu_ids = kzalloc(sizeof(unsigned long) *
BITS_TO_LONGS(htt->max_num_pending_tx),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!htt->used_msdu_ids) {
kfree(htt->pending_tx);
return -ENOMEM;
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 5307dee..ecd191b 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -1689,7 +1689,7 @@ static int ath10k_update_channel_list(struct ath10k *ar)
}
len = sizeof(struct wmi_channel_arg) * arg.n_channels;
- arg.channels = kzalloc(len, GFP_KERNEL);
+ arg.channels = kzalloc(len, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!arg.channels)
return -ENOMEM;
@@ -4559,7 +4559,7 @@ int ath10k_mac_register(struct ath10k *ar)
if (ar->phy_capability & WHAL_WLAN_11G_CAPABILITY) {
channels = kmemdup(ath10k_2ghz_channels,
sizeof(ath10k_2ghz_channels),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!channels) {
ret = -ENOMEM;
goto err_free;
@@ -4580,7 +4580,7 @@ int ath10k_mac_register(struct ath10k *ar)
if (ar->phy_capability & WHAL_WLAN_11A_CAPABILITY) {
channels = kmemdup(ath10k_5ghz_channels,
sizeof(ath10k_5ghz_channels),
- GFP_KERNEL);
+ GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!channels) {
ret = -ENOMEM;
goto err_free;
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 66b1f30..427d861 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1321,7 +1321,7 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
if (resp && resp_len && *resp_len == 0)
return -EINVAL;
- treq = kmemdup(req, req_len, GFP_KERNEL);
+ treq = kmemdup(req, req_len, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!treq)
return -ENOMEM;
@@ -1331,7 +1331,7 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
goto err_dma;
if (resp && resp_len) {
- tresp = kzalloc(*resp_len, GFP_KERNEL);
+ tresp = kzalloc(*resp_len, GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (!tresp) {
ret = -ENOMEM;
goto err_req;
@@ -2568,7 +2568,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
ath10k_dbg(ATH10K_DBG_PCI, "pci probe\n");
- ar_pci = kzalloc(sizeof(*ar_pci), GFP_KERNEL);
+ ar_pci = kzalloc(sizeof(*ar_pci), GFP_KERNEL|__GFP_REPEAT|__GFP_HIGH);
if (ar_pci == NULL)
return -ENOMEM;
--
1.9.1.423.g4596e3a