1. 21 5月, 2018 6 次提交
  2. 26 3月, 2018 1 次提交
    • F
      usb: dwc3: gadget: never call ->complete() from ->ep_queue() · c91815b5
      Felipe Balbi 提交于
      This is a requirement which has always existed but, somehow, wasn't
      reflected in the documentation and problems weren't found until now
      when Tuba Yavuz found a possible deadlock happening between dwc3 and
      f_hid. She described the situation as follows:
      
      spin_lock_irqsave(&hidg->write_spinlock, flags); // first acquire
      /* we our function has been disabled by host */
      if (!hidg->req) {
      	free_ep_req(hidg->in_ep, hidg->req);
      	goto try_again;
      }
      
      [...]
      
      status = usb_ep_queue(hidg->in_ep, hidg->req, GFP_ATOMIC);
      =>
      	[...]
      	=> usb_gadget_giveback_request
      		=>
      		f_hidg_req_complete
      			=>
      			spin_lock_irqsave(&hidg->write_spinlock, flags); // second acquire
      
      Note that this happens because dwc3 would call ->complete() on a
      failed usb_ep_queue() due to failed Start Transfer command. This is,
      anyway, a theoretical situation because dwc3 currently uses "No
      Response Update Transfer" command for Bulk and Interrupt endpoints.
      
      It's still good to make this case impossible to happen even if the "No
      Reponse Update Transfer" command is changed.
      Reported-by: NTuba Yavuz <tuba@ece.ufl.edu>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c91815b5
  3. 22 3月, 2018 3 次提交
  4. 13 3月, 2018 1 次提交
    • R
      usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume · 498f0478
      Roger Quadros 提交于
      In the following test we get stuck by sleeping forever in _dwc3_set_mode()
      after which dual-role switching doesn't work.
      
      On dra7-evm's dual-role port,
      - Load g_zero gadget driver and enumerate to host
      - suspend to mem
      - disconnect USB cable to host and connect otg cable with Pen drive in it.
      - resume system
      - we sleep indefinitely in _dwc3_set_mode due to.
        dwc3_gadget_exit()->usb_del_gadget_udc()->udc_stop()->
      	dwc3_gadget_stop()->wait_event_lock_irq()
      
      To fix this instead of waiting indefinitely with wait_event_lock_irq()
      we use wait_event_interruptible_lock_irq_timeout() and print
      and error message if there was a timeout.
      Signed-off-by: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      498f0478
  5. 12 2月, 2018 1 次提交
    • T
      usb: dwc3: gadget: Set maxpacket size for ep0 IN · 61800263
      Thinh Nguyen 提交于
      There are 2 control endpoint structures for DWC3. However, the driver
      only updates the OUT direction control endpoint structure during
      ConnectDone event. DWC3 driver needs to update the endpoint max packet
      size for control IN endpoint as well. If the max packet size is not
      properly set, then the driver will incorrectly calculate the data
      transfer size and fail to send ZLP for HS/FS 3-stage control read
      transfer.
      
      The fix is simply to update the max packet size for the ep0 IN direction
      during ConnectDone event.
      
      Cc: stable@vger.kernel.org
      Fixes: 72246da4 ("usb: Introduce DesignWare USB3 DRD Driver")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      61800263
  6. 11 12月, 2017 3 次提交
    • R
      usb: dwc3: Allow disabling of metastability workaround · 42bf02ec
      Roger Quadros 提交于
      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: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      42bf02ec
    • M
      usb: dwc3: gadget: Fix PCM1 for ISOC EP with ep->mult less than 3 · ec5bb87e
      Manu Gautam 提交于
      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: NManu Gautam <mgautam@codeaurora.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      ec5bb87e
    • V
      usb: dwc3: gadget: Wait longer for controller to end command processing · 8722e095
      Vincent Pelletier 提交于
      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: NVincent Pelletier <plr.vincent@gmail.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      8722e095
  7. 07 11月, 2017 1 次提交
    • G
      USB: dwc3: Remove redundant license text · b5ea4757
      Greg Kroah-Hartman 提交于
      Now that the SPDX tag is in all USB files, that identifies the license
      in a specific and legally-defined manner.  So the extra GPL text wording
      can be removed as it is no longer needed at all.
      
      This is done on a quest to remove the 700+ different ways that files in
      the kernel describe the GPL license text.  And there's unneeded stuff
      like the address (sometimes incorrect) for the FSF which is never
      needed.
      
      No copyright headers or other non-license-description text was removed.
      
      Cc: Kukjin Kim <kgene@kernel.org>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Cc: Patrice Chotard <patrice.chotard@st.com>
      Acked-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5ea4757
  8. 04 11月, 2017 1 次提交
  9. 19 10月, 2017 4 次提交
  10. 03 8月, 2017 1 次提交
    • M
      usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets · 40d829fb
      Manu Gautam 提交于
      The PIDs for Isochronous data transfers are incorrect
      for high bandwidth IN endpoints when the request length
      is less than EP wMaxPacketSize.
      
      As per spec correct PIDs for ISOC data transfers are:
      
      1) For request length <= maxpacket
      	- DATA0,
      
      2) For maxpacket < length <= (2 * maxpacket)
      	- DATA1, DATA0
      
      3) For (2 * maxpacket) <  length <= (3 * maxpacket)
      	- DATA2, DATA1, DATA0.
      
      But driver always sets PCM fields based on wMaxPacketSize
      due to which DATA2 happens even for small requests.
      
      Fix this by setting the PCM field of trb->size depending
      on request length rather than fixing it to the value
      depending on wMaxPacketSize.
      
      Ideally it shouldn't give any issues as dwc3 will send
      0-length packet for next IN token if host sends (even
      after receiving a short packet). Windows seems to ignore
      this but with MacOS frame loss observed when using f_uvc.
      Signed-off-by: NManu Gautam <mgautam@codeaurora.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      40d829fb
  11. 17 7月, 2017 1 次提交
    • J
      usb: dwc3: gadget: only unmap requests from DMA if mapped · 4a71fcb8
      Jack Pham 提交于
      A recent optimization was made so that a request put on the
      pending_list wouldn't get mapped for DMA until just before
      preparing a TRB for it. However, this poses a problem in case
      the request is dequeued or the endpoint is disabled before the
      mapping is done as that would lead to dwc3_gadget_giveback()
      unconditionally calling usb_gadget_unmap_request_for_dev() with
      an invalid request->dma handle. Depending on the platform's DMA
      implementation the unmap operation could result in a panic.
      
      Since we know a successful mapping is a prerequisite for getting
      a TRB, the unmap can be conditionally called only when req->trb
      is non-NULL.
      
      Fixes: cdb55b39 ("usb: dwc3: gadget: lazily map requests for DMA")
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      4a71fcb8
  12. 13 6月, 2017 2 次提交
  13. 02 6月, 2017 3 次提交
  14. 17 5月, 2017 2 次提交
  15. 16 5月, 2017 2 次提交
    • T
      usb: dwc3: gadget: Prevent losing events in event cache · d325a1de
      Thinh Nguyen 提交于
      The dwc3 driver can overwite its previous events if its top-half IRQ
      handler (TH) gets invoked again before processing the events in the
      cache. We see this as a hang in the file transfer and the host will
      attempt to reset the device. TH gets the event count and deasserts the
      interrupt line by writing DWC3_GEVNTSIZ_INTMASK to DWC3_GEVNTSIZ. If
      there's a new event coming between reading the event count and interrupt
      deassertion, dwc3 will lose previous pending events. More generally, we
      will see 0 event count, which should not affect anything.
      
      This shouldn't be possible in the current dwc3 implementation. However,
      through testing and reading the PCIe trace, the TH occasionally still
      gets invoked one more time after HW interrupt deassertion. (With PCIe
      legacy interrupts, TH is called repeatedly as long as the interrupt line
      is asserted). We suspect that there is a small detection delay in the
      SW.
      
      To avoid this issue, Check DWC3_EVENT_PENDING flag to determine if the
      events are processed in the bottom-half IRQ handler. If not, return
      IRQ_HANDLED and don't process new event.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      d325a1de
    • R
      usb: dwc3: gadget: Fix ISO transfer performance · f1d6826c
      Roger Quadros 提交于
      Commit 08a36b54 ("usb: dwc3: gadget: simplify __dwc3_gadget_ep_queue()")
      caused a small change in the way ISO transfer is handled in the case
      when XferInProgress event happens on Isoc EP with an active transfer.
      This caused a performance degradation of 50%. e.g. using g_webcam on DUT
      and luvcview on host the video frame rate dropped from 16fps to 8fps
      @high-speed.
      
      Make the ISO transfer handling equivalent to that prior to that commit
      to get back the original ISO performance numbers.
      
      Fixes: 08a36b54 ("usb: dwc3: gadget: simplify __dwc3_gadget_ep_queue()")
      Signed-off-by: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      f1d6826c
  16. 11 4月, 2017 6 次提交
  17. 22 3月, 2017 1 次提交
  18. 08 3月, 2017 1 次提交