blob: d9716780b9a788fbe1e16f9a7d0bd18c30742866 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*===========================================================================
43 @file vos_memory.c
44
45 @brief Virtual Operating System Services Memory API
46
47
48 Copyright (c) 2008 QUALCOMM Incorporated.
49 All Rights Reserved.
50 Qualcomm Confidential and Proprietary
51===========================================================================*/
52
53/*===========================================================================
54
55 EDIT HISTORY FOR FILE
56
57
58 This section contains comments describing changes made to the module.
59 Notice that changes are listed in reverse chronological order.
60
61
62 $Header:$ $DateTime: $ $Author: $
63
64
65 when who what, where, why
66 -------- --- --------------------------------------------------------
67
68===========================================================================*/
69
70/*---------------------------------------------------------------------------
71 * Include Files
72 * ------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -070073#include "vos_memory.h"
74#include "vos_trace.h"
75
Mohit Khanna49a87a82012-09-11 18:03:14 -070076#ifdef CONFIG_WCNSS_MEM_PRE_ALLOC
77#include <linux/wcnss_wlan.h>
78#define WCNSS_PRE_ALLOC_GET_THRESHOLD (4*1024)
79#endif
80
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef MEMORY_DEBUG
82#include "wlan_hdd_dp_utils.h"
83
84hdd_list_t vosMemList;
85
86static v_U8_t WLAN_MEM_HEADER[] = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68 };
87static v_U8_t WLAN_MEM_TAIL[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87};
88
89struct s_vos_mem_struct
90{
91 hdd_list_node_t pNode;
92 char* fileName;
93 unsigned int lineNum;
94 unsigned int size;
95 v_U8_t header[8];
96};
97#endif
98
99/*---------------------------------------------------------------------------
100 * Preprocessor Definitions and Constants
101 * ------------------------------------------------------------------------*/
102
103/*---------------------------------------------------------------------------
104 * Type Declarations
105 * ------------------------------------------------------------------------*/
106
107/*---------------------------------------------------------------------------
108 * Data definitions
109 * ------------------------------------------------------------------------*/
110
111/*---------------------------------------------------------------------------
112 * External Function implementation
113 * ------------------------------------------------------------------------*/
114#ifdef MEMORY_DEBUG
115void vos_mem_init()
116{
117 /* Initalizing the list with maximum size of 60000 */
118 hdd_list_init(&vosMemList, 60000);
119 return;
120}
121
122void vos_mem_clean()
123{
124 v_SIZE_t listSize;
125 hdd_list_size(&vosMemList, &listSize);
126
127 if(listSize)
128 {
129 hdd_list_node_t* pNode;
130 VOS_STATUS vosStatus;
131
132 struct s_vos_mem_struct* memStruct;
Manjunathappa Prakash0e7e3472013-11-22 15:38:14 -0800133 char* prev_mleak_file = "";
134 unsigned int prev_mleak_lineNum = 0;
135 unsigned int prev_mleak_sz = 0;
136 unsigned int mleak_cnt = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137
138 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700139 "%s: List is not Empty. listSize %d ", __func__, (int)listSize);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140
141 do
142 {
143 spin_lock(&vosMemList.lock);
144 vosStatus = hdd_list_remove_front(&vosMemList, &pNode);
145 spin_unlock(&vosMemList.lock);
146 if(VOS_STATUS_SUCCESS == vosStatus)
147 {
148 memStruct = (struct s_vos_mem_struct*)pNode;
Manjunathappa Prakash0e7e3472013-11-22 15:38:14 -0800149
150 /* Take care to log only once multiple memory leaks from
151 * the same place */
152 if(strcmp(prev_mleak_file, memStruct->fileName) ||
153 (prev_mleak_lineNum != memStruct->lineNum) ||
154 (prev_mleak_sz != memStruct->size))
155 {
156 if(mleak_cnt != 0)
157 {
158 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
159 "%d Time Memory Leak@ File %s, @Line %d, size %d",
160 mleak_cnt, prev_mleak_file, prev_mleak_lineNum,
161 prev_mleak_sz);
162 }
163 prev_mleak_file = memStruct->fileName;
164 prev_mleak_lineNum = memStruct->lineNum;
165 prev_mleak_sz = memStruct->size;
166 mleak_cnt = 0;
167 }
168 mleak_cnt++;
169
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 kfree((v_VOID_t*)memStruct);
171 }
172 }while(vosStatus == VOS_STATUS_SUCCESS);
lukez092ea1a2013-03-15 14:53:55 -0700173
Manjunathappa Prakash0e7e3472013-11-22 15:38:14 -0800174 /* Print last memory leak from the module */
175 if(mleak_cnt)
176 {
177 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
178 "%d Time memory Leak@ File %s, @Line %d, size %d",
179 mleak_cnt, prev_mleak_file, prev_mleak_lineNum,
180 prev_mleak_sz);
181 }
182
183
lukez092ea1a2013-03-15 14:53:55 -0700184#ifdef CONFIG_HALT_KMEMLEAK
185 BUG_ON(0);
186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 }
188}
189
190void vos_mem_exit()
191{
192 vos_mem_clean();
193 hdd_list_destroy(&vosMemList);
194}
195
196v_VOID_t * vos_mem_malloc_debug( v_SIZE_t size, char* fileName, v_U32_t lineNum)
197{
198 struct s_vos_mem_struct* memStruct;
199 v_VOID_t* memPtr = NULL;
200 v_SIZE_t new_size;
201
202 if (size > (1024*1024))
203 {
204 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700205 "%s: called with arg > 1024K; passed in %d !!!", __func__,size);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 return NULL;
207 }
Madan Mohan Koyyalamudi5c0fe232013-09-16 22:21:26 +0530208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 if (in_interrupt())
210 {
Madan Mohan Koyyalamudi5c0fe232013-09-16 22:21:26 +0530211 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be "
212 "called from interrupt context!!!", __func__);
213 return NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 }
215
216 new_size = size + sizeof(struct s_vos_mem_struct) + 8;
217
218 memStruct = (struct s_vos_mem_struct*)kmalloc(new_size,GFP_KERNEL);
219
220 if(memStruct != NULL)
221 {
222 VOS_STATUS vosStatus;
223
224 memStruct->fileName = fileName;
225 memStruct->lineNum = lineNum;
226 memStruct->size = size;
227
228 vos_mem_copy(&memStruct->header[0], &WLAN_MEM_HEADER[0], sizeof(WLAN_MEM_HEADER));
229 vos_mem_copy( (v_U8_t*)(memStruct + 1) + size, &WLAN_MEM_TAIL[0], sizeof(WLAN_MEM_TAIL));
230
231 spin_lock(&vosMemList.lock);
232 vosStatus = hdd_list_insert_front(&vosMemList, &memStruct->pNode);
233 spin_unlock(&vosMemList.lock);
234 if(VOS_STATUS_SUCCESS != vosStatus)
235 {
236 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800237 "%s: Unable to insert node into List vosStatus %d", __func__, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 }
239
240 memPtr = (v_VOID_t*)(memStruct + 1);
241 }
242 return memPtr;
243}
244
245v_VOID_t vos_mem_free( v_VOID_t *ptr )
246{
Madan Mohan Koyyalamudi5c0fe232013-09-16 22:21:26 +0530247
248 if (in_interrupt())
249 {
250 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be "
251 "called from interrupt context!!!", __func__);
252 return;
253 }
254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 if (ptr != NULL)
256 {
257 VOS_STATUS vosStatus;
258 struct s_vos_mem_struct* memStruct = ((struct s_vos_mem_struct*)ptr) - 1;
259
260 spin_lock(&vosMemList.lock);
261 vosStatus = hdd_list_remove_node(&vosMemList, &memStruct->pNode);
262 spin_unlock(&vosMemList.lock);
263
264 if(VOS_STATUS_SUCCESS == vosStatus)
265 {
266 if(0 == vos_mem_compare(memStruct->header, &WLAN_MEM_HEADER[0], sizeof(WLAN_MEM_HEADER)) )
267 {
268 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
269 "Memory Header is corrupted. MemInfo: Filename %s, LineNum %d",
270 memStruct->fileName, (int)memStruct->lineNum);
271 }
272 if(0 == vos_mem_compare( (v_U8_t*)ptr + memStruct->size, &WLAN_MEM_TAIL[0], sizeof(WLAN_MEM_TAIL ) ) )
273 {
274 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
275 "Memory Trailer is corrupted. MemInfo: Filename %s, LineNum %d",
276 memStruct->fileName, (int)memStruct->lineNum);
277 }
278 kfree((v_VOID_t*)memStruct);
279 }
280 else
281 {
282 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700283 "%s: Unallocated memory (double free?)", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 VOS_ASSERT(0);
285 }
286 }
287}
288#else
289v_VOID_t * vos_mem_malloc( v_SIZE_t size )
290{
Mohit Khanna49a87a82012-09-11 18:03:14 -0700291#ifdef CONFIG_WCNSS_MEM_PRE_ALLOC
292 v_VOID_t* pmem;
293#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 if (size > (1024*1024))
295 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700296 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s: called with arg > 1024K; passed in %d !!!", __func__,size);
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 return NULL;
298 }
299 if (in_interrupt())
300 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700301 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be called from interrupt context!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 return NULL;
303 }
Mohit Khanna49a87a82012-09-11 18:03:14 -0700304#ifdef CONFIG_WCNSS_MEM_PRE_ALLOC
305 if(size > WCNSS_PRE_ALLOC_GET_THRESHOLD)
306 {
307 pmem = wcnss_prealloc_get(size);
308 if(NULL != pmem)
309 return pmem;
310 }
311#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 return kmalloc(size, GFP_KERNEL);
313}
314
315v_VOID_t vos_mem_free( v_VOID_t *ptr )
316{
317 if (ptr == NULL)
318 return;
Mohit Khanna49a87a82012-09-11 18:03:14 -0700319
320 if (in_interrupt())
321 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700322 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be called from interrupt context!!!", __func__);
Mohit Khanna49a87a82012-09-11 18:03:14 -0700323 return;
324 }
325#ifdef CONFIG_WCNSS_MEM_PRE_ALLOC
326 if(wcnss_prealloc_put(ptr))
327 return;
328#endif
329
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 kfree(ptr);
331}
332#endif
333
334v_VOID_t vos_mem_set( v_VOID_t *ptr, v_SIZE_t numBytes, v_BYTE_t value )
335{
336 if (ptr == NULL)
337 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700338 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s called with NULL parameter ptr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 return;
340 }
341 memset(ptr, value, numBytes);
342}
343
344v_VOID_t vos_mem_zero( v_VOID_t *ptr, v_SIZE_t numBytes )
345{
346 if (0 == numBytes)
347 {
348 // special case where ptr can be NULL
349 return;
350 }
351
352 if (ptr == NULL)
353 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700354 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s called with NULL parameter ptr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 return;
356 }
357 memset(ptr, 0, numBytes);
358
359}
360
361
362//This function is to validate one list in SME. We suspect someone corrupt te list. This code need to be removed
363//once the issue is fixed.
364extern int csrCheckValidateLists(void * dest, const void *src, v_SIZE_t num, int idx);
365
366v_VOID_t vos_mem_copy( v_VOID_t *pDst, const v_VOID_t *pSrc, v_SIZE_t numBytes )
367{
368 if (0 == numBytes)
369 {
370 // special case where pDst or pSrc can be NULL
371 return;
372 }
373
374 if ((pDst == NULL) || (pSrc==NULL))
375 {
376 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
377 "%s called with NULL parameter, source:%p destination:%p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700378 __func__, pSrc, pDst);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 VOS_ASSERT(0);
380 return;
381 }
382 //These two check function calls are to see if someone corrupt the list while doing mem copy.
383 csrCheckValidateLists(pDst, pSrc, numBytes, 1);
384 memcpy(pDst, pSrc, numBytes);
385 csrCheckValidateLists(pDst, pSrc, numBytes, 2);
386}
387
388v_VOID_t vos_mem_move( v_VOID_t *pDst, const v_VOID_t *pSrc, v_SIZE_t numBytes )
389{
390 if (0 == numBytes)
391 {
392 // special case where pDst or pSrc can be NULL
393 return;
394 }
395
396 if ((pDst == NULL) || (pSrc==NULL))
397 {
398 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
399 "%s called with NULL parameter, source:%p destination:%p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700400 __func__, pSrc, pDst);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 VOS_ASSERT(0);
402 return;
403 }
404 memmove(pDst, pSrc, numBytes);
405}
406
407v_BOOL_t vos_mem_compare( v_VOID_t *pMemory1, v_VOID_t *pMemory2, v_U32_t numBytes )
408{
409 if (0 == numBytes)
410 {
411 // special case where pMemory1 or pMemory2 can be NULL
412 return VOS_TRUE;
413 }
414
415 if ((pMemory1 == NULL) || (pMemory2==NULL))
416 {
417 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
418 "%s called with NULL parameter, p1:%p p2:%p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700419 __func__, pMemory1, pMemory2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700420 VOS_ASSERT(0);
421 return VOS_FALSE;
422 }
423 return (memcmp(pMemory1, pMemory2, numBytes)?VOS_FALSE:VOS_TRUE);
424}
425
426
427v_SINT_t vos_mem_compare2( v_VOID_t *pMemory1, v_VOID_t *pMemory2, v_U32_t numBytes )
428
429{
430 return( (v_SINT_t) memcmp( pMemory1, pMemory2, numBytes ) );
431}
432
433/*----------------------------------------------------------------------------
434
435 \brief vos_mem_dma_malloc() - vOSS DMA Memory Allocation
436
437 This function will dynamicallly allocate the specified number of bytes of
438 memory. This memory will have special attributes making it DMA friendly i.e.
439 it will exist in contiguous, 32-byte aligned uncached memory. A normal
440 vos_mem_malloc does not yield memory with these attributes.
441
442 NOTE: the special DMA friendly memory is very scarce and this API must be
443 used sparingly
444
445 On WM, there is nothing special about this memory. SDHC allocates the
446 DMA friendly buffer and copies the data into it
447
448 \param size - the number of bytes of memory to allocate.
449
450 \return Upon successful allocate, returns a non-NULL pointer to the
451 allocated memory. If this function is unable to allocate the amount of
452 memory specified (for any reason) it returns NULL.
453
454 \sa
455
456 --------------------------------------------------------------------------*/
457#ifdef MEMORY_DEBUG
458v_VOID_t * vos_mem_dma_malloc_debug( v_SIZE_t size, char* fileName, v_U32_t lineNum)
459{
460 struct s_vos_mem_struct* memStruct;
461 v_VOID_t* memPtr = NULL;
462 v_SIZE_t new_size;
463
464 if (in_interrupt())
465 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700466 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be called from interrupt context!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return NULL;
468 }
469
470 new_size = size + sizeof(struct s_vos_mem_struct) + 8;
471
472 memStruct = (struct s_vos_mem_struct*)kmalloc(new_size,GFP_KERNEL);
473
474 if(memStruct != NULL)
475 {
476 VOS_STATUS vosStatus;
477
478 memStruct->fileName = fileName;
479 memStruct->lineNum = lineNum;
480 memStruct->size = size;
481
482 vos_mem_copy(&memStruct->header[0], &WLAN_MEM_HEADER[0], sizeof(WLAN_MEM_HEADER));
483 vos_mem_copy( (v_U8_t*)(memStruct + 1) + size, &WLAN_MEM_TAIL[0], sizeof(WLAN_MEM_TAIL));
484
485 spin_lock(&vosMemList.lock);
486 vosStatus = hdd_list_insert_front(&vosMemList, &memStruct->pNode);
487 spin_unlock(&vosMemList.lock);
488 if(VOS_STATUS_SUCCESS != vosStatus)
489 {
490 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800491 "%s: Unable to insert node into List vosStatus %d", __func__, vosStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 }
493
494 memPtr = (v_VOID_t*)(memStruct + 1);
495 }
496
497 return memPtr;
498}
499
500v_VOID_t vos_mem_dma_free( v_VOID_t *ptr )
501{
502 if (ptr != NULL)
503 {
504 VOS_STATUS vosStatus;
505 struct s_vos_mem_struct* memStruct = ((struct s_vos_mem_struct*)ptr) - 1;
506
507 spin_lock(&vosMemList.lock);
508 vosStatus = hdd_list_remove_node(&vosMemList, &memStruct->pNode);
509 spin_unlock(&vosMemList.lock);
510
511 if(VOS_STATUS_SUCCESS == vosStatus)
512 {
513 if(0 == vos_mem_compare(memStruct->header, &WLAN_MEM_HEADER[0], sizeof(WLAN_MEM_HEADER)) )
514 {
515 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
516 "Memory Header is corrupted. MemInfo: Filename %s, LineNum %d",
517 memStruct->fileName, (int)memStruct->lineNum);
518 }
519 if(0 == vos_mem_compare( (v_U8_t*)ptr + memStruct->size, &WLAN_MEM_TAIL[0], sizeof(WLAN_MEM_TAIL ) ) )
520 {
521 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
522 "Memory Trailer is corrupted. MemInfo: Filename %s, LineNum %d",
523 memStruct->fileName, (int)memStruct->lineNum);
524 }
525 kfree((v_VOID_t*)memStruct);
526 }
527 }
528}
529#else
530v_VOID_t* vos_mem_dma_malloc( v_SIZE_t size )
531{
532 if (in_interrupt())
533 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700534 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR, "%s cannot be called from interrupt context!!!", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 return NULL;
536 }
537 return kmalloc(size, GFP_KERNEL);
538}
539
540/*----------------------------------------------------------------------------
541
542 \brief vos_mem_dma_free() - vOSS DMA Free Memory
543
544 This function will free special DMA friendly memory pointed to by 'ptr'.
545
546 On WM, there is nothing special about the memory being free'd. SDHC will
547 take care of free'ing the DMA friendly buffer
548
549 \param ptr - pointer to the starting address of the memory to be
550 free'd.
551
552 \return Nothing
553
554 \sa
555
556 --------------------------------------------------------------------------*/
557v_VOID_t vos_mem_dma_free( v_VOID_t *ptr )
558{
559 if (ptr == NULL)
560 return;
561 kfree(ptr);
562}
563#endif