aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-12-12usb: xhci: make function xhci_dbc_free_req staticColin Ian King1-1/+1
Function xhci_dbc_free_req is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: symbol 'xhci_dbc_free_req' was not declared. Should it be static? Signed-off-by: Colin Ian King <colin.king@canonical.com> Cc: Mathias Nyman <mathias.nyman@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-12xhci: fixup incorrect memset size parameter when clearing up DbC on exit.Mathias Nyman1-1/+1
Incorrect size was given to memset when zeroing the DbC endpoint structures on exit. Use element size * ARRAY_SIZE to fix it Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-12USB: remove the URB_NO_FSBR flagAlan Stern4-10/+1
The URB_NO_FSBR flag has never really been used. It was introduced as a potential way for UHCI to minimize PCI bus usage (by not attempting full-speed bulk and control transfers more than once per frame), but the flag was not set by any drivers. There's no point in keeping it around. This patch simplifies the API by removing it. Unfortunately, it does have to be kept as part of the usbfs ABI, but at least we can document in include/uapi/linux/usbdevice_fs.h that it doesn't do anything. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-12usb: typec: wcove: fix the sink capabilitiesHeikki Krogerus1-3/+1
USB Power Delivery Specification (v3.0) dictates in ch. 6.4.1 - Capabilities Message - that the vSafe5V Fixed Supply Object shall always be the first object. tcpm.c now checks that this rule is obeyed (commit 5007e1b5db73 "typec: tcpm Validate source and sink caps"), and that makes the typec_wcove.c fail to probe. The voltage is higher then what is permitted for the vSafe5V parameter. Dropping the voltage in the first Fixed Supply object of the sink capabilities down to 5V, and maximum current down to 500mA, making the driver probe successfully again. Also, removing the Battery and Variable Supply objects, as there is no need for them. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-12USB: core: only clean up what we allocatedAndrey Konovalov1-3/+6
When cleaning up the configurations, make sure we only free the number of configurations and interfaces that we could have allocated. Reported-by: Andrey Konovalov <andreyknvl@google.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-12Merge tag 'fixes-for-v4.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linusGreg Kroah-Hartman7-66/+34
Felipe writes: usb: fixes for v4.15-rc4 We have a few fixes on dwc3: - one fix which only happens with some implementations where we need to wait longer for some commands to finish. - Another fix for high-bandwidth isochronous endpoint programming making sure that we send the correct DATA tokens in the correct sequence - A couple PM fixes on dwc3-of-simple The other synopsys controller driver (dwc2) got a fix for FIFO size programming. Other than these, we have a couple Kconfig fixes making sure that dependencies are properly setup.
2017-12-12usb: dwc2: add optional usb ecc reset bitDinh Nguyen2-0/+11
The dwc2 USB controller in Stratix10 has an additional ECC reset bit that needs to get de-asserted in order for the controller to work properly. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Dinh Nguyen <dinguyen@kernel.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12usb: renesas_usbhs: use PIPEnCLR.ACLRM instead of {C,Dn}FIFOCTR.BCLR in usbhs_pkt_pop()Yoshihiro Shimoda1-3/+2
This patch uses usbhs_pipe_clear_without_sequence() instead of usbhsf_fifo_clear() because usbhsf_fifo_clear() may not clear the pipe buffer completely. This patch also changes the clearing condition from DMA only to both DMA and PIO. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12usb: renesas_usbhs: add usbhs_pipe_clear_without_sequence() functionYoshihiro Shimoda2-5/+16
This patch adds usbhs_pipe_clear_without_sequence() function. The controller has the pipe buffer and the PIPEnCTR.ACLRM can clear it completely. But, it's also clear the data sequence. So, the driver needs to get the sequence before. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12usb: renesas_usbhs: remove redundant polling in usbhsf_fifo_barrier()Yoshihiro Shimoda1-11/+5
The datasheet doesn't mention that needs to poll of FRDY is set or not. So, this patch removes such handling in the usbhsf_fifo_barrier(). Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12usb: phy: Factor out the usb charger initializationBaolin Wang1-4/+10
Factor out the guts of usb charger initialization into usb_charger_init() function, to make the usb_add_extcon() only do the extcon related things. Meanwhile we also should initialize the USB charger before registering the extcon device, in case the extcon notification was issued earlier than usb charger initialization. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12Revert "usb: gadget: allow to enable legacy drivers without USB_ETH"Felipe Balbi2-12/+2
This reverts commit 7a9618a22aadffb55027d665491adf466bced61a. Romain Izard recently reported that commit 7a9618a22aad ended up allowing every legacy gadget driver to statically linked to the kernel, however that doesn't work, since only one legacy gadget can be bound to a controller. Because of that, let's revert the original commit and fix the problem. Reported-by: Romain Izard <romain.izard.pro@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-12usb: gadget: webcam: fix V4L2 Kconfig dependencyArnd Bergmann1-1/+1
Configuring the USB_G_WEBCAM driver as built-in leads to a link error when CONFIG_VIDEO_V4L2 is a loadable module: drivers/usb/gadget/function/f_uvc.o: In function `uvc_function_setup': f_uvc.c:(.text+0xfe): undefined reference to `v4l2_event_queue' drivers/usb/gadget/function/f_uvc.o: In function `uvc_function_ep0_complete': f_uvc.c:(.text+0x188): undefined reference to `v4l2_event_queue' This changes the Kconfig dependency to disallow that configuration, and force it to be a module in that case as well. This is apparently a rather old bug, but very hard to trigger even in thousands of randconfig builds. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: Allow disabling of metastability workaroundRoger Quadros3-2/+10
Some platforms (e.g. TI's DRA7 USB2 instance) have more trouble with the metastability workaround as it supports only a High-Speed PHY and the PHY can enter into an Erratic state [1] when the controller is set in SuperSpeed mode as part of the metastability workaround. This causes upto 2 seconds delay in enumeration on DRA7's USB2 instance in gadget mode. If these platforms can be better off without the workaround, provide a device tree property to suggest that so the workaround is avoided. [1] Device mode enumeration trace showing PHY Erratic Error. irq/90-dwc3-969 [000] d... 52.323145: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.560646: dwc3_event: event (00000901): Erratic Error [U0] irq/90-dwc3-969 [000] d... 52.798144: dwc3_event: event (00000901): Erratic Error [U0] Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11USB: dummy-hcd: Adapt dummy_udc_set_speed()Roger Quadros1-13/+1
The UDC core ensures that .udc_set_speed() is called with a speed that is a minimum of the max speeds supported by the gadget function driver and the UDC driver. We can now use the speed argument as is. Get rid of the debug print as that condition will never happen. Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11USB: dummy-hcd: don't set gadget.speed in dummy_hub_control()Roger Quadros1-2/+0
There will never be a case when gadget.speed isn't already USB_SPEED_FULL if connection is not USB-3 and gadget.speed is not USB_SPEED_HIGH or USB_SPEED_LOW. Remove the unnecessary code. Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: gadget: bcm63xx_udc: Use common error handling code in bcm63xx_udc_probe()Markus Elfring1-8/+8
Add a jump target so that a specific error message is stored only once at the end of this function implementation. Replace two calls of the function "dev_err" by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: gadget: pxa27x: Remove redundant assignment to is_short and devColin Ian King1-3/+0
Variable is_short is set to zero but this value is never read as it is overwritten with a new value later on, hence it is a redundant assignment and can be removed. Pointer dev is assigned a value that is not read and it is updated a few statements later, this too is redundant and can be removed. Cleans up clan warnings: drivers/usb/gadget/udc/pxa27x_udc.c:986:3: warning: Value stored to 'is_short' is never read drivers/usb/gadget/udc/pxa27x_udc.c:1141:2: warning: Value stored to 'dev' is never read Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: gadget: udc-xilinx: remove redundant pointer udcColin Ian King1-2/+0
Pointer udc is assigned but never read, hence it is redundant and can be removed. Cleans up clang warning: drivers/usb/gadget/udc/udc-xilinx.c:974:2: warning: Value stored to 'udc' is never read Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11USB: gadget: legacy: remove redundant zero assignment to variable 'value'Colin Ian King1-1/+0
The variable value is being assigned to zero but that value is never being read. Either value is being reassigned in the following if condition, or it is never read and the function returns. In both cases the assignment is redundant and can be removed. Cleans up clang warning: drivers/usb/gadget/legacy/inode.c:1473:4: warning: Value stored to 'value' is never read Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11USB: gadget: udc: fix spelling mistake "unexpect" -> "unexpected"Colin Ian King1-1/+1
Trival fix to spelling mistake in ERR message Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: gadget: ffs: Make sparse happierVincent Pelletier1-3/+6
Silences the following warnings: drivers/usb/gadget/function/f_fs.c:1253:37: warning: incorrect type in argument 1 (different address spaces) drivers/usb/gadget/function/f_fs.c:1253:37: expected void [noderef] <asn:1>*to drivers/usb/gadget/function/f_fs.c:1253:37: got void *<noident> drivers/usb/gadget/function/f_fs.c:2322:23: warning: cast to restricted __le32 drivers/usb/gadget/function/f_fs.c:2876:38: warning: cast to restricted __le32 drivers/usb/gadget/function/f_fs.c:272:12: warning: context imbalance in '__ffs_ep0_queue_wait' - unexpected unlock drivers/usb/gadget/function/f_fs.c:450:17: warning: context imbalance in 'ffs_ep0_write' - different lock contexts for basic block drivers/usb/gadget/function/f_fs.c:490:24: warning: context imbalance in '__ffs_ep0_read_events' - unexpected unlock drivers/usb/gadget/function/f_fs.c:496:16: warning: context imbalance in 'ffs_ep0_read' - different lock contexts for basic block Also, add an "unlocks spinlock" comment for consistency with existing ones. No behaviour change is intended. Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: gadget: u_serial: Use kfifo instead of homemade circular bufferLu Baolu1-168/+24
The kernel FIFO implementation, kfifo, provides interfaces to manipulate a first-in-first-out circular buffer. Use kfifo instead of the homemade one to make the code more concise and readable. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: Make sparse a bit happierVincent Pelletier1-2/+2
Fixes the following warnings: drivers/usb/dwc3/io.h:43:31: warning: incorrect type in argument 1 (different address spaces) drivers/usb/dwc3/io.h:43:31: expected void *base drivers/usb/dwc3/io.h:43:31: got void [noderef] <asn:2>* drivers/usb/dwc3/io.h:62:32: warning: incorrect type in argument 1 (different address spaces) drivers/usb/dwc3/io.h:62:32: expected void *base drivers/usb/dwc3/io.h:62:32: got void [noderef] <asn:2>* This fixes the noisiest ones as they get emitted multiple times. A few warnings remain, for which the proper fix is less clear. No behaviour change is expected. Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11gadget event trace : add request pointerMatthieu CASTET1-2/+4
This allows to identify transfer request, if more than one are in queue. This is allowed by usb_ep_queue : "Any endpoint (except control endpoints like ep0) may have more than one transfer request queued; they complete in FIFO order." For example with adb gadget with function fs : <-transport-225 [002] d..1 47.136641: usb_ep_queue: ep1out: req ffffffc07b93ef10 length 0/24 sgs 0/0 stream 0 zsI status -115 --> 0 ->transport-224 [000] d..1 47.153947: usb_ep_queue: ep1in: req ffffffc07c0def10 length 0/24 sgs 0/0 stream 0 zsI status -115 --> 0 sh-452 [000] d.h2 47.153984: usb_gadget_giveback_request: ep1in: req ffffffc07c0def10 length 24/24 sgs 0/0 stream 0 zsI status 0 --> 0 sh-452 [000] d.h. 47.154305: usb_gadget_giveback_request: ep1out: req ffffffc07b93ef10 length 24/24 sgs 0/0 stream 0 zsI status 0 --> 0 <-transport-225 [002] d..1 47.154363: usb_ep_queue: ep1out: req ffffffc07b93ef10 length 0/21 sgs 0/0 stream 0 zsI status -115 --> 0 sh-452 [000] d.h. 47.154378: usb_gadget_giveback_request: ep1out: req ffffffc07b93ef10 length 21/21 sgs 0/0 stream 0 zsI status 0 --> 0 <-transport-225 [002] d..1 47.154463: usb_ep_queue: ep1out: req ffffffc07b93ef10 length 0/24 sgs 0/0 stream 0 zsI status -115 --> 0 ->transport-224 [000] d..1 47.154583: usb_ep_queue: ep1in: req ffffffc07c0def10 length 0/24 sgs 0/0 stream 0 zsI status -115 --> 0 sh-452 [000] d.h2 47.154600: usb_gadget_giveback_request: ep1in: req ffffffc07c0def10 length 24/24 sgs 0/0 stream 0 zsI status 0 --> 0 ->transport-224 [000] d..1 47.164863: usb_ep_queue: ep1in: req ffffffc07c0def10 length 0/24 sgs 0/0 stream 0 zsI status -115 --> 0 ->transport-224 [000] d.h1 47.164887: usb_gadget_giveback_request: ep1in: req ffffffc07c0def10 length 24/24 sgs 0/0 stream 0 zsI status 0 --> 0 ->transport-224 [000] d..1 47.164907: usb_ep_queue: ep1in: req ffffffc07c0def10 length 0/122 sgs 0/0 stream 0 zsI status -115 --> 0 Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: ep0: use gadget->isoch_delay for isoch_delay valueFelipe Balbi2-7/+1
Instead of keeping our own isoch_delay, let's make use of the newly introduced isoch_delay member in struct usb_gadget. The benefit here is that we would be using a generic "API" which other UDCs can use, resulting in a common setup for gadget drivers who may be interested in Isoch Delay value. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: debug: decode a few more featuresFelipe Balbi1-0/+9
We were missing U1, U2 and LTM Enable features. Let's decode them. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc2: Fix TxFIFOn sizes and total TxFIFO size issuesMinas Harutyunyan3-50/+25
In host mode reading from DPTXSIZn returning invalid value in dwc2_check_param_tx_fifo_sizes function. In total TxFIFO size calculations unnecessarily reducing by ep_info. hw->total_fifo_size can be fully allocated for FIFO's. Added num_dev_in_eps member in dwc2_hw_params structure to save number of IN EPs. Added g_tx_fifo_size array in dwc2_hw_params structure to store power on reset values of DPTXSIZn registers in forced device mode. Updated dwc2_hsotg_tx_fifo_count() function to get TxFIFO count from num_dev_in_eps. Updated dwc2_get_dev_hwparams() function to store DPTXFSIZn in g_tx_fifo_size array. dwc2_get_host/dev_hwparams() functions call moved after num_dev_in_eps set from hwcfg4. Modified dwc2_check_param_tx_fifo_sizes() function to check TxFIFOn sizes based on g_tx_fifo_size array. Removed ep_info subtraction during calculation of tx_addr_max in dwc2_hsotg_tx_fifo_total_depth() function. Also removed dwc2_hsotg_ep_info_size() function as no more need. Acked-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Gevorg Sahakyan <sahakyan@synopsys.com> Signed-off-by: Minas Harutyunyan <hminas@synopsys.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: gadget: Fix PCM1 for ISOC EP with ep->mult less than 3Manu Gautam1-1/+1
For isochronous endpoints with ep->mult less than 3, PCM1 value of trb->size in set incorrectly. For ep->mult = 2, this is set to 0/-1 and for ep->mult = 1, this is set to -2. This is because the initial mult is set to ep->mult - 1 instead of 2. Signed-off-by: Manu Gautam <mgautam@codeaurora.org> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: of-simple: set dev_pm_opsMasahiro Yamada1-0/+1
dwc3_of_simple_dev_pm_ops has never been used since the initial support by commit 16adc674d0d6 ("usb: dwc3: add generic OF glue layer"). I guess it just missed to set .pm struct member. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: of-simple: fix missing clk_disable_unprepareAndreas Platschek1-1/+3
If of_clk_get() fails, the clean-up of already initialized clocks should be the same as when clk_prepare_enable() fails. Thus a clk_disable_unprepare() for each clock should be called before the clk_put(). Found by Linux Driver Verification project (linuxtesting.org). Fixes: 16adc674d0d6 ("usb: dwc3: ep0: fix setup_packet_pending initialization") Signed-off-by: Andreas Platschek <andreas.platschek@opentech.at> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-11usb: dwc3: gadget: Wait longer for controller to end command processingVincent Pelletier1-1/+1
DWC3_DEPCMD_ENDTRANSFER has been witnessed to require around 600 iterations before controller would become idle again after unplugging the USB cable with AIO reads submitted. Bump timeout from 500 iterations to 1000 so dwc3_stop_active_transfer does not receive -ETIMEDOUT and does not WARN: [ 81.326273] ------------[ cut here ]------------ [ 81.335341] WARNING: CPU: 0 PID: 1874 at drivers/usb/dwc3/gadget.c:2627 dwc3_stop_active_transfer.constprop.23+0x69/0xc0 [dwc3] [ 81.347094] Modules linked in: usb_f_fs libcomposite configfs bnep btsdio bluetooth ecdh_generic brcmfmac brcmutil dwc3 intel_powerclamp coretemp ulpi kvm_intel udc_core kvm irqbypass crc32_pclmul crc32c_intel pcbc dwc3_pci aesni_intel aes_i586 crypto_simd cryptd ehci_pci ehci_hcd basincove_gpadc industrialio gpio_keys usbcore usb_common [ 81.378142] CPU: 0 PID: 1874 Comm: irq/34-dwc3 Not tainted 4.14.0-edison+ #119 [ 81.385545] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48 [ 81.394548] task: f5b1be00 task.stack: f420a000 [ 81.399219] EIP: dwc3_stop_active_transfer.constprop.23+0x69/0xc0 [dwc3] [ 81.406086] EFLAGS: 00010086 CPU: 0 [ 81.409672] EAX: 0000001f EBX: f5729800 ECX: c132a2a2 EDX: 00000000 [ 81.416096] ESI: f4054014 EDI: f41cf400 EBP: f420be10 ESP: f420bdf4 [ 81.422521] DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068 [ 81.428061] CR0: 80050033 CR2: b7a3f000 CR3: 01d94000 CR4: 001006d0 [ 81.434483] Call Trace: [ 81.437063] __dwc3_gadget_ep_disable+0xa3/0x2b0 [dwc3] [ 81.442438] ? _raw_spin_lock_irqsave+0x32/0x40 [ 81.447135] dwc3_gadget_ep_disable+0xbf/0xe0 [dwc3] [ 81.452269] usb_ep_disable+0x1c/0xd0 [udc_core] [ 81.457048] ffs_func_eps_disable.isra.15+0x3b/0x90 [usb_f_fs] [ 81.463070] ffs_func_set_alt+0x7d/0x310 [usb_f_fs] [ 81.468132] ffs_func_disable+0x14/0x20 [usb_f_fs] [ 81.473075] reset_config+0x5b/0x90 [libcomposite] [ 81.478023] composite_disconnect+0x2b/0x50 [libcomposite] [ 81.483685] dwc3_disconnect_gadget+0x39/0x50 [dwc3] [ 81.488808] dwc3_gadget_disconnect_interrupt+0x21b/0x250 [dwc3] [ 81.495014] dwc3_thread_interrupt+0x2a8/0xf70 [dwc3] [ 81.500219] ? __schedule+0x78c/0x7e0 [ 81.504027] irq_thread_fn+0x18/0x30 [ 81.507715] ? irq_thread+0xb7/0x180 [ 81.511400] irq_thread+0x111/0x180 [ 81.515000] ? irq_finalize_oneshot+0xe0/0xe0 [ 81.519490] ? wake_threads_waitq+0x30/0x30 [ 81.523806] kthread+0x107/0x110 [ 81.527131] ? disable_percpu_irq+0x50/0x50 [ 81.531439] ? kthread_stop+0x150/0x150 [ 81.535397] ret_from_fork+0x19/0x24 [ 81.539136] Code: 89 d8 c7 45 ec 00 00 00 00 c7 45 f0 00 00 00 00 c7 45 f4 00 00 00 00 e8 56 ef ff ff 85 c0 74 12 50 68 b9 1c 14 f8 e8 64 0f f7 c8 <0f> ff 58 5a 8d 76 00 8b 83 98 00 00 00 c6 83 a0 00 00 00 00 83 [ 81.559295] ---[ end trace f3133eec81a473b8 ]--- Number of iterations measured on 4 consecutive unplugs: [ 1088.799777] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 605 times [ 1222.024986] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 580 times [ 1317.590452] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 598 times [ 1453.218314] dwc3_send_gadget_ep_cmd(cmd=331016, params={0, 0, 0}) iterated 594 times Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-12-08usb: xhci: fix TDS for MTK xHCI1.1Chunfeng Yun1-3/+3
For MTK's xHCI 1.0 or latter, TD size is the number of max packet sized packets remaining in the TD, not including this TRB (following spec). For MTK's xHCI 0.96 and older, TD size is the number of max packet sized packets remaining in the TD, including this TRB (not following spec). Cc: stable <stable@vger.kernel.org> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08xhci: Don't add a virt_dev to the devs array before it's fully allocatedMathias Nyman1-4/+11
Avoid null pointer dereference if some function is walking through the devs array accessing members of a new virt_dev that is mid allocation. Add the virt_dev to xhci->devs[i] _after_ the virt_device and all its members are properly allocated. issue found by KASAN: null-ptr-deref in xhci_find_slot_id_by_port "Quick analysis suggests that xhci_alloc_virt_device() is not mutex protected. If so, there is a time frame where xhci->devs[slot_id] is set but not fully initialized. Specifically, xhci->devs[i]->udev can be NULL." Cc: stable <stable@vger.kernel.org> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08xhci: add port status tracing for Get Hub Status requestsMathias Nyman2-0/+7
Trace the port status of each port of a roothub when the xhci roothub receives a Get Hub Status request. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08xhci: add port status tracing for Get Port Status hub requestsMathias Nyman2-0/+6
Add tracing showing the port status register content each time the xhci roothub receives a Get Port Status request. Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: allow imod-interval to be configurableAdam Wallis5-5/+20
The xHCI driver currently has the IMOD set to 160, which translates to an IMOD interval of 40,000ns (160 * 250)ns Commit 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller") introduced a QUIRK for the MTK platform to adjust this interval to 20, which translates to an IMOD interval of 5,000ns (20 * 250)ns. This is due to the fact that the MTK controller IMOD interval is 8 times as much as defined in xHCI spec. Instead of adding more quirk bits for additional platforms, this patch introduces the ability for vendors to set the IMOD_INTERVAL as is optimal for their platform. By using device_property_read_u32() on "imod-interval-ns", the IMOD INTERVAL can be specified in nano seconds. If no interval is specified, the default of 40,000ns (IMOD=160) will be used. No bounds checking has been implemented due to the fact that a vendor may have violated the spec and would need to specify a value outside of the max 8,000 IRQs/second limit specified in the xHCI spec. Tested-by: Chunfeng Yun <chunfeng.yun@mediatek.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Adam Wallis <awallis@codeaurora.org> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: Cleanup printk debug message for ERSTLu Baolu3-21/+0
Each event segment has been exposed through debugfs. There is no need to dump ERST content with printk in code. Remove it to make code more concise and readable. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: Cleanup printk debug message for registersLu Baolu4-258/+0
The content of each register has been exposed through debugfs. There is no need to dump register content with printk in code lines. Remove them to make code more concise and readable. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: Add DbC support in xHCI driverLu Baolu8-0/+1804
xHCI compatible USB host controllers(i.e. super-speed USB3 controllers) can be implemented with the Debug Capability(DbC). It presents a debug device which is fully compliant with the USB framework and provides the equivalent of a very high performance full-duplex serial link. The debug capability operation model and registers interface are defined in 7.6.8 of the xHCI specification, revision 1.1. The DbC debug device shares a root port with the xHCI host. By default, the debug capability is disabled and the root port is assigned to xHCI. When the DbC is enabled, the root port will be assigned to the DbC debug device, and the xHCI sees nothing on this port. This implementation uses a sysfs node named <dbc> under the xHCI device to manage the enabling and disabling of the debug capability. When the debug capability is enabled, it will present a debug device through the debug port. This debug device is fully compliant with the USB3 framework, and it can be enumerated by a debug host on the other end of the USB link. As soon as the debug device is configured, a TTY serial device named /dev/ttyDBC0 will be created. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: Make some static functions globalLu Baolu3-42/+72
This patch makes some static functions global to avoid duplications in different files. These functions can be used in the implementation of xHCI debug capability. There is no functional change. Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08xhci: remove unnecessary boolean parameter from xhci_alloc_commandMathias Nyman5-31/+16
commands with input contexts are allocated with the xhci_alloc_command_with_ctx helper. No functional changes Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08xhci: add helper to allocate command with input contextMathias Nyman3-4/+26
Add a xhci_alloc_command_with_ctx() helper to get rid of one of the boolean parameters telling if a context should be allocated with the command. No functional changes, improves core readability Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: remove unused variable ep_ringCorentin Labbe1-2/+0
Fix the build warning about variable 'ep_ring' set but not used [Minor commit message change -Mathias] Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: remove unused variable urb_privCorentin Labbe1-2/+0
Fix the build warning: variable 'urb_priv' set but not used Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: remove unused variable epCorentin Labbe1-2/+0
Fix the build warning: variable 'ep' set but not used Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usb: xhci: remove unused variable last_freed_endpointCorentin Labbe1-3/+0
Fix the build warning about variable 'last_freed_endpoint' set but not used [-Wunused-but-set-variable] Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usbip: fix stub_send_ret_submit() vulnerability to null transfer_bufferShuah Khan1-0/+7
stub_send_ret_submit() handles urb with a potential null transfer_buffer, when it replays a packet with potential malicious data that could contain a null buffer. Add a check for the condition when actual_length > 0 and transfer_buffer is null. Reported-by: Secunia Research <vuln@secunia.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usbip: prevent vhci_hcd driver from leaking a socket pointer addressShuah Khan2-9/+17
When a client has a USB device attached over IP, the vhci_hcd driver is locally leaking a socket pointer address via the /sys/devices/platform/vhci_hcd/status file (world-readable) and in debug output when "usbip --debug port" is run. Fix it to not leak. The socket pointer address is not used at the moment and it was made visible as a convenient way to find IP address from socket pointer address by looking up /proc/net/{tcp,tcp6}. As this opens a security hole, the fix replaces socket pointer address with sockfd. Reported-by: Secunia Research <vuln@secunia.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-08usbip: fix stub_rx: harden CMD_SUBMIT path to handle malicious inputShuah Khan1-4/+31
Harden CMD_SUBMIT path to handle malicious input that could trigger large memory allocations. Add checks to validate transfer_buffer_length and number_of_packets to protect against bad input requesting for unbounded memory allocations. Validate early in get_pipe() and return failure. Reported-by: Secunia Research <vuln@secunia.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>