HSIC_HOST: Wait for BAM Pipe to be empty before suspend

HSIC_CONS release notification doesn't confirm that all IPA HSIC BAM pipes'
are empty used for HSIC host mode functionality. In some of regression
testing, it has been found that HSIC host is being suspended when there is
data pending in HSIC IPA BAM pipe which causes BAM data stall issue. Hence
this change adds required support to check all used BAM pipes' state with
HSIC Host mode before performing suspend and notifying IPA driver to switch
of IPA clocks.

This change also checks pipe state before resuming root hub in resume
sequeunce, and would crash device if there is any pending data i.e. data is
written to HSIC BAM when HSIC host was suspended.

CRs-Fixed: 711785
Change-Id: I207a99e9cec0516f41f3991d13f673b6ab371736
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Bikshapathi Kothapeta <bkotha@codeaurora.org>
USB: gadget: u_bam_data: Check USB state under spinlock

While starting/stopping endless transfers, USB may get
disconnected. This is checked using port_data just before
calling usb_ep_queue. But, this is possibility of disconnect
happening after this check resulting in NULL pointer
dereference when accessing port_usb->in/out EPs. Fix this
by checking for cable connection under spinlock and using
a copy of EP context for calling usb_ep_queue.

Change-Id: I196650223f1350a5c5cc2cd173a67dc3c64c2dc6
CRs-fixed: 756048
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Signed-off-by: Sridhar Ancha <sancha@codeaurora.org>
USB: gadget: rndis: Allow reading of 'rx_trigger' attribute value

rx_trigger attribute is used by userspace to kickstart RX
once end to end data path is setup on USB connection.
Currently this attribute is write only. Make it readable
so that userspace can read it back during fast USB connect
disconnect scenarios which results in net core missing to
send NETLINK DISCONNECT events. Userspace can read this back
on CONNECT to figure out any missed disconnect events.

Change-Id: Ief1d93b1e29103336b672cf0e8abcfe881aaa617
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Merge "USB: gadget: u_bam_data: Check USB state under spinlock" into LNX.LE.3.2.c1
usb: gadget: ci13xxx: Cancel pending suspend work before resuming h/w

Composite driver can try to disable pull-up (or disconnect) to carry
out composition switch after bus suspend. There is a possible race in
this scenario between OTG driver trying to suspend hardware and UDC
checking for this state before disabling/enabling pull-up.
Hence, flush OTG driver's suspend work before checking LPM state in UDC.

Change-Id: Id3e6dfda8a41b79678db3388d9d4685a547be9d4
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
usb: gadget: qc_ecm: Release EPs if disable happens before set_alt(1)

DATA EPs (bulk IN/OUT) are used only after set_alt(1). If disconnect
(disable) happens before this then EPs are configured again based
on the stopped. Things work fine if there is no change in speed on
next connection. Otherwise for a scenario like below device ends up
using wrong maxPacketSize with endpoint.
 -ECM gadget connects in FullSpeed
 -SET_CONFIG happens: This results in set_alt(0)
 -Disconnection and reconnect in HighSpeed
 -SET_CONFIG
 -set_alt(1) for ECM.
This results in ECM using 64bytes maxpacket size in high speed and
may result in data stall.

Fix this by explicitly clearing ep->driver_data on disconnect.

CRs-Fixed: 722950
Change-Id: Ieb6b333195387e42df35f76b40ac1e171d46b1da
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
ARM: dts: msm: Enable HSUSB BAM early and don't RESET it on connect

HSUSB BAM is not NDP BAM and it must be enabled early before
starting peripheral controller to avoid switching USB core mode
from legacy to BAM with ongoing data transfers.
Additionally resetting HSUSB BAM requires switching USB core from
BAM to legacy and back to BAM mode. As this operation is not
recommended while USB is active, don't reset BAM on every connect
and just pipe reset should be fine.

Change-Id: Ie21477b8ded402dd8fb173b7eb067072ba72aca4
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
usb_bam: Allow HSUSB BAM to be enabled on bootup itself

HSUSB BAM is not NDP BAM and it must be enabled early before
starting peripheral controller to avoid switching USB core mode
from legacy to BAM with ongoing data transfers.
Also, there could be a possibility that USB OTG driver puts USB
in LPM after its probe incase USB is not connected and before
USB BAM driver is probed. This may result in unclocked access
while enabling USB BAM. To handle this make sure that USB BAM
is probed only after USB OTG and use pm_runtime APIs before
enabling HSUSB BAM.

Change-Id: I4b0fe14d046fbaa485e832a0aed7026e340be225
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
Merge "ARM: dts: msm: Enable HSUSB BAM early and don't RESET it on connect" into LNX.LE.3.2.c1