net: usbnet: Undo double reservation

This reserves twice if we're not in raw IP mode. Drop it.

Change-Id: I7d4ce53c938e809e4e63d08188cb2e9d03f93dfa
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Don't flush and disable all endpoints during disconnect

Flushing and disabling all endpoints during disconnect in controller
driver is simply wasteful and unnecessary.  Flushing endpoints before
notifying disconnect to composite driver will have side effects too.
The active endpoints will be disabled by function drivers when they
notified about disconnect.

The current code use 100 msec timeout for flush operation.  If controller
driver flush and disable all endpoints, the worst case timeout will be
added up to several seconds.  This is leading to watch dog timeout.

CRs-Fixed: 431623
Change-Id: If6a2e87006cda367c2eb4def616e9672e13eadf5
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Fix possible NULL pointer dereference

Don't access dev->platform_data before checking dev against NULL.

CRs-fixed: 440043
Change-Id: Ia891720b926d26a46a044e688b64ac4e3cda73e2
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Add support for larger ( > 16K) length USB requests

The maximum recommended transfer size of a device transfer descriptor(dTD)
is 16K bytes.  The current code limits the USB request length to 16K bytes.
Add support for larger length USB requests by spanning them into multiple
dTD.  Remove the special handling of zero length packet termination and use
multi dTD logic to achieve the same.

The "QUEUE" and "DEBUG" event messages are slightly modified to accommodate
request pointer, actual length and original length.  Update sysfs file
implementation to print all dTD for any given USB request.

CRs-Fixed: 429212
Change-Id: If3fbb986c84ac9d138429c624a4c73ecee943ce5
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Add module param to enable streaming mode

The streaming mode is disabled by default for ci13xxx_msm.  Add
a module param to enable streaming.  This module param overrides
flag.

This allows user space to enable streaming mode for selected USB
compositions.

CRs-Fixed: 429212
Change-Id: I9ee76841d7de9797452090e29d00d09385024ae5
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Avoid flushing endpoint twice during disable

The ep_disable() function nukes all pending requests before
disabling the endpoint in hardware.  The endpoint is flushed
during nuking.  Don't flush the endpoint again.

CRs-Fixed: 445916
Change-Id: Ib330c67b360b448ec524e6ef0e8c040f04fdf0b8
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Don't flush inactive endpoints

The endpoint must be flushed prior to retiring pending requests.
This is done during disabling an endpoint.  Don't flush an endpoint
if there are no pending requests.  According databook flushing
endpoint may take large amount of time.  This optimization will
make USB disconnect/reset processing a little bit faster.

CRs-Fixed: 445916
Change-Id: I035b624dbac4529bbe33a67f9e7e1916d4772d6f
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Skip flushing endpoints upon failure

Flushing an endpoint involve polling ENDPTFLUSH and ENDPTSTAT
registers.  The worst case timeout is 100 msec for each endpoint.
The reason for failure is unknown.  When flushing an endpoint
fails, successive flushing of remaining endpoints are also failing.
Hence skip flushing remaining endpoints.  Reset this condition
upon USB bus reset.

CRs-Fixed: 445916
Change-Id: I9feeeb434dc180f1df859275ef1364c7dd829d78
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: f_rndis: Check if cdev is NULL before accessing

RNDIS control path completion handlers are getting called after setting
cdev to NULL during disconnect as part of composition switch and this
is leading to a crash. Avoid this crash, by checking, if cdev is NULL
before accessing. Also don't queue request's to DCD, if composition switch
is in progress.

CRs-Fixed: 433534
Change-Id: Ic0790415ec3eaf866af2895370249e45adcbba5d
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Revert "USB: ci13xxx_udc: Add support for larger ( > 16K) length USB requests"

This reverts commit d2a03614a4ead5146860a550f8ee778e5297e260.

The original patch spans larger requests into multiple dTDs.  This
implementation is having problems with short packets.  When host
terminates the transfer with short packet, the controller will
advance to the next dTD of the current request. If host sends more
data, it will be received unintentionally.

CRs-Fixed: 449733
Change-Id: I06c88b93305ff2becd8096a1f6a8d82d6df7e638
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
USB: ci13xxx_udc: Add support for large requests

Spanning large request into multiple dTDs will fail with short
packets.  Instead queue one dTD at a time.  This patch has
the following limitations.

1. Large requests are supported only on Bulk OUT endpoints. This
feature is mainly required for MTP driver to achieve better write
throughputs. The VFS performs well with larger buffers.

2. To keep it simple, don't allow queuing while processing large
request. Don't allow larger request queuing while the queue is
busy.

CRs-Fixed: 449733
Change-Id: I262a62af3316d673a97f11842290609092c6e7df
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
gadget: ci13xxx_udc: Fix duplicate kmalloc and plug leak

A bad merge duplicated this kmalloc and leaks the previous
allocation. Remove the duplicate kmalloc.

Change-Id: I27dccdebaa30786cd302f58614401955bc4eba61
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>