Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6492bd8d authored by Ravi Aravamudhan's avatar Ravi Aravamudhan Committed by Gerrit - the friendly Code Review server
Browse files

diag: Streamline diag memory pool



The current design of Diag memory pools makes it difficult to scale.
Diag HSIC structures maintain their own memory pools. Make changes
to bring all memory pools together.

Change-Id: I08acbd2ea35438637f875fdc5c2ab896d9db3dd9
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent 220f08c3
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1290,8 +1290,8 @@ unsigned char *dci_get_buffer_from_bridge(int index)
	unsigned char *buf = NULL;

	do {
		buf = diagmem_alloc(driver, WRITE_HSIC_BUF_SIZE_DCI,
			POOL_TYPE_HSIC_DCI_WRITE + index);
		buf = diagmem_alloc(driver, DIAG_MDM_DCI_BUF_SIZE,
				    POOL_TYPE_MDM_DCI_WRITE + index);
		if (!buf) {
			usleep_range(5000, 5100);
			retries++;
@@ -1376,7 +1376,7 @@ static int diag_send_dci_pkt_remote(unsigned char *data, int len, int tag,
	if (ret != write_len) {
		pr_err("diag: In %s, unable to write to DCI HSIC channel, err: %d\n",
			__func__, ret);
		diagmem_free(driver, buf, POOL_TYPE_HSIC_DCI_WRITE + b_index);
		diagmem_free(driver, buf, POOL_TYPE_MDM_DCI_WRITE + b_index);
	} else {
		ret = DIAG_DCI_NO_ERROR;
	}
@@ -2004,7 +2004,7 @@ int diag_send_dci_event_mask_remote(int token)
	err = diag_dci_write_bridge(b_index, buf, write_len);
	if (err != write_len) {
		pr_err("diag: error writing to hsic channel, err: %d\n", err);
		diagmem_free(driver, buf, POOL_TYPE_HSIC_DCI_WRITE + b_index);
		diagmem_free(driver, buf, POOL_TYPE_MDM_DCI_WRITE + b_index);
		ret = err;
	} else {
		ret = DIAG_DCI_NO_ERROR;
@@ -2182,7 +2182,7 @@ int diag_send_dci_log_mask_remote(int token)
			pr_err("diag: error writing log mask to MDM hsic channel, equip_id: %d, err: %d\n",
									i, err);
			diagmem_free(driver, buf,
				     POOL_TYPE_HSIC_DCI_WRITE + b_index);
				     POOL_TYPE_MDM_DCI_WRITE + b_index);
			updated = 0;
		}
		if (updated)
+46 −102
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#define DEBUG_BUF_SIZE	4096
static struct dentry *diag_dbgfs_dent;
static int diag_dbgfs_table_index;
static int diag_dbgfs_mempool_index;
static int diag_dbgfs_finished;
static int diag_dbgfs_dci_data_index;
static int diag_dbgfs_dci_finished;
@@ -476,76 +477,23 @@ static ssize_t diag_dbgfs_read_table(struct file *file, char __user *ubuf,
	return ret;
}

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf,
						size_t count, loff_t *ppos)
{
	char *buf = NULL;
	int ret = 0, i = 0;
	int ret = 0;
	int i = 0;
	unsigned int buf_size;
	buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL);
	if (ZERO_OR_NULL_PTR(buf)) {
		pr_err("diag: %s, Error allocating memory\n", __func__);
		return -ENOMEM;
	}
	buf_size = ksize(buf);

	ret = scnprintf(buf, buf_size,
		"POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_WRITE_STRUCT: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_DCI: [0x%p : 0x%p] count = %d\n",
		driver->diagpool,
		diag_pools_array[POOL_COPY_IDX],
		driver->count,
		driver->diag_hdlc_pool,
		diag_pools_array[POOL_HDLC_IDX],
		driver->count_hdlc_pool,
		driver->diag_user_pool,
		diag_pools_array[POOL_USER_IDX],
		driver->count_user_pool,
		driver->diag_write_struct_pool,
		diag_pools_array[POOL_WRITE_STRUCT_IDX],
		driver->count_write_struct_pool,
		driver->diag_dci_pool,
		diag_pools_array[POOL_DCI_IDX],
		driver->count_dci_pool);

	for (i = 0; i < MAX_HSIC_DATA_CH; i++) {
		if (!diag_hsic[i].hsic_inited)
			continue;
		ret += scnprintf(buf+ret, buf_size-ret,
				"POOL_TYPE_HSIC_%d: [0x%p : 0x%p] count = %d\n",
				i+1,
				diag_hsic[i].diag_hsic_pool,
				diag_pools_array[POOL_HSIC_IDX + i],
				diag_hsic[i].count_hsic_pool);
	}

	for (i = 0; i < MAX_HSIC_DATA_CH; i++) {
		if (!diag_hsic[i].hsic_inited)
			continue;
		ret += scnprintf(buf+ret, buf_size-ret,
				"POOL_TYPE_HSIC_%d_WRITE: [0x%p : 0x%p] count = %d\n",
				i+1,
				diag_hsic[i].diag_hsic_write_pool,
				diag_pools_array[POOL_HSIC_WRITE_IDX + i],
				diag_hsic[i].count_hsic_write_pool);
	}

	ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret);
	unsigned int bytes_remaining = 0;
	unsigned int bytes_written = 0;
	unsigned int bytes_in_buffer = 0;
	struct diag_mempool_t *mempool = NULL;

	kfree(buf);
	return ret;
	if (diag_dbgfs_mempool_index >= NUM_MEMORY_POOLS) {
		/* Done. Reset to prepare for future requests */
		diag_dbgfs_mempool_index = 0;
		return 0;
	}
