usb_bam: Fix handling of ipa_resume during fast suspend/resume

During fast HSIC CONS release and request scenario, there is a
race condition possible - if Pipe resumed while we dropped lock
due to HSIC CONS request then ipa_resume may not have been called.
During this scenario, restore in_lpm to allow ipa_resume when HSIC
resumes next time from msm_bam_wait_for_hsic_prod_granted().

Change-Id: I48a413a553dd456eb29b4d22ab577489c656f55d
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
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.

Change-Id: I460e628dc704e45285e47b70dc8aaf5963555031
CRs-Fixed: 709563
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Merge "usb_bam: Fix BUG in HSIC remove making pm usage_count negative"
USB: gadget: u_bam: Bail out from disconnect_w if already disconnected

IPA BAM port is disconnect in suspend state as well if remote wakeup
is not enabled. If disconnect happens after suspend then driver
tries to perform BAM disconnect again which fails. It also results
in USB failing to enter LPM as usb_bam_lpm_ok then return FALSE if
usb_bam disconnect had failed with error.

CRs-fixed: 721518
Change-Id: Ib26b97c49801d4994aa4f36fa84c3a2ee9a89ce4
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Merge "usb_bam: Fix handling of ipa_resume during fast suspend/resume"
Merge "USB: gadget: u_bam: Bail out from disconnect_w if already disconnected"
USB: msm_otg: Process HOST disconnect only after system RESUME

If Host Cable (ID_GND) is disconnected in system suspend then
it results in race between device removal and device pm_resume.
PM core does't handle this correctly and sometimes frees up
parent device before children are resumed. To avoid this race
make sure that system has resumed completely before handling
ID_FLOAT (or host cable disconnect) event.

CRs-fixed: 652870, 651561
Change-Id: Id0956a9677d819d3fa3f17f54965cae38f2ee31d
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
msm: smd: flush pending work on release

If an SMD device is closed while the device is active and then
immediately re-opened, then a delayed work item may get processed while
data structures are in the process of being re-initialized.

Move initialization of data structures to device creation which happens
once during module initialization.

CRs-Fixed: 698603
Change-Id: Ida85d8452f32b62fd848c706ba046f1a9a08bc85
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
Merge "msm: smd: flush pending work on release"
Merge "USB: msm_otg: Process HOST disconnect only after system RESUME"