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

Commit cc54a032 authored by Manu Gautam's avatar Manu Gautam
Browse files

usb_bam: Fix BUG in HSIC remove making pm usage_count negative



Runtime PM usage count of HSIC device is also used by usb_bam
to allow/forbid HSIC entering LPM. HSIC is allowed to enter
LPM only when both PROD and CONS are released by usb_bam.
During initialization, usb_bam increments pm usage_count when
HSIC registers with it and vice versa it decrements the count
when HSIC is de-registered. But, if HSIC was already in LPM when
getting de-registered then usb_bam ends up making pm usage_count
-1 later on HSIC remove. Next time when HSIC is registered again
then pm usage count toggles between 0 and -1. Negative pm
usage_count results in failure to wake up HSIC using pm_runtim_get
on async_irq (remote wakeup) or any usb_bam triggers.

CRs-Fixed: 709563
Change-Id: I460e628dc704e45285e47b70dc8aaf5963555031
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent 169417fe
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -232,12 +232,14 @@ void msm_bam_set_hsic_host_dev(struct device *dev)
		pr_debug("%s: Getting hsic device %p\n", __func__, dev);
		pm_runtime_get(dev);
	} else if (host_info[HSIC_CTRL].dev) {
		pr_debug("%s: Putting hsic device %p\n", __func__,
			host_info[HSIC_CTRL].dev);
		/* Just free previous device*/
		pr_debug("%s: Try Putting hsic device %p, lpm:%d\n", __func__,
			host_info[HSIC_CTRL].dev, info[HSIC_CTRL].in_lpm);
		/* Just release previous device if not already done */
		if (!info[HSIC_CTRL].in_lpm) {
			info[HSIC_CTRL].in_lpm = true;
			pm_runtime_put(host_info[HSIC_CTRL].dev);
		}
	}

	host_info[HSIC_CTRL].dev = dev;
	host_info[HSIC_CTRL].in_lpm = false;