1. 25 1月, 2017 3 次提交
  2. 04 1月, 2017 2 次提交
    • O
      xhci: Fix race related to abort operation · 1c111b6c
      OGAWA Hirofumi 提交于
      Current abort operation has race.
      
          xhci_handle_command_timeout()
            xhci_abort_cmd_ring()
              xhci_write_64(CMD_RING_ABORT)
              xhci_handshake(5s)
      	  do {
      	    check CMD_RING_RUNNING
                  udelay(1)
      					 ...
      					 COMP_CMD_ABORT event
      					 COMP_CMD_STOP event
      					 xhci_handle_stopped_cmd_ring()
      					   restart cmd_ring
                                                 CMD_RING_RUNNING become 1 again
      	  } while ()
                return -ETIMEDOUT
              xhci_write_64(CMD_RING_ABORT)
              /* can abort random command */
      
      To do abort operation correctly, we have to wait both of COMP_CMD_STOP
      event and negation of CMD_RING_RUNNING.
      
      But like above, while timeout handler is waiting negation of
      CMD_RING_RUNNING, event handler can restart cmd_ring. So timeout
      handler never be notice negation of CMD_RING_RUNNING, and retry of
      CMD_RING_ABORT can abort random command (BTW, I guess retry of
      CMD_RING_ABORT was workaround of this race).
      
      To fix this race, this moves xhci_handle_stopped_cmd_ring() to
      xhci_abort_cmd_ring().  And timeout handler waits COMP_CMD_STOP event.
      
      At this point, timeout handler is owner of cmd_ring, and safely
      restart cmd_ring by using xhci_handle_stopped_cmd_ring().
      
      [FWIW, as bonus, this way would be easily extend to add CMD_RING_PAUSE
      operation]
      
      [locks edited as patch is rebased on other locking fixes -Mathias]
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c111b6c
    • O
      xhci: Use delayed_work instead of timer for command timeout · cb4d5ce5
      OGAWA Hirofumi 提交于
      This is preparation to fix abort operation race (See "xhci: Fix race
      related to abort operation"). To make timeout sleepable, use
      delayed_work instead of timer.
      
      [change a newly added pending timer fix to pending work -Mathias]
      Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb4d5ce5
  3. 14 11月, 2016 5 次提交
  4. 03 11月, 2016 1 次提交
  5. 20 10月, 2016 1 次提交
    • M
      xhci: workaround for hosts missing CAS bit · 346e9973
      Mathias Nyman 提交于
      If a device is unplugged and replugged during Sx system suspend
      some  Intel xHC hosts will overwrite the CAS (Cold attach status) flag
      and no device connection is noticed in resume.
      
      A device in this state can be identified in resume if its link state
      is in polling or compliance mode, and the current connect status is 0.
      A device in this state needs to be warm reset.
      
      Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8
      
      Observed on Cherryview and Apollolake as they go into compliance mode
      if LFPS times out during polling, and re-plugged devices are not
      discovered at resume.
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      346e9973
  6. 27 6月, 2016 1 次提交
    • M
      xhci: TD-fragment, align the unsplittable case with a bounce buffer · f9c589e1
      Mathias Nyman 提交于
      If the last trb before a link is not packet size aligned, and is not
      splittable then use a bounce buffer for that chunk of max packet size
      unalignable data.
      
      Allocate a max packet size bounce buffer for every segment of a bulk
      endpoint ring at the same time as allocating the ring.
      If we need to align the data before the link trb in that segment then
      copy the data to the segment bounce buffer, dma map it, and enqueue it.
      Once the td finishes, or is cancelled, unmap it.
      
      For in transfers we need to first map the bounce buffer, then queue it,
      after it finishes, copy the bounce buffer to the original sg list, and
      finally unmap it
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f9c589e1
  7. 27 4月, 2016 2 次提交
  8. 14 4月, 2016 2 次提交
  9. 15 2月, 2016 3 次提交
  10. 04 2月, 2016 2 次提交
  11. 02 12月, 2015 2 次提交
  12. 17 10月, 2015 2 次提交
  13. 04 10月, 2015 4 次提交
  14. 09 8月, 2015 2 次提交
  15. 23 7月, 2015 1 次提交
  16. 31 5月, 2015 1 次提交
  17. 25 5月, 2015 1 次提交
    • C
      usb: host: xhci: add mutex for non-thread-safe data · a00918d0
      Chris Bainbridge 提交于
      Regression in commit 638139eb ("usb: hub: allow to process more usb
      hub events in parallel")
      
      The regression resulted in intermittent failure to initialise a 10-port
      hub (with three internal VL812 4-port hub controllers) on boot, with a
      failure rate of around 8%, due to multiple race conditions when
      accessing addr_dev and slot_id in struct xhci_hcd.
      
      This regression also exposed a problem with xhci_setup_device, which
      "should be protected by the usb_address0_mutex" but no longer is due to
      
      commit 6fecd4f2 ("USB: separate usb_address0 mutexes for each bus")
      
      With separate buses (and locks) it is no longer the case that a single
      lock will protect xhci_setup_device from accesses by two parallel
      threads processing events on the two buses.
      
      Fix this by adding a mutex to protect addr_dev and slot_id in struct
      xhci_hcd, and by making the assignment of slot_id atomic.
      
      Fixes multiple boot errors:
      
      [ 0.583008] xhci_hcd 0000:00:14.0: Bad Slot ID 2
      [ 0.583009] xhci_hcd 0000:00:14.0: Could not allocate xHCI USB device data structures
      [ 0.583012] usb usb1-port3: couldn't allocate usb_device
      
      And:
      
      [ 0.637409] xhci_hcd 0000:00:14.0: Error while assigning device slot ID
      [ 0.637417] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 32.
      [ 0.637421] usb usb1-port1: couldn't allocate usb_device
      
      And:
      
      [ 0.753372] xhci_hcd 0000:00:14.0: ERROR: unexpected setup context command completion code 0x0.
      [ 0.753373] usb 1-3: hub failed to enable device, error -22
      [ 0.753400] xhci_hcd 0000:00:14.0: Error while assigning device slot ID
      [ 0.753402] xhci_hcd 0000:00:14.0: Max number of devices this xHCI host supports is 32.
      [ 0.753403] usb usb1-port3: couldn't allocate usb_device
      
      And:
      
      [ 11.018386] usb 1-3: device descriptor read/all, error -110
      
      And:
      
      [ 5.753838] xhci_hcd 0000:00:14.0: Timeout while waiting for setup device command
      
      Tested with 200 reboots, resulting in no USB hub init related errors.
      
      Fixes: 638139eb ("usb: hub: allow to process more usb hub events in parallel")
      Link: https://lkml.kernel.org/g/CAP-bSRb=A0iEYobdGCLpwynS7pkxpt_9ZnwyZTPVAoy0Y=Zo3Q@mail.gmail.comSigned-off-by: NChris Bainbridge <chris.bainbridge@gmail.com>
      Cc: <stable@vger.kernel.org> # 3.18+
      [changed git commit description style for checkpatch -Mathias]
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a00918d0
  18. 10 5月, 2015 1 次提交
    • M
      xhci: Solve full event ring by increasing TRBS_PER_SEGMENT to 256 · 18cc2f4c
      Mathias Nyman 提交于
      Our event ring consists of only one segment, and we risk filling
      the event ring in case we get isoc transfers with short intervals
      such as webcams that fill a TD every microframe (125us)
      
      With 64 TRB segment size one usb camera could fill the event ring in 8ms.
      A setup with several cameras and other devices can fill up the
      event ring as it is shared between all devices.
      This has occurred when uvcvideo queues 5 * 32TD URBs which then
      get cancelled when the video mode changes. The cancelled URBs are returned
      in the xhci interrupt context and blocks the interrupt handler from
      handling the new events.
      
      A full event ring will block xhci from scheduling traffic and affect all
      devices conneted to the xhci, will see errors such as Missed Service
      Intervals for isoc devices, and  and Split transaction errors for LS/FS
      interrupt devices.
      
      Increasing the TRB_PER_SEGMENT will also increase the default endpoint ring
      size, which is welcome as for most isoc transfer we had to dynamically
      expand the endpoint ring anyway to be able to queue the 5 * 32TDs uvcvideo
      queues.
      
      The default size used to be 64 TRBs per segment
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18cc2f4c
  19. 11 3月, 2015 1 次提交
  20. 07 3月, 2015 2 次提交
    • M
      xhci: Workaround for PME stuck issues in Intel xhci · b8cb91e0
      Mathias Nyman 提交于
      The xhci in Intel Sunrisepoint and Cherryview platforms need a driver
      workaround for a Stuck PME that might either block PME events in suspend,
      or create spurious PME events preventing runtime suspend.
      
      Workaround is to clear a internal PME flag, BIT(28) in a vendor specific
      PMCTRL register at offset 0x80a4, in both suspend resume callbacks
      
      Without this, xhci connected usb devices might never be able to wake up the
      system from suspend, or prevent device from going to suspend (xhci d3)
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8cb91e0
    • A
      xhci: fix reporting of 0-sized URBs in control endpoint · 45ba2154
      Aleksander Morgado 提交于
      When a control transfer has a short data stage, the xHCI controller generates
      two transfer events: a COMP_SHORT_TX event that specifies the untransferred
      amount, and a COMP_SUCCESS event. But when the data stage is not short, only the
      COMP_SUCCESS event occurs. Therefore, xhci-hcd must set urb->actual_length to
      urb->transfer_buffer_length while processing the COMP_SUCCESS event, unless
      urb->actual_length was set already by a previous COMP_SHORT_TX event.
      
      The driver checks this by seeing whether urb->actual_length == 0, but this alone
      is the wrong test, as it is entirely possible for a short transfer to have an
      urb->actual_length = 0.
      
      This patch changes the xhci driver to rely on a new td->urb_length_set flag,
      which is set to true when a COMP_SHORT_TX event is received and the URB length
      updated at that stage.
      
      This fixes a bug which affected the HSO plugin, which relies on URBs with
      urb->actual_length == 0 to halt re-submitting the RX URB in the control
      endpoint.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAleksander Morgado <aleksander@aleksander.es>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45ba2154
  21. 25 2月, 2015 1 次提交