Statistics
| Branch: | Revision:

root / hw / usb / hcd-uhci.c @ afd347ab

History | View | Annotate | Download (38.3 kB)

# Date Author Comment
89eb147c 01/08/2013 11:56 am Gerd Hoffmann

uhci: stop using portio lists

Signed-off-by: Gerd Hoffmann <>

719c130d 01/07/2013 01:57 pm Hans de Goede

uhci: Fix 1 ms delay in interrupt reporting to the guest

Re-arrange how we process frames / increase frnum / report pending interrupts,
to avoid a 1 ms delay in interrupt reporting to the guest. This increases
the packet throughput for cases where the guest submits a single packet,...

ecfdc15f 01/07/2013 01:57 pm Hans de Goede

uhci: Fix pending interrupts getting lost on migration

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

475443cf 01/07/2013 01:57 pm Hans de Goede

uhci: Add a QH_VALID define

Rather then using the magic 32 value in various places.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

f8f48b69 01/07/2013 01:57 pm Hans de Goede

uhci: Limit amount of frames processed in one go

Before this patch uhci would process an unlimited amount of frames when
behind on schedule, by setting the timer to a time already past, causing the
timer subsys to immediately recall the frame_timer function gain....

9fdf7027 01/07/2013 01:57 pm Hans de Goede

uhci: Maximize how many frames we catch up when behind

If somehow we've gotten behind a lot, simply skip ahead, like the ehci code
does.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

f79738b0 01/07/2013 01:57 pm Hans de Goede

usb: Add an usb_device_ep_stopped USBDevice method

Some usb devices (host or network redirection) can benefit from knowing when
the guest stops using an endpoint. Redirection may involve submitting packets
independently from the guest (in combination with a fifo buffer between the...

9c17d615 12/19/2012 09:32 am Paolo Bonzini

softmmu: move include files to include/sysemu/

Signed-off-by: Paolo Bonzini <>

1de7afc9 12/19/2012 09:32 am Paolo Bonzini

misc: move include files to include/qemu/

Signed-off-by: Paolo Bonzini <>

a2cb15b0 12/17/2012 01:02 pm Michael S. Tsirkin

pci: update all users to look in pci/

update all users so we can remove the makefile hack.

Signed-off-by: Michael S. Tsirkin <>

6c2d1c32 11/29/2012 09:04 am Gerd Hoffmann

usb: tag usb host adapters as not hotpluggable.

Hotplugging them simply doesn't work, so tag them accordingly to
avoid users trying and then crashing qemu.

For xhci there is nothing fundamental which prevents hotplug from
working, we'll "only" need a exit() function which cleans up...

88793816 11/21/2012 03:55 pm Hans de Goede

uhci: Add a completions_only flag for async completions

Add a completions_only flag, and set this when running process_frame for async
completion handling, this fixes 2 issues in a single patch:

1) It makes sure async completed packets get written to guest mem immediately,...

1cbdde90 11/21/2012 03:55 pm Hans de Goede

uhci: Don't allow the guest to set port-enabled when there is no dev connected

It is possible for device disconnect and the guest trying to reset the port
(because of USB xact errors prior to the disconnect getting signaled) to race,
when we hit this race, the guest will write the port-control register with its...

71d2c9cf 11/21/2012 03:55 pm Hans de Goede

uhci: Fix double unlink

uhci_async_cancel() already does a uhci_async_unlink().

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

9a77a0f5 11/08/2012 07:41 pm Hans de Goede

usb: split packet result into actual_length + status

Since with the ehci and xhci controllers a single packet can be larger
then maxpacketsize, it is possible for the result of a single packet
to be both having transferred some data as well as the transfer to have...

faccca00 11/01/2012 04:17 pm Hans de Goede

uhci: Add a uhci_handle_td_error() helper function

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

7f102ebe 11/01/2012 04:17 pm Hans de Goede

uhci: Don't crash on device disconnect

My recent uhci cleanup series has introduced a regression, where
qemu sometimes crashes on a device disconnect. The problem is that
the uhci code never checked for a device not / no longer existing, instead
it was relying on usb_handle_packet accepting a NULL device....

2c2e8525 11/01/2012 04:17 pm Gerd Hoffmann

uhci: dynamic type generation

Signed-off-by: Gerd Hoffmann <>

8f3f90b0 11/01/2012 04:17 pm Gerd Hoffmann

uhci: stick irq routing info into UHCIInfo too.

Kills the ugly "switch (device_id) { ... }" struct and makes it easier
to figure what the differences between the uhci variants are.

Need our own DeviceClass struct for that so we can allocate some space
to store UHCIInfo....

74625ea2 11/01/2012 04:17 pm Gerd Hoffmann