#else
static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf,
						size_t count, loff_t *ppos)
{
	char *buf = NULL;
	int ret = 0;
	unsigned int buf_size;

	buf = kzalloc(sizeof(char) * DEBUG_BUF_SIZE, GFP_KERNEL);
	if (ZERO_OR_NULL_PTR(buf)) {
@@ -554,34 +502,45 @@ static ssize_t diag_dbgfs_read_mempool(struct file *file, char __user *ubuf,
	}

	buf_size = ksize(buf);
	ret = scnprintf(buf, buf_size,
		"POOL_TYPE_COPY: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_HDLC: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_USER: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_WRITE_STRUCT: [0x%p : 0x%p] count = %d\n"
		"POOL_TYPE_DCI: [0x%p : 0x%p] count = %d\n",
		driver->diagpool,
		diag_pools_array[POOL_COPY_IDX],
		driver->count,
		driver->diag_hdlc_pool,
		diag_pools_array[POOL_HDLC_IDX],
		driver->count_hdlc_pool,
		driver->diag_user_pool,
		diag_pools_array[POOL_USER_IDX],
		driver->count_user_pool,
		driver->diag_write_struct_pool,
		diag_pools_array[POOL_WRITE_STRUCT_IDX],
		driver->count_write_struct_pool,
		driver->diag_dci_pool,
		diag_pools_array[POOL_DCI_IDX],
		driver->count_dci_pool);
	bytes_remaining = buf_size;
	bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining,
			"%-24s\t"
			"%-10s\t"
			"%-5s\t"
			"%-5s\t"
			"%-5s\n",
			"POOL", "HANDLE", "COUNT", "SIZE", "ITEMSIZE");
	bytes_in_buffer += bytes_written;
	bytes_remaining = buf_size - bytes_in_buffer;

	ret = simple_read_from_buffer(ubuf, count, ppos, buf, ret);
	for (i = diag_dbgfs_mempool_index; i < NUM_MEMORY_POOLS; i++) {
		mempool = &diag_mempools[i];
		bytes_written = scnprintf(buf+bytes_in_buffer, bytes_remaining,
			"%-24s\t"
			"%-10p\t"
			"%-5d\t"
			"%-5d\t"
			"%-5d\n",
			mempool->name,
			mempool->pool,
			mempool->count,
			mempool->poolsize,
			mempool->itemsize);
		bytes_in_buffer += bytes_written;

		/* Check if there is room to add another table entry */
		bytes_remaining = buf_size - bytes_in_buffer;

		if (bytes_remaining < bytes_written)
			break;
	}
	diag_dbgfs_mempool_index = i+1;
	*ppos = 0;
	ret = simple_read_from_buffer(ubuf, count, ppos, buf, bytes_in_buffer);

	kfree(buf);
	return ret;
}
#endif

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf,
@@ -650,10 +609,6 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf,
			"hsic_suspend: %d\n"
			"in_busy_hsic_read_on_device: %d\n"
			"in_busy_hsic_write: %d\n"
			"count_hsic_pool: %d\n"
			"count_hsic_write_pool: %d\n"
			"diag_hsic_pool: %p\n"
			"diag_hsic_write_pool: %p\n"
			"HSIC write_len: %d\n"
			"num_hsic_buf_tbl_entries: %d\n"
			"HSIC usb_connected: %d\n"
