qcacmn: Remove qdf_flex_mem_release()

Due to a limitation in the memory leak detection logic when qdf_flex_mem
was written, qdf_flex_mem_release() was necessary to free any
dynamically allocated memory in the qdf_flex_mem_pool during certain
points in the WLAN driver lifecycle. This was done to avoid flagging any
dynamically allocated qdf_flex_mem_segments as false positive leaks
when the memory domains were changed and leak checking was performed.
With the introduction of qdf_talloc(), this workaround is no longer
required. Replace the calls to qdf_mem_malloc/free with qdf_talloc/free,
and remove qdf_flex_mem_release() altogether.

Change-Id: Ia5fd21386b94fc117af5f27853db5d8341601738
CRs-Fixed: 2404955
This commit is contained in:
Dustin Brown 2019-02-25 13:53:18 -08:00 • committed by nshrivas
commit 8ddef7dd9a
4 changed files with 17 additions and 51 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -130,14 +130,4 @@ void *qdf_flex_mem_alloc(struct qdf_flex_mem_pool *pool);
*/
void qdf_flex_mem_free(struct qdf_flex_mem_pool *pool, void *ptr);
/**
* qdf_flex_mem_release() - release unused segments
* @pool: the pool to operate against
*
* This function physically releases as much unused pool memory as possible.
*
* Return: None
*/
void qdf_flex_mem_release(struct qdf_flex_mem_pool *pool);
#endif /* __QDF_FLEX_MEM_H */

View file

@ -625,8 +625,6 @@ static void qdf_nbuf_map_leaks_print(void)
void qdf_nbuf_map_check_for_leaks(void)
{
qdf_flex_mem_release(&qdf_nbuf_map_pool);
qdf_spin_lock_irqsave(&qdf_nbuf_map_lock);
if (!hash_empty(qdf_nbuf_map_ht))
qdf_nbuf_map_leaks_print();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -21,6 +21,7 @@
#include "qdf_lock.h"
#include "qdf_mem.h"
#include "qdf_module.h"
#include "qdf_talloc.h"
#include "qdf_trace.h"
#include "qdf_util.h"
@ -31,7 +32,7 @@ qdf_flex_mem_seg_alloc(struct qdf_flex_mem_pool *pool)
size_t total_size = sizeof(struct qdf_flex_mem_segment) +
pool->item_size * QDF_FM_BITMAP_BITS;
seg = qdf_mem_malloc(total_size);
seg = qdf_talloc(pool, total_size);
if (!seg)
return NULL;
@ -56,10 +57,19 @@ qdf_export_symbol(qdf_flex_mem_init);
void qdf_flex_mem_deinit(struct qdf_flex_mem_pool *pool)
{
qdf_flex_mem_release(pool);
QDF_BUG(!qdf_list_size(&pool->seg_list));
struct qdf_flex_mem_segment *seg, *next;
qdf_spinlock_destroy(&pool->lock);
qdf_list_for_each_del(&pool->seg_list, seg, next, node) {
QDF_BUG(!seg->used_bitmap);
if (seg->used_bitmap)
continue;
qdf_list_remove_node(&pool->seg_list, &seg->node);
if (seg->dynamic)
qdf_tfree(seg);
}
}
qdf_export_symbol(qdf_flex_mem_deinit);
@ -118,9 +128,8 @@ static void qdf_flex_mem_seg_free(struct qdf_flex_mem_pool *pool,
if (qdf_list_size(&pool->seg_list) <= pool->reduction_limit)
return;
qdf_list_remove_node(&pool->seg_list, &seg->node);
qdf_mem_free(seg);
qdf_tfree(seg);
}
static void __qdf_flex_mem_free(struct qdf_flex_mem_pool *pool, void *ptr)
@ -166,32 +175,3 @@ void qdf_flex_mem_free(struct qdf_flex_mem_pool *pool, void *ptr)
}
qdf_export_symbol(qdf_flex_mem_free);
static void __qdf_flex_mem_release(struct qdf_flex_mem_pool *pool)
{
struct qdf_flex_mem_segment *seg;
struct qdf_flex_mem_segment *next;
qdf_list_for_each_del(&pool->seg_list, seg, next, node) {
if (!seg->dynamic)
continue;
if (seg->used_bitmap != 0)
continue;
qdf_list_remove_node(&pool->seg_list, &seg->node);
qdf_mem_free(seg);
}
}
void qdf_flex_mem_release(struct qdf_flex_mem_pool *pool)
{
QDF_BUG(pool);
if (!pool)
return;
qdf_spin_lock_bh(&pool->lock);
__qdf_flex_mem_release(pool);
qdf_spin_unlock_bh(&pool->lock);
}
qdf_export_symbol(qdf_flex_mem_release);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2018 The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2019 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@ -455,7 +455,5 @@ void scheduler_queues_flush(struct scheduler_ctx *sched_ctx)
mq = &sched_ctx->queue_ctx.sch_msg_q[i];
scheduler_flush_single_queue(mq);
}
qdf_flex_mem_release(&sched_pool);
}