1. 14 9月, 2016 5 次提交
  2. 09 9月, 2016 1 次提交
    • C
      usb: chipidea: udc: fix NULL ptr dereference in isr_setup_status_phase · 6f3c4fb6
      Clemens Gruber 提交于
      Problems with the signal integrity of the high speed USB data lines or
      noise on reference ground lines can cause the i.MX6 USB controller to
      violate USB specs and exhibit unexpected behavior.
      
      It was observed that USBi_UI interrupts were triggered first and when
      isr_setup_status_phase was called, ci->status was NULL, which lead to a
      NULL pointer dereference kernel panic.
      
      This patch fixes the kernel panic, emits a warning once and returns
      -EPIPE to halt the device and let the host get stalled.
      It also adds a comment to point people, who are experiencing this issue,
      to their USB hardware design.
      
      Cc: <stable@vger.kernel.org> #4.1+
      Signed-off-by: NClemens Gruber <clemens.gruber@pqgruber.com>
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      6f3c4fb6
  3. 19 8月, 2016 1 次提交
  4. 04 3月, 2016 1 次提交
  5. 29 2月, 2016 1 次提交
  6. 24 12月, 2015 3 次提交
  7. 02 12月, 2015 1 次提交
  8. 18 11月, 2015 1 次提交
  9. 15 9月, 2015 1 次提交
    • P
      usb: chipidea: udc: using the correct stall implementation · 56ffa1d1
      Peter Chen 提交于
      According to spec, there are functional and protocol stalls.
      
      For functional stall, it is for bulk and interrupt endpoints,
      below are cases for it:
      - Host sends SET_FEATURE request for Set-Halt, the udc driver
      needs to set stall, and return true unconditionally.
      - The gadget driver may call usb_ep_set_halt to stall certain
      endpoints, if there is a transfer in pending, the udc driver
      should not set stall, and return -EAGAIN accordingly.
      These two kinds of stall need to be cleared by host using CLEAR_FEATURE
      request (Clear-Halt).
      
      For protocol stall, it is for control endpoint, this stall will
      be set if the control request has failed. This stall will be
      cleared by next setup request (hardware will do it).
      
      It fixed usbtest (drivers/usb/misc/usbtest.c) Test 13 "set/clear halt"
      test failure, meanwhile, this change has been verified by
      USB2 CV Compliance Test and MSC Tests.
      
      Cc: <stable@vger.kernel.org> #3.10+
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Felipe Balbi <balbi@ti.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      56ffa1d1
  10. 14 8月, 2015 2 次提交
  11. 05 8月, 2015 1 次提交
  12. 03 8月, 2015 1 次提交
  13. 29 7月, 2015 1 次提交
  14. 08 4月, 2015 1 次提交
    • L
      usb: chipidea: udc: bypass pullup DP when gadget connect in OTG fsm mode · 9b6567e1
      Li Jun 提交于
      By pass pullup DP in OTG fsm mode when do gadget connect, to let it handled
      by OTG state machine.
      
      This patch can fix the problem you found with my HNP polling patchset after
      below 3 patches introduced:
      467a78c8 usb: chipidea: udc: apply new usb_udc_vbus_handler interface
      628ef0d2 usb: udc: add usb_udc_vbus_handler
      dfea9c94 usb: udc: store usb_udc pointer in struct usb_gadget
      
      Problem:
      - Connect USB cable and MicroAB cable between two boards
      - Boot up two boards
      - load g_mass_storage at B-device side, the enumeration will success,
      and A will see a usb mass-storage device
      - load g_mass_storage at A-device side, the problem has occurred, the
      connection will be lost at the beginning, then connect again.
      
      This patch is based on
      commit eff933c1d3a2e046492b3dfc86db813856553a29
      (chipidea: pci: make it depends on NOP_USB_XCEIV)
      on branch peter-usb-dev of
      git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.gitSigned-off-by: NLi Jun <jun.li@freescale.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      9b6567e1
  15. 20 3月, 2015 1 次提交
  16. 18 3月, 2015 2 次提交
    • S
      usb: chipidea: Add errata for revision 2.40a · 06bdfcdb
      Sanchayan Maity 提交于
      At chipidea revision 2.40a, there is a below errata:
      
      9000531823  B2-Medium  Adding a dTD to a Primed Endpoint May Not Get Recognized
      
      Title: Adding a dTD to a Primed Endpoint May Not Get Recognized
      
      Impacted Configuration: All device mode configurations.
      
      Description:
      There is an issue with the add dTD tripwire semaphore (ATDTW bit in USBCMD register)
      that can cause the controller to ignore a dTD that is added to a primed endpoint.
      When this happens, the software can read the tripwire bit and the status bit at '1'
      even though the endpoint is unprimed.
      
      After executing a dTD, the device controller endpoint state machine executes a final
      read of the dTD terminate bit to check if the application added a dTD to the linked
      list at the last moment. This read is done in the finpkt_read_latest_next_td (44) state.
      After the read is performed, if the terminate bit is still set, the state machine moves
      to unprime the endpoint. The decision to unprime the endpoint is done in the
      checkqh_decision (59) state, based on the value of the terminate bit.
      Before reaching the checkqh_decision state, the state machine traverses the
      writeqhtd_status (57), writeqh_status (56), and release_prime_mask (42) states.
      As shown in the waveform, the ep_addtd_tripwire_clr signal is not set to clear
      the tripwire bit in these states.
      
      Workaround:
      The software must implement a periodic poll cycle, and check for each dTD
      pending on execution (Active = 1), if the enpoint is primed. It can do this by reading
      the corresponding bits in the ENDPTPRIME and ENDPTSTAT registers. If these bits are
      read at 0, the software needs to re-prime the endpoint by writing 1 to the corresponding
      bit in the ENDPTPRIME register. This can be done for every microframe, every frame or
      with a larger interval, depending on the urgency of transfer execution for the application.
      Tested-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NSanchayan Maity <maitysanchayan@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06bdfcdb
    • P
      usb: chipidea: udc: return immediately if re-enable non-empty endpoint · d5d1e1be
      Peter Chen 提交于
      Some gadget driver (like uac1) will try to enable endpoint again even
      the ep is not empty, it will cause the ep reset again and may affect
      the dTD list which has already queued.
      
      It returns -EBUSY immediately, and indicate the endpoint is in use.
      In this way, the ep's behavior will not be affected, and the gadget
      driver is also notified.
      
      Cc: Xuebing Wang <xbing6@gmail.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5d1e1be
  17. 15 3月, 2015 1 次提交
    • L
      usb: chipidea: otg: add a_alt_hnp_support response for B device · d20f7807
      Li Jun 提交于
      This patch adds response to a_alt_hnp_support set feature request from legacy
      A device, that is, B-device can provide a message to the user indicating that
      the user needs to connect the B-device to an alternate port on the A-device.
      A device sets this feature indicates to the B-device that it is connected
      to an A-device port that is not capable of HNP, but that the A-device does have
      an alternate port that is capable of HNP.
      
      [Peter]
      Without this patch, the OTG B device can't be enumerated on
      non-HNP port at A device, see below log:
      [    2.287464] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.293105] usb 1-1: can't set HNP mode: -32
      [    2.417422] usb 1-1: new high-speed USB device number 4 using ci_hdrc
      [    2.460635] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.466424] usb 1-1: can't set HNP mode: -32
      [    2.587464] usb 1-1: new high-speed USB device number 5 using ci_hdrc
      [    2.630649] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.636436] usb 1-1: can't set HNP mode: -32
      [    2.641003] usb usb1-port1: unable to enumerate USB device
      
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NLi Jun <b47624@freescale.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d20f7807
  18. 30 1月, 2015 1 次提交
  19. 27 11月, 2014 1 次提交
  20. 11 11月, 2014 1 次提交
  21. 04 11月, 2014 2 次提交
  22. 25 9月, 2014 1 次提交
  23. 18 7月, 2014 1 次提交
    • A
      usb: chipidea: udc: Disable auto ZLP generation on ep0 · 953c6646
      Abbas Raza 提交于
      There are 2 methods for ZLP (zero-length packet) generation:
      1) In software
      2) Automatic generation by device controller
      
      1) is implemented in UDC driver and it attaches ZLP to IN packet if
         descriptor->size < wLength
      2) can be enabled/disabled by setting ZLT bit in the QH
      
      When gadget ffs is connected to ubuntu host, the host sends
      get descriptor request and wLength in setup packet is 255 while the
      size of descriptor which will be sent by gadget in IN packet is
      64 byte. So the composite driver sets req->zero = 1.
      In UDC driver following code will be executed then
      
              if (hwreq->req.zero && hwreq->req.length
                  && (hwreq->req.length % hwep->ep.maxpacket == 0))
                      add_td_to_list(hwep, hwreq, 0);
      
      Case-A:
      So in case of ubuntu host, UDC driver will attach a ZLP to the IN packet.
      ubuntu host will request 255 byte in IN request, gadget will send 64 byte
      with ZLP and host will come to know that there is no more data.
      But hold on, by default ZLT=0 for endpoint 0 so hardware also tries to
      automatically generate the ZLP which blocks enumeration for ~6 seconds due
      to endpoint 0 STALL, NAKs are sent to host for any requests (OUT/PING)
      
      Case-B:
      In case when gadget ffs is connected to Apple device, Apple device sends
      setup packet with wLength=64. So descriptor->size = 64 and wLength=64
      therefore req->zero = 0 and UDC driver will not attach any ZLP to the
      IN packet. Apple device requests 64 bytes, gets 64 bytes and doesn't
      further request for IN data. But ZLT=0 by default for endpoint 0 so
      hardware tries to automatically generate the ZLP which blocks enumeration
      for ~6 seconds due to endpoint 0 STALL, NAKs are sent to host for any
      requests (OUT/PING)
      
      According to USB2.0 specs:
      
          8.5.3.2 Variable-length Data Stage
          A control pipe may have a variable-length data phase in which the
          host requests more data than is contained in the specified data
          structure. When all of the data structure is returned to the host,
          the function should indicate that the Data stage is ended by
          returning a packet that is shorter than the MaxPacketSize for the
          pipe. If the data structure is an exact multiple of wMaxPacketSize
          for the pipe, the function will return a zero-length packet to indicate
          the end of the Data stage.
      
      In Case-A mentioned above:
      If we disable software ZLP generation & ZLT=0 for endpoint 0 OR if software
      ZLP generation is not disabled but we set ZLT=1 for endpoint 0 then
      enumeration doesn't block for 6 seconds.
      
      In Case-B mentioned above:
      If we disable software ZLP generation & ZLT=0 for endpoint then enumeration
      still blocks due to ZLP automatically generated by hardware and host not needing
      it. But if we keep software ZLP generation enabled but we set ZLT=1 for
      endpoint 0 then enumeration doesn't block for 6 seconds.
      
      So the proper solution for this issue seems to disable automatic ZLP generation
      by hardware (i.e by setting ZLT=1 for endpoint 0) and let software (UDC driver)
      handle the ZLP generation based on req->zero field.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAbbas Raza <Abbas_Raza@mentor.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      953c6646
  24. 02 7月, 2014 1 次提交
    • P
      usb: chipidea: udc: delete td from req's td list at ep_dequeue · e4adcff0
      Peter Chen 提交于
      We need to delete un-finished td from current request's td list
      at ep_dequeue API, otherwise, this non-user td will be remained
      at td list before this request is freed. So if we do ep_queue->
      ep_dequeue->ep_queue sequence, when the complete interrupt for
      the second ep_queue comes, we search td list for this request,
      the first td (added by the first ep_queue) will be handled, and
      its status is still active, so we will consider the this transfer
      still not be completed, but in fact, it has completed. It causes
      the peripheral side considers it never receives current data for
      this transfer.
      
      We met this problem when do "Error Recovery Test - Device Configured"
      test item for USBCV2 MSC test, the host has never received ACK for
      the IN token for CSW due to peripheral considers it does not get this
      CBW, the USBCV test log like belows:
      
      --------------------------------------------------------------------------
      INFO
      Issuing BOT MSC Reset, reset should always succeed
      INFO
      Retrieving status on CBW endpoint
      INFO
      CBW endpoint status = 0x0
      INFO
      Retrieving status on CSW endpoint
      INFO
      CSW endpoint status = 0x0
      INFO
      Issuing required command (Test Unit Ready) to verify device has recovered
      INFO
      Issuing CBW (attempt #1):
      INFO
      |----- CBW LUN                  = 0x0
      INFO
      |----- CBW Flags                = 0x0
      INFO
      |----- CBW Data Transfer Length = 0x0
      INFO
      |----- CBW CDB Length           = 0x6
      INFO
      |----- CBW CDB-00 = 0x0
      INFO
      |----- CBW CDB-01 = 0x0
      INFO
      |----- CBW CDB-02 = 0x0
      INFO
      |----- CBW CDB-03 = 0x0
      INFO
      |----- CBW CDB-04 = 0x0
      INFO
      |----- CBW CDB-05 = 0x0
      INFO
      Issuing CSW : try 1
      INFO
      CSW Bulk Request timed out!
      ERROR
      Failed CSW phase : should have been success or stall
      FAIL
      (5.3.4) The CSW status value must be 0x00, 0x01, or 0x02.
      ERROR
      BOTCommonMSCRequest failed:  error=80004000
      
      Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4adcff0
  25. 23 5月, 2014 2 次提交
  26. 25 4月, 2014 4 次提交
  27. 13 3月, 2014 1 次提交