@@ -668,10 +623,6 @@ static ssize_t diag_dbgfs_read_bridge(struct file *file, char __user *ubuf,
			diag_hsic[i].hsic_suspend,
			diag_hsic[i].in_busy_hsic_read_on_device,
			diag_hsic[i].in_busy_hsic_write,
			diag_hsic[i].count_hsic_pool,
			diag_hsic[i].count_hsic_write_pool,
			diag_hsic[i].diag_hsic_pool,
			diag_hsic[i].diag_hsic_write_pool,
			diag_bridge[i].write_len,
			diag_hsic[i].num_hsic_buf_tbl_entries,
			diag_bridge[i].usb_connected,
@@ -748,10 +699,6 @@ static ssize_t diag_dbgfs_read_bridge_dci(struct file *file, char __user *ubuf,
			"hsic_opened: %d\n"
			"hsic_suspend: %d\n"
			"in_busy_hsic_write: %d\n"
			"count_hsic_pool: %d\n"
			"count_hsic_write_pool: %d\n"
			"diag_hsic_pool: %p\n"
			"diag_hsic_write_pool: %p\n"
			"data: %p\n"
			"data_buf: %p\n"
			"data_len: %d\n"
@@ -764,10 +711,6 @@ static ssize_t diag_dbgfs_read_bridge_dci(struct file *file, char __user *ubuf,
			diag_hsic_dci[i].hsic_device_opened,
			diag_hsic_dci[i].hsic_suspend,
			diag_hsic_dci[i].in_busy_hsic_write,
			diag_hsic_dci[i].count_hsic_pool,
			diag_hsic_dci[i].count_hsic_write_pool,
			diag_hsic_dci[i].diag_hsic_pool,
			diag_hsic_dci[i].diag_hsic_write_pool,
			diag_hsic_dci[i].data,
			diag_hsic_dci[i].data_buf,
			diag_hsic_dci[i].data_len,
@@ -885,6 +828,7 @@ int diag_debugfs_init(void)
#endif

	diag_dbgfs_table_index = 0;
	diag_dbgfs_mempool_index = 0;
	diag_dbgfs_finished = 0;
	diag_dbgfs_dci_data_index = 0;
	diag_dbgfs_dci_finished = 0;
+7 −53
Original line number Diff line number Diff line
@@ -34,42 +34,8 @@
/* Size of the buffer used for deframing a packet
  reveived from the PC tool*/
#define HDLC_MAX 4096
#define HDLC_OUT_BUF_SIZE	8192
#define POOL_TYPE_COPY		1
#define POOL_TYPE_HDLC		2
#define POOL_TYPE_USER		3
#define POOL_TYPE_WRITE_STRUCT	4
#define POOL_TYPE_HSIC		5
#define POOL_TYPE_HSIC_2	6
#define POOL_TYPE_HSIC_DCI	7
#define POOL_TYPE_HSIC_DCI_2	8
#define POOL_TYPE_HSIC_WRITE	11
#define POOL_TYPE_HSIC_2_WRITE	12
#define POOL_TYPE_HSIC_DCI_WRITE	13
#define POOL_TYPE_HSIC_DCI_2_WRITE	14
#define POOL_TYPE_ALL		10
#define POOL_TYPE_DCI		20

#define POOL_COPY_IDX		0
#define POOL_HDLC_IDX		1
#define POOL_USER_IDX		2
#define POOL_WRITE_STRUCT_IDX	3
#define POOL_DCI_IDX		4
#define POOL_BRIDGE_BASE	POOL_DCI_IDX
#define POOL_HSIC_IDX		(POOL_BRIDGE_BASE + 1)
#define POOL_HSIC_DCI_IDX	(POOL_BRIDGE_BASE + 2)
#define POOL_HSIC_3_IDX		(POOL_BRIDGE_BASE + 3)
#define POOL_HSIC_4_IDX		(POOL_BRIDGE_BASE + 4)
#define POOL_HSIC_WRITE_IDX	(POOL_BRIDGE_BASE + 5)
#define POOL_HSIC_DCI_WRITE_IDX	(POOL_BRIDGE_BASE + 6)
#define POOL_HSIC_3_WRITE_IDX	(POOL_BRIDGE_BASE + 7)
#define POOL_HSIC_4_WRITE_IDX	(POOL_BRIDGE_BASE + 8)

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
#define NUM_MEMORY_POOLS	13
#else
#define NUM_MEMORY_POOLS	5
#endif
#define HDLC_OUT_BUF_SIZE	(driver->itemsize_hdlc)
#define DIAG_HDLC_BUF_SIZE	8195

#define MAX_SSID_PER_RANGE	200

@@ -185,6 +151,10 @@

#define DIAG_TS_SIZE	50

#define DIAG_MDM_BUF_SIZE	2048
/* The Maximum request size is 2k + DCI header + footer (6 bytes) */
#define DIAG_MDM_DCI_BUF_SIZE	(2048 + 6)

#define MAX_HSIC_DATA_CH	2
#define MAX_HSIC_DCI_CH		2
#define MAX_HSIC_CH		(MAX_HSIC_DATA_CH + MAX_HSIC_DCI_CH)
@@ -401,30 +371,14 @@ struct diagchar_dev {
	unsigned char *apps_dci_buf;
	int dci_state;
	struct workqueue_struct *diag_dci_wq;
	/* Memory pool parameters */
	/* Sizes that reflect memory pool sizes */
	unsigned int itemsize;
	unsigned int poolsize;
	unsigned int itemsize_hdlc;
	unsigned int poolsize_hdlc;
	unsigned int itemsize_user;
	unsigned int poolsize_user;
	unsigned int itemsize_write_struct;
	unsigned int poolsize_write_struct;
	unsigned int itemsize_dci;
	unsigned int poolsize_dci;
	unsigned int debug_flag;
	/* State for the mempool for the char driver */
	mempool_t *diagpool;
	mempool_t *diag_hdlc_pool;
	mempool_t *diag_user_pool;
	mempool_t *diag_write_struct_pool;
	mempool_t *diag_dci_pool;
	spinlock_t diag_mem_lock;
	int count;
	int count_hdlc_pool;
	int count_user_pool;
	int count_write_struct_pool;
	int count_dci_pool;
	int used;
	/* Buffers for masks */
	struct mutex diag_cntl_mutex;
+121 −36
Original line number Diff line number Diff line
@@ -58,26 +58,86 @@ struct diagchar_dev *driver;
struct diagchar_priv {
	int pid;
};
/* The following variables can be specified by module options */
 /* for copy buffer */
static unsigned int itemsize = 4096; /*Size of item in the mempool */
static unsigned int poolsize = 12; /*Number of items in the mempool */
/* for hdlc buffer */
static unsigned int itemsize_hdlc = 8192; /*Size of item in the mempool */
static unsigned int poolsize_hdlc = 10;  /*Number of items in the mempool */
/* for user buffer */
static unsigned int itemsize_user = 8192; /*Size of item in the mempool */
static unsigned int poolsize_user = 8;  /*Number of items in the mempool */
/* for write structure buffer */
/*Size of item in the mempool */
static unsigned int itemsize_write_struct = sizeof(struct diag_request);
static unsigned int poolsize_write_struct = 10;/* Num of items in the mempool */
/* For the dci memory pool */
static unsigned int itemsize_dci = IN_BUF_SIZE; /*Size of item in the mempool */
static unsigned int poolsize_dci = 10;  /*Number of items in the mempool */

/* Memory pool variables */
/* Used for copying any incoming packet from user space clients. */
static unsigned int itemsize = 4096;
static unsigned int poolsize = 12;
module_param(itemsize, uint, 0);
module_param(poolsize, uint, 0);

/*
 * Used for HDLC encoding packets coming from the user
 * space. Itemsize is defined in diagchar_init. HDLC
 * Buffer can be at most twice as long as the itemsize.
 * Add 3 bytes for CRC bytes and delimiter. Don't expose
 * itemsize_hdlc as it is dependent on itemsize.By
 * default it is set to DIAG_HDLC_BUF_SIZE (8K)
 */
static unsigned int itemsize_hdlc = DIAG_HDLC_BUF_SIZE;
static unsigned int poolsize_hdlc = 10;
module_param(poolsize_hdlc, uint, 0);

/*
 * This is used for incoming DCI requests from the user space clients.
 * Don't expose itemsize as it is internal.
 */
static unsigned int itemsize_user = 8192;
static unsigned int poolsize_user = 8;
module_param(poolsize_user, uint, 0);

/*
 * USB structures allocated for writing Diag data generated on the Apps to USB.
 * Don't expose itemsize as it is constant.
 */
static unsigned int itemsize_usb_apps = sizeof(struct diag_request);
static unsigned int poolsize_usb_apps = 10;
module_param(poolsize_usb_apps, uint, 0);

/* Used for DCI client buffers. Don't expose itemsize as it is constant. */
static unsigned int itemsize_dci = IN_BUF_SIZE;
static unsigned int poolsize_dci = 10;
module_param(poolsize_dci, uint, 0);

#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
/* Used for reading data from the remote device. */
static unsigned int itemsize_mdm = DIAG_MDM_BUF_SIZE;
static unsigned int poolsize_mdm = 8;
module_param(itemsize_mdm, uint, 0);
module_param(poolsize_mdm, uint, 0);

/*
 * Used for reading DCI data from the remote device.
 * Don't expose poolsize for DCI data. There is only one read buffer
 */
static unsigned int itemsize_mdm_dci = DIAG_MDM_BUF_SIZE;
static unsigned int poolsize_mdm_dci = 1;
module_param(itemsize_mdm_dci, uint, 0);

/*
 * Used for USB structues associated with a remote device.
 * Don't expose the itemsize since it is constant.
 */
static unsigned int itemsize_mdm_usb = sizeof(struct diag_request);
static unsigned int poolsize_mdm_usb = 8;
module_param(poolsize_mdm_usb, uint, 0);

/*
 * Used for writing read DCI data to remote peripherals. Don't
 * expose poolsize for DCI data. There is only one read
 * buffer. Add 6 bytes for DCI header information: Start (1),
 * Version (1), Length (2), Tag (2)
 */
static unsigned int itemsize_mdm_dci_write = DIAG_MDM_DCI_BUF_SIZE;
static unsigned int poolsize_mdm_dci_write = 1;
module_param(itemsize_mdm_dci_write, uint, 0);
#endif

/* This is the max number of user-space clients supported at initialization*/
static unsigned int max_clients = 15;
static unsigned int threshold_client_limit = 30;
module_param(max_clients, uint, 0);

/* This is the maximum number of pkt registrations supported at initialization*/
int diag_max_reg = 600;
int diag_threshold_reg = 750;
@@ -86,9 +146,6 @@ int diag_threshold_reg = 750;
static struct timer_list drain_timer;
static int timer_in_progress;
void *buf_hdlc;
module_param(itemsize, uint, 0);
module_param(poolsize, uint, 0);
module_param(max_clients, uint, 0);

#define DIAGPKT_MAX_DELAYED_RSP 0xFFFF

@@ -194,7 +251,7 @@ void diag_clear_hsic_tbl(void)
					/* Return the buffer to the pool */
					diagmem_free(driver, (unsigned char *)
						(diag_hsic[j].hsic_buf_tbl[i].
						 buf), j+POOL_TYPE_HSIC);
						 buf), j+POOL_TYPE_MDM);
					diag_hsic[j].hsic_buf_tbl[i].buf = 0;
				}
				diag_hsic[j].hsic_buf_tbl[i].length = 0;
@@ -220,6 +277,20 @@ void diag_add_client(int i, struct file *file)
	driver->client_map[i].name[19] = '\0';
}