uhci: add ich9 00:1a.* variants

Signed-off-by: Gerd Hoffmann <>

420ca987 10/25/2012 10:08 am Hans de Goede

uhci: When the guest marks a pending td non-active, cancel the queue

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

3905097e 10/25/2012 10:08 am Hans de Goede

uhci: Always mark a queue valid when we encounter it

Before this patch we would not mark a queue valid when its head was a
non-active td. This causes us to misbehave in the following scenario:

1) queue with multiple input transfers queued
2) We hit some latency issue, causing qemu to get behind processing frames...

8928c9c4 10/25/2012 10:08 am Hans de Goede

uhci: Retry to fill the queue while waiting for td completion

If the guest is using multiple transfers to try and keep the usb bus busy /
used at maximum efficiency, currently we would see / do the following:

1) submit transfer 1 to the device
2) submit transfer 2 to the device...

6fe30910 10/25/2012 10:08 am Hans de Goede

uhci: Use only one queue for ctrl endpoints

ctrl endpoints use different pids for different phases of a control
transfer, this patch makes us use only one queue for a ctrl ep, rather
then 3.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

3c87c76d 10/25/2012 10:08 am Hans de Goede

uhci: Drop unnecessary forward declaration of some static functions

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

40507377 10/25/2012 10:08 am Hans de Goede

uhci: Move emptying of the queue's asyncs' queue to uhci_queue_free

Cleanup: all callers of uhci_queue_free first unconditionally cancel
all remaining asyncs in the queue, so lets move this to uhci_queue_free().

Signed-off-by: Hans de Goede <>...

1f250cc7 10/25/2012 10:08 am Hans de Goede

uhci: Rename UHCIAsync->td to UHCIAsync->td_addr

We use the name td both to refer to a UHCI_TD read from guest memory as
well as to refer to the guest address where a td is stored, switch over
to always use td_addr in the second case for consistency.

Signed-off-by: Hans de Goede <>...

963a68b5 10/25/2012 10:08 am Hans de Goede

uhci: Add uhci_read_td() helper function

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

a4f30cd7 10/25/2012 10:08 am Hans de Goede

uhci: Make uhci_fill_queue() actually operate on an UHCIQueue

And move its calling point to handle_td, this removes the ep_ret ugliness,
and prepates the way for further cleanups in the follow-up patches in this
patch-set.

Signed-off-by: Hans de Goede <>...

11d15e40 10/25/2012 10:08 am Hans de Goede

uhci: Store ep in UHCIQueue

This avoids the need to repeatedly lookup the device, and ep.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

5ad23e87 10/25/2012 10:08 am Hans de Goede

uhci: Immediately free queues on device disconnect

There is no need to just cancel any in-flight packets, and then wait
for validate-end to clean things up, we can simply clean things up
immediately on device removal.

Signed-off-by: Hans de Goede <>...

66a08cbe 10/25/2012 10:08 am Hans de Goede

uhci: Verify queue has not been changed by guest

According to the spec a guest can unlink a qh, and then as soon as frindex
has changed by 1 since the unlink, assume it is idle and re-use it. However
for various reasons, we cannot simply consider a qh as unlinked if we've not...

8c75a899 10/25/2012 10:08 am Hans de Goede

uhci: Detect guest td re-use

A td can be reused by the guest in a different queue, before we notice
the original queue has been unlinked. So search for tds by addr only, detect
guest td reuse, and cancel the original queue, this is necessary to keep our
packet ids unique....

0cae7b1a 10/25/2012 10:08 am Hans de Goede

usb: Move clearing of queue on halt to the core

hcds which queue up more then one packet at once (uhci, ehci and xhci),
must clear the queue after an error which has caused the queue to halt.

Currently this is handled as a special case inside the hcd code, this...

6ba43f1f 10/25/2012 10:08 am Hans de Goede

usb: Move short-not-ok handling to the core

After a short-not-ok packet ending short, we should not advance the queue.
Move enforcing this to the core, rather then handling it in the hcd code.

This may result in the queue now actually containing multiple input packets...

a6fb2ddb 10/25/2012 10:08 am Hans de Goede

usb: Add an int_req flag to USBPacket

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

5b352ed5 10/25/2012 10:08 am Hans de Goede

uhci: No need to handle async completion of isoc packets

No devices ever return async for isoc endpoints and the core
already enforces this.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

2f2ee268 10/25/2012 10:08 am Hans de Goede

uhci: cleanup: Add an unlink call to uhci_async_cancel()

All callers of uhci_async_cancel() call uhci_async_unlink() first, so
lets move the unlink call to uhci_async_cancel()

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

a89e255b 10/25/2012 10:08 am Hans de Goede

