1. 11 2月, 2020 1 次提交
    • A
      usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields · 5ee85897
      Anurag Kumar Vulisha 提交于
      The current code in dwc3_gadget_ep_reclaim_completed_trb() will
      check for IOC/LST bit in the event->status and returns if
      IOC/LST bit is set. This logic doesn't work if multiple TRBs
      are queued per request and the IOC/LST bit is set on the last
      TRB of that request.
      
      Consider an example where a queued request has multiple queued
      TRBs and IOC/LST bit is set only for the last TRB. In this case,
      the core generates XferComplete/XferInProgress events only for
      the last TRB (since IOC/LST are set only for the last TRB). As
      per the logic in dwc3_gadget_ep_reclaim_completed_trb()
      event->status is checked for IOC/LST bit and returns on the
      first TRB. This leaves the remaining TRBs left unhandled.
      
      Similarly, if the gadget function enqueues an unaligned request
      with sglist already in it, it should fail the same way, since we
      will append another TRB to something that already uses more than
      one TRB.
      
      To aviod this, this patch changes the code to check for IOC/LST
      bits in TRB->ctrl instead.
      
      At a practical level, this patch resolves USB transfer stalls seen
      with adb on dwc3 based HiKey960 after functionfs gadget added
      scatter-gather support around v4.20.
      
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Yang Fei <fei.yang@intel.com>
      Cc: Thinh Nguyen <thinhn@synopsys.com>
      Cc: Tejas Joglekar <tejas.joglekar@synopsys.com>
      Cc: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
      Cc: Jack Pham <jackp@codeaurora.org>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Linux USB List <linux-usb@vger.kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Tested-by: NTejas Joglekar <tejas.joglekar@synopsys.com>
      Reviewed-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
      [jstultz: forward ported to mainline, reworded commit log, reworked
       to only check trb->ctrl as suggested by Felipe]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      5ee85897
  2. 15 1月, 2020 6 次提交
  3. 31 12月, 2019 1 次提交
  4. 10 12月, 2019 2 次提交
  5. 01 11月, 2019 1 次提交
  6. 07 10月, 2019 2 次提交
  7. 30 8月, 2019 1 次提交
    • T
      usb: dwc3: gadget: Workaround Mirosoft's BESL check · 17b63704
      Thinh Nguyen 提交于
      While testing our host system using Microsoft's usb stack against our
      gadget for various BESL values, we found an issue with their usb stack
      when the recommended baseline BESL value is 0 (125us) or when the deep
      BESL is 1 or less. The Windows host will issue a usb reset immediately
      after it receives the extended BOS descriptor and the enumeration will
      fail after a few attempts.
      
      To keep compatibility with Microsoft's host usb stack, let's workaround
      this issue by using the recommended baseline BESL of 1 (or 150us)
      and clamp the deep BESL value within 2 to 15.
      
      This was tested against Windows 10 build 18956.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      17b63704
  8. 28 8月, 2019 3 次提交
    • T
      usb: dwc3: gadget: Set BESL config parameter · 54fb5ba6
      Thinh Nguyen 提交于
      When operating with LPM signals, the controller asserts the deep
      low-power signal (utmi_l1_suspend_n) to the phy when the BESL value of
      the LPM token is equal to or greater than DCTL.HIRD_Thres[3:0] (and
      with DCTL.HIRD_Thres[4] set). Otherwise, the shallow low-power signal
      (utmi_sleep_n) is asserted. Set the recommended deep BESL equal to the
      controller's DCTL.HIRD_Thres[3:0] setting, and set the baseline BESL
      to 0 for the shallow low-power signal. This maximizes the opportunity
      for L1 residency and optimizes power savings.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      54fb5ba6
    • T
      usb: dwc3: Separate field holding multiple properties · 16fe4f30
      Thinh Nguyen 提交于
      dwc->hird_threshold field should store "snps,hird_threshold" property
      only and not a combination of multiple properties. Remove the value of
      "snps,is-utmi-l1-suspend" property from the field dwc->hird_threshold.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      16fe4f30
    • R
      usb: dwc3: don't set gadget->is_otg flag · c09b73cf
      Roger Quadros 提交于
      This reverts
      commit 6a4290cc ("usb: dwc3: gadget: set the OTG flag in dwc3 gadget driver.")
      
      We don't yet support any of the OTG mechanisms (HNP/SRP/ADP)
      and are not setting gadget->otg_caps, so don't set gadget->is_otg
      flag.
      
      If we do then we end up publishing a OTG1.0 descriptor in
      the gadget descriptor which causes device enumeration to fail
      if we are connected to a host with CONFIG_USB_OTG enabled.
      
      Host side log without this patch
      
      [   96.720453] usb 1-1: new high-speed USB device number 2 using xhci-hcd
      [   96.901391] usb 1-1: Dual-Role OTG device on non-HNP port
      [   96.907552] usb 1-1: set a_alt_hnp_support failed: -32
      [   97.060447] usb 1-1: new high-speed USB device number 3 using xhci-hcd
      [   97.241378] usb 1-1: Dual-Role OTG device on non-HNP port
      [   97.247536] usb 1-1: set a_alt_hnp_support failed: -32
      [   97.253606] usb usb1-port1: attempt power cycle
      [   97.960449] usb 1-1: new high-speed USB device number 4 using xhci-hcd
      [   98.141383] usb 1-1: Dual-Role OTG device on non-HNP port
      [   98.147540] usb 1-1: set a_alt_hnp_support failed: -32
      [   98.300453] usb 1-1: new high-speed USB device number 5 using xhci-hcd
      [   98.481391] usb 1-1: Dual-Role OTG device on non-HNP port
      [   98.487545] usb 1-1: set a_alt_hnp_support failed: -32
      [   98.493532] usb usb1-port1: unable to enumerate USB device
      Signed-off-by: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      c09b73cf
  9. 20 6月, 2019 1 次提交
  10. 18 6月, 2019 1 次提交
    • A
      usb: dwc3: gadget: Add support for disabling U1 and U2 entries · 729dcffd
      Anurag Kumar Vulisha 提交于
      Gadget applications may have a requirement to disable the U1 and U2
      entry based on the usecase. Below are few usecases where the disabling
      U1/U2 entries may be possible.
      
      Usecase 1:
      When combining dwc3 with an redriver for a USB Type-C device solution, it
      sometimes have problems with leaving U1/U2 for certain hosts, resulting in
      link training errors and reconnects. For this U1/U2 state entries may be
      avoided.
      
      Usecase 2:
      When performing performance benchmarking on mass storage gadget the
      U1 and U2 entries can be disabled.
      
      Usecase 3:
      When periodic transfers like ISOC transfers are used with bInterval
      of 1 which doesn't require the link to enter into U1 or U2 state entry
      (since ping is issued from host for every uframe interval). In this
      case the U1 and U2 entry can be disabled.
      
      Disablement of U1/U2 can be done by setting U1DevExitLat and U2DevExitLat
      values to 0 in the BOS descriptor. Host on seeing 0 value for U1DevExitLat
      and U2DevExitLat, it doesn't send SET_SEL requests to the gadget. There
      may be some hosts which may send SET_SEL requests even after seeing 0 in
      the UxDevExitLat of BOS descriptor. To aviod U1/U2 entries for these type
      of hosts, dwc3 controller can be programmed to reject those U1/U2 requests
      by not enabling ACCEPTUxENA bits in DCTL register.
      
      This patch updates the same.
      Signed-off-by: NAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
      Signed-off-by: NClaus H. Stovgaard <cst@phaseone.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      729dcffd
  11. 03 5月, 2019 3 次提交
    • T
      usb: dwc3: Rename DWC3_DCTL_LPM_ERRATA · 2e487d28
      Thinh Nguyen 提交于
      The macro name DWC3_DCTL_LPM_ERRATA is uninformative and does not do
      masking. Remove DWC3_DCTL_LPM_ERRATA_MASK and rename
      DWC3_DCTL_LPM_ERRATA to DWC3_DCTL_NYET_THRES with proper masking.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      2e487d28
    • T
      usb: dwc3: gadget: Set lpm_capable · c729969b
      Thinh Nguyen 提交于
      All DWC3 controllers are LPM capable. Report that in the
      usb_gadget.lpm_capable for the gadget driver to properly output the
      bcdUSB value in the descriptor.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      c729969b
    • M
      usb: dwc3: move synchronize_irq() out of the spinlock protected block · 41a91c60
      Marek Szyprowski 提交于
      dwc3_gadget_suspend() is called under dwc->lock spinlock. In such context
      calling synchronize_irq() is not allowed. Move the problematic call out
      of the protected block to fix the following kernel BUG during system
      suspend:
      
      BUG: sleeping function called from invalid context at kernel/irq/manage.c:112
      in_atomic(): 1, irqs_disabled(): 128, pid: 1601, name: rtcwake
      6 locks held by rtcwake/1601:
       #0: f70ac2a2 (sb_writers#7){.+.+}, at: vfs_write+0x130/0x16c
       #1: b5fe1270 (&of->mutex){+.+.}, at: kernfs_fop_write+0xc0/0x1e4
       #2: 7e597705 (kn->count#60){.+.+}, at: kernfs_fop_write+0xc8/0x1e4
       #3: 8b3527d0 (system_transition_mutex){+.+.}, at: pm_suspend+0xc4/0xc04
       #4: fc7f1c42 (&dev->mutex){....}, at: __device_suspend+0xd8/0x74c
       #5: 4b36507e (&(&dwc->lock)->rlock){....}, at: dwc3_gadget_suspend+0x24/0x3c
      irq event stamp: 11252
      hardirqs last  enabled at (11251): [<c09c54a4>] _raw_spin_unlock_irqrestore+0x6c/0x74
      hardirqs last disabled at (11252): [<c09c4d44>] _raw_spin_lock_irqsave+0x1c/0x5c
      softirqs last  enabled at (9744): [<c0102564>] __do_softirq+0x3a4/0x66c
      softirqs last disabled at (9737): [<c0128528>] irq_exit+0x140/0x168
      Preemption disabled at:
      [<00000000>]   (null)
      CPU: 7 PID: 1601 Comm: rtcwake Not tainted
      5.0.0-rc3-next-20190122-00039-ga3f4ee4f8a52 #5252
      Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
      [<c01110f0>] (unwind_backtrace) from [<c010d120>] (show_stack+0x10/0x14)
      [<c010d120>] (show_stack) from [<c09a4d04>] (dump_stack+0x90/0xc8)
      [<c09a4d04>] (dump_stack) from [<c014c700>] (___might_sleep+0x22c/0x2c8)
      [<c014c700>] (___might_sleep) from [<c0189d68>] (synchronize_irq+0x28/0x84)
      [<c0189d68>] (synchronize_irq) from [<c05cbbf8>] (dwc3_gadget_suspend+0x34/0x3c)
      [<c05cbbf8>] (dwc3_gadget_suspend) from [<c05bd020>] (dwc3_suspend_common+0x154/0x410)
      [<c05bd020>] (dwc3_suspend_common) from [<c05bd34c>] (dwc3_suspend+0x14/0x2c)
      [<c05bd34c>] (dwc3_suspend) from [<c051c730>] (platform_pm_suspend+0x2c/0x54)
      [<c051c730>] (platform_pm_suspend) from [<c05285d4>] (dpm_run_callback+0xa4/0x3dc)
      [<c05285d4>] (dpm_run_callback) from [<c0528a40>] (__device_suspend+0x134/0x74c)
      [<c0528a40>] (__device_suspend) from [<c052c508>] (dpm_suspend+0x174/0x588)
      [<c052c508>] (dpm_suspend) from [<c0182134>] (suspend_devices_and_enter+0xc0/0xe74)
      [<c0182134>] (suspend_devices_and_enter) from [<c0183658>] (pm_suspend+0x770/0xc04)
      [<c0183658>] (pm_suspend) from [<c0180ddc>] (state_store+0x6c/0xcc)
      [<c0180ddc>] (state_store) from [<c09a9a70>] (kobj_attr_store+0x14/0x20)
      [<c09a9a70>] (kobj_attr_store) from [<c02d6800>] (sysfs_kf_write+0x4c/0x50)
      [<c02d6800>] (sysfs_kf_write) from [<c02d594c>] (kernfs_fop_write+0xfc/0x1e4)
      [<c02d594c>] (kernfs_fop_write) from [<c02593d8>] (__vfs_write+0x2c/0x160)
      [<c02593d8>] (__vfs_write) from [<c0259694>] (vfs_write+0xa4/0x16c)
      [<c0259694>] (vfs_write) from [<c0259870>] (ksys_write+0x40/0x8c)
      [<c0259870>] (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
      Exception stack(0xed55ffa8 to 0xed55fff0)
      ...
      
      Fixes: 01c10880 ("usb: dwc3: gadget: synchronize_irq dwc irq in suspend")
      Signed-off-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      41a91c60
  12. 13 2月, 2019 2 次提交
  13. 04 2月, 2019 3 次提交
  14. 01 2月, 2019 1 次提交
  15. 28 1月, 2019 5 次提交
  16. 14 1月, 2019 3 次提交
    • Z
      usb: dwc3: gadget: Fix the uninitialized link_state when udc starts · 88b1bb1f
      Zeng Tao 提交于
      Currently the link_state is uninitialized and the default value is 0(U0)
      before the first time we start the udc, and after we start the udc then
       stop the udc, the link_state will be undefined.
      We may have the following warnings if we start the udc again with
      an undefined link_state:
      
      WARNING: CPU: 0 PID: 327 at drivers/usb/dwc3/gadget.c:294 dwc3_send_gadget_ep_cmd+0x304/0x308
      dwc3 100e0000.hidwc3_0: wakeup failed --> -22
      [...]
      Call Trace:
      [<c010f270>] (unwind_backtrace) from [<c010b3d8>] (show_stack+0x10/0x14)
      [<c010b3d8>] (show_stack) from [<c034a4dc>] (dump_stack+0x84/0x98)
      [<c034a4dc>] (dump_stack) from [<c0118000>] (__warn+0xe8/0x100)
      [<c0118000>] (__warn) from [<c0118050>](warn_slowpath_fmt+0x38/0x48)
      [<c0118050>] (warn_slowpath_fmt) from [<c0442ec0>](dwc3_send_gadget_ep_cmd+0x304/0x308)
      [<c0442ec0>] (dwc3_send_gadget_ep_cmd) from [<c0445e68>](dwc3_ep0_start_trans+0x48/0xf4)
      [<c0445e68>] (dwc3_ep0_start_trans) from [<c0446750>](dwc3_ep0_out_start+0x64/0x80)
      [<c0446750>] (dwc3_ep0_out_start) from [<c04451c0>](__dwc3_gadget_start+0x1e0/0x278)
      [<c04451c0>] (__dwc3_gadget_start) from [<c04452e0>](dwc3_gadget_start+0x88/0x10c)
      [<c04452e0>] (dwc3_gadget_start) from [<c045ee54>](udc_bind_to_driver+0x88/0xbc)
      [<c045ee54>] (udc_bind_to_driver) from [<c045f29c>](usb_gadget_probe_driver+0xf8/0x140)
      [<c045f29c>] (usb_gadget_probe_driver) from [<bf005424>](gadget_dev_desc_UDC_store+0xac/0xc4 [libcomposite])
      [<bf005424>] (gadget_dev_desc_UDC_store [libcomposite]) from[<c023d8e0>] (configfs_write_file+0xd4/0x160)
      [<c023d8e0>] (configfs_write_file) from [<c01d51e8>] (__vfs_write+0x1c/0x114)
      [<c01d51e8>] (__vfs_write) from [<c01d5ff4>] (vfs_write+0xa4/0x168)
      [<c01d5ff4>] (vfs_write) from [<c01d6d40>] (SyS_write+0x3c/0x90)
      [<c01d6d40>] (SyS_write) from [<c0107400>] (ret_fast_syscall+0x0/0x3c)
      Signed-off-by: NZeng Tao <prime.zeng@hisilicon.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      88b1bb1f
    • J
      usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup · bd674224
      Jack Pham 提交于
      OUT endpoint requests may somtimes have this flag set when
      preparing to be submitted to HW indicating that there is an
      additional TRB chained to the request for alignment purposes.
      If that request is removed before the controller can execute the
      transfer (e.g. ep_dequeue/ep_disable), the request will not go
      through the dwc3_gadget_ep_cleanup_completed_request() handler
      and will not have its needs_extra_trb flag cleared when
      dwc3_gadget_giveback() is called.  This same request could be
      later requeued for a new transfer that does not require an
      extra TRB and if it is successfully completed, the cleanup
      and TRB reclamation will incorrectly process the additional TRB
      which belongs to the next request, and incorrectly advances the
      TRB dequeue pointer, thereby messing up calculation of the next
      requeust's actual/remaining count when it completes.
      
      The right thing to do here is to ensure that the flag is cleared
      before it is given back to the function driver.  A good place
      to do that is in dwc3_gadget_del_and_unmap_request().
      
      Fixes: c6267a51 ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
      Cc: stable@vger.kernel.org
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      bd674224
    • B
      usb: dwc3: gadget: synchronize_irq dwc irq in suspend · 01c10880
      Bo He 提交于
      We see dwc3 endpoint stopped by unwanted irq during
      suspend resume test, which is caused dwc3 ep can't be started
      with error "No Resource".
      
      Here, add synchronize_irq before suspend to sync the
      pending IRQ handlers complete.
      Signed-off-by: NBo He <bo.he@intel.com>
      Signed-off-by: NYu Wang <yu.y.wang@intel.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      01c10880
  17. 10 12月, 2018 1 次提交
    • T
      usb: dwc3: gadget: Disable CSP for stream OUT ep · 244add8e
      Tejas Joglekar 提交于
      In stream mode, when fast-forwarding TRBs, the stream number
      is not cleared causing the new stream to not get assigned. So
      we don't want controller to carry on transfers when short packet
      is received. So disable the CSP for stream capable endpoint.
      
      This is based on the 3.30a Programming guide, where table 3-1
      device descriptor structure field definitions says for CSP bit
      If this bit is 0, the controller generates an XferComplete event
      and remove the stream. So if we keep CSP as 1 then switching between
      streams would not happen as in stream mode, when fast-forwarding
      TRBs, the stream number is not cleared causing the new stream to not get
      assigned.
      Signed-off-by: NTejas Joglekar <joglekar@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      244add8e
  18. 05 12月, 2018 3 次提交