static void diag_mempool_init(void)
{
	int i = 0;
	for (i = 0; i < POOL_TYPE_LOCAL_LAST; i++)
		diagmem_init(driver, i);
}

static void diag_mempool_exit(void)
{
	int i = 0;
	for (i = 0; i < POOL_TYPE_LOCAL_LAST; i++)
		diagmem_exit(driver, i);
}

static int diagchar_open(struct inode *inode, struct file *file)
{
	int i = 0;
@@ -272,7 +343,7 @@ static int diagchar_open(struct inode *inode, struct file *file)
		driver->data_ready[i] |= DCI_EVENT_MASKS_TYPE;

		if (driver->ref_count == 0)
			diagmem_init(driver);
			diag_mempool_init();
		driver->ref_count++;
		mutex_unlock(&driver->diagchar_mutex);
		return 0;
@@ -354,12 +425,9 @@ static int diagchar_close(struct inode *inode, struct file *file)

	mutex_lock(&driver->diagchar_mutex);
	driver->ref_count--;
	/* On Client exit, try to destroy all 5 pools */
	diagmem_exit(driver, POOL_TYPE_COPY);
	diagmem_exit(driver, POOL_TYPE_HDLC);
	diagmem_exit(driver, POOL_TYPE_USER);
	diagmem_exit(driver, POOL_TYPE_WRITE_STRUCT);
	diagmem_exit(driver, POOL_TYPE_DCI);
	if (driver->ref_count == 0)
		diag_mempool_exit();

	for (i = 0; i < driver->num_clients; i++) {
		if (NULL != diagpriv_data && diagpriv_data->pid ==
						driver->client_map[i].pid) {
@@ -572,7 +640,7 @@ drop_hsic:
				/* Return the buffer to the pool */
				diagmem_free(driver,
					(unsigned char *)(hsic_buf_tbl[i].buf),
					index+POOL_TYPE_HSIC);
					index+POOL_TYPE_MDM);

				/* Call the write complete function */
				diagfwd_write_complete_hsic(NULL, index);
@@ -2533,14 +2601,21 @@ static int __init diagchar_init(void)
	setup_timer(&drain_timer, drain_timer_func, 1234);
	driver->itemsize = itemsize;
	driver->poolsize = poolsize;
	/*
	 * HDLC buffer can be at most twice as much as itemsize. Add 3 for
	 * 16-bit CRC and delimiter.
	 */
	itemsize_hdlc = (itemsize * 2) + 3;
	driver->itemsize_hdlc = itemsize_hdlc;
	driver->poolsize_hdlc = poolsize_hdlc;
	driver->itemsize_user = itemsize_user;
	driver->poolsize_user = poolsize_user;
	driver->itemsize_write_struct = itemsize_write_struct;
	driver->poolsize_write_struct = poolsize_write_struct;
	driver->itemsize_dci = itemsize_dci;
	driver->poolsize_dci = poolsize_dci;
	diagmem_setsize(POOL_TYPE_COPY, itemsize, poolsize);
	diagmem_setsize(POOL_TYPE_HDLC, itemsize_hdlc, poolsize_hdlc);
	diagmem_setsize(POOL_TYPE_USER, itemsize_user, poolsize_user);
	diagmem_setsize(POOL_TYPE_USB_APPS, itemsize_usb_apps,
			poolsize_usb_apps);
	diagmem_setsize(POOL_TYPE_DCI, itemsize_dci, poolsize_dci);
	driver->num_clients = max_clients;
	driver->logging_mode = USB_MODE;
	driver->socket_process = NULL;
@@ -2567,6 +2642,18 @@ static int __init diagchar_init(void)
	if (ret)
		goto fail;
#ifdef CONFIG_DIAGFWD_BRIDGE_CODE
	diagmem_setsize(POOL_TYPE_MDM, itemsize_mdm, poolsize_mdm);
	diagmem_setsize(POOL_TYPE_MDM2, itemsize_mdm, poolsize_mdm);
	diagmem_setsize(POOL_TYPE_MDM_DCI, itemsize_mdm_dci, poolsize_mdm_dci);
	diagmem_setsize(POOL_TYPE_MDM2_DCI, itemsize_mdm_dci,
			poolsize_mdm_dci);
	diagmem_setsize(POOL_TYPE_MDM_USB, itemsize_mdm_usb, poolsize_mdm_usb);
	diagmem_setsize(POOL_TYPE_MDM2_USB, itemsize_mdm_usb, poolsize_mdm_usb);
	diagmem_setsize(POOL_TYPE_MDM_DCI_WRITE, itemsize_mdm_dci_write,
			poolsize_mdm_dci_write);
	diagmem_setsize(POOL_TYPE_MDM2_DCI_WRITE, itemsize_mdm_dci_write,
			poolsize_mdm_dci_write);

	ret = diagfwd_bridge_init(HSIC_DATA_CH);
	if (ret)
		goto fail;
@@ -2633,9 +2720,7 @@ fail:
static void diagchar_exit(void)
{
	printk(KERN_INFO "diagchar exiting ..\n");
	/* On Driver exit, send special pool type to
	 ensure no memory leaks */
	diagmem_exit(driver, POOL_TYPE_ALL);
	diag_mempool_exit();
	diagfwd_exit();
	diagfwd_cntl_exit();
	diag_dci_exit();
+5 −5
Original line number Diff line number Diff line
@@ -919,7 +919,7 @@ int diag_device_write(void *buf, int data_type, struct diag_request *write_ptr)
		if (data_type == APPS_DATA) {
			driver->write_ptr_svc = (struct diag_request *)
			(diagmem_alloc(driver, sizeof(struct diag_request),
				 POOL_TYPE_WRITE_STRUCT));
				 POOL_TYPE_USB_APPS));
			if (driver->write_ptr_svc) {
				driver->write_ptr_svc->length = driver->used;
				driver->write_ptr_svc->buf = buf;
@@ -930,7 +930,7 @@ int diag_device_write(void *buf, int data_type, struct diag_request *write_ptr)
					diagmem_free(driver,
						     (unsigned char *)driver->
						     write_ptr_svc,
						     POOL_TYPE_WRITE_STRUCT);
						     POOL_TYPE_USB_APPS);
				}
			} else {
				err = -ENOMEM;
@@ -957,7 +957,7 @@ int diag_device_write(void *buf, int data_type, struct diag_request *write_ptr)
						diagmem_alloc(driver,
						sizeof(struct diag_request),
							index +
							POOL_TYPE_HSIC_WRITE);
							POOL_TYPE_MDM_USB);
				if (write_ptr_mdm) {
					write_ptr_mdm->buf = buf;
					write_ptr_mdm->length =
@@ -970,7 +970,7 @@ int diag_device_write(void *buf, int data_type, struct diag_request *write_ptr)
						diagmem_free(driver,
							write_ptr_mdm,
							index +
							POOL_TYPE_HSIC_WRITE);
							POOL_TYPE_MDM_USB);
						pr_err_ratelimited("diag: HSIC write failure, err: %d, ch %d\n",
							err, index);
					}
@@ -1684,7 +1684,7 @@ int diagfwd_write_complete(struct diag_request *diag_write_ptr)
		diagmem_free(driver, (unsigned char *)buf,
						POOL_TYPE_HDLC);
		diagmem_free(driver, (unsigned char *)diag_write_ptr,
						POOL_TYPE_WRITE_STRUCT);
						POOL_TYPE_USB_APPS);
	}
	return 0;
}
Loading