uhci: Don't retry on error

Since we are either dealing with emulated devices, where retrying is
not going to help, or with redirected devices where the host OS will
have already retried, don't bother retrying on failed transfers.

Also move some common/indentical code out of all the error cases...

36dfe324 10/25/2012 10:08 am Hans de Goede

usb: Add USB_RET_ADD_TO_QUEUE packet result code

This can be used by usb-device code which wishes to process an entire endpoint
queue at once, to do this the usb-device code returns USB_RET_ADD_TO_QUEUE
from its handle_data class method and defines a flush_ep_queue class method...

00a0770d 10/25/2012 10:08 am Hans de Goede

uhci: Properly unmap packets on cancel / invalid pid

Packets with an invalid pid, or which were cancelled have
usb_packet_map() called on them on init, but not usb_packet_unmap()
before being freed.

Signed-off-by: Hans de Goede <>
Signed-off-by: Gerd Hoffmann <>

7c2eaca4 10/25/2012 10:08 am Hans de Goede

uhci: Move checks to continue queuing to uhci_fill_queue()

Rather then having a special check to start queuing after the first packet,
and then another check for the other packets in uhci_fill_queue(), simply
check the previous packet beforehand in uhci_fill_queue()...

883bca77 10/11/2012 10:33 am Hans de Goede

uhci: Raise interrupt when requested even for non active tds

According to the spec we must raise an interrupt when one is requested
even for non active tds.

Linux depends on this, for bulk transfers it runs an inactivity timer
to work around a bug in early uhci revisions, when we take longer then...

72a04d0c 09/13/2012 10:50 am Hans de Goede

uhci: Don't queue up packets after one with the SPD flag set

Don't queue up packets after a packet with the SPD (short packet detect)
flag set. Since we won't know if the packet will actually be short until it
has completed, and if it is short we should stop the queue....

45b339b1 09/11/2012 08:42 am Hans de Goede

usb: controllers do not need to check for babble themselves

If an (emulated) usb-device tries to write more data to a packet then
its iov len, this will trigger an assert in usb_packet_copy(), and if
a driver somehow circumvents that check and writes more data to the...

e983395d 08/31/2012 12:57 pm Gerd Hoffmann

usb: unique packet ids

This patch adds IDs to usb packets. Those IDs are (a) supposed to be
unique for the lifecycle of a packet (from packet setup until the packet
is either completed or canceled) and (b) stable across migration.

uhci, ohci, ehci and xhci use the guest physical address of the transfer...

0132b4b6 08/31/2012 12:55 pm Hans de Goede

usb: Halt ep queue en cancel pending packets on a packet error

For controllers which queue up more then 1 packet at a time, we must halt the
ep queue, and inside the controller code cancel all pending packets on an
error.

There are multiple reasons for this:...

5e59b024 07/29/2012 05:05 pm Michael S. Tsirkin

Merge branch pci into master

Merge master and pci branch, resolve build breakage in hw/esp.c
introduced by f90c2bcd.

Conflicts:
hw/esp.c

75f151cd 07/12/2012 04:00 pm Gerd Hoffmann

uhci: initialize expire_time when loading v1 vmstate

$subject says all: when loading old (v1) vmstate which doesn't contain
expire_time initialize it with a reasonable default (current time).

Signed-off-by: Gerd Hoffmann <>

f90c2bcd 07/04/2012 03:52 pm Alex Williamson

pci: convert PCIUnregisterFunc to void

Not a single driver has any possibility of failure on their
exit function, let's keep it that way.

Signed-off-by: Alex Williamson <>
Signed-off-by: Michael S. Tsirkin <>

e2f89926 06/28/2012 12:33 am David Gibson

usb: Convert usb_packet_{map, unmap} to universal DMA helpers

The USB UHCI and EHCI drivers were converted some time ago to use the
pci_dma_*() helper functions. However, this conversion was not complete
because in some places both these drivers do DMA via the usb_packet_map()...

77fa9aee 06/20/2012 03:46 pm Gerd Hoffmann

uhci: fix uhci_async_cancel_all

We update the QTAILQ in the loop, thus we must use the SAFE version
to make sure we don't touch the queue struct after freeing it.

https://bugzilla.novell.com/show_bug.cgi?id=766310

Signed-off-by: Gerd Hoffmann <>

4aed20e2 06/07/2012 11:02 am Gerd Hoffmann

uhci: fix bandwidth management

uhci_process_frame() can be invoked multiple times per frame, so
accounting usb bandwith in a local variable doesn't fly, use a variable
in UHCIState instead. Also check the limit more frequently.

Signed-off-by: Gerd Hoffmann <>

