From f1ae32a1ecda8aaff7a355c9030c0d8c363f3a70 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 7 Mar 2012 14:55:18 +0100 Subject: [PATCH 01/14] 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 paths to make it compile. No code changes. Signed-off-by: Gerd Hoffmann --- Makefile.objs | 24 ++++++++++--------- Makefile.target | 2 +- configure | 4 +++- hw/{usb-bus.c => usb/bus.c} | 6 ++--- hw/{usb.c => usb/core.c} | 2 +- hw/{usb-desc.c => usb/desc.c} | 4 ++-- hw/{usb-desc.h => usb/desc.h} | 0 hw/{usb-audio.c => usb/dev-audio.c} | 8 +++---- hw/{usb-bt.c => usb/dev-bluetooth.c} | 6 ++--- hw/{usb-hid.c => usb/dev-hid.c} | 8 +++---- hw/{usb-hub.c => usb/dev-hub.c} | 4 ++-- hw/{usb-net.c => usb/dev-network.c} | 4 ++-- hw/{usb-serial.c => usb/dev-serial.c} | 4 ++-- hw/{usb-ccid.c => usb/dev-smartcard-reader.c} | 4 ++-- hw/{usb-msd.c => usb/dev-storage.c} | 6 ++--- hw/{usb-wacom.c => usb/dev-wacom.c} | 6 ++--- hw/{usb-ehci.c => usb/hcd-ehci.c} | 6 ++--- hw/{usb-musb.c => usb/hcd-musb.c} | 6 ++--- hw/{usb-ohci.c => usb/hcd-ohci.c} | 12 +++++----- hw/{usb-uhci.c => usb/hcd-uhci.c} | 8 +++---- hw/{usb-xhci.c => usb/hcd-xhci.c} | 10 ++++---- usb-bsd.c => hw/usb/host-bsd.c | 0 usb-linux.c => hw/usb/host-linux.c | 0 usb-stub.c => hw/usb/host-stub.c | 0 hw/{usb-libhw.c => usb/libhw.c} | 2 +- usb-redir.c => hw/usb/redirect.c | 0 trace-events | 8 +++---- 27 files changed, 74 insertions(+), 70 deletions(-) rename hw/{usb-bus.c => usb/bus.c} (99%) rename hw/{usb.c => usb/core.c} (99%) rename hw/{usb-desc.c => usb/desc.c} (99%) rename hw/{usb-desc.h => usb/desc.h} (100%) rename hw/{usb-audio.c => usb/dev-audio.c} (99%) rename hw/{usb-bt.c => usb/dev-bluetooth.c} (99%) rename hw/{usb-hid.c => usb/dev-hid.c} (99%) rename hw/{usb-hub.c => usb/dev-hub.c} (99%) rename hw/{usb-net.c => usb/dev-network.c} (99%) rename hw/{usb-serial.c => usb/dev-serial.c} (99%) rename hw/{usb-ccid.c => usb/dev-smartcard-reader.c} (99%) rename hw/{usb-msd.c => usb/dev-storage.c} (99%) rename hw/{usb-wacom.c => usb/dev-wacom.c} (99%) rename hw/{usb-ehci.c => usb/hcd-ehci.c} (99%) rename hw/{usb-musb.c => usb/hcd-musb.c} (99%) rename hw/{usb-ohci.c => usb/hcd-ohci.c} (99%) rename hw/{usb-uhci.c => usb/hcd-uhci.c} (99%) rename hw/{usb-xhci.c => usb/hcd-xhci.c} (99%) rename usb-bsd.c => hw/usb/host-bsd.c (100%) rename usb-linux.c => hw/usb/host-linux.c (100%) rename usb-stub.c => hw/usb/host-stub.c (100%) rename hw/{usb-libhw.c => usb/libhw.c} (99%) rename usb-redir.c => hw/usb/redirect.c (100%) diff --git a/Makefile.objs b/Makefile.objs index 5f0b3f7136..1eca4a8623 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -107,13 +107,15 @@ common-obj-y += eeprom93xx.o common-obj-y += scsi-disk.o cdrom.o common-obj-y += scsi-generic.o scsi-bus.o common-obj-y += hid.o -common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o -common-obj-y += usb-serial.o usb-net.o usb-bus.o usb-desc.o usb-audio.o +common-obj-y += usb/core.o usb/bus.o usb/desc.o usb/dev-hub.o +common-obj-y += usb/host-$(HOST_USB).o +common-obj-y += usb/dev-hid.o usb/dev-storage.o usb/dev-wacom.o +common-obj-y += usb/dev-serial.o usb/dev-network.o usb/dev-audio.o common-obj-$(CONFIG_SSI) += ssi.o common-obj-$(CONFIG_SSI_SD) += ssi-sd.o common-obj-$(CONFIG_SD) += sd.o -common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o -common-obj-y += bt-hci-csr.o +common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o +common-obj-y += bt-hci-csr.o usb/dev-bluetooth.o common-obj-y += buffered_file.o migration.o migration-tcp.o common-obj-y += qemu-char.o #aio.o common-obj-y += msmouse.o ps2.o @@ -194,7 +196,7 @@ user-obj-y += $(trace-obj-y) hw-obj-y = hw-obj-y += vl.o loader.o hw-obj-$(CONFIG_VIRTIO) += virtio-console.o -hw-obj-y += usb-libhw.o +hw-obj-y += usb/libhw.o hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o hw-obj-y += fw_cfg.o hw-obj-$(CONFIG_PCI) += pci.o pci_bridge.o @@ -217,10 +219,10 @@ hw-obj-$(CONFIG_PARALLEL) += parallel.o hw-obj-$(CONFIG_I8254) += i8254_common.o i8254.o hw-obj-$(CONFIG_PCSPK) += pcspk.o hw-obj-$(CONFIG_PCKBD) += pckbd.o -hw-obj-$(CONFIG_USB_UHCI) += usb-uhci.o -hw-obj-$(CONFIG_USB_OHCI) += usb-ohci.o -hw-obj-$(CONFIG_USB_EHCI) += usb-ehci.o -hw-obj-$(CONFIG_USB_XHCI) += usb-xhci.o +hw-obj-$(CONFIG_USB_UHCI) += usb/hcd-uhci.o +hw-obj-$(CONFIG_USB_OHCI) += usb/hcd-ohci.o +hw-obj-$(CONFIG_USB_EHCI) += usb/hcd-ehci.o +hw-obj-$(CONFIG_USB_XHCI) += usb/hcd-xhci.o hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o @@ -228,9 +230,9 @@ hw-obj-$(CONFIG_DMA) += dma.o hw-obj-$(CONFIG_I82374) += i82374.o hw-obj-$(CONFIG_HPET) += hpet.o hw-obj-$(CONFIG_APPLESMC) += applesmc.o -hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o +hw-obj-$(CONFIG_SMARTCARD) += usb/dev-smartcard-reader.o ccid-card-passthru.o hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o -hw-obj-$(CONFIG_USB_REDIR) += usb-redir.o +hw-obj-$(CONFIG_USB_REDIR) += usb/redirect.o hw-obj-$(CONFIG_I8259) += i8259_common.o i8259.o # PPC devices diff --git a/Makefile.target b/Makefile.target index 1bd25a89ad..ed769527f7 100644 --- a/Makefile.target +++ b/Makefile.target @@ -370,7 +370,7 @@ obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o \ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \ omap_gpmc.o omap_sdrc.o omap_spi.o omap_tap.o omap_l4.o obj-arm-y += omap_sx1.o palm.o tsc210x.o -obj-arm-y += nseries.o blizzard.o onenand.o cbus.o tusb6010.o usb-musb.o +obj-arm-y += nseries.o blizzard.o onenand.o cbus.o tusb6010.o usb/hcd-musb.o obj-arm-y += mst_fpga.o mainstone.o obj-arm-y += z2.o obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o diff --git a/configure b/configure index d7631ed247..fe4fc4fb96 100755 --- a/configure +++ b/configure @@ -3447,6 +3447,7 @@ mkdir -p $target_dir mkdir -p $target_dir/fpu mkdir -p $target_dir/tcg mkdir -p $target_dir/ide +mkdir -p $target_dir/usb mkdir -p $target_dir/9pfs mkdir -p $target_dir/kvm if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then @@ -3863,7 +3864,7 @@ done # for target in $targets DIRS="tests tests/tcg tests/tcg/cris slirp audio block net pc-bios/optionrom" DIRS="$DIRS pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" -DIRS="$DIRS fsdev ui" +DIRS="$DIRS fsdev ui usb" DIRS="$DIRS qapi qapi-generated" DIRS="$DIRS qga trace qom" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" @@ -3904,6 +3905,7 @@ for hwlib in 32 64; do d=libhw$hwlib mkdir -p $d mkdir -p $d/ide + mkdir -p $d/usb symlink $source_path/Makefile.hw $d/Makefile mkdir -p $d/9pfs echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak diff --git a/hw/usb-bus.c b/hw/usb/bus.c similarity index 99% rename from hw/usb-bus.c rename to hw/usb/bus.c index 70b7ebc086..d3f835895d 100644 --- a/hw/usb-bus.c +++ b/hw/usb/bus.c @@ -1,6 +1,6 @@ -#include "hw.h" -#include "usb.h" -#include "qdev.h" +#include "hw/hw.h" +#include "hw/usb.h" +#include "hw/qdev.h" #include "sysemu.h" #include "monitor.h" #include "trace.h" diff --git a/hw/usb.c b/hw/usb/core.c similarity index 99% rename from hw/usb.c rename to hw/usb/core.c index 1ec2e90ef7..494989a5e7 100644 --- a/hw/usb.c +++ b/hw/usb/core.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "usb.h" +#include "hw/usb.h" #include "iov.h" #include "trace.h" diff --git a/hw/usb-desc.c b/hw/usb/desc.c similarity index 99% rename from hw/usb-desc.c rename to hw/usb/desc.c index ccf85ade9e..9847a75b83 100644 --- a/hw/usb-desc.c +++ b/hw/usb/desc.c @@ -1,5 +1,5 @@ -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "trace.h" /* ------------------------------------------------------------------ */ diff --git a/hw/usb-desc.h b/hw/usb/desc.h similarity index 100% rename from hw/usb-desc.h rename to hw/usb/desc.h diff --git a/hw/usb-audio.c b/hw/usb/dev-audio.c similarity index 99% rename from hw/usb-audio.c rename to hw/usb/dev-audio.c index fed136117b..426b95c82b 100644 --- a/hw/usb-audio.c +++ b/hw/usb/dev-audio.c @@ -30,10 +30,10 @@ */ #include "qemu-common.h" -#include "usb.h" -#include "usb-desc.h" -#include "hw.h" -#include "audiodev.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" +#include "hw/hw.h" +#include "hw/audiodev.h" #include "audio/audio.h" #define USBAUDIO_VENDOR_NUM 0x46f4 /* CRC16() of "QEMU" */ diff --git a/hw/usb-bt.c b/hw/usb/dev-bluetooth.c similarity index 99% rename from hw/usb-bt.c rename to hw/usb/dev-bluetooth.c index 23c39ecc23..195370c24a 100644 --- a/hw/usb-bt.c +++ b/hw/usb/dev-bluetooth.c @@ -19,10 +19,10 @@ */ #include "qemu-common.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "net.h" -#include "bt.h" +#include "hw/bt.h" struct USBBtState { USBDevice dev; diff --git a/hw/usb-hid.c b/hw/usb/dev-hid.c similarity index 99% rename from hw/usb-hid.c rename to hw/usb/dev-hid.c index 37bca78eca..f29544d954 100644 --- a/hw/usb-hid.c +++ b/hw/usb/dev-hid.c @@ -22,12 +22,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" +#include "hw/hw.h" #include "console.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "qemu-timer.h" -#include "hid.h" +#include "hw/hid.h" /* HID interface requests */ #define GET_REPORT 0xa101 diff --git a/hw/usb-hub.c b/hw/usb/dev-hub.c similarity index 99% rename from hw/usb-hub.c rename to hw/usb/dev-hub.c index a12856e2e9..eb4e711207 100644 --- a/hw/usb-hub.c +++ b/hw/usb/dev-hub.c @@ -22,8 +22,8 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" //#define DEBUG diff --git a/hw/usb-net.c b/hw/usb/dev-network.c similarity index 99% rename from hw/usb-net.c rename to hw/usb/dev-network.c index 22b82017e3..cff55f223e 100644 --- a/hw/usb-net.c +++ b/hw/usb/dev-network.c @@ -24,8 +24,8 @@ */ #include "qemu-common.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "net.h" #include "qemu-queue.h" #include "sysemu.h" diff --git a/hw/usb-serial.c b/hw/usb/dev-serial.c similarity index 99% rename from hw/usb-serial.c rename to hw/usb/dev-serial.c index 0aae379b20..8dcac8bc88 100644 --- a/hw/usb-serial.c +++ b/hw/usb/dev-serial.c @@ -10,8 +10,8 @@ #include "qemu-common.h" #include "qemu-error.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "qemu-char.h" //#define DEBUG_Serial diff --git a/hw/usb-ccid.c b/hw/usb/dev-smartcard-reader.c similarity index 99% rename from hw/usb-ccid.c rename to hw/usb/dev-smartcard-reader.c index ced687f288..8e66675d86 100644 --- a/hw/usb-ccid.c +++ b/hw/usb/dev-smartcard-reader.c @@ -36,8 +36,8 @@ #include "qemu-common.h" #include "qemu-error.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" #include "monitor.h" #include "hw/ccid.h" diff --git a/hw/usb-msd.c b/hw/usb/dev-storage.c similarity index 99% rename from hw/usb-msd.c rename to hw/usb/dev-storage.c index c6f08a0313..6ffaf70661 100644 --- a/hw/usb-msd.c +++ b/hw/usb/dev-storage.c @@ -10,9 +10,9 @@ #include "qemu-common.h" #include "qemu-option.h" #include "qemu-config.h" -#include "usb.h" -#include "usb-desc.h" -#include "scsi.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" +#include "hw/scsi.h" #include "console.h" #include "monitor.h" #include "sysemu.h" diff --git a/hw/usb-wacom.c b/hw/usb/dev-wacom.c similarity index 99% rename from hw/usb-wacom.c rename to hw/usb/dev-wacom.c index 197e2dced5..c1cfd74403 100644 --- a/hw/usb-wacom.c +++ b/hw/usb/dev-wacom.c @@ -25,10 +25,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" +#include "hw/hw.h" #include "console.h" -#include "usb.h" -#include "usb-desc.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" /* Interface requests */ #define WACOM_GET_REPORT 0x2101 diff --git a/hw/usb-ehci.c b/hw/usb/hcd-ehci.c similarity index 99% rename from hw/usb-ehci.c rename to hw/usb/hcd-ehci.c index df742f7f02..58811d3ef0 100644 --- a/hw/usb-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -22,10 +22,10 @@ * along with this program; if not, see . */ -#include "hw.h" +#include "hw/hw.h" #include "qemu-timer.h" -#include "usb.h" -#include "pci.h" +#include "hw/usb.h" +#include "hw/pci.h" #include "monitor.h" #include "trace.h" #include "dma.h" diff --git a/hw/usb-musb.c b/hw/usb/hcd-musb.c similarity index 99% rename from hw/usb-musb.c rename to hw/usb/hcd-musb.c index 820907a9a9..fa9385ee49 100644 --- a/hw/usb-musb.c +++ b/hw/usb/hcd-musb.c @@ -22,9 +22,9 @@ */ #include "qemu-common.h" #include "qemu-timer.h" -#include "usb.h" -#include "irq.h" -#include "hw.h" +#include "hw/usb.h" +#include "hw/irq.h" +#include "hw/hw.h" /* Common USB registers */ #define MUSB_HDRC_FADDR 0x00 /* 8-bit */ diff --git a/hw/usb-ohci.c b/hw/usb/hcd-ohci.c similarity index 99% rename from hw/usb-ohci.c rename to hw/usb/hcd-ohci.c index 20aaa74250..dd79cef81f 100644 --- a/hw/usb-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -26,13 +26,13 @@ * o BIOS work to boot from USB storage */ -#include "hw.h" +#include "hw/hw.h" #include "qemu-timer.h" -#include "usb.h" -#include "pci.h" -#include "usb-ohci.h" -#include "sysbus.h" -#include "qdev-addr.h" +#include "hw/usb.h" +#include "hw/pci.h" +#include "hw/usb-ohci.h" +#include "hw/sysbus.h" +#include "hw/qdev-addr.h" //#define DEBUG_OHCI /* Dump packet contents. */ diff --git a/hw/usb-uhci.c b/hw/usb/hcd-uhci.c similarity index 99% rename from hw/usb-uhci.c rename to hw/usb/hcd-uhci.c index 304b84b831..7c2e9b35ff 100644 --- a/hw/usb-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -25,11 +25,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "hw.h" -#include "usb.h" -#include "pci.h" +#include "hw/hw.h" +#include "hw/usb.h" +#include "hw/pci.h" #include "qemu-timer.h" -#include "usb-uhci.h" +#include "hw/usb-uhci.h" #include "iov.h" #include "dma.h" diff --git a/hw/usb-xhci.c b/hw/usb/hcd-xhci.c similarity index 99% rename from hw/usb-xhci.c rename to hw/usb/hcd-xhci.c index e8f1b6e3a5..73b0c7f5e5 100644 --- a/hw/usb-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -18,12 +18,12 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ -#include "hw.h" +#include "hw/hw.h" #include "qemu-timer.h" -#include "usb.h" -#include "pci.h" -#include "qdev-addr.h" -#include "msi.h" +#include "hw/usb.h" +#include "hw/pci.h" +#include "hw/qdev-addr.h" +#include "hw/msi.h" //#define DEBUG_XHCI //#define DEBUG_DATA diff --git a/usb-bsd.c b/hw/usb/host-bsd.c similarity index 100% rename from usb-bsd.c rename to hw/usb/host-bsd.c diff --git a/usb-linux.c b/hw/usb/host-linux.c similarity index 100% rename from usb-linux.c rename to hw/usb/host-linux.c diff --git a/usb-stub.c b/hw/usb/host-stub.c similarity index 100% rename from usb-stub.c rename to hw/usb/host-stub.c diff --git a/hw/usb-libhw.c b/hw/usb/libhw.c similarity index 99% rename from hw/usb-libhw.c rename to hw/usb/libhw.c index 162b42bd5b..2462351389 100644 --- a/hw/usb-libhw.c +++ b/hw/usb/libhw.c @@ -21,7 +21,7 @@ */ #include "qemu-common.h" #include "cpu-common.h" -#include "usb.h" +#include "hw/usb.h" #include "dma.h" int usb_packet_map(USBPacket *p, QEMUSGList *sgl) diff --git a/usb-redir.c b/hw/usb/redirect.c similarity index 100% rename from usb-redir.c rename to hw/usb/redirect.c diff --git a/trace-events b/trace-events index 74bb92af4f..bcfe13a9f7 100644 --- a/trace-events +++ b/trace-events @@ -227,16 +227,16 @@ sun4m_iommu_page_get_flags(uint64_t pa, uint64_t iopte, uint32_t ret) "get flags sun4m_iommu_translate_pa(uint64_t addr, uint64_t pa, uint32_t iopte) "xlate dva %"PRIx64" => pa %"PRIx64" iopte = %x" sun4m_iommu_bad_addr(uint64_t addr) "bad addr %"PRIx64 -# hw/usb.c +# hw/usb/core.c usb_packet_state_change(int bus, const char *port, int ep, void *p, const char *o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s -> %s" -# hw/usb-bus.c +# hw/usb/bus.c usb_port_claim(int bus, const char *port) "bus %d, port %s" usb_port_attach(int bus, const char *port) "bus %d, port %s" usb_port_detach(int bus, const char *port) "bus %d, port %s" usb_port_release(int bus, const char *port) "bus %d, port %s" -# hw/usb-ehci.c +# hw/usb/hcd-ehci.c usb_ehci_reset(void) "=== RESET ===" usb_ehci_mmio_readl(uint32_t addr, const char *str, uint32_t val) "rd mmio %04x [%s] = %x" usb_ehci_mmio_writel(uint32_t addr, const char *str, uint32_t val) "wr mmio %04x [%s] = %x" @@ -269,7 +269,7 @@ usb_set_interface(int addr, int iface, int alt, int ret) "dev %d, interface %d, usb_clear_device_feature(int addr, int feature, int ret) "dev %d, feature %d, ret %d" usb_set_device_feature(int addr, int feature, int ret) "dev %d, feature %d, ret %d" -# usb-linux.c +# hw/usb/host-linux.c usb_host_open_started(int bus, int addr) "dev %d:%d" usb_host_open_success(int bus, int addr) "dev %d:%d" usb_host_open_failure(int bus, int addr) "dev %d:%d" From afb9a60ecb391cbccfd38e6bf400ebfcf40c5d0c Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 7 Mar 2012 15:06:32 +0100 Subject: [PATCH 02/14] 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 --- hw/alpha_sys.h | 1 - hw/mips_fulong2e.c | 7 ++++--- hw/mips_malta.c | 3 +-- hw/pc_piix.c | 4 +--- hw/ppc_newworld.c | 3 +-- hw/ppc_oldworld.c | 3 +-- hw/ppc_prep.c | 3 +-- hw/realview.c | 3 +-- hw/usb-ohci.h | 9 --------- hw/usb-uhci.h | 10 ---------- hw/usb/hcd-ohci.c | 6 ------ hw/usb/hcd-uhci.c | 16 ---------------- hw/versatilepb.c | 3 +-- 13 files changed, 11 insertions(+), 60 deletions(-) delete mode 100644 hw/usb-ohci.h delete mode 100644 hw/usb-uhci.h diff --git a/hw/alpha_sys.h b/hw/alpha_sys.h index d54b18f8ed..f9506c69a7 100644 --- a/hw/alpha_sys.h +++ b/hw/alpha_sys.h @@ -8,7 +8,6 @@ #include "ide.h" #include "net.h" #include "pc.h" -#include "usb-ohci.h" #include "irq.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index e3ba9dd42d..efdfdc29ff 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -29,7 +29,6 @@ #include "mips.h" #include "mips_cpudevs.h" #include "pci.h" -#include "usb-uhci.h" #include "qemu-char.h" #include "sysemu.h" #include "audio/audio.h" @@ -355,8 +354,10 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, isa_bus_irqs(isa_bus, i8259); vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(FULONG2E_VIA_SLOT, 1)); - usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2)); - usb_uhci_vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3)); + pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 2), + "vt82c686b-usb-uhci"); + pci_create_simple(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 3), + "vt82c686b-usb-uhci"); smbus = vt82c686b_pm_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 4), 0xeee1, NULL); diff --git a/hw/mips_malta.c b/hw/mips_malta.c index b1563ed2a7..866699dbf0 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -33,7 +33,6 @@ #include "mips.h" #include "mips_cpudevs.h" #include "pci.h" -#include "usb-uhci.h" #include "vmware_vga.h" #include "qemu-char.h" #include "sysemu.h" @@ -965,7 +964,7 @@ void mips_malta_init (ram_addr_t ram_size, isa_bus_irqs(isa_bus, s->i8259); pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1); - usb_uhci_piix4_init(pci_bus, piix4_devfn + 2); + pci_create_simple(pci_bus, piix4_devfn + 2, "piix4-usb-uhci"); smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_get_irq(NULL, 9), NULL, 0); /* TODO: Populate SPD eeprom data. */ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 6c5c40f5df..3f99f9a7c2 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -28,8 +28,6 @@ #include "pc.h" #include "apic.h" #include "pci.h" -#include "usb-uhci.h" -#include "usb-ohci.h" #include "net.h" #include "boards.h" #include "ide.h" @@ -284,7 +282,7 @@ static void pc_init1(MemoryRegion *system_memory, floppy, idebus[0], idebus[1], rtc_state); if (pci_enabled && usb_enabled) { - usb_uhci_piix3_init(pci_bus, piix3_devfn + 2); + pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); } if (pci_enabled && acpi_enabled) { diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 506187b182..2fec5b4d67 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -54,7 +54,6 @@ #include "nvram.h" #include "pc.h" #include "pci.h" -#include "usb-ohci.h" #include "net.h" #include "sysemu.h" #include "boards.h" @@ -352,7 +351,7 @@ static void ppc_core99_init (ram_addr_t ram_size, dbdma_mem, cuda_mem, NULL, 3, ide_mem, escc_bar); if (usb_enabled) { - usb_ohci_init_pci(pci_bus, -1); + pci_create_simple(pci_bus, -1, "pci-ohci"); } /* U3 needs to use USB for input because Linux doesn't support via-cuda diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 9295a34f59..49c2c9795e 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -34,7 +34,6 @@ #include "net.h" #include "isa.h" #include "pci.h" -#include "usb-ohci.h" #include "boards.h" #include "fw_cfg.h" #include "escc.h" @@ -278,7 +277,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, dbdma_mem, cuda_mem, nvr, 2, ide_mem, escc_bar); if (usb_enabled) { - usb_ohci_init_pci(pci_bus, -1); + pci_create_simple(pci_bus, -1, "pci-ohci"); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index eb43fb5849..dc9edd7bf5 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -30,7 +30,6 @@ #include "isa.h" #include "pci.h" #include "pci_host.h" -#include "usb-ohci.h" #include "ppc.h" #include "boards.h" #include "qemu-log.h" @@ -688,7 +687,7 @@ static void ppc_prep_init (ram_addr_t ram_size, #endif if (usb_enabled) { - usb_ohci_init_pci(pci_bus, -1); + pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); diff --git a/hw/realview.c b/hw/realview.c index ae1bbcdac3..50ea67cb26 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -12,7 +12,6 @@ #include "primecell.h" #include "devices.h" #include "pci.h" -#include "usb-ohci.h" #include "net.h" #include "sysemu.h" #include "boards.h" @@ -305,7 +304,7 @@ static void realview_init(ram_addr_t ram_size, sysbus_connect_irq(busdev, 3, pic[51]); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { - usb_ohci_init_pci(pci_bus, -1); + pci_create_simple(pci_bus, -1, "pci-ohci"); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { diff --git a/hw/usb-ohci.h b/hw/usb-ohci.h deleted file mode 100644 index eefcef3602..0000000000 --- a/hw/usb-ohci.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef QEMU_USB_OHCI_H -#define QEMU_USB_OHCI_H - -#include "qemu-common.h" - -void usb_ohci_init_pci(struct PCIBus *bus, int devfn); - -#endif - diff --git a/hw/usb-uhci.h b/hw/usb-uhci.h deleted file mode 100644 index 3e4d3777d4..0000000000 --- a/hw/usb-uhci.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef QEMU_USB_UHCI_H -#define QEMU_USB_UHCI_H - -#include "qemu-common.h" - -void usb_uhci_piix3_init(PCIBus *bus, int devfn); -void usb_uhci_piix4_init(PCIBus *bus, int devfn); -void usb_uhci_vt82c686b_init(PCIBus *bus, int devfn); - -#endif diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index dd79cef81f..51fa111390 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -30,7 +30,6 @@ #include "qemu-timer.h" #include "hw/usb.h" #include "hw/pci.h" -#include "hw/usb-ohci.h" #include "hw/sysbus.h" #include "hw/qdev-addr.h" @@ -1815,11 +1814,6 @@ static int usb_ohci_initfn_pci(struct PCIDevice *dev) return 0; } -void usb_ohci_init_pci(struct PCIBus *bus, int devfn) -{ - pci_create_simple(bus, devfn, "pci-ohci"); -} - typedef struct { SysBusDevice busdev; OHCIState ohci; diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 7c2e9b35ff..5c708cf670 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -29,7 +29,6 @@ #include "hw/usb.h" #include "hw/pci.h" #include "qemu-timer.h" -#include "hw/usb-uhci.h" #include "iov.h" #include "dma.h" @@ -1391,18 +1390,3 @@ static void uhci_register_types(void) } type_init(uhci_register_types) - -void usb_uhci_piix3_init(PCIBus *bus, int devfn) -{ - pci_create_simple(bus, devfn, "piix3-usb-uhci"); -} - -void usb_uhci_piix4_init(PCIBus *bus, int devfn) -{ - pci_create_simple(bus, devfn, "piix4-usb-uhci"); -} - -void usb_uhci_vt82c686b_init(PCIBus *bus, int devfn) -{ - pci_create_simple(bus, devfn, "vt82c686b-usb-uhci"); -} diff --git a/hw/versatilepb.c b/hw/versatilepb.c index b9102f4a54..c1687a5b89 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -13,7 +13,6 @@ #include "net.h" #include "sysemu.h" #include "pci.h" -#include "usb-ohci.h" #include "boards.h" #include "blockdev.h" #include "exec-memory.h" @@ -240,7 +239,7 @@ static void versatile_init(ram_addr_t ram_size, } } if (usb_enabled) { - usb_ohci_init_pci(pci_bus, -1); + pci_create_simple(pci_bus, -1, "pci-ohci"); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { From fcb70eca3f14349a0ef8e74dc808360f81592026 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2012 12:10:11 +0100 Subject: [PATCH 03/14] usb-ehci: drop unused isoch_pause variable Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ehci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 58811d3ef0..60f9f5bdb5 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -419,7 +419,6 @@ struct EHCIState { USBPacket ipacket; QEMUSGList isgl; - int isoch_pause; uint64_t last_run_ns; }; @@ -907,7 +906,6 @@ static void ehci_reset(void *opaque) s->astate = EST_INACTIVE; s->pstate = EST_INACTIVE; - s->isoch_pause = -1; s->attach_poll_counter = 0; for(i = 0; i < NB_PORTS; i++) { @@ -2150,9 +2148,7 @@ static void ehci_frame_timer(void *opaque) for (i = 0; i < frames; i++) { if ( !(ehci->usbsts & USBSTS_HALT)) { - if (ehci->isoch_pause <= 0) { - ehci->frindex += 8; - } + ehci->frindex += 8; if (ehci->frindex > 0x00001fff) { ehci->frindex = 0; From 86e18cae209f8101ff9a6013a1ff6ae620c06944 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Thu, 8 Mar 2012 12:10:44 +1100 Subject: [PATCH 04/14] usb-ohci: DMA writeback bug fixes This patch fixes two bugs in the OHCI device where the device writes back data to system memory that should be exclusively under the control of the guest side driver. In OHCI specification Section 5.2.7, it mentioned "In all cases, Host Controller Driver is responsible for the insertion and removal of all Endpoint Descriptors in the various Host Controller Endpoint Descriptor lists". In the ohci_frame_boundary(), ohci_put_hcca() writes the entire hcca back including the interrupt ED lists which should be under driver control. This violates the specification and can race with a host driver updating that list at the same time. In the OHCI Spec Section 4.6, Transfer Descriptor Queue Processing, it mentioned "Since the TD pointed to by TailP is not accessed by the HC, the Host Controller Driver can initialize that TD and link at least one other to it without creating a coherency or synchronization problem". While the function ohci_put_ed() writes the entire endpoint descriptor back including the TailP which should under driver control. This violate the specification and can race with a host driver updating the TD list at the same time. In each case the solution is to make sure we don't write data which is under driver control. Cc: Gerd Hoffman Signed-off-by: Wei Yang Signed-off-by: David Gibson Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-ohci.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 51fa111390..1a1cc88b1f 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -121,6 +121,11 @@ struct ohci_hcca { uint16_t frame, pad; uint32_t done; }; +#define HCCA_WRITEBACK_OFFSET offsetof(struct ohci_hcca, frame) +#define HCCA_WRITEBACK_SIZE 8 /* frame, pad, done */ + +#define ED_WBACK_OFFSET offsetof(struct ohci_ed, head) +#define ED_WBACK_SIZE 4 static void ohci_bus_stop(OHCIState *ohci); static void ohci_async_cancel_device(OHCIState *ohci, USBDevice *dev); @@ -568,7 +573,13 @@ static inline int ohci_read_hcca(OHCIState *ohci, static inline int ohci_put_ed(OHCIState *ohci, uint32_t addr, struct ohci_ed *ed) { - return put_dwords(ohci, addr, (uint32_t *)ed, sizeof(*ed) >> 2); + /* ed->tail is under control of the HCD. + * Since just ed->head is changed by HC, just write back this + */ + + return put_dwords(ohci, addr + ED_WBACK_OFFSET, + (uint32_t *)((char *)ed + ED_WBACK_OFFSET), + ED_WBACK_SIZE >> 2); } static inline int ohci_put_td(OHCIState *ohci, @@ -587,7 +598,9 @@ static inline int ohci_put_iso_td(OHCIState *ohci, static inline int ohci_put_hcca(OHCIState *ohci, uint32_t addr, struct ohci_hcca *hcca) { - cpu_physical_memory_write(addr + ohci->localmem_base, hcca, sizeof(*hcca)); + cpu_physical_memory_write(addr + ohci->localmem_base + HCCA_WRITEBACK_OFFSET, + (char *)hcca + HCCA_WRITEBACK_OFFSET, + HCCA_WRITEBACK_SIZE); return 1; } From 5ac2731cf821a7ecae90786d9052891afb09dfc2 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 8 Mar 2012 12:27:47 +0100 Subject: [PATCH 05/14] usb: improve packet state sanity checks Add a new function to check whenever the packet state is as expected, log more informations in case it isn't. Signed-off-by: Gerd Hoffmann --- hw/usb.h | 1 + hw/usb/core.c | 37 +++++++++++++++++++++++++++++++------ trace-events | 1 + 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/hw/usb.h b/hw/usb.h index d60d03df9c..e95085f0b3 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -336,6 +336,7 @@ struct USBPacket { void usb_packet_init(USBPacket *p); void usb_packet_set_state(USBPacket *p, USBPacketState state); +void usb_packet_check_state(USBPacket *p, USBPacketState expected); void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep); void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len); int usb_packet_map(USBPacket *p, QEMUSGList *sgl); diff --git a/hw/usb/core.c b/hw/usb/core.c index 494989a5e7..a4048fe3e0 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -378,7 +378,7 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p) } assert(dev == p->ep->dev); assert(dev->state == USB_STATE_DEFAULT); - assert(p->state == USB_PACKET_SETUP); + usb_packet_check_state(p, USB_PACKET_SETUP); assert(p->ep != NULL); if (QTAILQ_EMPTY(&p->ep->queue) || p->ep->pipeline) { @@ -406,7 +406,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p) USBEndpoint *ep = p->ep; int ret; - assert(p->state == USB_PACKET_ASYNC); + usb_packet_check_state(p, USB_PACKET_ASYNC); assert(QTAILQ_FIRST(&ep->queue) == p); usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); @@ -417,7 +417,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p) if (p->state == USB_PACKET_ASYNC) { break; } - assert(p->state == USB_PACKET_QUEUED); + usb_packet_check_state(p, USB_PACKET_QUEUED); ret = usb_process_one(p); if (ret == USB_RET_ASYNC) { usb_packet_set_state(p, USB_PACKET_ASYNC); @@ -450,7 +450,7 @@ void usb_packet_init(USBPacket *p) qemu_iovec_init(&p->iov, 1); } -void usb_packet_set_state(USBPacket *p, USBPacketState state) +static const char *usb_packet_state_name(USBPacketState state) { static const char *name[] = { [USB_PACKET_UNDEFINED] = "undef", @@ -460,11 +460,36 @@ void usb_packet_set_state(USBPacket *p, USBPacketState state) [USB_PACKET_COMPLETE] = "complete", [USB_PACKET_CANCELED] = "canceled", }; + if (state < ARRAY_SIZE(name)) { + return name[state]; + } + return "INVALID"; +} + +void usb_packet_check_state(USBPacket *p, USBPacketState expected) +{ + USBDevice *dev; + USBBus *bus; + + if (p->state == expected) { + return; + } + dev = p->ep->dev; + bus = usb_bus_from_device(dev); + trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p, + usb_packet_state_name(p->state), + usb_packet_state_name(expected)); + assert(!"usb packet state check failed"); +} + +void usb_packet_set_state(USBPacket *p, USBPacketState state) +{ USBDevice *dev = p->ep->dev; USBBus *bus = usb_bus_from_device(dev); - trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr, - p, name[p->state], name[state]); + trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr, p, + usb_packet_state_name(p->state), + usb_packet_state_name(state)); p->state = state; } diff --git a/trace-events b/trace-events index bcfe13a9f7..301374e602 100644 --- a/trace-events +++ b/trace-events @@ -229,6 +229,7 @@ sun4m_iommu_bad_addr(uint64_t addr) "bad addr %"PRIx64 # hw/usb/core.c usb_packet_state_change(int bus, const char *port, int ep, void *p, const char *o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s -> %s" +usb_packet_state_fault(int bus, const char *port, int ep, void *p, const char *o, const char *n) "bus %d, port %s, ep %d, packet %p, state %s, expected %s" # hw/usb/bus.c usb_port_claim(int bus, const char *port) "bus %d, port %s" From 16ce543ed14acc796768a732c9d3ea1288efde24 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 8 Mar 2012 13:15:56 +0100 Subject: [PATCH 06/14] 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 --- hw/usb/hcd-uhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 5c708cf670..476db1f099 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -198,11 +198,12 @@ static void uhci_queue_free(UHCIQueue *queue) g_free(queue); } -static UHCIAsync *uhci_async_alloc(UHCIQueue *queue) +static UHCIAsync *uhci_async_alloc(UHCIQueue *queue, uint32_t addr) { UHCIAsync *async = g_new0(UHCIAsync, 1); async->queue = queue; + async->td = addr; usb_packet_init(&async->packet); pci_dma_sglist_init(&async->sgl, &queue->uhci->dev, 1); @@ -814,7 +815,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in } /* Allocate new packet */ - async = uhci_async_alloc(uhci_queue_get(s, td)); + async = uhci_async_alloc(uhci_queue_get(s, td), addr); if (!async) return 1; @@ -822,7 +823,6 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in * for initial isochronous requests */ async->queue->valid = 32; - async->td = addr; async->isoc = td->ctrl & TD_CTRL_IOS; max_len = ((td->token >> 21) + 1) & 0x7ff; From 60f8afcb5d734b6e8a6ba6cb26254dc04e8d9f8d Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 8 Mar 2012 13:29:07 +0100 Subject: [PATCH 07/14] uhci: fix uhci_async_cancel_all It should also free all queues. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 476db1f099..416f7034b8 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -300,6 +300,7 @@ static void uhci_async_cancel_all(UHCIState *s) uhci_async_unlink(curr); uhci_async_cancel(curr); } + uhci_queue_free(queue); } } From d9a528db7f2d71d92e869e20bda37774f11fbbe1 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 8 Mar 2012 13:37:52 +0100 Subject: [PATCH 08/14] uhci: cancel on schedule stop. Cancel any in-flight transaction when the guest stops the uhci schedule. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 416f7034b8..5177e33c37 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -1126,6 +1126,7 @@ static void uhci_frame_timer(void *opaque) if (!(s->cmd & UHCI_CMD_RS)) { /* Full stop */ qemu_del_timer(s->frame_timer); + uhci_async_cancel_all(s); /* set hchalted bit in status - UHCI11D 2.1.2 */ s->status |= UHCI_STS_HCHALTED; From 50dcc0f85da5d2a74760af4b67c040c4d0c8b939 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Thu, 8 Mar 2012 13:12:38 +0100 Subject: [PATCH 09/14] uhci: tracing support Zap DPRINTF, add tracepoints instead. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 87 +++++++++++++++++------------------------------ trace-events | 31 +++++++++++++++++ 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 5177e33c37..054ae19620 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -31,6 +31,7 @@ #include "qemu-timer.h" #include "iov.h" #include "dma.h" +#include "trace.h" //#define DEBUG //#define DEBUG_DUMP_DATA @@ -76,23 +77,6 @@ #define NB_PORTS 2 -#ifdef DEBUG -#define DPRINTF printf - -static const char *pid2str(int pid) -{ - switch (pid) { - case USB_TOKEN_SETUP: return "SETUP"; - case USB_TOKEN_IN: return "IN"; - case USB_TOKEN_OUT: return "OUT"; - } - return "?"; -} - -#else -#define DPRINTF(...) -#endif - typedef struct UHCIState UHCIState; typedef struct UHCIAsync UHCIAsync; typedef struct UHCIQueue UHCIQueue; @@ -187,6 +171,7 @@ static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td) queue->token = token; QTAILQ_INIT(&queue->asyncs); QTAILQ_INSERT_HEAD(&s->queues, queue, next); + trace_usb_uhci_queue_add(queue->token); return queue; } @@ -194,6 +179,7 @@ static void uhci_queue_free(UHCIQueue *queue) { UHCIState *s = queue->uhci; + trace_usb_uhci_queue_del(queue->token); QTAILQ_REMOVE(&s->queues, queue, next); g_free(queue); } @@ -206,12 +192,14 @@ static UHCIAsync *uhci_async_alloc(UHCIQueue *queue, uint32_t addr) async->td = addr; usb_packet_init(&async->packet); pci_dma_sglist_init(&async->sgl, &queue->uhci->dev, 1); + trace_usb_uhci_packet_add(async->queue->token, async->td); return async; } static void uhci_async_free(UHCIAsync *async) { + trace_usb_uhci_packet_del(async->queue->token, async->td); usb_packet_cleanup(&async->packet); qemu_sglist_destroy(&async->sgl); g_free(async); @@ -221,19 +209,19 @@ static void uhci_async_link(UHCIAsync *async) { UHCIQueue *queue = async->queue; QTAILQ_INSERT_TAIL(&queue->asyncs, async, next); + trace_usb_uhci_packet_link_async(async->queue->token, async->td); } static void uhci_async_unlink(UHCIAsync *async) { UHCIQueue *queue = async->queue; QTAILQ_REMOVE(&queue->asyncs, async, next); + trace_usb_uhci_packet_unlink_async(async->queue->token, async->td); } static void uhci_async_cancel(UHCIAsync *async) { - DPRINTF("uhci: cancel td 0x%x token 0x%x done %u\n", - async->td, async->token, async->done); - + trace_usb_uhci_packet_cancel(async->queue->token, async->td, async->done); if (!async->done) usb_cancel_packet(&async->packet); uhci_async_free(async); @@ -351,7 +339,7 @@ static void uhci_reset(void *opaque) int i; UHCIPort *port; - DPRINTF("uhci: full reset\n"); + trace_usb_uhci_reset(); pci_conf = s->dev.config; @@ -451,12 +439,13 @@ static void uhci_ioport_writew(void *opaque, uint32_t addr, uint32_t val) UHCIState *s = opaque; addr &= 0x1f; - DPRINTF("uhci: writew port=0x%04x val=0x%04x\n", addr, val); + trace_usb_uhci_mmio_writew(addr, val); switch(addr) { case 0x00: if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) { /* start frame processing */ + trace_usb_uhci_schedule_start(); s->expire_time = qemu_get_clock_ns(vm_clock) + (get_ticks_per_sec() / FRAME_TIMER_FREQ); qemu_mod_timer(s->frame_timer, qemu_get_clock_ns(vm_clock)); @@ -561,7 +550,7 @@ static uint32_t uhci_ioport_readw(void *opaque, uint32_t addr) break; } - DPRINTF("uhci: readw port=0x%04x val=0x%04x\n", addr, val); + trace_usb_uhci_mmio_readw(addr, val); return val; } @@ -571,7 +560,7 @@ static void uhci_ioport_writel(void *opaque, uint32_t addr, uint32_t val) UHCIState *s = opaque; addr &= 0x1f; - DPRINTF("uhci: writel port=0x%04x val=0x%08x\n", addr, val); + trace_usb_uhci_mmio_writel(addr, val); switch(addr) { case 0x08: @@ -594,6 +583,7 @@ static uint32_t uhci_ioport_readl(void *opaque, uint32_t addr) val = 0xffffffff; break; } + trace_usb_uhci_mmio_readl(addr, val); return val; } @@ -729,12 +719,14 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_ if ((td->ctrl & TD_CTRL_SPD) && len < max_len) { *int_mask |= 0x02; /* short packet: do not update QH */ - DPRINTF("uhci: short packet. td 0x%x token 0x%x\n", async->td, async->token); + trace_usb_uhci_packet_complete_shortxfer(async->queue->token, + async->td); return 1; } } /* success */ + trace_usb_uhci_packet_complete_success(async->queue->token, async->td); return 0; out: @@ -747,6 +739,7 @@ out: *int_mask |= 0x01; } uhci_update_irq(s); + trace_usb_uhci_packet_complete_stall(async->queue->token, async->td); return 1; case USB_RET_BABBLE: @@ -758,6 +751,7 @@ out: } uhci_update_irq(s); /* frame interrupted */ + trace_usb_uhci_packet_complete_babble(async->queue->token, async->td); return -1; case USB_RET_NAK: @@ -784,6 +778,8 @@ out: if (td->ctrl & TD_CTRL_IOC) *int_mask |= 0x01; uhci_update_irq(s); + trace_usb_uhci_packet_complete_error(async->queue->token, + async->td); } } td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) | @@ -874,8 +870,6 @@ static void uhci_async_complete(USBPort *port, USBPacket *packet) UHCIAsync *async = container_of(packet, UHCIAsync, packet); UHCIState *s = async->queue->uhci; - DPRINTF("uhci: async complete. td 0x%x token 0x%x\n", async->td, async->token); - if (async->isoc) { UHCI_TD td; uint32_t link = async->td; @@ -963,6 +957,7 @@ static void uhci_fill_queue(UHCIState *s, UHCI_TD *td) if (uhci_queue_token(&ptd) != token) { break; } + trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); ret = uhci_handle_td(s, plink, &ptd, &int_mask); assert(ret == 2); /* got USB_RET_ASYNC */ assert(int_mask == 0); @@ -981,8 +976,6 @@ static void uhci_process_frame(UHCIState *s) frame_addr = s->fl_base_addr + ((s->frnum & 0x3ff) << 2); - DPRINTF("uhci: processing frame %d addr 0x%x\n" , s->frnum, frame_addr); - pci_dma_read(&s->dev, frame_addr, &link, 4); le32_to_cpus(&link); @@ -994,6 +987,7 @@ static void uhci_process_frame(UHCIState *s) for (cnt = FRAME_MAX_LOOPS; is_valid(link) && cnt; cnt--) { if (is_qh(link)) { /* QH */ + trace_usb_uhci_qh_load(link & ~0xf); if (qhdb_insert(&qhdb, link)) { /* @@ -1006,14 +1000,14 @@ static void uhci_process_frame(UHCIState *s) * (b) we've reached the usb 1.1 bandwidth, which is * 1280 bytes/frame. */ - DPRINTF("uhci: detected loop. qh 0x%x\n", link); if (td_count == 0) { - DPRINTF("uhci: no transaction last round, stop\n"); + trace_usb_uhci_frame_loop_stop_idle(); break; } else if (bytes_count >= 1280) { - DPRINTF("uhci: bandwidth limit reached, stop\n"); + trace_usb_uhci_frame_loop_stop_bandwidth(); break; } else { + trace_usb_uhci_frame_loop_continue(); td_count = 0; qhdb_reset(&qhdb); qhdb_insert(&qhdb, link); @@ -1024,9 +1018,6 @@ static void uhci_process_frame(UHCIState *s) le32_to_cpus(&qh.link); le32_to_cpus(&qh.el_link); - DPRINTF("uhci: QH 0x%x load. link 0x%x elink 0x%x\n", - link, qh.link, qh.el_link); - if (!is_valid(qh.el_link)) { /* QH w/o elements */ curr_qh = 0; @@ -1045,9 +1036,7 @@ static void uhci_process_frame(UHCIState *s) le32_to_cpus(&td.ctrl); le32_to_cpus(&td.token); le32_to_cpus(&td.buffer); - - DPRINTF("uhci: TD 0x%x load. link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, td.link, td.ctrl, td.token, curr_qh); + trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token); old_td_ctrl = td.ctrl; ret = uhci_handle_td(s, link, &td, &int_mask); @@ -1062,16 +1051,12 @@ static void uhci_process_frame(UHCIState *s) goto out; case 1: /* goto next queue */ - DPRINTF("uhci: TD 0x%x skip. " - "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, td.link, td.ctrl, td.token, curr_qh); + trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; case 2: /* got USB_RET_ASYNC */ - DPRINTF("uhci: TD 0x%x async. " - "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, td.link, td.ctrl, td.token, curr_qh); + trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); if (is_valid(td.link)) { uhci_fill_queue(s, &td); } @@ -1079,10 +1064,7 @@ static void uhci_process_frame(UHCIState *s) continue; case 0: /* completed TD */ - DPRINTF("uhci: TD 0x%x done. " - "link 0x%x ctrl 0x%x token 0x%x qh 0x%x\n", - link, td.link, td.ctrl, td.token, curr_qh); - + trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf); link = td.link; td_count++; bytes_count += (td.ctrl & 0x7ff) + 1; @@ -1095,10 +1077,6 @@ static void uhci_process_frame(UHCIState *s) if (!depth_first(link)) { /* done with this QH */ - - DPRINTF("uhci: QH 0x%x done. link 0x%x elink 0x%x\n", - curr_qh, qh.link, qh.el_link); - curr_qh = 0; link = qh.link; } @@ -1125,12 +1103,11 @@ static void uhci_frame_timer(void *opaque) if (!(s->cmd & UHCI_CMD_RS)) { /* Full stop */ + trace_usb_uhci_schedule_stop(); qemu_del_timer(s->frame_timer); uhci_async_cancel_all(s); /* set hchalted bit in status - UHCI11D 2.1.2 */ s->status |= UHCI_STS_HCHALTED; - - DPRINTF("uhci: halted\n"); return; } @@ -1145,7 +1122,7 @@ static void uhci_frame_timer(void *opaque) /* Start new frame */ s->frnum = (s->frnum + 1) & 0x7ff; - DPRINTF("uhci: new frame #%u\n" , s->frnum); + trace_usb_uhci_frame_start(s->frnum); uhci_async_validate_begin(s); diff --git a/trace-events b/trace-events index 301374e602..c8317a0fa5 100644 --- a/trace-events +++ b/trace-events @@ -258,6 +258,37 @@ usb_ehci_port_reset(uint32_t port, int enable) "reset port #%d - %d" usb_ehci_data(int rw, uint32_t cpage, uint32_t offset, uint32_t addr, uint32_t len, uint32_t bufpos) "write %d, cpage %d, offset 0x%03x, addr 0x%08x, len %d, bufpos %d" usb_ehci_queue_action(void *q, const char *action) "q %p: %s" +# hw/usb/hcd-uhci.c +usb_uhci_reset(void) "=== RESET ===" +usb_uhci_schedule_start(void) "" +usb_uhci_schedule_stop(void) "" +usb_uhci_frame_start(uint32_t num) "nr %d" +usb_uhci_frame_loop_stop_idle(void) "" +usb_uhci_frame_loop_stop_bandwidth(void) "" +usb_uhci_frame_loop_continue(void) "" +usb_uhci_mmio_readw(uint32_t addr, uint32_t val) "addr %04x, ret 0x04%x" +usb_uhci_mmio_writew(uint32_t addr, uint32_t val) "addr %04x, val 0x04%x" +usb_uhci_mmio_readl(uint32_t addr, uint32_t val) "addr %04x, ret 0x08%x" +usb_uhci_mmio_writel(uint32_t addr, uint32_t val) "addr %04x, val 0x08%x" +usb_uhci_queue_add(uint32_t token) "token 0x%x" +usb_uhci_queue_del(uint32_t token) "token 0x%x" +usb_uhci_packet_add(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_link_async(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_unlink_async(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_cancel(uint32_t token, uint32_t addr, int done) "token 0x%x, td 0x%x, done %d" +usb_uhci_packet_complete_success(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_complete_shortxfer(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_complete_stall(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_complete_babble(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_complete_error(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_packet_del(uint32_t token, uint32_t addr) "token 0x%x, td 0x%x" +usb_uhci_qh_load(uint32_t qh) "qh 0x%x" +usb_uhci_td_load(uint32_t qh, uint32_t td, uint32_t ctrl, uint32_t token) "qh 0x%x, td 0x%x, ctrl 0x%x, token 0x%x" +usb_uhci_td_queue(uint32_t td, uint32_t ctrl, uint32_t token) "td 0x%x, ctrl 0x%x, token 0x%x" +usb_uhci_td_nextqh(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" +usb_uhci_td_async(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" +usb_uhci_td_complete(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" + # hw/usb-desc.c usb_desc_device(int addr, int len, int ret) "dev %d query device, len %d, ret %d" usb_desc_device_qualifier(int addr, int len, int ret) "dev %d query device qualifier, len %d, ret %d" From 60e1b2a6ddf1fd9cc93ad81d8ba7d8ac4369cc78 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 9 Mar 2012 11:09:49 +0100 Subject: [PATCH 10/14] uhci: use enum for uhci_handle_td return codes Step #1 (separate for better bisectability): replace numbers with names. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 054ae19620..25dfc2b154 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -77,6 +77,13 @@ #define NB_PORTS 2 +enum { + TD_RESULT_STOP_FRAME = -1, + TD_RESULT_COMPLETE = 0, + TD_RESULT_NEXT_QH = 1, + TD_RESULT_ASYNC = 2, +}; + typedef struct UHCIState UHCIState; typedef struct UHCIAsync UHCIAsync; typedef struct UHCIQueue UHCIQueue; @@ -721,13 +728,13 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_ /* short packet: do not update QH */ trace_usb_uhci_packet_complete_shortxfer(async->queue->token, async->td); - return 1; + return TD_RESULT_NEXT_QH; } } /* success */ trace_usb_uhci_packet_complete_success(async->queue->token, async->td); - return 0; + return TD_RESULT_COMPLETE; out: switch(ret) { @@ -740,7 +747,7 @@ out: } uhci_update_irq(s); trace_usb_uhci_packet_complete_stall(async->queue->token, async->td); - return 1; + return TD_RESULT_NEXT_QH; case USB_RET_BABBLE: td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL; @@ -752,13 +759,13 @@ out: uhci_update_irq(s); /* frame interrupted */ trace_usb_uhci_packet_complete_babble(async->queue->token, async->td); - return -1; + return TD_RESULT_STOP_FRAME; case USB_RET_NAK: td->ctrl |= TD_CTRL_NAK; if (pid == USB_TOKEN_SETUP) break; - return 1; + return TD_RESULT_NEXT_QH; case USB_RET_IOERROR: case USB_RET_NODEV: @@ -784,7 +791,7 @@ out: } td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) | (err << TD_CTRL_ERROR_SHIFT); - return 1; + return TD_RESULT_NEXT_QH; } static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *int_mask) @@ -797,7 +804,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in /* Is active ? */ if (!(td->ctrl & TD_CTRL_ACTIVE)) - return 1; + return TD_RESULT_NEXT_QH; async = uhci_async_find_td(s, addr, td); if (async) { @@ -805,7 +812,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in async->queue->valid = 32; if (!async->done) - return 1; + return TD_RESULT_NEXT_QH; uhci_async_unlink(async); goto done; @@ -814,7 +821,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in /* Allocate new packet */ async = uhci_async_alloc(uhci_queue_get(s, td), addr); if (!async) - return 1; + return TD_RESULT_NEXT_QH; /* valid needs to be large enough to handle 10 frame delay * for initial isochronous requests @@ -848,12 +855,12 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in uhci_async_free(async); s->status |= UHCI_STS_HCPERR; uhci_update_irq(s); - return -1; + return TD_RESULT_STOP_FRAME; } if (len == USB_RET_ASYNC) { uhci_async_link(async); - return 2; + return TD_RESULT_ASYNC; } async->packet.result = len; @@ -959,7 +966,7 @@ static void uhci_fill_queue(UHCIState *s, UHCI_TD *td) } trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); ret = uhci_handle_td(s, plink, &ptd, &int_mask); - assert(ret == 2); /* got USB_RET_ASYNC */ + assert(ret == TD_RESULT_ASYNC); assert(int_mask == 0); plink = ptd.link; } @@ -1047,15 +1054,15 @@ static void uhci_process_frame(UHCIState *s) } switch (ret) { - case -1: /* interrupted frame */ + case TD_RESULT_STOP_FRAME: /* interrupted frame */ goto out; - case 1: /* goto next queue */ + case TD_RESULT_NEXT_QH: trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; - case 2: /* got USB_RET_ASYNC */ + case TD_RESULT_ASYNC: trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); if (is_valid(td.link)) { uhci_fill_queue(s, &td); @@ -1063,7 +1070,7 @@ static void uhci_process_frame(UHCIState *s) link = curr_qh ? qh.link : td.link; continue; - case 0: /* completed TD */ + case TD_RESULT_COMPLETE: trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf); link = td.link; td_count++; From 0cd178ca2cabf94e7acaa64eca6714f966edaa0d Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 9 Mar 2012 11:11:46 +0100 Subject: [PATCH 11/14] 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 --- hw/usb/hcd-uhci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 25dfc2b154..fd50be11a3 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -78,10 +78,10 @@ #define NB_PORTS 2 enum { - TD_RESULT_STOP_FRAME = -1, - TD_RESULT_COMPLETE = 0, - TD_RESULT_NEXT_QH = 1, - TD_RESULT_ASYNC = 2, + TD_RESULT_STOP_FRAME = 10, + TD_RESULT_COMPLETE, + TD_RESULT_NEXT_QH, + TD_RESULT_ASYNC, }; typedef struct UHCIState UHCIState; From 4efe4ef3b8f7530c5a62e23630ba3d439cd82ee6 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 9 Mar 2012 11:15:41 +0100 Subject: [PATCH 12/14] uhci: new uhci_handle_td return code for tds still in flight Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index fd50be11a3..8e34961859 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -81,7 +81,8 @@ enum { TD_RESULT_STOP_FRAME = 10, TD_RESULT_COMPLETE, TD_RESULT_NEXT_QH, - TD_RESULT_ASYNC, + TD_RESULT_ASYNC_START, + TD_RESULT_ASYNC_CONT, }; typedef struct UHCIState UHCIState; @@ -812,7 +813,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in async->queue->valid = 32; if (!async->done) - return TD_RESULT_NEXT_QH; + return TD_RESULT_ASYNC_CONT; uhci_async_unlink(async); goto done; @@ -860,7 +861,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in if (len == USB_RET_ASYNC) { uhci_async_link(async); - return TD_RESULT_ASYNC; + return TD_RESULT_ASYNC_START; } async->packet.result = len; @@ -966,7 +967,7 @@ static void uhci_fill_queue(UHCIState *s, UHCI_TD *td) } trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token); ret = uhci_handle_td(s, plink, &ptd, &int_mask); - assert(ret == TD_RESULT_ASYNC); + assert(ret == TD_RESULT_ASYNC_START); assert(int_mask == 0); plink = ptd.link; } @@ -1058,11 +1059,12 @@ static void uhci_process_frame(UHCIState *s) goto out; case TD_RESULT_NEXT_QH: + case TD_RESULT_ASYNC_CONT: trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf); link = curr_qh ? qh.link : td.link; continue; - case TD_RESULT_ASYNC: + case TD_RESULT_ASYNC_START: trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf); if (is_valid(td.link)) { uhci_fill_queue(s, &td); From 6c60134091cb2754d810b012773754967d8bbf92 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 9 Mar 2012 11:10:48 +0100 Subject: [PATCH 13/14] uhci: alloc can't fail, drop check. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-uhci.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 8e34961859..e55dad914c 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -821,8 +821,6 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in /* Allocate new packet */ async = uhci_async_alloc(uhci_queue_get(s, td), addr); - if (!async) - return TD_RESULT_NEXT_QH; /* valid needs to be large enough to handle 10 frame delay * for initial isochronous requests From e2854bf3239f57d160cfe5230033110c0c0d2837 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Thu, 8 Mar 2012 11:41:10 +1100 Subject: [PATCH 14/14] Endian fix an assertion in usb-msd This fixes a broken endian assumption in an assertion in usb-msd. Cc: Gerd Hoffman Signed-off-by: Benjamin Herrenschmidt Signed-off-by: David Gibson Signed-off-by: Gerd Hoffmann --- hw/usb/dev-storage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 6ffaf70661..bdbe7bdd11 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -193,9 +193,9 @@ static void usb_msd_send_status(MSDState *s, USBPacket *p) int len; DPRINTF("Command status %d tag 0x%x, len %zd\n", - s->csw.status, s->csw.tag, p->iov.size); + s->csw.status, le32_to_cpu(s->csw.tag), p->iov.size); - assert(s->csw.sig == 0x53425355); + assert(s->csw.sig == cpu_to_le32(0x53425355)); len = MIN(sizeof(s->csw), p->iov.size); usb_packet_copy(p, &s->csw, len); memset(&s->csw, 0, sizeof(s->csw)); @@ -233,7 +233,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r s->csw.sig = cpu_to_le32(0x53425355); s->csw.tag = cpu_to_le32(req->tag); - s->csw.residue = s->residue; + s->csw.residue = cpu_to_le32(s->residue); s->csw.status = status != 0; if (s->packet) {