0001 ===========
0002 EHCI driver
0003 ===========
0004
0005 27-Dec-2002
0006
0007 The EHCI driver is used to talk to high speed USB 2.0 devices using
0008 USB 2.0-capable host controller hardware. The USB 2.0 standard is
0009 compatible with the USB 1.1 standard. It defines three transfer speeds:
0010
0011 - "High Speed" 480 Mbit/sec (60 MByte/sec)
0012 - "Full Speed" 12 Mbit/sec (1.5 MByte/sec)
0013 - "Low Speed" 1.5 Mbit/sec
0014
0015 USB 1.1 only addressed full speed and low speed. High speed devices
0016 can be used on USB 1.1 systems, but they slow down to USB 1.1 speeds.
0017
0018 USB 1.1 devices may also be used on USB 2.0 systems. When plugged
0019 into an EHCI controller, they are given to a USB 1.1 "companion"
0020 controller, which is a OHCI or UHCI controller as normally used with
0021 such devices. When USB 1.1 devices plug into USB 2.0 hubs, they
0022 interact with the EHCI controller through a "Transaction Translator"
0023 (TT) in the hub, which turns low or full speed transactions into
0024 high speed "split transactions" that don't waste transfer bandwidth.
0025
0026 At this writing, this driver has been seen to work with implementations
0027 of EHCI from (in alphabetical order): Intel, NEC, Philips, and VIA.
0028 Other EHCI implementations are becoming available from other vendors;
0029 you should expect this driver to work with them too.
0030
0031 While usb-storage devices have been available since mid-2001 (working
0032 quite speedily on the 2.4 version of this driver), hubs have only
0033 been available since late 2001, and other kinds of high speed devices
0034 appear to be on hold until more systems come with USB 2.0 built-in.
0035 Such new systems have been available since early 2002, and became much
0036 more typical in the second half of 2002.
0037
0038 Note that USB 2.0 support involves more than just EHCI. It requires
0039 other changes to the Linux-USB core APIs, including the hub driver,
0040 but those changes haven't needed to really change the basic "usbcore"
0041 APIs exposed to USB device drivers.
0042
0043 - David Brownell
0044 <dbrownell@users.sourceforge.net>
0045
0046
0047 Functionality
0048 =============
0049
0050 This driver is regularly tested on x86 hardware, and has also been
0051 used on PPC hardware so big/little endianness issues should be gone.
0052 It's believed to do all the right PCI magic so that I/O works even on
0053 systems with interesting DMA mapping issues.
0054
0055 Transfer Types
0056 --------------
0057
0058 At this writing the driver should comfortably handle all control, bulk,
0059 and interrupt transfers, including requests to USB 1.1 devices through
0060 transaction translators (TTs) in USB 2.0 hubs. But you may find bugs.
0061
0062 High Speed Isochronous (ISO) transfer support is also functional, but
0063 at this writing no Linux drivers have been using that support.
0064
0065 Full Speed Isochronous transfer support, through transaction translators,
0066 is not yet available. Note that split transaction support for ISO
0067 transfers can't share much code with the code for high speed ISO transfers,
0068 since EHCI represents these with a different data structure. So for now,
0069 most USB audio and video devices can't be connected to high speed buses.
0070
0071 Driver Behavior
0072 ---------------
0073
0074 Transfers of all types can be queued. This means that control transfers
0075 from a driver on one interface (or through usbfs) won't interfere with
0076 ones from another driver, and that interrupt transfers can use periods
0077 of one frame without risking data loss due to interrupt processing costs.
0078
0079 The EHCI root hub code hands off USB 1.1 devices to its companion
0080 controller. This driver doesn't need to know anything about those
0081 drivers; a OHCI or UHCI driver that works already doesn't need to change
0082 just because the EHCI driver is also present.
0083
0084 There are some issues with power management; suspend/resume doesn't
0085 behave quite right at the moment.
0086
0087 Also, some shortcuts have been taken with the scheduling periodic
0088 transactions (interrupt and isochronous transfers). These place some
0089 limits on the number of periodic transactions that can be scheduled,
0090 and prevent use of polling intervals of less than one frame.
0091
0092
0093 Use by
0094 ======
0095
0096 Assuming you have an EHCI controller (on a PCI card or motherboard)
0097 and have compiled this driver as a module, load this like::
0098
0099 # modprobe ehci-hcd
0100
0101 and remove it by::
0102
0103 # rmmod ehci-hcd
0104
0105 You should also have a driver for a "companion controller", such as
0106 "ohci-hcd" or "uhci-hcd". In case of any trouble with the EHCI driver,
0107 remove its module and then the driver for that companion controller will
0108 take over (at lower speed) all the devices that were previously handled
0109 by the EHCI driver.
0110
0111 Module parameters (pass to "modprobe") include:
0112
0113 log2_irq_thresh (default 0):
0114 Log2 of default interrupt delay, in microframes. The default
0115 value is 0, indicating 1 microframe (125 usec). Maximum value
0116 is 6, indicating 2^6 = 64 microframes. This controls how often
0117 the EHCI controller can issue interrupts.
0118
0119 If you're using this driver on a 2.5 kernel, and you've enabled USB
0120 debugging support, you'll see three files in the "sysfs" directory for
0121 any EHCI controller:
0122
0123 "async"
0124 dumps the asynchronous schedule, used for control
0125 and bulk transfers. Shows each active qh and the qtds
0126 pending, usually one qtd per urb. (Look at it with
0127 usb-storage doing disk I/O; watch the request queues!)
0128 "periodic"
0129 dumps the periodic schedule, used for interrupt
0130 and isochronous transfers. Doesn't show qtds.
0131 "registers"
0132 show controller register state, and
0133
0134 The contents of those files can help identify driver problems.
0135
0136
0137 Device drivers shouldn't care whether they're running over EHCI or not,
0138 but they may want to check for "usb_device->speed == USB_SPEED_HIGH".
0139 High speed devices can do things that full speed (or low speed) ones
0140 can't, such as "high bandwidth" periodic (interrupt or ISO) transfers.
0141 Also, some values in device descriptors (such as polling intervals for
0142 periodic transfers) use different encodings when operating at high speed.
0143
0144 However, do make a point of testing device drivers through USB 2.0 hubs.
0145 Those hubs report some failures, such as disconnections, differently when
0146 transaction translators are in use; some drivers have been seen to behave
0147 badly when they see different faults than OHCI or UHCI report.
0148
0149
0150 Performance
0151 ===========
0152
0153 USB 2.0 throughput is gated by two main factors: how fast the host
0154 controller can process requests, and how fast devices can respond to
0155 them. The 480 Mbit/sec "raw transfer rate" is obeyed by all devices,
0156 but aggregate throughput is also affected by issues like delays between
0157 individual high speed packets, driver intelligence, and of course the
0158 overall system load. Latency is also a performance concern.
0159
0160 Bulk transfers are most often used where throughput is an issue. It's
0161 good to keep in mind that bulk transfers are always in 512 byte packets,
0162 and at most 13 of those fit into one USB 2.0 microframe. Eight USB 2.0
0163 microframes fit in a USB 1.1 frame; a microframe is 1 msec/8 = 125 usec.
0164
0165 So more than 50 MByte/sec is available for bulk transfers, when both
0166 hardware and device driver software allow it. Periodic transfer modes
0167 (isochronous and interrupt) allow the larger packet sizes which let you
0168 approach the quoted 480 MBit/sec transfer rate.
0169
0170 Hardware Performance
0171 --------------------
0172
0173 At this writing, individual USB 2.0 devices tend to max out at around
0174 20 MByte/sec transfer rates. This is of course subject to change;
0175 and some devices now go faster, while others go slower.
0176
0177 The first NEC implementation of EHCI seems to have a hardware bottleneck
0178 at around 28 MByte/sec aggregate transfer rate. While this is clearly
0179 enough for a single device at 20 MByte/sec, putting three such devices
0180 onto one bus does not get you 60 MByte/sec. The issue appears to be
0181 that the controller hardware won't do concurrent USB and PCI access,
0182 so that it's only trying six (or maybe seven) USB transactions each
0183 microframe rather than thirteen. (Seems like a reasonable trade off
0184 for a product that beat all the others to market by over a year!)
0185
0186 It's expected that newer implementations will better this, throwing
0187 more silicon real estate at the problem so that new motherboard chip
0188 sets will get closer to that 60 MByte/sec target. That includes an
0189 updated implementation from NEC, as well as other vendors' silicon.
0190
0191 There's a minimum latency of one microframe (125 usec) for the host
0192 to receive interrupts from the EHCI controller indicating completion
0193 of requests. That latency is tunable; there's a module option. By
0194 default ehci-hcd driver uses the minimum latency, which means that if
0195 you issue a control or bulk request you can often expect to learn that
0196 it completed in less than 250 usec (depending on transfer size).
0197
0198 Software Performance
0199 --------------------
0200
0201 To get even 20 MByte/sec transfer rates, Linux-USB device drivers will
0202 need to keep the EHCI queue full. That means issuing large requests,
0203 or using bulk queuing if a series of small requests needs to be issued.
0204 When drivers don't do that, their performance results will show it.
0205
0206 In typical situations, a usb_bulk_msg() loop writing out 4 KB chunks is
0207 going to waste more than half the USB 2.0 bandwidth. Delays between the
0208 I/O completion and the driver issuing the next request will take longer
0209 than the I/O. If that same loop used 16 KB chunks, it'd be better; a
0210 sequence of 128 KB chunks would waste a lot less.
0211
0212 But rather than depending on such large I/O buffers to make synchronous
0213 I/O be efficient, it's better to just queue up several (bulk) requests
0214 to the HC, and wait for them all to complete (or be canceled on error).
0215 Such URB queuing should work with all the USB 1.1 HC drivers too.
0216
0217 In the Linux 2.5 kernels, new usb_sg_*() api calls have been defined; they
0218 queue all the buffers from a scatterlist. They also use scatterlist DMA
0219 mapping (which might apply an IOMMU) and IRQ reduction, all of which will
0220 help make high speed transfers run as fast as they can.
0221
0222
0223 TBD:
0224 Interrupt and ISO transfer performance issues. Those periodic
0225 transfers are fully scheduled, so the main issue is likely to be how
0226 to trigger "high bandwidth" modes.
0227
0228 TBD:
0229 More than standard 80% periodic bandwidth allocation is possible
0230 through sysfs uframe_periodic_max parameter. Describe that.