cnss_prealloc: update prealloc mem pool based on device type
Update prealloc mem pool based on device type. Change-Id: Ic7fc2145a0039aa55643672b8e125857c096a3ee CRs-Fixed: 3459351
This commit is contained in:

committed by
Madan Koyyalamudi

parent
21bd3e2016
commit
97303bf330
16
cnss2/bus.h
16
cnss2/bus.h
@@ -9,25 +9,9 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define QCA6174_VENDOR_ID 0x168C
|
||||
#define QCA6174_DEVICE_ID 0x003E
|
||||
#define QCA6174_REV_ID_OFFSET 0x08
|
||||
#define QCA6174_REV3_VERSION 0x5020000
|
||||
#define QCA6174_REV3_2_VERSION 0x5030000
|
||||
#define QCA6290_VENDOR_ID 0x17CB
|
||||
#define QCA6290_DEVICE_ID 0x1100
|
||||
#define QCA6390_VENDOR_ID 0x17CB
|
||||
#define QCA6390_DEVICE_ID 0x1101
|
||||
#define QCA6490_VENDOR_ID 0x17CB
|
||||
#define QCA6490_DEVICE_ID 0x1103
|
||||
#define QCN7605_VENDOR_ID 0x17CB
|
||||
#define QCN7605_DEVICE_ID 0x1102
|
||||
#define KIWI_VENDOR_ID 0x17CB
|
||||
#define KIWI_DEVICE_ID 0x1107
|
||||
#define MANGO_VENDOR_ID 0x17CB
|
||||
#define MANGO_DEVICE_ID 0x110A
|
||||
#define PEACH_VENDOR_ID 0x17CB
|
||||
#define PEACH_DEVICE_ID 0x110E
|
||||
|
||||
enum cnss_dev_bus_type cnss_get_dev_bus_type(struct device *dev);
|
||||
enum cnss_dev_bus_type cnss_get_bus_type(struct cnss_plat_data *plat_priv);
|
||||
|
@@ -4867,6 +4867,8 @@ static int cnss_probe(struct platform_device *plat_dev)
|
||||
goto reset_plat_dev;
|
||||
}
|
||||
|
||||
cnss_initialize_prealloc_pool(plat_priv->device_id);
|
||||
|
||||
ret = cnss_get_pld_bus_ops_name(plat_priv);
|
||||
if (ret)
|
||||
cnss_pr_err("Failed to find bus ops name, err = %d\n",
|
||||
@@ -4970,6 +4972,7 @@ free_res:
|
||||
cnss_put_resources(plat_priv);
|
||||
reset_ctx:
|
||||
platform_set_drvdata(plat_dev, NULL);
|
||||
cnss_deinitialize_prealloc_pool();
|
||||
reset_plat_dev:
|
||||
cnss_clear_plat_priv(plat_priv);
|
||||
out:
|
||||
@@ -4999,6 +5002,8 @@ static int cnss_remove(struct platform_device *plat_dev)
|
||||
if (!IS_ERR_OR_NULL(plat_priv->mbox_chan))
|
||||
mbox_free_channel(plat_priv->mbox_chan);
|
||||
|
||||
cnss_deinitialize_prealloc_pool();
|
||||
|
||||
platform_set_drvdata(plat_dev, NULL);
|
||||
cnss_clear_plat_priv(plat_priv);
|
||||
|
||||
|
@@ -41,6 +41,8 @@
|
||||
#endif
|
||||
#include <linux/iommu.h>
|
||||
#include "qmi.h"
|
||||
#include "cnss_prealloc.h"
|
||||
#include "cnss_common.h"
|
||||
|
||||
#define MAX_NO_OF_MAC_ADDR 4
|
||||
#define QMI_WLFW_MAX_TIMESTAMP_LEN 32
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
ifeq ($(CONFIG_CNSS_OUT_OF_TREE),y)
|
||||
ccflags-y += -I$(WLAN_PLATFORM_ROOT)/inc
|
||||
ccflags-y += -I$(WLAN_PLATFORM_ROOT)/cnss_utils
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_WCNSS_MEM_PRE_ALLOC) += cnss_prealloc.o
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <linux/err.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/version.h>
|
||||
#include "cnss_common.h"
|
||||
#ifdef CONFIG_CNSS_OUT_OF_TREE
|
||||
#include "cnss_prealloc.h"
|
||||
#else
|
||||
@@ -68,7 +69,7 @@ struct cnss_pool {
|
||||
*/
|
||||
|
||||
/* size, min pool reserve, name, memorypool handler, cache handler*/
|
||||
static struct cnss_pool cnss_pools[] = {
|
||||
static struct cnss_pool cnss_pools_default[] = {
|
||||
{8 * 1024, 16, "cnss-pool-8k", NULL, NULL},
|
||||
{16 * 1024, 16, "cnss-pool-16k", NULL, NULL},
|
||||
{32 * 1024, 22, "cnss-pool-32k", NULL, NULL},
|
||||
@@ -76,6 +77,17 @@ static struct cnss_pool cnss_pools[] = {
|
||||
{128 * 1024, 10, "cnss-pool-128k", NULL, NULL},
|
||||
};
|
||||
|
||||
static struct cnss_pool cnss_pools_adrastea[] = {
|
||||
{8 * 1024, 2, "cnss-pool-8k", NULL, NULL},
|
||||
{16 * 1024, 10, "cnss-pool-16k", NULL, NULL},
|
||||
{32 * 1024, 8, "cnss-pool-32k", NULL, NULL},
|
||||
{64 * 1024, 4, "cnss-pool-64k", NULL, NULL},
|
||||
{128 * 1024, 2, "cnss-pool-128k", NULL, NULL},
|
||||
};
|
||||
|
||||
struct cnss_pool *cnss_pools;
|
||||
unsigned int cnss_prealloc_pool_size = ARRAY_SIZE(cnss_pools_default);
|
||||
|
||||
/**
|
||||
* cnss_pool_alloc_threshold() - Allocation threshold
|
||||
*
|
||||
@@ -104,7 +116,7 @@ static int cnss_pool_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cnss_pools); i++) {
|
||||
for (i = 0; i < cnss_prealloc_pool_size; i++) {
|
||||
/* Create the slab cache */
|
||||
cnss_pools[i].cache =
|
||||
kmem_cache_create_usercopy(cnss_pools[i].name,
|
||||
@@ -149,7 +161,7 @@ static void cnss_pool_deinit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cnss_pools); i++) {
|
||||
for (i = 0; i < cnss_prealloc_pool_size; i++) {
|
||||
pr_info("cnss_prealloc: destroy mempool %s\n",
|
||||
cnss_pools[i].name);
|
||||
mempool_destroy(cnss_pools[i].mp);
|
||||
@@ -157,6 +169,41 @@ static void cnss_pool_deinit(void)
|
||||
}
|
||||
}
|
||||
|
||||
void cnss_assign_prealloc_pool(unsigned long device_id)
|
||||
{
|
||||
pr_info("cnss_prealloc: assign cnss pool for device id 0x%lx", device_id);
|
||||
|
||||
switch (device_id) {
|
||||
case ADRASTEA_DEVICE_ID:
|
||||
cnss_pools = cnss_pools_adrastea;
|
||||
cnss_prealloc_pool_size = ARRAY_SIZE(cnss_pools_adrastea);
|
||||
break;
|
||||
case WCN6750_DEVICE_ID:
|
||||
case WCN6450_DEVICE_ID:
|
||||
case QCA6390_DEVICE_ID:
|
||||
case QCA6490_DEVICE_ID:
|
||||
case MANGO_DEVICE_ID:
|
||||
case PEACH_DEVICE_ID:
|
||||
case KIWI_DEVICE_ID:
|
||||
default:
|
||||
cnss_pools = cnss_pools_default;
|
||||
cnss_prealloc_pool_size = ARRAY_SIZE(cnss_pools_default);
|
||||
}
|
||||
}
|
||||
|
||||
void cnss_initialize_prealloc_pool(unsigned long device_id)
|
||||
{
|
||||
cnss_assign_prealloc_pool(device_id);
|
||||
cnss_pool_init();
|
||||
}
|
||||
EXPORT_SYMBOL(cnss_initialize_prealloc_pool);
|
||||
|
||||
void cnss_deinitialize_prealloc_pool(void)
|
||||
{
|
||||
cnss_pool_deinit();
|
||||
}
|
||||
EXPORT_SYMBOL(cnss_deinitialize_prealloc_pool);
|
||||
|
||||
/**
|
||||
* cnss_pool_get_index() - Get the index of memory pool
|
||||
* @mem: Allocated memory
|
||||
@@ -186,7 +233,7 @@ static int cnss_pool_get_index(void *mem)
|
||||
return -ENOENT;
|
||||
|
||||
/* Check if memory belongs to a pool */
|
||||
for (i = 0; i < ARRAY_SIZE(cnss_pools); i++) {
|
||||
for (i = 0; i < cnss_prealloc_pool_size; i++) {
|
||||
if (cnss_pools[i].cache == cache)
|
||||
return i;
|
||||
}
|
||||
@@ -213,7 +260,7 @@ static int cnss_pool_get_index(void *mem)
|
||||
return -ENOENT;
|
||||
|
||||
/* Check if memory belongs to a pool */
|
||||
for (i = 0; i < ARRAY_SIZE(cnss_pools); i++) {
|
||||
for (i = 0; i < cnss_prealloc_pool_size; i++) {
|
||||
if (cnss_pools[i].cache == cache)
|
||||
return i;
|
||||
}
|
||||
@@ -245,7 +292,7 @@ void *wcnss_prealloc_get(size_t size)
|
||||
|
||||
if (size >= cnss_pool_alloc_threshold()) {
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cnss_pools); i++) {
|
||||
for (i = 0; i < cnss_prealloc_pool_size; i++) {
|
||||
if (cnss_pools[i].size >= size && cnss_pools[i].mp) {
|
||||
mem = mempool_alloc(cnss_pools[i].mp, gfp_mask);
|
||||
if (mem)
|
||||
@@ -281,7 +328,7 @@ int wcnss_prealloc_put(void *mem)
|
||||
return 0;
|
||||
|
||||
i = cnss_pool_get_index(mem);
|
||||
if (i >= 0 && i < ARRAY_SIZE(cnss_pools) && cnss_pools[i].mp) {
|
||||
if (i >= 0 && i < cnss_prealloc_pool_size && cnss_pools[i].mp) {
|
||||
mempool_free(mem, cnss_pools[i].mp);
|
||||
return 1;
|
||||
}
|
||||
@@ -327,12 +374,12 @@ static int __init cnss_prealloc_init(void)
|
||||
if (!cnss_prealloc_is_valid_dt_node_found())
|
||||
return -ENODEV;
|
||||
|
||||
return cnss_pool_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit cnss_prealloc_exit(void)
|
||||
{
|
||||
cnss_pool_deinit();
|
||||
return;
|
||||
}
|
||||
|
||||
module_init(cnss_prealloc_init);
|
||||
|
25
cnss_utils/cnss_common.h
Normal file
25
cnss_utils/cnss_common.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved
|
||||
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#define QCA6174_VENDOR_ID 0x168C
|
||||
#define QCA6174_DEVICE_ID 0x003E
|
||||
#define QCA6290_VENDOR_ID 0x17CB
|
||||
#define QCA6290_DEVICE_ID 0x1100
|
||||
#define QCA6390_VENDOR_ID 0x17CB
|
||||
#define QCA6390_DEVICE_ID 0x1101
|
||||
#define QCA6490_VENDOR_ID 0x17CB
|
||||
#define QCA6490_DEVICE_ID 0x1103
|
||||
#define QCN7605_VENDOR_ID 0x17CB
|
||||
#define QCN7605_DEVICE_ID 0x1102
|
||||
#define KIWI_VENDOR_ID 0x17CB
|
||||
#define KIWI_DEVICE_ID 0x1107
|
||||
#define MANGO_VENDOR_ID 0x17CB
|
||||
#define MANGO_DEVICE_ID 0x110A
|
||||
#define PEACH_VENDOR_ID 0x17CB
|
||||
#define PEACH_DEVICE_ID 0x110E
|
||||
#define WCN6750_DEVICE_ID 0x6750
|
||||
#define WCN6450_DEVICE_ID 0x6450
|
||||
#define ADRASTEA_DEVICE_ID 0xabcd
|
@@ -4541,6 +4541,8 @@ static int icnss_probe(struct platform_device *pdev)
|
||||
INIT_LIST_HEAD(&priv->clk_list);
|
||||
icnss_allow_recursive_recovery(dev);
|
||||
|
||||
cnss_initialize_prealloc_pool(priv->device_id);
|
||||
|
||||
icnss_init_control_params(priv);
|
||||
|
||||
icnss_read_device_configs(priv);
|
||||
@@ -4656,6 +4658,7 @@ smmu_cleanup:
|
||||
out_free_resources:
|
||||
icnss_put_resources(priv);
|
||||
out_reset_drvdata:
|
||||
cnss_deinitialize_prealloc_pool();
|
||||
dev_set_drvdata(dev, NULL);
|
||||
return ret;
|
||||
}
|
||||
@@ -4750,6 +4753,8 @@ static int icnss_remove(struct platform_device *pdev)
|
||||
|
||||
icnss_put_resources(priv);
|
||||
|
||||
cnss_deinitialize_prealloc_pool();
|
||||
|
||||
dev_set_drvdata(&pdev->dev, NULL);
|
||||
|
||||
return 0;
|
||||
|
@@ -18,12 +18,11 @@
|
||||
#include <soc/qcom/icnss2.h>
|
||||
#endif
|
||||
#include "wlan_firmware_service_v01.h"
|
||||
#include "cnss_prealloc.h"
|
||||
#include "cnss_common.h"
|
||||
#include <linux/mailbox_client.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
#define WCN6750_DEVICE_ID 0x6750
|
||||
#define WCN6450_DEVICE_ID 0x6450
|
||||
#define ADRASTEA_DEVICE_ID 0xabcd
|
||||
#define THERMAL_NAME_LENGTH 20
|
||||
#define ICNSS_SMEM_VALUE_MASK 0xFFFFFFFF
|
||||
#define ICNSS_SMEM_SEQ_NO_POS 16
|
||||
|
@@ -15,5 +15,7 @@ extern void *wcnss_prealloc_get(size_t size);
|
||||
extern int wcnss_prealloc_put(void *ptr);
|
||||
extern int wcnss_pre_alloc_reset(void);
|
||||
void wcnss_prealloc_check_memory_leak(void);
|
||||
extern void cnss_initialize_prealloc_pool(unsigned long device_id);
|
||||
extern void cnss_deinitialize_prealloc_pool(void);
|
||||
|
||||
#endif /* _NET_CNSS__PREALLOC_H_ */
|
||||
|
Reference in New Issue
Block a user