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

Commit d41050f0 authored by Eric Holmberg's avatar Eric Holmberg
Browse files

char: msm_smd_pkt: use open timeout for opening existing channel



If an SMD channel already exists, a default timeout of 2 seconds is used
instead of the opening timeout even though some clients need the
configured timeout.

Change code to use the opening timeout for all operations leading up to
the fully-opened state for the SMD channel.

CRs-Fixed: 755650
Change-Id: Id47aa057c3204f88ba55ae98d6c9e6d89c925cce
Signed-off-by: default avatarEric Holmberg <eholmber@codeaurora.org>
parent cb0b4937
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -1035,6 +1035,8 @@ int smd_pkt_open(struct inode *inode, struct file *file)

	mutex_lock(&smd_pkt_devp->ch_lock);
	if (smd_pkt_devp->ch == 0) {
		unsigned open_wait_rem = smd_pkt_devp->open_modem_wait * 1000;

		INIT_COMPLETION(smd_pkt_devp->ch_allocated);

		r = smd_pkt_add_driver(smd_pkt_devp);
@@ -1056,7 +1058,7 @@ int smd_pkt_open(struct inode *inode, struct file *file)
				 * retry by user-space modules and to avoid
				 * possible watchdog bite.
				 */
				msleep((smd_pkt_devp->open_modem_wait * 1000));
				msleep(open_wait_rem);
				goto release_pd;
			}
		}
@@ -1077,12 +1079,12 @@ int smd_pkt_open(struct inode *inode, struct file *file)
		 * Wait for a packet channel to be allocated so we know
		 * the modem is ready enough.
		 */
		if (smd_pkt_devp->open_modem_wait) {
		if (open_wait_rem) {
			r = wait_for_completion_interruptible_timeout(
				&smd_pkt_devp->ch_allocated,
				msecs_to_jiffies(
					smd_pkt_devp->open_modem_wait
						 * 1000));
				msecs_to_jiffies(open_wait_rem));
			if (r >= 0)
				open_wait_rem = jiffies_to_msecs(r);
			if (r == 0)
				r = -ETIMEDOUT;
			if (r < 0) {
@@ -1103,9 +1105,11 @@ int smd_pkt_open(struct inode *inode, struct file *file)
			goto release_pil;
		}

		open_wait_rem = max_t(unsigned, 2000, open_wait_rem);
		r = wait_event_interruptible_timeout(
				smd_pkt_devp->ch_opened_wait_queue,
				smd_pkt_devp->is_open, (2 * HZ));
				smd_pkt_devp->is_open,
				msecs_to_jiffies(open_wait_rem));
		if (r == 0) {
			r = -ETIMEDOUT;
			/* close the ch to sync smd's state with smd_pkt */