1. 05 5月, 2020 4 次提交
  2. 17 4月, 2020 1 次提交
    • T
      usb: dwc3: gadget: Fix request completion check · 49e0590e
      Thinh Nguyen 提交于
      A request may not be completed because not all the TRBs are prepared for
      it. This happens when we run out of available TRBs. When some TRBs are
      completed, the driver needs to prepare the rest of the TRBs for the
      request. The check dwc3_gadget_ep_request_completed() shouldn't be
      checking the amount of data received but rather the number of pending
      TRBs. Revise this request completion check.
      
      Cc: stable@vger.kernel.org
      Fixes: e0c42ce5 ("usb: dwc3: gadget: simplify IOC handling")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      49e0590e
  3. 16 4月, 2020 3 次提交
    • T
      usb: dwc3: gadget: Do link recovery for SS and SSP · d0550cd2
      Thinh Nguyen 提交于
      The controller always supports link recovery for device in SS and SSP.
      Remove the speed limit check. Also, when the device is in RESUME or
      RESET state, it means the controller received the resume/reset request.
      The driver must send the link recovery to acknowledge the request. They
      are valid states for the driver to send link recovery.
      
      Fixes: 72246da4 ("usb: Introduce DesignWare USB3 DRD Driver")
      Fixes: ee5cd41c ("usb: dwc3: Update speed checks for SuperSpeedPlus")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      d0550cd2
    • T
      usb: dwc3: gadget: Properly set maxpacket limit · d94ea531
      Thinh Nguyen 提交于
      Currently the calculation of max packet size limit for IN endpoints is
      too restrictive. This prevents a matching of a capable hardware endpoint
      during configuration. Below is the minimum recommended HW configuration
      to support a particular endpoint setup from the databook:
      
      For OUT endpoints, the databook recommended the minimum RxFIFO size to
      be at least 3x MaxPacketSize + 3x setup packets size (8 bytes each) +
      clock crossing margin (16 bytes).
      
      For IN endpoints, the databook recommended the minimum TxFIFO size to be
      at least 3x MaxPacketSize for endpoints that support burst. If the
      endpoint doesn't support burst or when the device is operating in USB
      2.0 mode, a minimum TxFIFO size of 2x MaxPacketSize is recommended.
      
      Base on these recommendations, we can calculate the MaxPacketSize limit
      of each endpoint. This patch revises the IN endpoint MaxPacketSize limit
      and also sets the MaxPacketSize limit for OUT endpoints.
      
      Reference: Databook 3.30a section 3.2.2 and 3.2.3
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      d94ea531
    • T
      usb: dwc3: Fix GTXFIFOSIZ.TXFDEP macro name · 586f4335
      Thinh Nguyen 提交于
      Change the macro name DWC3_GTXFIFOSIZ_TXFDEF to DWC3_GTXFIFOSIZ_TXFDEP
      to match with the register name GTXFIFOSIZ.TXFDEP.
      
      Fixes: 457e84b6 ("usb: dwc3: gadget: dynamically re-size TxFifos")
      Fixes: 0cab8d26 ("usb: dwc3: Update DWC_usb31 GTXFIFOSIZ reg fields")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      586f4335
  4. 15 3月, 2020 2 次提交
  5. 04 3月, 2020 1 次提交
    • P
      usb: dwc3: gadget: Update chain bit correctly when using sg list · dad2aff3
      Pratham Pratap 提交于
      If scatter-gather operation is allowed, a large USB request is split
      into multiple TRBs. For preparing TRBs for sg list, driver iterates
      over the list and creates TRB for each sg and mark the chain bit to
      false for the last sg. The current IOMMU driver is clubbing the list
      of sgs which shares a page boundary into one and giving it to USB driver.
      With this the number of sgs mapped it not equal to the the number of sgs
      passed. Because of this USB driver is not marking the chain bit to false
      since it couldn't iterate to the last sg. This patch addresses this issue
      by marking the chain bit to false if it is the last mapped sg.
      
      At a practical level, this patch resolves USB transfer stalls
      seen with adb on dwc3 based db845c, pixel3 and other qcom
      hardware after functionfs gadget added scatter-gather support
      around v4.20.
      
      Credit also to Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
      who implemented a very similar fix to this issue.
      
      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> #4.20+
      Signed-off-by: NPratham Pratap <prathampratap@codeaurora.org>
      [jstultz: Slight tweak to remove sg_is_last() usage, reworked
                commit message, minor comment tweak]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Link: https://lore.kernel.org/r/20200302214443.55783-1-john.stultz@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dad2aff3
  6. 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
  7. 15 1月, 2020 6 次提交
  8. 31 12月, 2019 1 次提交
  9. 10 12月, 2019 2 次提交
  10. 01 11月, 2019 1 次提交
  11. 07 10月, 2019 2 次提交
  12. 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
  13. 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
  14. 20 6月, 2019 1 次提交
  15. 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
  16. 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
  17. 13 2月, 2019 2 次提交
  18. 04 2月, 2019 3 次提交
  19. 01 2月, 2019 1 次提交
  20. 28 1月, 2019 1 次提交