Re: [PATCH] ath10k: Fix DMA alloc failure for target requested memory chunks

2015-09-09 Thread Kalle Valo
Vasanthakumar Thiagarajan  writes:

> During long hours of stress testing like AP interface up/down along
> with continuous ping flood from a station doing connect/disconnect,
> it is observed that the system is not able to allocate DMA consistent
> memory of size > 512KB chunks as requested by firmware in WMI_SERVICE_EVENTID.
> With the system memory getting fragmented during the run based on the
> size of the memory requested, the failure to return physically continguous
> memory of high order can happen. Once the system gets to this situation,
> bringing up the wifi interface will fail and a system reboot may be needed
> to make it work again. This problem is obseved with QCA99X0.
>
> To fix this issue, allocate the DMA memory requested by firmware during
> device probe time and keep it during the life time of the device. WMI service
> ready event handler is changed to allocate the memory chunks if it is
> not already allocated or if the memory allocated for the previous ready
> event is not same as the current requested ones. After this patch the
> memory usage when wifi is inactive will be inceased by few 100KB to
> 3MB based on the target type.
>
> Failure happens with the following stack trace
>
> [29557.488773] kworker/u4:1: page allocation failure: order:8, mode:0xd0
> [29557.494297] CPU: 0 PID: 8402 Comm: kworker/u4:1 Not tainted 3.14.43 #7
> [29557.500793] Workqueue: ath10k_aux_wq ath10k_wmi_event_service_ready_work 
> [ath10k_core]
> [29557.508602] [] (unwind_backtrace) from [] 
> (show_stack+0x10/0x14)
> [29557.516580] [] (show_stack) from [] 
> (dump_stack+0x88/0xcc)
> [29557.523612] [] (dump_stack) from [] 
> (warn_alloc_failed+0xdc/0x108)
> [29557.531515] [] (warn_alloc_failed) from [] 
> (__alloc_pages_nodemask+0x4f0/0x654)
> [29557.540485] [] (__alloc_pages_nodemask) from [] 
> (__dma_alloc_buffer.isra.20+0x2c/0x104)
> [29557.550260] [] (__dma_alloc_buffer.isra.20) from [] 
> (__alloc_remap_buffer.isra.23+0x14/0xb8)
> [29557.560413] [] (__alloc_remap_buffer.isra.23) from [] 
> (__dma_alloc+0x224/0x2b8)
> [29557.569490] [] (__dma_alloc) from [] 
> (arm_dma_alloc+0x84/0x90)
> [29557.577010] [] (arm_dma_alloc) from [] 
> (ath10k_wmi_event_service_ready_work+0x2f8/0x420 [ath10k_core])
> [29557.588055] [] (ath10k_wmi_event_service_ready_work 
> [ath10k_core]) from [] (process_one_work+0x20c/0x328)
> [29557.599305] [] (process_one_work) from [] 
> (worker_thread+0x228/0x360)
> [29557.607470] [] (worker_thread) from [] 
> (kthread+0xd8/0xec)
> [29557.614750] [] (kthread) from [] 
> (ret_from_fork+0x14/0x3c)
> [29557.712751] Normal: 696*4kB (UEMR) 512*8kB (UEMR) 367*16kB (UEMR) 404*32kB 
> (UEMR) 455*64kB (UEMR) 424*128kB (UEMR) 379*256kB (UMR) 327*512kB (UMR) 
> 1*1024kB (R) 0*2048kB 0*4096kB = 374544kB
>
> Signed-off-by: Vasanthakumar Thiagarajan 

Thanks, applied.

-- 
Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ath10k: Fix DMA alloc failure for target requested memory chunks

2015-08-28 Thread Vasanthakumar Thiagarajan
During long hours of stress testing like AP interface up/down along
with continuous ping flood from a station doing connect/disconnect,
it is observed that the system is not able to allocate DMA consistent
memory of size  512KB chunks as requested by firmware in WMI_SERVICE_EVENTID.
With the system memory getting fragmented during the run based on the
size of the memory requested, the failure to return physically continguous
memory of high order can happen. Once the system gets to this situation,
bringing up the wifi interface will fail and a system reboot may be needed
to make it work again. This problem is obseved with QCA99X0.

To fix this issue, allocate the DMA memory requested by firmware during
device probe time and keep it during the life time of the device. WMI service
ready event handler is changed to allocate the memory chunks if it is
not already allocated or if the memory allocated for the previous ready
event is not same as the current requested ones. After this patch the
memory usage when wifi is inactive will be inceased by few 100KB to
3MB based on the target type.

