瀏覽代碼

qcacmn: Pre-allocate flex-mem segments

Pre-allocate the reduction_limit number of segments during
flex-mem-pool initialization.

Change-Id: I91581e04b94597ee4314ce8691b37a45066c5273
CRs-Fixed: 2241805
Dustin Brown 6 年之前
父節點
當前提交
a487539d7d
共有 1 個文件被更改,包括 22 次插入13 次删除
  1. 22 13
      qdf/src/qdf_flex_mem.c

+ 22 - 13
qdf/src/qdf_flex_mem.c

@@ -24,18 +24,6 @@
 #include "qdf_trace.h"
 #include "qdf_util.h"
 
-void qdf_flex_mem_init(struct qdf_flex_mem_pool *pool)
-{
-	qdf_spinlock_create(&pool->lock);
-}
-qdf_export_symbol(qdf_flex_mem_init);
-
-void qdf_flex_mem_deinit(struct qdf_flex_mem_pool *pool)
-{
-	qdf_spinlock_destroy(&pool->lock);
-}
-qdf_export_symbol(qdf_flex_mem_deinit);
-
 static struct qdf_flex_mem_segment *
 qdf_flex_mem_seg_alloc(struct qdf_flex_mem_pool *pool)
 {
@@ -49,10 +37,32 @@ qdf_flex_mem_seg_alloc(struct qdf_flex_mem_pool *pool)
 
 	seg->dynamic = true;
 	seg->bytes = (uint8_t *)(seg + 1);
+	seg->used_bitmap = 0;
+	qdf_list_insert_back(&pool->seg_list, &seg->node);
 
 	return seg;
 }
 
+void qdf_flex_mem_init(struct qdf_flex_mem_pool *pool)
+{
+	int i;
+
+	qdf_spinlock_create(&pool->lock);
+
+	for (i = 0; i < pool->reduction_limit; i++)
+		qdf_flex_mem_seg_alloc(pool);
+}
+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));
+
+	qdf_spinlock_destroy(&pool->lock);
+}
+qdf_export_symbol(qdf_flex_mem_deinit);
+
 static void *__qdf_flex_mem_alloc(struct qdf_flex_mem_pool *pool)
 {
 	struct qdf_flex_mem_segment *seg;
@@ -79,7 +89,6 @@ static void *__qdf_flex_mem_alloc(struct qdf_flex_mem_pool *pool)
 		return NULL;
 
 	seg->used_bitmap = 1;
-	qdf_list_insert_back(&pool->seg_list, &seg->node);
 
 	return seg->bytes;
 }