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

Commit 94c9932e authored by Liron Daniel's avatar Liron Daniel
Browse files

soc: qcom: Replace SPCOM channel owner pid with tgid



SPU HAL server uses multiple RPC threads to handle HAL client requests.
pid is not shared between the threads which prevents releasing SPCOM
channels properly. tgid, the group ID which is shared between the
threads is used instead.

Change-Id: I7b119b386868364f3c476d1f6dfdf915aac8c306
Signed-off-by: default avatarLiron Daniel <lirond@codeaurora.org>
parent 38b1718d
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@
#define SPCOM_MAX_READ_SIZE	(PAGE_SIZE)

/* Current Process ID */
#define current_pid() ((u32)(current->pid))
#define current_pid() ((u32)(current->tgid))

/*
 * After both sides get CONNECTED,
@@ -1471,6 +1471,11 @@ static int spcom_device_open(struct inode *inode, struct file *filp)
		return 0;
	}

	if (pid == 0) {
		spcom_pr_err("unknown PID\n");
		return -EINVAL;
	}

	ch = spcom_find_channel_by_name(name);
	if (!ch) {
		spcom_pr_err("ch[%s] doesn't exist, load app first\n", name);
@@ -1556,6 +1561,7 @@ static int spcom_device_release(struct inode *inode, struct file *filp)
	const char *name = file_to_filename(filp);
	int ret = 0;
	int i = 0;
	u32 pid = current_pid();

	if (strcmp(name, "unknown") == 0) {
		spcom_pr_err("name is unknown\n");
@@ -1571,6 +1577,11 @@ static int spcom_device_release(struct inode *inode, struct file *filp)
		return 0;
	}

	if (pid == 0) {
		spcom_pr_err("unknown PID\n");
		return -EINVAL;
	}

	ch = filp->private_data;
	if (!ch) {
		spcom_pr_dbg("ch is NULL, file name %s\n",
@@ -1587,7 +1598,8 @@ static int spcom_device_release(struct inode *inode, struct file *filp)
	}

	for (i = 0; i < SPCOM_MAX_CHANNEL_CLIENTS; i++) {
		if (ch->pid[i] == current_pid()) {
		if (ch->pid[i] == pid) {
			spcom_pr_dbg("PID [%x] is releasing ch [%s]\n", current->tgid, name);
			ch->pid[i] = 0;
			break;
		}
@@ -1598,7 +1610,7 @@ static int spcom_device_release(struct inode *inode, struct file *filp)
		 * Shared client is trying to close channel,
		 * release the sync_lock if applicable
		 */
		if (ch->active_pid == current_pid()) {
		if (ch->active_pid == pid) {
			spcom_pr_dbg("active_pid [%x] is releasing ch [%s] sync lock\n",
				 ch->active_pid, name);
			/* No longer the current active user of the channel */