1. 13 8月, 2013 30 次提交
    • F
      usb: pl2303: fix+improve the divsor based baud rate encoding method · 57ce61aa
      Frank Schäfer 提交于
      Based on the formula in the code description, Reinhard Max and me have
      investigated the devices behavior / functional principle of the divisor
      based baud rate encoding method.
      
      It turned out, that (although beeing a good starting point) the current
      code has some flaws. It doesn't work correctly for a wide range of baud
      rates and the divisor resolution can be improved. It also doesn't
      report the actually set baud rate.
      
      This patch fixes and improves the code for the divisor based baud rate
      encoding method a lot. It can now be used for the whole range of baud
      rates from 46 baud to 24M baud with a very good divisor resolution and
      userspace can read back the resulting baud rate.
      
      It also documents the formula used for encoding and the hardware
      behavior (including special cases).
      
      The basic algorithm, rounding and several code comments/explanations
      are provided by Reinhard Max.
      I've added some minor fixes, the handling of the special cases and
      further code/algorithm descriptions.
      Signed-off-by: NFrank Schäfer <fschaefer.oss@googlemail.com>
      Signed-off-by: NReinhard Max <max@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57ce61aa
    • T
      UWB: fix sysfs warning on HWA device unplug. · fbbde074
      Thomas Pugliese 提交于
      In the disconnect routine for the hwa_hc interface, it calls
      uwb_pal_unregister to unregister itself from the UWB subsystem.  This
      function attempts to clean up the link to the host controller directory in
      the device's UWB radio control interface directory.  If the disconnect
      routine for the radio control interface has already run, the uwb directory
      will be gone so the call to sysfs_remove_link generates a warning.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fbbde074
    • T
      HWA: avoid constant suspend and resume on the root hub · 644f6a12
      Thomas Pugliese 提交于
      Prevent the USB core from suspending the HWA root hub since bus_suspend
      and bus_resume are not yet supported.  Otherwise the PM system will chew
      up CPU time constantly attempting to suspend and resume the root hub but
      never succeeding.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      644f6a12
    • T
      HWA RC: fix a kernel panic when unplugging the HWA dongle · c654ecbb
      Thomas Pugliese 提交于
      This patch fixes a kernel panic that can occur when unplugging the HWA
      dongle while a downstream device is in the process of disconnecting.
      This involved 2 changes.  First, call usb_lock_device_for_reset before
      usb_reset_device to synchronize the HWA's post_rest and disconnect
      routines.  Second, set the hwarc->neep_urb and hwarc->rd_buffer to NULL
      when they are freed in the error path in the post_reset routine.  This
      prevents a double free when the disconnect routine is called and attempts
      to free those resources again.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c654ecbb
    • O
      USB: cdc-wdm: fix race between interrupt handler and tasklet · 6dd433e6
      Oliver Neukum 提交于
      Both could want to submit the same URB. Some checks of the flag
      intended to prevent that were missing.
      Signed-off-by: NOliver Neukum <oneukum@suse.de>
      CC: stable@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dd433e6
    • T
      wusbcore: clean up list locking in urb enqueue · e9a088fa
      Thomas Pugliese 提交于
      wa_urb_enqueue_run locks and unlocks its list lock as it traverses the
      list of queued transfers.  This was done to prevent deadlocking due to
      acquiring locks in reverse order in different places.  The problem is that
      releasing the lock during the list traversal could allow the dequeue
      routine to corrupt the list while it is being iterated over.  This patch
      moves all list entries to a temp list while holding the list lock, then
      traverses the temp list with no lock held.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9a088fa
    • T
      wusbcore: fix root hub hub_status_data to only return > 0 if status has actually changed · 467d296f
      Thomas Pugliese 提交于
      The hub_status_data function on the wireless USB root hub controller
      (wusbhc_rh_status_data) always returns a positive value even if no ports
      have changed.  This patch updates wusbhc_rh_status_data to only return a
      positive value if the root hub status needs to be queried.  The current
      implementation can also leave the upper bits of the port bitmap
      uninitialized if wusbhc->ports_max is not one less than an even multiple
      of 8.  This patch fixes that as well by initializing the buffer to 0.
      Signed-off-by: NThomas Pugliese <thomas.pugliese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      467d296f
    • M
      usb: ehci: Add support for SINGLE_STEP_SET_FEATURE test of EHSET · 9841f37a
      Manu Gautam 提交于
      The USB Embedded High-speed Host Electrical Test (EHSET) defines the
      SINGLE_STEP_SET_FEATURE test as follows:
      
      1) The host enumerates the test device with VID:0x1A0A, PID:0x0108
      2) The host sends the SETUP stage of a GetDescriptor(Device)
      3) The device ACKs the request
      4) The host issues SOFs for 15 seconds allowing the test operator to
         raise the scope trigger just above the SOF voltage level
      5) The host sends the IN packet
      6) The device sends data in response, triggering the scope
      7) The host sends an ACK in response to the data
      
      This patch adds additional handling to the EHCI hub driver and allows
      the EHSET driver to initiate this test mode by issuing a a SetFeature
      request to the root hub with a Test Selector value of 0x06. From there
      it mimics ehci_urb_enqueue() but separately submits QTDs for the
      SETUP and DATA/STATUS stages in order to insert a delay in between.
      Signed-off-by: NManu Gautam <mgautam@codeaurora.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      [jackp@codeaurora.org: imported from commit c2084930 on codeaurora.org;
       minor cleanup and updated author email]
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9841f37a
    • M
      usb/hcd: Log error code if reset() fails · c10750b2
      Mark Brown 提交于
      If someone provided meaningful error codes from reset() we should tell the
      user what they were.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c10750b2
    • H
      usb: config->desc.bLength may not exceed amount of data returned by the device · b4f17a48
      Hans de Goede 提交于
      While reading the config parsing code I noticed this check is missing, without
      this check config->desc.wTotalLength can end up with a value larger then the
      dev->rawdescriptors length for the config, and when userspace then tries to
      get the rawdescriptors bad things may happen.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4f17a48
    • M
      usb: misc: usb3503: Support operation with no I2C control · 3f0d1c67
      Mark Brown 提交于
      Refactor so that register writes for configuration are only performed if
      the device has a regmap provided and also register as a platform driver.
      This allows the driver to be used to manage GPIO based control of the
      device.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Cc: devicetree@vger.kernel.org
      Reviewed-by: NDongjin Kim <tobetter@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f0d1c67
    • M
      usb: misc: usb3503: Add USB3503A to the compatible list · 5bdd1f4a
      Mark Brown 提交于
      There are no software visible differences that I am aware of but in case
      any are discovered allow the DTS to specify exactly which device is
      present.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5bdd1f4a
    • M
      usb: misc: usb3503: Default to hub mode · e5a0c874
      Mark Brown 提交于
      Since there is no runtime interface for changing modes this is probably
      the most sensible default.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e5a0c874
    • M
      dd8e670d
    • M
      usb: misc: usb3503: Factor out I2C probe · 2487e3ee
      Mark Brown 提交于
      In preparation for supporting operation without an I2C control interface
      factor out the I2C-specific parts of the probe routine from those that
      don't do any register I/O.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2487e3ee
    • M
      usb: misc: usb3503: Convert to regmap · 68b14134
      Mark Brown 提交于
      This will give access to the diagnostic infrastructure regmap has but
      the main point is to support future refactoring.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68b14134
    • M
      usb: misc: usb3503: Actively manage Hub Connect GPIO · 8e7245b8
      Mark Brown 提交于
      If the connect signal is pulled high then the device will start up meaning
      that if we just pull it high on probe then the device will start running
      prior to the configuration being written out. Fix this by pulling the GPIO
      low when we reset and only pulling it high when configuration is finished.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e7245b8
    • M
      usb: misc: usb3503: Use gpio_set_value_cansleep() · 24455b09
      Mark Brown 提交于
      The /RESET GPIO is not manipulated from atomic context so support GPIOs
      that can't be written from atomic context by using _cansleep().
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24455b09
    • D
      usb: Move definition of USB_EHCI_BIG_ENDIAN_MMIO et al. out side of the ifs. · 900e0621
      David Daney 提交于
      When CONFIG_USB_SUPPORT is not selected we get things like:
      
      scripts/kconfig/mconf Kconfig
      warning: (MIPS_SEAD3 && PMC_MSP && CPU_CAVIUM_OCTEON) selects USB_EHCI_BIG_ENDIAN_MMIO which has unmet direct dependencies (USB_SUPPORT && USB)
      
      It is much cleaner to make the various system Kconfigs select
      USB_EHCI_BIG_ENDIAN_MMIO rather than move the system config
      information into USB's Kconfig, but the warnings are annoying.
      
      Eliminate the warning by moving the definition of
      USB_EHCI_BIG_ENDIAN_MMIO outside of all the Kconfig if statements.
      While we are at it move USB_OHCI_BIG_ENDIAN_DESC,
      USB_OHCI_BIG_ENDIAN_MMIO, USB_OHCI_LITTLE_ENDIAN and
      USB_EHCI_BIG_ENDIAN_DESC too, as they could very well suffer similar
      problems for other systems.
      
      Get rid of the redundant "default n" in USB_OHCI_BIG_ENDIAN_DESC and
      USB_OHCI_BIG_ENDIAN_MMIO
      Signed-off-by: NDavid Daney <david.daney@cavium.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      900e0621
    • M
      usb: misc: usb3503: Convert to devm_ APIs · cffedd67
      Mark Brown 提交于
      Saves us a bit of code.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cffedd67
    • M
      usb: misc: Fix swapped properties in usb3503 DT parsing · 42416cc8
      Mark Brown 提交于
      The intn and connect GPIO properties are swapped in the code which will
      cause failures at runtime if these are connected, fix the code.
      
      There are currently no in-tree users of this device to check or update.
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Acked-by: NOlof Johansson <olof@lixom.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42416cc8
    • G
      USB: serial: move the "simple" drivers into usb-serial-simple.c · 1f923071
      Greg Kroah-Hartman 提交于
      Instead of having to create a new driver for a "simple" usb to serial
      device, mush them all into one file, with a macro, so as to make it easy
      to add new ones.
      
      Cc: "René Bürgel" <rene.buergel@sohard.de>
      Acked-by: NWei Shuai <cpuwolf@gmail.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Acked-by: NFrans Klaver <frans.klaver@xsens.com>
      Cc: "Wesley W. Terpstra" <w.terpstra@gsi.de>
      Cc: Johan Hovold <jhovold@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f923071
    • M
      USBNET: ax88179_178a: enable tso if usb host supports sg dma · 3804fad4
      Ming Lei 提交于
      This patch enables 'can_dma_sg' flag for ax88179_178a device
      if the attached host controller supports building packet from
      discontinuous buffers(DMA SG is possible), so TSO can be enabled
      and skb fragment buffers can be passed to usb stack via urb->sg
      directly.
      
      With the patch, system CPU utilization decreased ~50% and throughput
      increased by ~10% when doing iperf client test on one ARM A15 dual
      core board.
      
      Cc: Ben Hutchings <bhutchings@solarflare.com>
      Cc: Grant Grundler <grundler@google.com>
      Cc: Oliver Neukum <oneukum@suse.de>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Freddy Xin <freddy@asix.com.tw>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Acked-by: NEric Dumazet <edumazet@gmail.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3804fad4
    • M
      USBNET: support DMA SG · 638c5115
      Ming Lei 提交于
      This patch introduces support of DMA SG if the USB host controller
      which usbnet device is attached to is capable of building packet from
      discontinuous buffers.
      
      The patch supports passing the skb fragment buffers to usb stack directly
      via urb->sg.
      
      Cc: Ben Hutchings <bhutchings@solarflare.com>
      Cc: Grant Grundler <grundler@google.com>
      Cc: Freddy Xin <freddy@asix.com.tw>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Acked-by: NOliver Neukum <oneukum@suse.de>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      638c5115
    • M
      USB: XHCI: mark no_sg_constraint · fc76051c
      Ming Lei 提交于
      This patch marks all xHCI controllers as no_sg_constraint
      since xHCI supports building packet from discontinuous buffers.
      
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc76051c
    • M
      USB: introduce usb_device_no_sg_constraint() helper · bcc48f1a
      Ming Lei 提交于
      Some host controllers(such as xHCI) can support building
      packet from discontinuous buffers, so introduce one flag
      and helper for this kind of host controllers, then the
      feature can help some applications(such as usbnet) by
      supporting arbitrary length of sg buffers.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcc48f1a
    • M
      USB: EHCI: support running URB giveback in tasklet context · 428aac8a
      Ming Lei 提交于
      All 4 transfer types can work well on EHCI HCD after switching to run
      URB giveback in tasklet context, so mark all HCD drivers to support
      it.
      
      Also we don't need to release ehci->lock during URB giveback any more.
      
      >From below test results on 3 machines(2 ARM and one x86), time
      consumed by EHCI interrupt handler droped much without performance
      loss.
      
      1 test description
      1.1 mass storage performance test:
      - run below command 10 times and compute the average performance
      
          dd if=/dev/sdN iflag=direct of=/dev/null bs=200M count=1
      
      - two usb mass storage device:
      A: sandisk extreme USB 3.0 16G(used in test case 1 & case 2)
      B: kingston DataTraveler G2 4GB(only used in test case 2)
      
      1.2 uvc function test:
      - run one simple capture program in the below link
      
         http://kernel.ubuntu.com/~ming/up/capture.c
      
      - capture format 640*480 and results in High Bandwidth mode on the
      uvc device: Z-Star 0x0ac8/0x3450
      
      - on T410(x86) laptop, also use guvcview to watch video capture/playback
      
      1.3 about test2 and test4
      - both two devices involved are tested concurrently by above test items
      
      1.4 how to compute irq time(the time consumed by ehci_irq)
      - use trace points of irq:irq_handler_entry and irq:irq_handler_exit
      
      1.5 kernel
      3.10.0-rc3-next-20130528
      
      1.6 test machines
      Pandaboard A1: ARM CortexA9 dural core
      Arndale board: ARM CortexA15 dural core
      T410: i5 CPU 2.67GHz quad core
      
      2 test result
      2.1 test case1: single mass storage device performance test
      --------------------------------------------------------------------
      		upstream 		| patched
      		perf(MB/s)+irq time(us)	| perf(MB/s)+irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  25.280(avg:145,max:772)	| 25.540(avg:14, max:75)
      Arndale board:  29.700(avg:33, max:129)	| 29.700(avg:10,  max:50)
      T410: 		34.430(avg:17, max:154*)| 34.660(avg:12, max:155)
      ---------------------------------------------------------------------
      
      2.2 test case2: two mass storage devices' performance test
      --------------------------------------------------------------------
      		upstream 			| patched
      		perf(MB/s)+irq time(us)		| perf(MB/s)+irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  15.840/15.580(avg:158,max:1216)	| 16.500/16.160(avg:15,max:139)
      Arndale board:  17.370/16.220(avg:33 max:234)	| 17.480/16.200(avg:11, max:91)
      T410: 		21.180/19.820(avg:18 max:160)	| 21.220/19.880(avg:11, max:149)
      ---------------------------------------------------------------------
      
      2.3 test case3: one uvc streaming test
      - uvc device works well(on x86, luvcview can be used too and has
      same result with uvc capture)
      --------------------------------------------------------------------
      		upstream 		| patched
      		irq time(us)		| irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  (avg:445, max:873)	| (avg:33, max:44)
      Arndale board:  (avg:316, max:630)	| (avg:20, max:27)
      T410: 		(avg:39,  max:107)	| (avg:10, max:65)
      ---------------------------------------------------------------------
      
      2.4 test case4: one uvc streaming plus one mass storage device test
      --------------------------------------------------------------------
      		upstream 		| patched
      		perf(MB/s)+irq time(us)	| perf(MB/s)+irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  20.340(avg:259,max:1704)| 20.390(avg:24, max:101)
      Arndale board:  23.460(avg:124,max:726)	| 23.370(avg:15, max:52)
      T410: 		28.520(avg:27, max:169)	| 28.630(avg:13, max:160)
      ---------------------------------------------------------------------
      
      2.5 test case5: read single mass storage device with small transfer
      - run below command 10 times and compute the average speed
      
       dd if=/dev/sdN iflag=direct of=/dev/null bs=4K count=4000
      
      1), test device A:
      --------------------------------------------------------------------
      		upstream 		| patched
      		perf(MB/s)+irq time(us)	| perf(MB/s)+irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  6.5(avg:21, max:64)	| 6.5(avg:10, max:24)
      Arndale board:  8.13(avg:12, max:23)	| 8.06(avg:7,  max:17)
      T410: 		6.66(avg:13, max:131)   | 6.84(avg:11, max:149)
      ---------------------------------------------------------------------
      
      2), test device B:
      --------------------------------------------------------------------
      		upstream 		| patched
      		perf(MB/s)+irq time(us)	| perf(MB/s)+irq time(us)
      --------------------------------------------------------------------
      Pandaboard A1:  5.5(avg:21,max:43)	| 5.49(avg:10, max:24)
      Arndale board:  5.9(avg:12, max:22)	| 5.9(avg:7, max:17)
      T410: 		5.48(avg:13, max:155)	| 5.48(avg:7, max:140)
      ---------------------------------------------------------------------
      
      * On T410, sometimes read ehci status register in ehci_irq takes more
      than 100us, and the problem has been reported on the link:
      
      	http://marc.info/?t=137065867300001&r=1&w=2Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      428aac8a
    • M
      USB: EHCI: improve interrupt qh unlink · 9118f9eb
      Ming Lei 提交于
      ehci-hcd currently unlinks an interrupt QH when it becomes empty, that
      is, after its last URB completes.  This works well because in almost
      all cases, the completion handler for an interrupt URB resubmits the
      URB; therefore the QH doesn't become empty and doesn't get unlinked.
      
      When we start using tasklets for URB completion, this scheme won't work
      as well.  The resubmission won't occur until the tasklet runs, which
      will be some time after the completion is queued with the tasklet.
      During that delay, the QH will be empty and so will be unlinked
      unnecessarily.
      
      To prevent this problem, this patch adds a 5-ms time delay before empty
      interrupt QHs are unlinked.  Most often, during that time the interrupt
      URB will be resubmitted and thus we can avoid unlinking the QH.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9118f9eb
    • M
      USB: EHCI: improve ehci_endpoint_disable · 35371e4f
      Ming Lei 提交于
      The patch does the below improvement:
      
      - think QH_STATE_COMPLETING as unlinking state since all URBs on the
      endpoint should be in unlinking or unlinked when doing endpoint_disable()
      
      - add "WARN_ON(!list_empty(&qh->qtd_list));" if qh->qh_state is
      QH_STATE_LINKED because there shouldn't be any active transfer in qh
      
      - when qh->qh_state is QH_STATE_LINKED, the QH(async or periodic)
      should be in its corresponding list, so the search through the async
      list isn't necessary.
      
      - unlink periodic QH to speed up unlinking if the QH is in linked
      state
      
      Basically, only the last one is related with this patchset because
      the assumption of "periodic qh self-unlinks on empty" isn't true
      any more when we introduce unlink-wait for periodic qh.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35371e4f
    • M
      USB: HCD: support giveback of URB in tasklet context · 94dfd7ed
      Ming Lei 提交于
      This patch implements the mechanism of giveback of URB in
      tasklet context, so that hardware interrupt handling time for
      usb host controller can be saved much, and HCD interrupt handling
      can be simplified.
      
      Motivations:
      
      1), on some arch(such as ARM), DMA mapping/unmapping is a bit
      time-consuming, for example: when accessing usb mass storage
      via EHCI on pandaboard, the common length of transfer buffer is 120KB,
      the time consumed on DMA unmapping may reach hundreds of microseconds;
      even on A15 based box, the time is still about scores of microseconds
      
      2), on some arch, reading DMA coherent memoery is very time-consuming,
      the most common example is usb video class driver[1]
      
      3), driver's complete() callback may do much things which is driver
      specific, so the time is consumed unnecessarily in hardware irq context.
      
      4), running driver's complete() callback in hardware irq context causes
      that host controller driver has to release its lock in interrupt handler,
      so reacquiring the lock after return may busy wait a while and increase
      interrupt handling time. More seriously, releasing the HCD lock makes
      HCD becoming quite complicated to deal with introduced races.
      
      So the patch proposes to run giveback of URB in tasklet context, then
      time consumed in HCD irq handling doesn't depend on drivers' complete and
      DMA mapping/unmapping any more, also we can simplify HCD since the HCD
      lock isn't needed to be released during irq handling.
      
      The patch should be reasonable and doable:
      
      1), for drivers, they don't care if the complete() is called in hard irq
      context or softirq context
      
      2), the biggest change is the situation in which usb_submit_urb() is called
      in complete() callback, so the introduced tasklet schedule delay might be a
      con, but it shouldn't be a big deal:
      
      	- control/bulk asynchronous transfer isn't sensitive to schedule
      	  delay
      
      	- the patch schedules giveback of periodic URBs using
      	  tasklet_hi_schedule, so the introduced delay should be very
      	  small
      
      	- for ISOC transfer, generally, drivers submit several URBs
      	  concurrently to avoid interrupt delay, so it is OK with the
      	  little schedule delay.
      
      	- for interrupt transfer, generally, drivers only submit one URB
      	  at the same time, but interrupt transfer is often used in event
      	  report, polling, ... situations, and a little delay should be OK.
      
      Considered that HCDs may optimize on submitting URB in complete(), the
      patch may cause the optimization not working, so introduces one flag to mark
      if the HCD supports to run giveback URB in tasklet context. When all HCDs
      are ready, the flag can be removed.
      
      [1], http://marc.info/?t=136438111600010&r=1&w=2
      
      Cc: Oliver Neukum <oliver@neukum.org>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NMing Lei <ming.lei@canonical.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94dfd7ed
  2. 04 8月, 2013 10 次提交