1. 24 1月, 2017 1 次提交
    • J
      usb: dwc2: Cleanup some checkpatch issues · 9da51974
      John Youn 提交于
      This commmit is the result of running checkpatch --fix.
      
      The results were verified for correctness. Some of the fixes result in
      line over 80 char which we will fix manually later.
      
      The following is a summary of what was done by checkpatch:
      * Remove externs on function prototypes.
      * Replace symbolic permissions with octal.
      * Align code to open parens.
      * Replace 'unsigned' with 'unsigned int'.
      * Remove unneccessary blank lines.
      * Add blank lines after declarations.
      * Add spaces around operators.
      * Remove unnecessary spaces after casts.
      * Replace 'x == NULL' with '!x'.
      * Replace kzalloc() with kcalloc().
      * Concatenate multi-line strings.
      * Use the BIT() macro.
      Signed-off-by: NJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
      9da51974
  2. 18 11月, 2016 3 次提交
  3. 04 3月, 2016 9 次提交
  4. 17 2月, 2016 1 次提交
  5. 15 12月, 2015 3 次提交
    • D
      usb: dwc2: host: Clear interrupts before handling them · 29539019
      Douglas Anderson 提交于
      In general it is wise to clear interrupts before processing them.  If
      you don't do that, you can get:
       1. Interrupt happens
       2. You look at system state and process interrupt
       3. A new interrupt happens
       4. You clear interrupt without processing it.
      
      This patch was actually a first attempt to fix missing device insertions
      as described in (usb: dwc2: host: Fix missing device insertions) and it
      did solve some of the signal bouncing problems but not all of
      them (which is why I submitted the other patch).  Specifically, this
      patch itself would sometimes change:
       1. hardware sees connect
       2. hardware sees disconnect
       3. hardware sees connect
       4. dwc2_port_intr() - clears connect interrupt
       5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()
      
      ...to:
       1. hardware sees connect
       2. hardware sees disconnect
       3. dwc2_port_intr() - clears connect interrupt
       4. hardware sees connect
       5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()
      
      ...but with different timing then sometimes we'd still miss cable
      insertions.
      
      In any case, though this patch doesn't fix any (known) problems, it
      still seems wise as a general policy to clear interrupt before handling
      them.
      
      Note that for dwc2_handle_usb_port_intr(), instead of moving the clear
      of PRTINT to the beginning of the function we remove it completely.  The
      only way to clear PRTINT is to clear the sources that set it in the
      first place.
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      29539019
    • D
      usb: dwc2: host: Fix missing device insertions · 6a659531
      Douglas Anderson 提交于
      If you've got your interrupt signals bouncing a bit as you insert your
      USB device, you might end up in a state when the device is connected but
      the driver doesn't know it.
      
      Specifically, the observed order is:
       1. hardware sees connect
       2. hardware sees disconnect
       3. hardware sees connect
       4. dwc2_port_intr() - clears connect interrupt
       5. dwc2_handle_common_intr() - calls dwc2_hcd_disconnect()
      
      Now you'll be stuck with the cable plugged in and no further interrupts
      coming in but the driver will think we're disconnected.
      
      We'll fix this by checking for the missing connect interrupt and
      re-connecting after the disconnect is posted.  We don't skip the
      disconnect because if there is a transitory disconnect we really want to
      de-enumerate and re-enumerate.
      
      Notes:
      1. As part of this change we add a "force" parameter to
         dwc2_hcd_disconnect() so that when we're unloading the module we
         avoid the new behavior.  The need for this was pointed out by John
         Youn.
      2. The bit of code needed at the end of dwc2_hcd_disconnect() is
         exactly the same bit of code from dwc2_port_intr().  To avoid
         duplication, we refactor that code out into a new function
         dwc2_hcd_connect().
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Acked-by: NJohn Youn <johnyoun@synopsys.com>
      Tested-by: NJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      6a659531
    • M
      usb: dwc2: host: enable descriptor dma for fs devices · fbb9e22b
      Mian Yousaf Kaukab 提交于
      As descriptor dma mode does not support split transfers, it can't be
      enabled for high speed devices. Add a core parameter to enable it for
      full speed devices.
      
      Ensure frame list and descriptor list are correctly freed during
      disconnect.
      Acked-by: NJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: NMian Yousaf Kaukab <yousaf.kaukab@intel.com>
      Signed-off-by: NGregory Herrero <gregory.herrero@intel.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      fbb9e22b
  6. 19 10月, 2015 1 次提交
    • D
      usb: dwc2: host: Fix use after free w/ simultaneous irqs · dc873084
      Doug Anderson 提交于
      While plugging / unplugging on a DWC2 host port with "slub_debug=FZPUA"
      enabled, I found a crash that was quite obviously a use after free.
      
      It appears that in some cases when we handle the various sub-cases of
      HCINT we may end up freeing the QTD.  If there is more than one bit set
      in HCINT we may then end up continuing to use the QTD, which is bad.
      Let's be paranoid and check for this after each sub-case.  This should
      be safe since we officially have the "hsotg->lock" (it was grabbed in
      dwc2_handle_hcd_intr).
      
      The specific crash I found was:
       Unable to handle kernel paging request at virtual address 6b6b6b9f
      
      At the time of the crash, the kernel reported:
       (dwc2_hc_nak_intr+0x5c/0x198)
       (dwc2_handle_hcd_intr+0xa84/0xbf8)
       (_dwc2_hcd_irq+0x1c/0x20)
       (usb_hcd_irq+0x34/0x48)
      
      Popping into kgdb found that "*qtd" was filled with "0x6b", AKA qtd had
      been freed and filled with slub_debug poison.
      
      kgdb gave a little better stack crawl:
       0 dwc2_hc_nak_intr (hsotg=hsotg@entry=0xec42e058,
           chan=chan@entry=0xec546dc0, chnum=chnum@entry=4,
           qtd=qtd@entry=0xec679600) at drivers/usb/dwc2/hcd_intr.c:1237
       1 dwc2_hc_n_intr (chnum=4, hsotg=0xec42e058) at
           drivers/usb/dwc2/hcd_intr.c:2041
       2 dwc2_hc_intr (hsotg=0xec42e058) at drivers/usb/dwc2/hcd_intr.c:2078
       3 dwc2_handle_hcd_intr (hsotg=0xec42e058) at
           drivers/usb/dwc2/hcd_intr.c:2128
       4 _dwc2_hcd_irq (hcd=<optimized out>) at drivers/usb/dwc2/hcd.c:2837
       5 usb_hcd_irq (irq=<optimized out>, __hcd=<optimized out>) at
           drivers/usb/core/hcd.c:2353
      
      Popping up to frame #1 (dwc2_hc_n_intr) found:
       (gdb) print /x hcint
       $12 = 0x12
      
      AKA:
       #define HCINTMSK_CHHLTD  (1 << 1)
       #define HCINTMSK_NAK     (1 << 4)
      
      Further debugging found that by simulating receiving those two
      interrupts at the same time it was trivial to replicate the
      use-after-free.  See <http://crosreview.com/305712> for a patch and
      instructions.  This lead to getting the following stack crawl of the
      actual free:
       0  arch_kgdb_breakpoint () at arch/arm/include/asm/outercache.h:103
       1  kgdb_breakpoint () at kernel/debug/debug_core.c:1054
       2  dwc2_hcd_qtd_unlink_and_free (hsotg=<optimized out>, qh=<optimized
            out>, qtd=0xe4479a00) at drivers/usb/dwc2/hcd.h:488
       3  dwc2_deactivate_qh (free_qtd=<optimized out>, qh=0xe5efa280,
            hsotg=0xed424618) at drivers/usb/dwc2/hcd_intr.c:671
       4  dwc2_release_channel (hsotg=hsotg@entry=0xed424618,
            chan=chan@entry=0xed5be000, qtd=<optimized out>,
            halt_status=<optimized out>) at drivers/usb/dwc2/hcd_intr.c:742
       5  dwc2_halt_channel (hsotg=0xed424618, chan=0xed5be000, qtd=<optimized
            out>, halt_status=<optimized out>) at
            drivers/usb/dwc2/hcd_intr.c:804
       6  dwc2_complete_non_periodic_xfer (chnum=<optimized out>,
            halt_status=<optimized out>, qtd=<optimized out>, chan=<optimized
            out>, hsotg=<optimized out>) at drivers/usb/dwc2/hcd_intr.c:889
       7  dwc2_hc_xfercomp_intr (hsotg=hsotg@entry=0xed424618,
            chan=chan@entry=0xed5be000, chnum=chnum@entry=6,
            qtd=qtd@entry=0xe4479a00) at drivers/usb/dwc2/hcd_intr.c:1065
       8  dwc2_hc_chhltd_intr_dma (qtd=0xe4479a00, chnum=6, chan=0xed5be000,
            hsotg=0xed424618) at drivers/usb/dwc2/hcd_intr.c:1823
       9  dwc2_hc_chhltd_intr (qtd=0xe4479a00, chnum=6, chan=0xed5be000,
            hsotg=0xed424618) at drivers/usb/dwc2/hcd_intr.c:1944
       10 dwc2_hc_n_intr (chnum=6, hsotg=0xed424618) at
            drivers/usb/dwc2/hcd_intr.c:2052
       11 dwc2_hc_intr (hsotg=0xed424618) at drivers/usb/dwc2/hcd_intr.c:2097
       12 dwc2_handle_hcd_intr (hsotg=0xed424618) at
            drivers/usb/dwc2/hcd_intr.c:2147
       13 _dwc2_hcd_irq (hcd=<optimized out>) at drivers/usb/dwc2/hcd.c:2837
       14 usb_hcd_irq (irq=<optimized out>, __hcd=<optimized out>) at
            drivers/usb/core/hcd.c:2353
      
      Though we could add specific code to handle this case, adding the
      general purpose code to check for all cases where qtd might be freed
      seemed safer.
      Acked-by: NJohn Youn <johnyoun@synopsys.com>
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      dc873084
  7. 27 9月, 2015 1 次提交
  8. 30 4月, 2015 3 次提交
  9. 20 9月, 2014 1 次提交
    • P
      usb: dwc2: handle DMA buffer unmapping sanely · 5dce9555
      Paul Zimmerman 提交于
      The driver's handling of DMA buffers for non-aligned transfers
      was kind of nuts. For IN transfers, it left the URB DMA buffer
      mapped until the transfer completed, then synced it, copied the
      data from the bounce buffer, then synced it again.
      
      Instead of that, just call usb_hcd_unmap_urb_for_dma() to unmap
      the buffer before starting the transfer. Then no syncing is
      required when doing the copy. This should also allow handling of
      other types of mappings besides just dma_map_single() ones.
      
      Also reduce the size of the bounce buffer allocation for Isoc
      endpoints to 3K, since that's the largest possible transfer size.
      
      Tested on Raspberry Pi and Altera SOCFPGA.
      Signed-off-by: NPaul Zimmerman <paulz@synopsys.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5dce9555
  10. 15 9月, 2014 2 次提交
  11. 12 9月, 2014 1 次提交
  12. 16 2月, 2014 1 次提交
  13. 14 1月, 2014 1 次提交
  14. 04 12月, 2013 2 次提交
  15. 26 11月, 2013 1 次提交
  16. 31 10月, 2013 1 次提交
  17. 26 9月, 2013 1 次提交
    • D
      staging: dwc2: add microframe scheduler from downstream Pi kernel · 20f2eb9c
      Dom Cobley 提交于
      The transfer scheduler in the dwc2 driver is pretty basic, not to
      mention buggy. It works fairly well with just a couple of devices
      plugged in, but if you add, say, multiple devices with periodic
      endpoints, the scheduler breaks down and can't even enumerate all
      the devices.
      
      To improve this, import the "microframe scheduler" patch from the
      driver in the downstream Raspberry Pi kernel, which is based on
      the Synopsys vendor driver. The original patch came from Denx
      (http://git.denx.de/?p=linux-denx.git) and was commited to the
      raspberrypi.org git tree by "popcornmix" (Dom Cobley).
      
      I have added a driver parameter for this, enabled by default, in
      case anyone has problems with it and needs to disable it. I don't
      think we should add a DT binding for that, though, since I plan
      to remove the option once any bugs are fixed.
      
      [raspberrypi.org patch from Dom Cobley]
      Signed-off-by: NDom Cobley <popcornmix@gmail.com>
      [adapted to dwc2 driver by Paul Zimmerman]
      Signed-off-by: NPaul Zimmerman <paulz@synopsys.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20f2eb9c
  18. 31 8月, 2013 3 次提交
  19. 24 7月, 2013 3 次提交
  20. 23 5月, 2013 1 次提交