1. 02 10月, 2020 18 次提交
  2. 24 9月, 2020 2 次提交
    • T
      usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command · d97c78a1
      Thinh Nguyen 提交于
      According the programming guide (for all DWC3 IPs), when the driver
      handles ClearFeature(halt) request, it should issue CLEAR_STALL command
      _after_ the END_TRANSFER command completes. The END_TRANSFER command may
      take some time to complete. So, delay the ClearFeature(halt) request
      control status stage and wait for END_TRANSFER command completion
      interrupt. Only after END_TRANSFER command completes that the driver
      may issue CLEAR_STALL command.
      
      Cc: stable@vger.kernel.org
      Fixes: cb11ea56 ("usb: dwc3: gadget: Properly handle ClearFeature(halt)")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      d97c78a1
    • T
      usb: dwc3: gadget: Resume pending requests after CLEAR_STALL · c503672a
      Thinh Nguyen 提交于
      The function driver may queue new requests right after halting the
      endpoint (i.e. queue new requests while the endpoint is stalled).
      There's no restriction preventing it from doing so. However, dwc3
      currently drops those requests after CLEAR_STALL. The driver should only
      drop started requests. Keep the pending requests in the pending list to
      resume and process them after the host issues ClearFeature(Halt) to the
      endpoint.
      
      Cc: stable@vger.kernel.org
      Fixes: cb11ea56 ("usb: dwc3: gadget: Properly handle ClearFeature(halt)")
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      c503672a
  3. 17 8月, 2020 3 次提交
  4. 24 7月, 2020 3 次提交
  5. 15 7月, 2020 1 次提交
  6. 24 6月, 2020 1 次提交
  7. 25 5月, 2020 12 次提交
    • T
      usb: dwc3: gadget: Check for prepared TRBs · 63c7bb29
      Thinh Nguyen 提交于
      There are cases where the endpoint needs to be restarted. For example,
      it may need to restart for NoStream rejection to reinitiate stream. If
      so, check and make sure we don't prepare beyond the current transfer
      when we restart the endpoint.
      
      DWC_usb32 internal burst transfer feature will look into TRBs beyond a
      transfer. Other controllers will stop on the last TRB, but not
      DWC_usb32. This may cause the controller to incorrectly process TRBs of
      a different transfer. Make sure to explicitly prevent preparing TRBs of
      a different transfer.
      
      This should only affect DWC_usb32 releases prior to v1.00a since it
      doesn't use SET_ENDPOINT_PRIME to reinitiate stream. However, it's
      better to be cautious in case users don't want to use SET_ENDPOINT_PRIME
      command. Also, it's possible other controller IPs may share the same
      features as DWC_usb32 in new releases.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      63c7bb29
    • Y
      usb: dwc3: Increase timeout for CmdAct cleared by device controller · 1c0e69ae
      Yu Chen 提交于
      If the SS PHY is in P3, there is no pipe_clk, HW may use suspend_clk
      for function, as suspend_clk is slow so EP command need more time to
      complete, e.g, imx8M suspend_clk is 32K, set ep configuration will
      take about 380us per below trace time stamp(44.286278 - 44.285897
      = 0.000381):
      
      configfs_acm.sh-822   [000] d..1    44.285896: dwc3_writel: addr
      000000006d59aae1 value 00000401
      configfs_acm.sh-822   [000] d..1    44.285897: dwc3_readl: addr
      000000006d59aae1 value 00000401
      ... ...
      configfs_acm.sh-822   [000] d..1    44.286278: dwc3_readl: addr
      000000006d59aae1 value 00000001
      configfs_acm.sh-822   [000] d..1    44.286279: dwc3_gadget_ep_cmd:
      ep0out: cmd 'Set Endpoint Configuration' [401] params 00001000
      00000500 00000000 --> status: Successful
      
      This was originally found on Hisilicon Kirin Soc that need more time
      for the device controller to clear the CmdAct of DEPCMD.
      Signed-off-by: NYu Chen <chenyu56@huawei.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: NLi Jun <jun.li@nxp.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      1c0e69ae
    • T
      usb: dwc3: gadget: Use SET_EP_PRIME for NoStream · b10e1c25
      Thinh Nguyen 提交于
      DWC_usb32 v1.00a and later can use SET_EP_PRIME command to reinitiate a
      stream. Use the command to handle NoStream rejection instead of ending
      and restarting the endpoint.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      b10e1c25
    • T
      usb: dwc3: gadget: Handle stream transfers · 140ca4cf
      Thinh Nguyen 提交于
      Overview of stream transfer requirement:
       * A transfer will have a set of TRBs of the same stream ID.
       * A transfer is started with a stream ID in START_TRANSFER command.
       * A new stream will only start when the previous completes.
      
      Overview of stream events:
       * A "prime" from host indicates that its endpoints are active
         (buffers prepared and ready to receive/transmit data). The controller
         automatically initiates stream if it sees this.
       * A "NoStream" rejection event indicates that the host isn't ready.
         Host will put the endpoint back to idle state. Device may need to
         reinitiate the stream to start transfer again.
       * A Stream Found event means host accepted device initiated stream.
         Nothing needs to be done from driver.
      
      To initiate a stream, the driver will issue START_TRANSFER command with
      a stream ID. To reinitiate the stream, the driver must issue
      END_TRANSFER and restart the transfer with START_TRANSFER command with
      the same stream ID.
      
      This implementation handles device-initated streams (e.g. UASP driver).
      It also handles some hosts' quirky behavior where they only prime each
      endpoint once.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      140ca4cf
    • T
      usb: dwc3: gadget: Don't prepare beyond a transfer · aefe3d23
      Thinh Nguyen 提交于
      Don't prepare TRBs beyond a transfer. In DWC_usb32, its transfer burst
      capability may try to read and use TRBs beyond the active transfer. For
      other controllers, they don't process the next transfer TRBs until the
      current transfer is completed. Explicitly prevent preparing TRBs ahead
      for all controllers.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      aefe3d23
    • T
      usb: dwc3: gadget: Wait for transfer completion · e0d19563
      Thinh Nguyen 提交于
      If a transfer is in-progress, any new request should not kick off
      another transfer. The driver needs to wait for the current transfer to
      complete before starting off the next transfer. Introduce a new flag
      DWC3_EP_WAIT_TRANSFER_COMPLETE for this.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      e0d19563
    • T
      usb: dwc3: gadget: Handle XferComplete for streams · 3eaecd0c
      Thinh Nguyen 提交于
      In DWC3, to prepare TRBs for streams, all the TRBs of a transfer will
      use the same stream ID. To start a new stream, the driver needs to wait
      for the current transfer to complete or ended (by END_TRANFER command).
      As a result, inform the controller of the last TRB of a transfer so that
      it knows when a transfer completes and start a new transfer of a new
      stream.
      
      Even though the transfer completion handling can be applied for other
      non-isoc endpoints, only do it for streams due to its requirement.
      It's better to keep the controller's TRB cache full than waiting for
      transfer completion and starting a new transfer.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      3eaecd0c
    • T
      usb: dwc3: gadget: Enable XferComplete event · 548f8b31
      Thinh Nguyen 提交于
      To switch from one stream to another, this requires the driver to start
      a new transfer with a specific stream ID. For a transfer to complete,
      the driver needs to indicate the last TRB of a transfer, and it needs to
      enable XferComplete event to handle completed TRBs of a transfer. Let's
      enable this event only for stream capable endpoints.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      548f8b31
    • T
      usb: dwc3: gadget: Refactor TRB completion handler · 2e6e9e4b
      Thinh Nguyen 提交于
      To prepare for handling of XferComplete event, let's refactor and split
      up dwc3_gadget_endpoint_transfer_in_progress() to handle TRBs completion
      for different events. The handling of TRBs completion will be the same,
      but the status of XferComplete event is different than XferInProgress.
      No functional change in this commit.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      2e6e9e4b
    • T
      usb: dwc3: gadget: Check for in-progress END_TRANSFER · b6842d49
      Thinh Nguyen 提交于
      While handling TRBs completion, if a END_TRANSFER command isn't
      completed, don't kick new transfer or issue END_TRANSFER command.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      b6842d49
    • T
      usb: dwc3: Get MDWIDTH for DWC_usb32 · 4244ba02
      Thinh Nguyen 提交于
      DWC_usb32 supports MDWIDTH value larger than 255 and up to 1023. The
      field HWPARAMS6[9:8] stores the upper 2-bit values of the DWC_usb32's
      MDWIDTH. Check that parameter and properly get the MDWIDTH for
      DWC_usb32.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      4244ba02
    • T
      usb: dwc3: Add support for DWC_usb32 IP · 9af21dd6
      Thinh Nguyen 提交于
      Synopsys introduces a new controller DWC_usb32. It supports dual-lane
      and speed up to 20 Gbps, and the DWC3 driver will drive this controller.
      Currently the driver uses a single field dwc->revision to ID both
      DWC_usb3 and DWC_usb31 and their version number. This was sufficient for
      two IPs, but this method doesn't work with additional IPs. As a result,
      let's separate the dwc->revision field to 2 separate fields: ip and
      revision. The ip field now stores the ID of the controller's IP while
      the revision field stores the controller's version number.
      
      This new scheme enforces DWC3 to compare the revision within the same IP
      only. As a result, we must update all the revision check of the
      controller to check its corresponding IP.
      
      To help with this enforcement, we create a few macros to help with
      the common version checks:
      
      DWC3_IP_IS(IP)
      DWC3_VER_IS(IP, VERSION)
      DWC3_VER_IS_PRIOR(IP, VERSION)
      DWC3_VER_IS_WITHIN(IP, LOWER_VERSION, UPPER_VERSION)
      DWC3_VER_TYPE_IS_WITHIN(IP, VERSION,
      			LOWER_VERSION_TYPE,
      			UPPER_VERSION_TYPE)
      
      The DWC_usb32 controller operates using the same programming model and
      with very similar configurations as its previous controllers. Please
      note that the various IP and revision checks in this patch match the
      current checks for DWC_usb31 version 1.90a. Additional configurations
      that are unique to DWC_usb32 are applied separately.
      Signed-off-by: NThinh Nguyen <thinhn@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@kernel.org>
      9af21dd6