📄 ehci.txt
字号:
27-Dec-2002The EHCI driver is used to talk to high speed USB 2.0 devices usingUSB 2.0-capable host controller hardware. The USB 2.0 standard iscompatible with the USB 1.1 standard. It defines three transfer speeds: - "High Speed" 480 Mbit/sec (60 MByte/sec) - "Full Speed" 12 Mbit/sec (1.5 MByte/sec) - "Low Speed" 1.5 Mbit/secUSB 1.1 only addressed full speed and low speed. High speed devicescan be used on USB 1.1 systems, but they slow down to USB 1.1 speeds. USB 1.1 devices may also be used on USB 2.0 systems. When pluggedinto an EHCI controller, they are given to a USB 1.1 "companion"controller, which is a OHCI or UHCI controller as normally used withsuch devices. When USB 1.1 devices plug into USB 2.0 hubs, theyinteract with the EHCI controller through a "Transaction Translator"(TT) in the hub, which turns low or full speed transactions intohigh speed "split transactions" that don't waste transfer bandwidth.At this writing, this driver has been seen to work with implementationsof EHCI from (in alphabetical order): Intel, NEC, Philips, and VIA.Other EHCI implementations are becoming available from other vendors;you should expect this driver to work with them too.While usb-storage devices have been available since mid-2001 (workingquite speedily on the 2.4 version of this driver), hubs have onlybeen available since late 2001, and other kinds of high speed devicesappear to be on hold until more systems come with USB 2.0 built-in.Such new systems have been available since early 2002, and became muchmore typical in the second half of 2002.Note that USB 2.0 support involves more than just EHCI. It requiresother changes to the Linux-USB core APIs, including the hub driver,but those changes haven't needed to really change the basic "usbcore"APIs exposed to USB device drivers.- David Brownell <dbrownell@users.sourceforge.net>FUNCTIONALITYThis driver is regularly tested on x86 hardware, and has also beenused on PPC hardware so big/little endianness issues should be gone.It's believed to do all the right PCI magic so that I/O works even onsystems with interesting DMA mapping issues.Transfer TypesAt this writing the driver should comfortably handle all control, bulk,and interrupt transfers, including requests to USB 1.1 devices throughtransaction translators (TTs) in USB 2.0 hubs. But you may find bugs.High Speed Isochronous (ISO) transfer support is also functional, butat this writing no Linux drivers have been using that support.Full Speed Isochronous transfer support, through transaction translators,is not yet available. Note that split transaction support for ISOtransfers can't share much code with the code for high speed ISO transfers,since EHCI represents these with a different data structure. So for now,most USB audio and video devices can't be connected to high speed buses.Driver BehaviorTransfers of all types can be queued. This means that control transfersfrom a driver on one interface (or through usbfs) won't interfere withones from another driver, and that interrupt transfers can use periodsof one frame without risking data loss due to interrupt processing costs.The EHCI root hub code hands off USB 1.1 devices to its companioncontroller. This driver doesn't need to know anything about thosedrivers; a OHCI or UHCI driver that works already doesn't need to changejust because the EHCI driver is also present.There are some issues with power management; suspend/resume doesn'tbehave quite right at the moment.Also, some shortcuts have been taken with the scheduling periodictransactions (interrupt and isochronous transfers). These place somelimits on the number of periodic transactions that can be scheduled,and prevent use of polling intervals of less than one frame.USE BYAssuming you have an EHCI controller (on a PCI card or motherboard)and have compiled this driver as a module, load this like: # modprobe ehci-hcdand remove it by: # rmmod ehci-hcdYou should also have a driver for a "companion controller", such as"ohci-hcd" or "uhci-hcd". In case of any trouble with the EHCI driver,remove its module and then the driver for that companion controller willtake over (at lower speed) all the devices that were previously handledby the EHCI driver.Module parameters (pass to "modprobe") include: log2_irq_thresh (default 0): Log2 of default interrupt delay, in microframes. The default value is 0, indicating 1 microframe (125 usec). Maximum value is 6, indicating 2^6 = 64 microframes. This controls how often the EHCI controller can issue interrupts.If you're using this driver on a 2.5 kernel, and you've enabled USBdebugging support, you'll see three files in the "sysfs" directory forany EHCI controller: "async" dumps the asynchronous schedule, used for control and bulk transfers. Shows each active qh and the qtds pending, usually one qtd per urb. (Look at it with usb-storage doing disk I/O; watch the request queues!) "periodic" dumps the periodic schedule, used for interrupt and isochronous transfers. Doesn't show qtds. "registers" show controller register state, andThe contents of those files can help identify driver problems.Device drivers shouldn't care whether they're running over EHCI or not,but they may want to check for "usb_device->speed == USB_SPEED_HIGH".High speed devices can do things that full speed (or low speed) onescan't, such as "high bandwidth" periodic (interrupt or ISO) transfers.Also, some values in device descriptors (such as polling intervals forperiodic transfers) use different encodings when operating at high speed.However, do make a point of testing device drivers through USB 2.0 hubs.Those hubs report some failures, such as disconnections, differently whentransaction translators are in use; some drivers have been seen to behavebadly when they see different faults than OHCI or UHCI report.PERFORMANCEUSB 2.0 throughput is gated by two main factors: how fast the hostcontroller can process requests, and how fast devices can respond tothem. The 480 Mbit/sec "raw transfer rate" is obeyed by all devices,but aggregate throughput is also affected by issues like delays betweenindividual high speed packets, driver intelligence, and of course theoverall system load. Latency is also a performance concern.Bulk transfers are most often used where throughput is an issue. It'sgood to keep in mind that bulk transfers are always in 512 byte packets,and at most 13 of those fit into one USB 2.0 microframe. Eight USB 2.0microframes fit in a USB 1.1 frame; a microframe is 1 msec/8 = 125 usec.So more than 50 MByte/sec is available for bulk transfers, when bothhardware and device driver software allow it. Periodic transfer modes(isochronous and interrupt) allow the larger packet sizes which let youapproach the quoted 480 MBit/sec transfer rate.Hardware PerformanceAt this writing, individual USB 2.0 devices tend to max out at around20 MByte/sec transfer rates. This is of course subject to change;and some devices now go faster, while others go slower.The first NEC implementation of EHCI seems to have a hardware bottleneckat around 28 MByte/sec aggregate transfer rate. While this is clearlyenough for a single device at 20 MByte/sec, putting three such devicesonto one bus does not get you 60 MByte/sec. The issue appears to bethat the controller hardware won't do concurrent USB and PCI access,so that it's only trying six (or maybe seven) USB transactions eachmicroframe rather than thirteen. (Seems like a reasonable trade offfor a product that beat all the others to market by over a year!)It's expected that newer implementations will better this, throwingmore silicon real estate at the problem so that new motherboard chipsets will get closer to that 60 MByte/sec target. That includes anupdated implementation from NEC, as well as other vendors' silicon.There's a minimum latency of one microframe (125 usec) for the hostto receive interrupts from the EHCI controller indicating completionof requests. That latency is tunable; there's a module option. Bydefault ehci-hcd driver uses the minimum latency, which means that ifyou issue a control or bulk request you can often expect to learn thatit completed in less than 250 usec (depending on transfer size).Software PerformanceTo get even 20 MByte/sec transfer rates, Linux-USB device drivers willneed to keep the EHCI queue full. That means issuing large requests,or using bulk queuing if a series of small requests needs to be issued.When drivers don't do that, their performance results will show it.In typical situations, a usb_bulk_msg() loop writing out 4 KB chunks isgoing to waste more than half the USB 2.0 bandwidth. Delays between theI/O completion and the driver issuing the next request will take longerthan the I/O. If that same loop used 16 KB chunks, it'd be better; asequence of 128 KB chunks would waste a lot less.But rather than depending on such large I/O buffers to make synchronousI/O be efficient, it's better to just queue up several (bulk) requeststo the HC, and wait for them all to complete (or be canceled on error).Such URB queuing should work with all the USB 1.1 HC drivers too.In the Linux 2.5 kernels, new usb_sg_*() api calls have been defined; theyqueue all the buffers from a scatterlist. They also use scatterlist DMAmapping (which might apply an IOMMU) and IRQ reduction, all of which willhelp make high speed transfers run as fast as they can.TBD: Interrupt and ISO transfer performance issues. Those periodictransfers are fully scheduled, so the main issue is likely to be howto trigger "high bandwidth" modes.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -