Revert "qcacmn: modify QDF functions for memory allocation and free"

This reverts Change-Id: I2c19b72b82092d553d474a50385ed3095a0fab39
since it results in increased memory allocation due to 8 bytes of
headroom at the beginning of buffer, particularly for data path modules
when size is at the edge of the page boundary.

Change-Id: I72fd7e63b93f2646812acc09e817e3be531f27d8
CRs-Fixed: 3458603
This commit is contained in:
Rajesh Chauhan
2023-04-06 13:44:52 -07:00
committed by Madan Koyyalamudi
parent a5e00e2455
commit d7d85dfad9

View File

@@ -44,33 +44,6 @@
#endif
#endif
/* cnss prealloc maintains various prealloc pools of 8Kb, 16Kb, 32Kb and so
* on and allocates buffer from the pool for wlan driver. When wlan driver
* requests to free the memory buffer then cnss prealloc derives slab_cache
* from virtual memory via page struct to identify prealloc pool id to put
* back memory buffer into the pool. Kernel 5.17 removed slab_cache from page
* struct. So add headroom to store cache pointer at the beginning of
* allocated memory buffer to use it later in identifying prealloc pool id.
*/
#if defined(CNSS_MEM_PRE_ALLOC) && defined(CONFIG_CNSS_OUT_OF_TREE)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0))
static inline bool add_headroom_for_cnss_prealloc_cache_ptr(void)
{
return true;
}
#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) */
static inline bool add_headroom_for_cnss_prealloc_cache_ptr(void)
{
return false;
}
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)) */
#else /* defined(CNSS_MEM_PRE_ALLOC) && defined(CONFIG_CNSS_OUT_OF_TREE) */
static inline bool add_headroom_for_cnss_prealloc_cache_ptr(void)
{
return false;
}
#endif /* defined(CNSS_MEM_PRE_ALLOC) && defined(CONFIG_CNSS_OUT_OF_TREE) */
#if defined(MEMORY_DEBUG) || defined(NBUF_MEMORY_DEBUG)
static bool mem_debug_disabled;
qdf_declare_param(mem_debug_disabled, bool);
@@ -1391,9 +1364,6 @@ static void *qdf_mem_prealloc_get(size_t size)
if (!ptr)
return NULL;
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
memset(ptr, 0, size);
return ptr;
@@ -1552,9 +1522,6 @@ void *qdf_mem_malloc_debug(size_t size, const char *func, uint32_t line,
return NULL;
}
if (add_headroom_for_cnss_prealloc_cache_ptr())
size += sizeof(void *);
ptr = qdf_mem_prealloc_get(size);
if (ptr)
return ptr;
@@ -1587,9 +1554,6 @@ void *qdf_mem_malloc_debug(size_t size, const char *func, uint32_t line,
qdf_mem_kmalloc_inc(ksize(header));
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
return ptr;
}
qdf_export_symbol(qdf_mem_malloc_debug);
@@ -1612,9 +1576,6 @@ void *qdf_mem_malloc_atomic_debug(size_t size, const char *func,
return NULL;
}
if (add_headroom_for_cnss_prealloc_cache_ptr())
size += sizeof(void *);
ptr = qdf_mem_prealloc_get(size);
if (ptr)
return ptr;
@@ -1644,9 +1605,6 @@ void *qdf_mem_malloc_atomic_debug(size_t size, const char *func,
qdf_mem_kmalloc_inc(ksize(header));
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
return ptr;
}
@@ -1663,9 +1621,6 @@ void *qdf_mem_malloc_atomic_debug_fl(size_t size, const char *func,
return NULL;
}
if (add_headroom_for_cnss_prealloc_cache_ptr())
size += sizeof(void *);
ptr = qdf_mem_prealloc_get(size);
if (ptr)
return ptr;
@@ -1679,9 +1634,6 @@ void *qdf_mem_malloc_atomic_debug_fl(size_t size, const char *func,
qdf_mem_kmalloc_inc(ksize(ptr));
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
return ptr;
}
@@ -1702,9 +1654,6 @@ void qdf_mem_free_debug(void *ptr, const char *func, uint32_t line)
if (qdf_unlikely(!ptr))
return;
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr = ptr - sizeof(void *);
if (qdf_mem_prealloc_put(ptr))
return;
@@ -1897,9 +1846,6 @@ void *qdf_mem_malloc_atomic_fl(size_t size, const char *func, uint32_t line)
return NULL;
}
if (add_headroom_for_cnss_prealloc_cache_ptr())
size += sizeof(void *);
ptr = qdf_mem_prealloc_get(size);
if (ptr)
return ptr;
@@ -1913,9 +1859,6 @@ void *qdf_mem_malloc_atomic_fl(size_t size, const char *func, uint32_t line)
qdf_mem_kmalloc_inc(ksize(ptr));
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
return ptr;
}
qdf_export_symbol(qdf_mem_malloc_atomic_fl);
@@ -2073,9 +2016,6 @@ void __qdf_mem_free(void *ptr)
if (!ptr)
return;
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr = ptr - sizeof(void *);
if (qdf_might_be_prealloc(ptr)) {
if (qdf_mem_prealloc_put(ptr))
return;
@@ -2098,9 +2038,6 @@ void *__qdf_mem_malloc(size_t size, const char *func, uint32_t line)
return NULL;
}
if (add_headroom_for_cnss_prealloc_cache_ptr())
size += sizeof(void *);
ptr = qdf_mem_prealloc_get(size);
if (ptr)
return ptr;
@@ -2111,9 +2048,6 @@ void *__qdf_mem_malloc(size_t size, const char *func, uint32_t line)
qdf_mem_kmalloc_inc(ksize(ptr));
if (add_headroom_for_cnss_prealloc_cache_ptr())
ptr += sizeof(void *);
return ptr;
}