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

Commit 603f3f79 authored by Edgar Flores's avatar Edgar Flores Committed by Himateja Reddy
Browse files

msm: adsprpc: store process specific info in GETINFO ioctl call



Currently, process specific info like name and PID is being stored
in the internal data structures at the time of device open. But
since the DSP HAL service will now be opening the device node on
behalf of third-party applications, store process specific info in
GETINFO ioctl call which will be the first IOCTL call directly
from the client application.

Change-Id: If05d48123e4ec52c0271a7cb7f3ca790662d9abe
Acked-by: default avatarThyagarajan Venkatanarayanan <venkatan@qti.qualcomm.com>
Signed-off-by: default avatarEdgar Flores <edgarf@codeaurora.org>
Signed-off-by: default avatarHimateja Reddy <hmreddy@codeaurora.org>
parent b459044e
Loading
Loading
Loading
Loading
+26 −18
Original line number Original line Diff line number Diff line
@@ -4214,11 +4214,8 @@ static inline void fastrpc_register_wakeup_source(struct device *dev,
static int fastrpc_device_open(struct inode *inode, struct file *filp)
static int fastrpc_device_open(struct inode *inode, struct file *filp)
{
{
	int err = 0;
	int err = 0;
	struct dentry *debugfs_file;
	struct fastrpc_file *fl = NULL;
	struct fastrpc_file *fl = NULL;
	struct fastrpc_apps *me = &gfa;
	struct fastrpc_apps *me = &gfa;
	char strpid[PID_SIZE];
	int buf_size = 0;


	/*
	/*
	 * Indicates the device node opened
	 * Indicates the device node opened
@@ -4237,18 +4234,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
	if (err)
	if (err)
		return err;
		return err;


	snprintf(strpid, PID_SIZE, "%d", current->pid);
	buf_size = strlen(current->comm) + strlen("_") + strlen(strpid) + 1;
	VERIFY(err, NULL != (fl->debug_buf = kzalloc(buf_size, GFP_KERNEL)));
	if (err) {
		kfree(fl);
		return err;
	}
	snprintf(fl->debug_buf, UL_SIZE, "%.10s%s%d",
			current->comm, "_", current->pid);
	debugfs_file = debugfs_create_file(fl->debug_buf, 0644, debugfs_root,
						fl, &debugfs_fops);

	fastrpc_register_wakeup_source(me->non_secure_dev, "adsprpc-non_secure",
	fastrpc_register_wakeup_source(me->non_secure_dev, "adsprpc-non_secure",
						&fl->wake_source);
						&fl->wake_source);
	fastrpc_register_wakeup_source(me->secure_dev, "adsprpc-secure",
	fastrpc_register_wakeup_source(me->secure_dev, "adsprpc-secure",
@@ -4263,14 +4248,11 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
	init_waitqueue_head(&fl->async_wait_queue);
	init_waitqueue_head(&fl->async_wait_queue);
	INIT_HLIST_NODE(&fl->hn);
	INIT_HLIST_NODE(&fl->hn);
	fl->sessionid = 0;
	fl->sessionid = 0;
	fl->tgid = current->tgid;
	fl->apps = me;
	fl->apps = me;
	fl->mode = FASTRPC_MODE_SERIAL;
	fl->mode = FASTRPC_MODE_SERIAL;
	fl->cid = -1;
	fl->cid = -1;
	fl->dev_minor = dev_minor;
	fl->dev_minor = dev_minor;
	fl->init_mem = NULL;
	fl->init_mem = NULL;
	if (debugfs_file != NULL)
		fl->debugfs_file = debugfs_file;
	memset(&fl->perf, 0, sizeof(fl->perf));
	memset(&fl->perf, 0, sizeof(fl->perf));
	fl->qos_request = 0;
	fl->qos_request = 0;
	fl->dsp_proc_init = 0;
	fl->dsp_proc_init = 0;
@@ -4312,6 +4294,29 @@ static int fastrpc_get_process_gids(struct gid_list *gidlist)
	return err;
	return err;
}
}


static int fastrpc_set_process_info(struct fastrpc_file *fl)
{
	int err = 0, buf_size = 0;
	char strpid[PID_SIZE];

	fl->tgid = current->tgid;
	snprintf(strpid, PID_SIZE, "%d", current->pid);
	buf_size = strlen(current->comm) + strlen("_") + strlen(strpid) + 1;
	fl->debug_buf = kzalloc(buf_size, GFP_KERNEL);
	if (!fl->debug_buf) {
		err = -ENOMEM;
		return err;
	}
	snprintf(fl->debug_buf, UL_SIZE, "%.10s%s%d",
			current->comm, "_", current->pid);
	fl->debugfs_file = debugfs_create_file(fl->debug_buf, 0644,
					debugfs_root, fl, &debugfs_fops);
	if (!fl->debugfs_file)
		pr_warn("Error: %s: %s: failed to create debugfs file %s\n",
				current->comm, __func__, fl->debug_buf);
	return err;
}

static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
{
{
	int err = 0;
	int err = 0;
@@ -4321,6 +4326,9 @@ static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
	if (err)
	if (err)
		goto bail;
		goto bail;
	fastrpc_get_process_gids(&fl->gidlist);
	fastrpc_get_process_gids(&fl->gidlist);
	err = fastrpc_set_process_info(fl);
	if (err)
		goto bail;
	if (fl->cid == -1) {
	if (fl->cid == -1) {
		cid = *info;
		cid = *info;
		VERIFY(err, cid < NUM_CHANNELS);
		VERIFY(err, cid < NUM_CHANNELS);