9a16c595 06/07/2012 11:02 am Gerd Hoffmann

uhci: use bottom half

Schedule bottom half on completion of async packets instead of calling
uhci_process_frame directly. This way we run uhci_process_frame only
once in case multiple packets finish in a row. Also check whenever
there is bandwidth left before scheduling uhci_process_frame....

40141d12 06/07/2012 11:02 am Gerd Hoffmann

uhci: make bandwidth tunable

Add a property for the uhci bandwidth. Can be used to make uhci
emulation run faster than real hardware.

Signed-off-by: Gerd Hoffmann <>

5852d3bf 06/07/2012 11:02 am Gerd Hoffmann

uhci: zap uhci_pre_save

Cancel transactions before saving vmstate is pretty pointless and just
causes disruptions. We need to cancel them before loading vmstate,
but in that case uhci_reset() handles it already and no special action
is needed.

Signed-off-by: Gerd Hoffmann <>

973002c1 06/07/2012 11:02 am Gerd Hoffmann

uhci: fix irq routing

The multifunction ich9 ehci controller with uhci companions uses a
different interrupt pin for each function. The three uhci devices
get pins A, B and C, whereas ehci uses pin D. This way the guest
can assign different IRQ lines to each controller....

aba1f242 04/26/2012 01:21 pm Gerd Hoffmann

usb-uhci: update irq line on reset

uhci_reset() clears irq mask and irq status registers, but doesn't
update the irq line. Which may result in suspious IRQs after uhci
reset. Fix it.

Signed-off-by: Gerd Hoffmann <>

52b0fecd 04/17/2012 11:23 am Gerd Hoffmann

usb-uhci: stop queue filling when we find a in-flight td

Not only QHs can form rings, but TDs too. With the new
queuing/pipelining support we are following TD chains and
can actually walk in circles. An assert() prevents us from
entering an endless loop then....

ee008ba6 04/17/2012 11:23 am Gerd Hoffmann

usb-uhci: queuing fix

When we queue up usb packets we may happen to find a already queued
packet, which also might be finished at that point already. We don't
want continue processing the packet at this point though, so lets
just signal back we've found a in-flight packet when in queuing mode....

f1ae32a1 03/13/2012 11:15 am Gerd Hoffmann

usb: the big rename

Reorganize usb source files. Create a new hw/usb/ directory and move
all usb source code to that place. Also make filenames a bit more
descriptive. Host adapters are prefixed with "hch-" now, usb device
emulations are prefixed with "dev-". Fixup paths Makefile and include...

afb9a60e 03/13/2012 11:15 am Gerd Hoffmann

usb: zap hw/ush-{ohic,uhci}.h + init wrappers

Remove the uhci and ohci init wrappers, which all wrapped a
pci_create_simple() one-liner. Switch callsites to call
pci_create_simple directly. Remove the header files where
the wrappers where declared.

Signed-off-by: Gerd Hoffmann <>

16ce543e 03/13/2012 11:15 am Gerd Hoffmann

uhci: pass addr to uhci_async_alloc

Also do async->td initialization in uhci_async_alloc now.
Prepares for adding tracepoints.

Signed-off-by: Gerd Hoffmann <>

60f8afcb 03/13/2012 11:15 am Gerd Hoffmann

uhci: fix uhci_async_cancel_all

It should also free all queues.

Signed-off-by: Gerd Hoffmann <>

d9a528db 03/13/2012 11:15 am Gerd Hoffmann

uhci: cancel on schedule stop.

Cancel any in-flight transaction when the guest stops the uhci schedule.

Signed-off-by: Gerd Hoffmann <>

50dcc0f8 03/13/2012 11:15 am Gerd Hoffmann

uhci: tracing support

Zap DPRINTF, add tracepoints instead.

Signed-off-by: Gerd Hoffmann <>

60e1b2a6 03/13/2012 11:15 am Gerd Hoffmann

uhci: use enum for uhci_handle_td return codes

Step #1 (separate for better bisectability): replace numbers with names.

Signed-off-by: Gerd Hoffmann <>

0cd178ca 03/13/2012 11:15 am Gerd Hoffmann

uhci: renumber uhci_handle_td return codes

Step #2 (separate for better bisectability): renumber so the silly '-1'
goes away. Pick a range which doesn't overlap the old values.

Signed-off-by: Gerd Hoffmann <>

4efe4ef3 03/13/2012 11:15 am Gerd Hoffmann

uhci: new uhci_handle_td return code for tds still in flight

Signed-off-by: Gerd Hoffmann <>

6c601340 03/13/2012 11:15 am Gerd Hoffmann

uhci: alloc can't fail, drop check.

Signed-off-by: Gerd Hoffmann <>