Failure happens with the following stack trace

[29557.488773] kworker/u4:1: page allocation failure: order:8, mode:0xd0
[29557.494297] CPU: 0 PID: 8402 Comm: kworker/u4:1 Not tainted 3.14.43 #7
[29557.500793] Workqueue: ath10k_aux_wq ath10k_wmi_event_service_ready_work 
[ath10k_core]
[29557.508602] [c021e9b0] (unwind_backtrace) from [c021ba90] 
(show_stack+0x10/0x14)
[29557.516580] [c021ba90] (show_stack) from [c03bdddc] 
(dump_stack+0x88/0xcc)
[29557.523612] [c03bdddc] (dump_stack) from [c0290e34] 
(warn_alloc_failed+0xdc/0x108)
[29557.531515] [c0290e34] (warn_alloc_failed) from [c0292d88] 
(__alloc_pages_nodemask+0x4f0/0x654)
[29557.540485] [c0292d88] (__alloc_pages_nodemask) from [c0222b48] 
(__dma_alloc_buffer.isra.20+0x2c/0x104)
[29557.550260] [c0222b48] (__dma_alloc_buffer.isra.20) from [c0222c34] 
(__alloc_remap_buffer.isra.23+0x14/0xb8)
[29557.560413] [c0222c34] (__alloc_remap_buffer.isra.23) from [c022305c] 
(__dma_alloc+0x224/0x2b8)
[29557.569490] [c022305c] (__dma_alloc) from [c0223208] 
(arm_dma_alloc+0x84/0x90)
[29557.577010] [c0223208] (arm_dma_alloc) from [bf5159d0] 
(ath10k_wmi_event_service_ready_work+0x2f8/0x420 [ath10k_core])
[29557.588055] [bf5159d0] (ath10k_wmi_event_service_ready_work [ath10k_core]) 
from [c024260c] (process_one_work+0x20c/0x328)
[29557.599305] [c024260c] (process_one_work) from [c02432d0] 
(worker_thread+0x228/0x360)
[29557.607470] [c02432d0] (worker_thread) from [c0247f88] 
(kthread+0xd8/0xec)
[29557.614750] [c0247f88] (kthread) from [c0208d18] 
(ret_from_fork+0x14/0x3c)
[29557.712751] Normal: 696*4kB (UEMR) 512*8kB (UEMR) 367*16kB (UEMR) 404*32kB 
(UEMR) 455*64kB (UEMR) 424*128kB (UEMR) 379*256kB (UMR) 327*512kB (UMR) 
1*1024kB (R) 0*2048kB 0*4096kB = 374544kB

Signed-off-by: Vasanthakumar Thiagarajan vthia...@qti.qualcomm.com
---
 drivers/net/wireless/ath/ath10k/core.c |  1 +
 drivers/net/wireless/ath/ath10k/wmi.c  | 76 +++---
 drivers/net/wireless/ath/ath10k/wmi.h  |  1 +
 3 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c 
b/drivers/net/wireless/ath/ath10k/core.c
index b87b986..6e5aeed 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -1714,6 +1714,7 @@ void ath10k_core_destroy(struct ath10k *ar)
destroy_workqueue(ar-workqueue_aux);
 
ath10k_debug_destroy(ar);
+   ath10k_wmi_free_host_mem(ar);
ath10k_mac_destroy(ar);
 }
 EXPORT_SYMBOL(ath10k_core_destroy);
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index ce01107..87d9de2 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -3917,6 +3917,53 @@ static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, 
u32 req_id,
return 0;
 }
 
+static bool
+ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
+const struct wlan_host_mem_req **mem_reqs,
+u32 num_mem_reqs)
+{
+   u32 req_id, num_units, unit_size, num_unit_info;
+   u32 pool_size;
+   int i, j;
+   bool found;
+
+   if (ar-wmi.num_mem_chunks != num_mem_reqs)
+   return false;
+
+   for (i = 0; i  num_mem_reqs; ++i) {
+   req_id = __le32_to_cpu(mem_reqs[i]-req_id);
+   num_units = __le32_to_cpu(mem_reqs[i]-num_units);
+   unit_size = __le32_to_cpu(mem_reqs[i]-unit_size);
+   num_unit_info = __le32_to_cpu(mem_reqs[i]-num_unit_info);
+
+   if (num_unit_info  NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
+   if (ar-num_active_peers)
+   num_units = ar-num_active_peers + 1;
+   else
+   num_units = ar-max_num_peers + 1;
+   } else if (num_unit_info  NUM_UNITS_IS_NUM_PEERS) {
+