USB: f_mtp: Remove existing duplicate code

autoconfig of out endpoint is being done twice for mtp driver.
Hence, removing the duplicate code of autoconfig of out endpoint.

CRs-Fixed: 339985
Change-Id: I677462999d0bcc1387aafe4c068e09fda5df15f6
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
(cherry picked from commit 5e27b7675695c82b8fd61565950863567e5c0628)
USB: gadget: u_ether: Fix data stall issue in RNDIS tethering mode

For dual speed gadget, with current no. of request(10), there is
possibility of corner case occurence where all 10 reuqests are queued
to HW without setting IOC bit, which could lead to data stall in
RNDIS tethering and RNDIS local networking.

With this patch, counter will be incremented before queueing request to
HW and sets IOC bit for every nth request due to which the corner case
of all requests queued to HW without IOC bit set will be avoided.

CRs-Fixed: 340995
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
(cherry picked from commit 20b627e58cfdb8172db4315ef823e0d55b45684e)

Change-Id: I7db23f190ec20aa835ab2463b99287be4428fe91
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
USB: f_mtp: Handle corner cases on reception of Cancel request from Host

If the Host sends CANCEL request when an OUT request is queued,
the mtp_driver should dequeue the request and report the userspace about
the request CANCELLATION. As the mtp_read doesn't wakeup from the thread
which is expecting for the read completion, wakeup the thread using the
state change which occurs as a part of CANCEL request.

Also, when the request is dequeued and so mtp receives read completion
status as error, it moves the state to ERROR. Due to this the application
is not reported about the request cancellation for the next IN(mtp_write)
transfer as the state is not updated from STATE_ERROR to STATE_CANCELED.
So mtp_write proceeds queueing the IN requests for the corresponding sync
which are not processed by the Host and so the transfers initiated later
are observed as error in the HOST side.

So dequeue the OUT(mtp_read) request, if the driver receives a REQ_CANCEL
prior to read completion on mtp_read & update the state to STATE_CANCELED.

CRs-Fixed: 337676
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
(cherry picked from commit 20298e0f2f791f4df619aa6c99ee575f6004de52)

Change-Id: If364d239d107b140a5773f01f6dfba13525b9b01
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
usb: gadget: Fix minor issues in usb function drivers

1. Free port if create thread fails
2. Check req->buf before accessing it
3. Change count variable type to match smd_write return type

CRs-Fixed: 342316
Change-Id: I55a268d105eb2066d67fc704d31905eaf29a26a4
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
(cherry picked from commit b015f0c6ddef20291e83f02fef83b20d7367dbe6)
USB: android: Fix missing USB DISCONNECT uevent

Some userspace modules, e.g. MTP, work correctly only if
CONFIGURED uevent is preceded by DISCONNECT uevent. Hence,
explicitly send DISCONNECT uevent if missed out due to
really quick enumeration by USB Host.
Also, wait for some time before sending out CONFIGURED uevent
to give function drivers a chance to wakeup userspace threads
and notify previous disconnect.

CRs-Fixed: 348066
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
(cherry picked from commit a2b541424e9acac42f9bd9cb9183b1f9c9ac9cbf)

Change-Id: Ib1659db3f95d015a5eaf608550b08a9c0e9d7893
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
USB: u_serial: Don't allow UDC to append and send a zero length packet

Two zero length packets are sent by the target in the current scenario:
1. From the device controller driver (as the req->zero flag is set if
   it is the last packet).
2. From the u_serial driver when the length of the packet is zero while
   checking for the next packet in the list.

Hence removing the code for the case1, as the zero length packet is
sent via u_serial function driver.

CRs-Fixed: 350179
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
(cherry picked from commit 4098529688bfd441a5047a4017c222944a83b645)

Change-Id: Ibfcd4b21bb2eb40b1d2eae483ac104127ed3d930
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
USB: Set AHB HPROT Mode to allow posted data writes

Currently writing 0x0 into AHBMODE register which means both data
transactions and QH and TD descriptors are non-posted writes to
system memory. As per HW team recommendation, should write 0x08 value
to set AHB HPROT mode into the AHBMODE register which allows posted
data writes to system memory and will improve the throughput numbers.

CRs-Fixed: 349543
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
(cherry picked from commit 5f32d7ac13879b6bbe5fe286a578e16e40838476)

Conflicts:

	drivers/usb/gadget/ci13xxx_msm_hsic.c
	drivers/usb/host/ehci-msm2.c

Change-Id: Id3953c7832f76ed30222984536367f49897b8690
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
USB: f_mtp: Fix corner cases in MTP driver while syncing

Currently if USB composition switch happens while file transfer is
happening either from/to device, ep_queue fails and sets device state
to ERROR even if device state is already set to OFFLINE in function
disable call.

As part of ioctl call, if the state is not offline, moving the device
state to READY and returning the error. Since the device state is marked
as READY, the next write call tries to queue the request to hardware and
is blocked and due to this, userspace is not calling the release function.
Hence next mtp open fails even after cable reconnection.

CRs-Fixed: 360409
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
(cherry picked from commit 0097223c586963c9904c90803eaa5ee878565fbe)

Change-Id: I9d11cfd44f98a4fcf4e95f75462904bfb2b6cb2d
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
USB: gadget: Fix crash in ci13xxx_udc.c

In isr_setup_status_phase(), driver is not checking whether
the pointer is NULL before checking udc->status. Otherwise
it leads to crash. Fix it by checking for NULL.

CRs-Fixed: 367725
Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
(cherry picked from commit 28f14eecbd924d067520943613dcd0f965e0310e)

Change-Id: I115844013d508cc48eb432317710960f47ba79ba
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
video: msm: properly ifdef out items depending on FB_MSM_HDMI_MHL
elite: disable MHL since it interferes with USB detection