1. 20 6月, 2019 1 次提交
  2. 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
  3. 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
  4. 13 2月, 2019 2 次提交
  5. 04 2月, 2019 3 次提交
  6. 01 2月, 2019 1 次提交
  7. 28 1月, 2019 5 次提交
  8. 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
  9. 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
  10. 05 12月, 2018 4 次提交
  11. 27 11月, 2018 1 次提交
    • F
      usb: dwc3: gadget: check if dep->frame_number is still valid · d5370106
      Felipe Balbi 提交于
      Gadget driver may take an unbounded amount of time to queue requests
      after XferNotReady. This is important for isochronous endpoints which
      need to be started for a specific (micro-)frame.
      
      If we fail to start a transfer for isochronous endpoint, let's try
      queueing to a future interval and see if that helps. We will stop trying
      if we fail a start transfer for 5 intervals in the future.
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      d5370106
  12. 26 11月, 2018 11 次提交
  13. 14 11月, 2018 1 次提交
  14. 06 11月, 2018 1 次提交
    • T
      usb: dwc3: gadget: Properly check last unaligned/zero chain TRB · ba3a51ac
      Thinh Nguyen 提交于
      Current check for the last extra TRB for zero and unaligned transfers
      does not account for isoc OUT. The last TRB of the Buffer Descriptor for
      isoc OUT transfers will be retired with HWO=0. As a result, we won't
      return early. The req->remaining will be updated to include the BUFSIZ
      count of the extra TRB, and the actual number of transferred bytes
      calculation will be wrong.
      
      To fix this, check whether it's a short or zero packet and the last TRB
      chain bit to return early.
      
      Fixes: c6267a51 ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      ba3a51ac
  15. 02 10月, 2018 1 次提交
  16. 05 9月, 2018 1 次提交