summaryrefslogtreecommitdiff
path: root/drivers/usb (follow)
Commit message (Collapse)AuthorAge
...
| | * | | | | | USB: option: add support for SIM7100EAndrey Skvortsov2016-03-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 3158a8d416f4e1b79dcc867d67cb50013140772c upstream. $ lsusb: Bus 001 Device 101: ID 1e0e:9001 Qualcomm / Option $ usb-devices: T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#=101 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 2 P: Vendor=1e0e ProdID=9001 Rev= 2.32 S: Manufacturer=SimTech, Incorporated S: Product=SimTech, Incorporated S: SerialNumber=0123456789ABCDEF C:* #Ifs= 7 Cfg#= 1 Atr=80 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I:* If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan I:* If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) The last interface (6) is used for Android Composite ADB interface. Serial port layout: 0: QCDM/DIAG 1: NMEA 2: AT 3: AT/PPP 4: audio Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| | * | | | | | USB: cp210x: add IDs for GE B650V3 and B850V3 boardsKen Lin2016-03-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 6627ae19385283b89356a199d7f03c75ba35fb29 upstream. Add USB ID for cp2104/5 devices on GE B650v3 and B850v3 boards. Signed-off-by: Ken Lin <ken.lin@advantech.com.tw> Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| | * | | | | | usb: dwc3: Fix assignment of EP transfer resourcesJohn Youn2016-03-03
| | | |_|_|_|/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit c450960187f45d4260db87c7dd4fc0bceb5565d8 upstream. The assignement of EP transfer resources was not handled properly in the dwc3 driver. Commit aebda6187181 ("usb: dwc3: Reset the transfer resource index on SET_INTERFACE") previously fixed one aspect of this where resources may be exhausted with multiple calls to SET_INTERFACE. However, it introduced an issue where composite devices with multiple interfaces can be assigned the same transfer resources for different endpoints. This patch solves both issues. The assignment of transfer resources cannot perfectly follow the data book due to the fact that the controller driver does not have all knowledge of the configuration in advance. It is given this information piecemeal by the composite gadget framework after every SET_CONFIGURATION and SET_INTERFACE. Trying to follow the databook programming model in this scenario can cause errors. For two reasons: 1) The databook says to do DEPSTARTCFG for every SET_CONFIGURATION and SET_INTERFACE (8.1.5). This is incorrect in the scenario of multiple interfaces. 2) The databook does not mention doing more DEPXFERCFG for new endpoint on alt setting (8.1.6). The following simplified method is used instead: All hardware endpoints can be assigned a transfer resource and this setting will stay persistent until either a core reset or hibernation. So whenever we do a DEPSTARTCFG(0) we can go ahead and do DEPXFERCFG for every hardware endpoint as well. We are guaranteed that there are as many transfer resources as endpoints. This patch triggers off of the calling dwc3_gadget_start_config() for EP0-out, which always happens first, and which should only happen in one of the above conditions. Fixes: aebda6187181 ("usb: dwc3: Reset the transfer resource index on SET_INTERFACE") Reported-by: Ravi Babu <ravibabu@ti.com> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* | | | | | | Merge "usb: dwc3: Fix bug in ep disable operation"Linux Build Service Account2016-07-15
|\ \ \ \ \ \ \ | |_|_|/ / / / |/| | | | | |
| * | | | | | usb: dwc3: Fix bug in ep disable operationHemant Kumar2016-07-13
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __dwc3_gadget_ep_disable API doing memset 0 with size set to DWC3_TRB_NUM. Number of TRBs allocated for gsi endpoints are less than DWC3_TRB_NUM. This results in to memory corruption. Fix this bug by introducing num_trbs member in dwc3_ep structure to save number of trbs allocated in a dma pool upon dma pool creation. Ep disable operation will use num_trbs of a dwc3_ep to perform memset 0. Change-Id: I94b5865ca22b4e1fde0d2cd8dcb218906327a916 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | | | Merge "usb: gadget: f_gsi: Increase USB GSI OUT TRBs from 7 to 31 for ECM"Linux Build Service Account2016-07-13
|\ \ \ \ \ \
| * | | | | | usb: gadget: f_gsi: Increase USB GSI OUT TRBs from 7 to 31 for ECMMayank Rana2016-07-12
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB bus suspend with remote wakeup allowed case: 1. SUSPEND interrupt received from controller on USB bus suspend 2. gsi_suspend() blocks ringing of doorbell by USB controller to IPA GSI and schedule usb_ipa_w work with event EVNT_SUSPEND 3. ipa_work_handler() work handler makes sure that USB GSI interface is into IDLE state and calls ipa_usb_xdci_suspend() to put IPA GSI related channel into suspend state and allow turning of IPA's clock 5. ipa_work_handler() decrements PM usage count, allow USB to go into LPM 6. USB controller driver turns off USB clocks and put into LPM USB bus resume with remote wakeup allowed case: 1. WAKEUP interrupt received from controller on USB bus resume 2. USB controller driver turns on USB clocks 3. gsi_resume() increments PM usage count and schedule usb_ipa_w work with event EVENT_RESUME 4. ipa_work_handler() work handler calls ipa_usb_xdci_resume() to resume IPA GSI related channel and turning on IPA's clock 5. ipa_work_handler() unblocks ringing of doorbell by USB controller to IPA GSI In above USB bus resume case using specific host with ECM functionality, host is able to send PING or data packets equal to prepared number of TRBs (currently 7) on USB EP OUT successfully before above resume step 5 then GSI ignores rang doorbell as WRITE pointer updating last consumed TRB is already gone through full cycle. This results into data stall. Hence to fix this issue increase number of TRBs used with USB OUT endpoint from 7 to 31 for USB ECM function with GSI accelerated path. This helps to have always pending TRBs with USB controller and ringing of doorbell is not missed by GSI once above resume step 5 is completed. Also ECM doesn't support aggregation. Hence fix out aggregation size param. CRs-Fixed: 1023149 Change-Id: Ife0f265b65fda92a99f5170154da6cb4c6b113b7 Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | | | Merge "usb: dwc3: Change dwc3 irq to oneshot threaded irq"Linux Build Service Account2016-07-13
|\ \ \ \ \ \
| * | | | | | usb: dwc3: Change dwc3 irq to oneshot threaded irqHemant Kumar2016-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a possibility of dwc3 irq being fired as soon as it gets enabled by tasklet handler. As a result dwc3 hard irq handler disables the irq and schedules tasklet. If tasklet is still running, tasklet_schedule becomes no op and dwc3 irq remains disabled permanently. Fix this issue by handling irq in threaded context with IRQF_ONESHOT flag set. Also update the shared irq flag in xhci platform driver for irq registration in HCD driver. CRs-Fixed: 1038421 Change-Id: I9291cb08c4597922131b8c2d420e834a00a72621 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | | | | Merge "usb: gadget: f_gsi: Set speed descriptor pointers to NULL after free"Linux Build Service Account2016-07-13
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | |
| * | | | | | usb: gadget: f_gsi: Set speed descriptor pointers to NULL after freeHemant Kumar2016-07-08
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After gsi_unbind() if gsi_bind() function frees speed descriptor due to an error leads to double freeing of descriptor. Fix this issue by setting descriptor pointer back to NULL after freeing the descriptor memory. CRs-Fixed: 1038866 Change-Id: Ic5ee71389b6b20c8557e0a75f9bbe5a1749cf655 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* / / / / / usb: phy: qusb-v2: Add USB QUSB PHY for newer platformMayank Rana2016-07-07
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds USB QUSB PHY v2 driver which is compatible for USB QUSB PHY having major revision as 2. Change-Id: I1751352ebbe38d4b8c7886085d15043c2e5244f5 Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | | usb: xhci: Add helper APIs to return xhci dma addressesHemant Kumar2016-07-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dma address of secondary event ring, transfer ring and device context base address are required to pass to remote entity. Remote entity uses these addresses to program xhci controller registers. Change-Id: Ie0756d646a396a11b41b93e886bca9aff636ee5d Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | | usb: xhci: Add support for secondary interruptersHemant Kumar2016-07-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement APIs to dynamically allocate and free secondary event rings based upon interrupter number. Also add exported APIs in usb core layer which allows secondary event ring management via remote processor entity. Change-Id: I5ee7d44d6cad8e35e22d3c1a027a1eec5d208585 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | | usb: gadget: f_gsi: Use 16KB buffer with each TRB for MBIM DLMayank Rana2016-07-05
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is limitation when IPA is performing de/aggregation with MBIM in scatter-gather mode. Hence instead of 2KB buffer use 16KB buffer (i.e. size of aggregated frame) with each TRB for MBIM DL case. CRs-Fixed: 1032467 Change-Id: I4f73d30711b5606c2ac88ce9d05a8483d64b665d Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | usb: gadget: mtp: Increase RX transfer length to 1MHemant Kumar2016-06-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test results indicate that larger transfers improve write speeds. The Rx request transfer length is now 16K bytes. Increase the Rx transfer length from 16K to 1MB to get good throughputs. Change-Id: I3c64e6b96d569b4dc61805a53a0835db9142d55e Signed-off-by: ChandanaKishori Chiluveru <cchilu@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: Use mult as 3 for GSI related USB IN endpoint alwaysMayank Rana2016-06-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Interfaces like MBIM or ECM is having multiple data interfaces. In this case, SET_CONFIG() happens before set_alt with data interface 1. Due to this, TXFIFO of GSI IN endpoint is not resized causing low throughput in DL direction. Fix this issue by using mult as 3 for GSI related USB IN endpoint irrespective of super-speed or high-speed mode. CRs-Fixed: 1025031 Change-Id: I10de98ae57284699af3abcd90bafac63ba03844e Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | Revert "usb: dwc3: core: only setting the dma_mask when needed"Hemant Kumar2016-06-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 19bacdc925055f020a ("usb: dwc3: core: only setting the dma_mask when needed") does not allow to modify dma mask if it is already set. Since the platform device has default 32-bit dma mask set change prevents to update the dma mask to 64-bit. This leads to kernel panic due to out of SW-IOMMU space when a function driver tries to map more than 32-bit wide address. Change-Id: I38b178f38277f9a2fa40735f4e15385638403ae6 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: f_diag: Decrement counter if zero length packet queueing failsMayank Rana2016-06-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If usb_ep_queue() fails on queueing zero-length packet, driver is not decrementing dpkts_tolaptop_pending counter which may results into seeing count mismatch. Hence decrement dpkts_tolaptop_pending if zero length packet queueing fails. CRs-Fixed: 1027031 Change-Id: Id3c7c2627bdf37524067512db51d3180c570106d Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | usb: gadget: gsi: Fix reporting of USB device's usage countMayank Rana2016-06-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently driver is reading and logging usage count of gadget device but it is required to use usage count of gadget's parent device which is used to prevent USB controller's low power mode. Hence fix reporting of USB devices' usage count. Also mark sm_state to initialized and remove queueing of ipa_usb_wq as ipa_work_handler() is running without USB gadget is initialized i.e. gadget is NULL. CRs-Fixed: 1021499 Change-Id: Ia64afa3adb769674f6a9a60fde2c7397b7e4fe49 Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | usb: hcd: Fix double free with bandwidth_mutex on cable disconnectMayank Rana2016-06-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Roothub's (udev->dev) can be asynchronously suspended due to power.async_suspend is set to true i.e. at time of system suspend and resume, these devices' (usb1 and usb2) kobject count is decremented and incremented respectively. hcd_release() API expects that shared_hcd is being released first before hcd. Due to additional reference count at time of system resume, it results into hcd_release() is called first with hcd (primary) and then shared_hcd. With this, usb_hcd_is_primary_hcd() API is returning true for both hcd and shared_hcd which results into double free of bandwidth_mutex. Fix this issue by identifying hcd to release bandwidth_mutex without depending on which order hcd_release() is called with hcd and share_hcd. CRs-Fixed: 955531 Change-Id: I6bfcfd54525fa6472bd848d4c112fff0c9462355 Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | USB: f_mtp: Don't reset string id during function_unbindVijayavardhan Vennapusa2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently MTP driver is resetting string id during unbind, when cable is disconnected. Due to this, composite driver might run out of string ids, when it tries to allocate string id during next composition switch to MTP. This results in composition switch failure when MTP is selected and eventually causing USB enumeration failure. Fix this by not resetting string id and allocate it once only. Change-Id: Ieacdc8dd76bc45638002eb749ff87aa95f496fa3 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | | | usb: gadget: f_mtp: Fix mtp enumeration failure issueChandanaKishori Chiluveru2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If cable is disconnected while send_file work is in progress, Endpoints will be disabled and state will be marked as OFFLINE. As a part of endpoint disable pending requests will be retire out with -ECONNRESET error. Due to this we will modify the device state as ERROR in completion callback. If the state is not offline then we will mark the device state to ready in send_file_work. This results in mtp driver to not returning any error for next mtp_write operation and mtp release will not be called. Hence fix this issue by adding a proper check in completions to not moving device state to ERROR in case of disconnect. Change-Id: Idb4e075c89bdf94790a321bc464d30eba546eeaa Signed-off-by: ChandanaKishori Chiluveru <cchilu@codeaurora.org>
* | | | usb: gadget: f_mtp: Change the icon to camera for PTP compositionHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing code shows the phone icon in 'My Computer' of windows host, for PTP composition. Create a new Extended Configuration Descriptor for PTP composition and update the compatibleID to display a camera icon for PTP composition. Change-Id: If286c5b80874a95be0b5ecc533d0e5c7a14f39d3 Signed-off-by: Azhar Shaikh <azhars@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: f_mtp: Add support to capture time taken with vfs_write/readHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change captures time taken by each vfs_read() and vfs_write() call made from USB MTP gadget driver where data size is equal to USB request buffer size. It provides debugfs entry to get this information for 100 such call and resetting the same. How-To use: To get stats: cat /sys/kernel/debug/usb_mtp/status To reset stats: echo 0 > /sys/kernel/debug/usb_mtp/status Change-Id: I252e830568704e9e557660c1ae0f7597823e4b17 Signed-off-by: Mayank Rana <mrana@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: f_mtp: Fix issue of NULL pointer access in mtp_readHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MTP usb device node created as a part of mtp function init call. Userspace can read/write to MTP device using this node. If MTP is not enabled in the composition and trying to read mtp_usb dev node from the userspace leading to null pointer access in mtp_read. Do not access ep OUT maxpacket size in mtp_read. First block on mtp_read until the state become online which doesn't wakeup from the thread and expecting for the read completion or state change which occurs as a part of set_alt. Change-Id: Icbee5fe7ae2c02b2bca185a0dc7587eb4940058a Signed-off-by: ChandanaKishori Chiluveru <cchilu@codeaurora.org> Signed-off-by: Azhar Shaikh <azhars@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: Implement COMPAT_IOCTL for ioctlsHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 32-bit userspace calling into 64-bit kernel cause different ioctl codes to get generated. The different ioctl code gets generated because sizeof is used on mtp and accessory structures which is different for 32/64 compilation. Because of this, 64-bit kernel can never execute the right ioctl command. Implement compat_ioctl to handle such execution environment. Change-Id: I26cc10986e28a28eab6f3c65f28f4d2b808112d9 Signed-off-by: Sujeet Kumar <ksujeet@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: f_mtp: Fix bug in receive_file workHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If cable is disconnected while receive_file work is in progress, there is a case where mtp driver returns -ECANCELLED instead of -EIO. This results in mtp server thread not getting disconnect notification and mtp release will not be called. Due to this, mtp server will not start mtp connection after next USB connection. Change-Id: I909bebe0d22c19329cebb0a4a76424e08c82328c Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: mtp: Fix bug in freeing memory on allocation failureHemant Kumar2016-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current driver code doesn't handle the memory allocation failure correctly and ends up leaking memory and trying to free unallocated one. Change-Id: I7e3527b7e08ccfe566d85e3009d8a015d8daa707 Signed-off-by: Manu Gautam <mgautam@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: pd: Handle disconnection immediately if SDPJack Pham2016-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to a known PMIC HW bug, hard reset or PR swap may result in the charger notifying a CC disconnect event in sink mode, in which case the handler ignores it given these conditions. However, this closely resembles the case of a non-PD capable source getting physically disconnected as well. Consisdering the most probable case of this happening is disconnecting from an SDP while hard reset was just issued (and will fail), this workaround is currently racy if repeated plugin/plugout is performed as the timeout to detect failed hard reset takes a few seconds. For now, until a HW fix is available, optimize this legacy case by allowing the disconnect to go through if the detected charger type is SDP. Also fix the SINK_WAIT_CAP_TIME timeout as it was incorrectly multiplied by 3 during testing and was not removed. This will significantly reduce the amount of time for max failed hard reset attempts for non-PD && non-SDP cases and should decrease the window for racing with an actual disconnect. Change-Id: Ic57a369ed1e194ab512b4b86ce4d216df46b5f46 Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | | USB: f_mtp: Set maximum burst value to two for superspeed modeHemant Kumar2016-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently burst value is set to zero for superspeed in mtp driver. MTP throughput can be improved by setting max burst value to non zero value in superspeed mode. Hence set max burst value to two for both IN and OUT bulk endpoints in superspeed mode. Change-Id: Ib78b8fec5d1ab934f4d4ec80b7e008149707ce0f Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: pd: Add IPC logging to policy engineJack Pham2016-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert print messages to IPC logging facilities. This will allow for easier debugging from crash dumps as well as from debugfs. The print calls are converted to macros which also print to the console for flexibility. Change-Id: I6238b0434936fcff562d7a049e5e9d13794f9cdc Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | | USB: Add super speed descriptors for gadget functionsHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update function drivers mtp and accessory to operate in super speed. The burst capability is not enabled for now. Change-Id: Ie95cbfc9444c56c8268b70e2916713190699c71a Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: f_mtp: Check if the ep is not disabled before queuing itHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Queuing a request on a disabled endpoint during composition switch leads to prime failure. Hence return -EINVAL if a request is queued on a disabled endpoint. Also, in f_mtp, block queuing a request in OUT ep in receive_file_work, if the device state is STATE_OFFLINE. Change-Id: I0e706d5280a2460baf6ab05dbf97a09c59b642fb Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: f_mtp: Fix corner cases in MTP driver while syncingHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org> Change-Id: Ia8cbd1cd8c81b90389900b83744b2bed89068db5 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: f_mtp: Handle corner cases on reception of Cancel request from HostHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Change-Id: I2cd9780f8b3e0ce541472c4d25c8294f11a45d76 Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: mtp: Fix OUT endpoint request length usage in readHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DWC3 UDC requires OUT endpoint request length to be multiple of endpoint max packet size. Hence the OUT endpoint request is always set to the request buffer size in mtp read. The buffer can be allocated dynamically and is always multiple of 1024. If the count passed to read system call is less than the buffer size, we end up reading more bytes and not giving it to userspace. Userspace calls read with 512 bytes for receiving request from the host. If the request is for receiving a file, the read is called with 16K bytes for reading the header and some data. The remaining data is received via ioctl. If 1MB is used as request length for 16K read, the received file will be corrupted. Change-Id: I2eedf829f267150ff7a303824e95963219a1f555 Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: mtp: Add module parameters for Tx transfer lengthHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Tx request transfer length is 16K bytes by default. The test results indicate that larger transfers improve read speeds. Add provision for specifying Tx transfer length at runtime. echo -n 1048576 > /sys/module/g_android/parameters/mtp_tx_req_len The above command can be used to set Tx transfer length to 1MB. If the memory allocation is failed, fallback to the default length. Also add provision for specifying no. of Tx requests at runtime. echo 8 > /sys/module/g_android/parameters/mtp_tx_reqs Change-Id: I675fc3303be2aba081d2ab59a9efb94aa478f849 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: gadget: mtp: Add module parameter for Rx transfer lengthHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Rx request transfer length is 16K bytes by default. The test results indicate that larger transfers improve write speeds. Add provision for specifying Rx transfer length at runtime. echo -n 1048576 > /sys/module/g_android/parameters/mtp_rx_req_len The above command can be used to set Rx transfer length to 1MB. If the memory allocation is failed, fallback to the default length. Change-Id: I74d5da09437c25e9f1772f7cd49aecb8e4fedcf2 Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: f_mtp: Make RX buffer size aligned to EP's MTUManu Gautam2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Synopsys USB3 Controller (DWC3) has a restriction where size of OUT requests (TRB) queued to the controller must be aligned with the endpoint's max packet size. Generally, MTP userspace module submits RX requests aligned to 512 bytes which works fine in High speed mode. But, fails in Super-speed mode where max packet size can be 1024 bytes. To overcome this just change the size of RX request buffer while submitting to DCD as the buffers are already allocated with the size of 16KB. Change-Id: I68c32ef3d08b2cf943b52a7269785d0a00146953 Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
* | | | usb: dwc3: Fix extcon notification for non-type-c usb cableHemant Kumar2016-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case of non-type-c usb cable extcon cable state for EXTCON_USB_CC returns error and driver bails out. This causes usb enumeration failure. Hence set the typec_orientation to ORIENTATION_NONE and continue with usb enumeration. In case of super speed mode with type-c usb cable even if extcon cable state return error for EXTCON_USB_CC then also usb device will get enumerated falling back to high speed mode. Change-Id: Ibc0b0506b2090f4c090d649f6e3ae7d42b102c93 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | Revert "usb: gadget: gsi: Decrement USB gadget pm usage count on cable ↵Mayank Rana2016-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | disconnect" 'commit 3a7ce1db5661 ("usb: gadget: gsi: Decrement USB gadget pm usage count on cable disconnect")' added decrementing USB gadget device's pm usage count from STATE_INITIALIZED which results into multiple time decrementing USB gadget device's pm usage count on USB cable disconnect as below: 1. On USB cable disconnect, USB bus suspend event is being received which post EVT_DISCONNECTED. If state is STATE_CONNECTED, ipa_work_handles() decrements USB gadget device's pm usage count, and move state to STATE_INITIALIZED. 2. Due to USB cable disconnect, gsi_disable() posts EVT_DISCONNECTED. This event is processed into STATE_CONNECTED causing additional decrement of USB gadget device's pm usage count. Due to above case, USB goes into low power mode with dwc3's pm usage count negative. On connecting USB host mode cable, xhci resume is failing due to dwc3's (parent of xhci) is having negative usage count which results into no USB host mode functionality (pm_runtime_get_sync() returns -EBUSY). Hence revert commit to allow USB Host mode functionality. CRs-Fixed: 1020388 Change-Id: I853aba1d2d03945ee49adde7f0ea483cd406ce2b Signed-off-by: Mayank Rana <mrana@codeaurora.org>
* | | | usb: pd: Update power_supply type to USB_PD after PD is establishedJack Pham2016-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The USB power_supply now allows PROP_TYPE to be modified. Update it to 'USB_PD' only after PD communication has been established. This can happen only in a couple places: - in sink mode, when a source capabilities message is received - in source mode, when GoodCRC is received after sending the source capabilities message successfully Since PD_ACTIVE=1 is required to be set, also update it in source mode prior to sending out the capabilities, and clear it if all the attempts fail. Remove the unreachable/dead code found there as well. Change-Id: I77c5875ee8514395a82fac0109b7cff1d507250b Signed-off-by: Jack Pham <jackp@codeaurora.org>
* | | | usb: pd: Add support to notify plug orientation via extconHemant Kumar2016-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Policy engine needs to provide the plug orientation upon type-c cable plug in. qmp phy driver needs to program phy lane based upon this information. Change-Id: Idd236136c9f0a9163b4ae7a8405c412f1d69ca9e Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: phy: qmp: Configure phy lane based on plug orientationHemant Kumar2016-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to support super speed mode using type-c cable, phy driver needs to programe the phy with appropriate lane based upon plug orientation. Change-Id: I893c0b729015cd22791d168453309168246961e2 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: dwc3: Add support handle type-c plug orientationHemant Kumar2016-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Register callbacks for plug orientations in order to cache the current plug orientation reported by extcon. This allows super speed phy driver to configure the appropriate lane upon phy initialization. Change-Id: I906005680b4cc90cc38dc3d403beebf7aa515ad7 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | USB: dwc3: debugfs: Add boundary check in dwc3_store_ep_num()Vijayavardhan Vennapusa2016-05-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User can pass arguments as part of write to requests and endpoint number will be calculated based on the arguments. There is a chance that driver can access ep structue that is not allocated due to invalid arguments passed by user. Hence fix the issue by having check and return error in case of invalid arguments. Change-Id: I060ea878b55ce0f9983b91c50e58718c8a2c2fa1 Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
* | | | usb: gadget: Iterate over all IN EPs for allocation of TX FIFOsDevdutt Patnaik2016-05-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GSI EPs are assigned to the last 2 IN EPs. While allocating the TX FIFO sizes we need to iterate over all IN EPs to correctly allocate larger TX FIFOs for GSI accelerated endpoints. Update the logic from using min_t(int, dwc->num_in_eps, cdev->config->num_ineps_used + 1) to just use dwc->num_in_eps. The EPs that are not enabled will be given the default TX FIFO size while the ones that are enabled are given TX FIFO sizes based on the burst size configured for that EP. Change-Id: Ie9a21544966fb54cf9920e9c719309cc66157846 Signed-off-by: Devdutt Patnaik <dpatnaik@codeaurora.org>
* | | | usb: phy: qmp: Add support to select usb3 phy modeHemant Kumar2016-05-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qmp phy can run in display port mode or in usb3 mode. It is recommended to explicitly select the usb3 phy mode before programming the phy init sequence, since TCSR_USB3_DP_PHYMODE register is commonly used to select mode between display port driver as well as ssphy driver. Change-Id: I270596868762ccd4f2f2cc9b0daaca647a2bee88 Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
* | | | usb: gadget: gsi: Use drain_workqueue instead of flush_workqueueMayank Rana2016-05-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | USB GSI function driver uses usb_ipa_w work to queue different events like EVT_CONNECTED, EVT_DISCONNECTED and more. ipa_event_handler() uses those events as inputs to make necessary decision about performing connect and disconnect with IPA driver. It is required that before USB GSI driver calls ipa_usb_deinit_teth_prot(), it has invoked IPA disconnect API ipa_usb_xdci_disconnect() if it has called ipa_usb_xdci_connect() API. Current code is making sure that any running usb_ipa_w work is being completed before calling ipa_usb_deinit_teth_prot() but if work is not scheduled and pending, ipa_usb_xdci_connect() is not called (i.e. later when usb_ipw_w work is scheduled, EVT_DISCONNECTED is being processed but gsi_unbind() has changed sm_state as STATE_UNINITIALIZED which results into no-ops.) which results into USB and IPA driver go out of sync in terms of expected state machine. Hence calling ipa_usb_init_teth_prot() on next USB cable connect from gsi_bind_config() fails which results into no USB GSI functionality. Fix this issue by using drain_workqueue() instead of flush_workqueue() which makes sure that re-queue work is flushed. CRs-Fixed: 1005018 Change-Id: I64ff559b85f901688a4abd0110ebb32a5317e34d Signed-off-by: Mayank Rana <mrana@codeaurora.org>