From ae33eacb653ec4a7325072df71cb5f7cf26b6c08 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 12 Sep 2012 13:10:20 -0300 Subject: [RHEL6 qemu-kvm PATCH 01/14] usb: unique packet ids RH-Author: Hans de Goede Message-id: <1347455431-11260-2-git-send-email-hdegoede@redhat.com> Patchwork-id: 41852 O-Subject: [RHEL-6.4 qemu-kvm PATCH 01/12] usb: unique packet ids Bugzilla: RH-Acked-by: Alon Levy RH-Acked-by: Gerd Hoffmann RH-Acked-by: Christophe Fergeau Bugzilla-related: 805172 From: Gerd Hoffmann 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 descriptor for this. musb needs a different approach because there is no transfer descriptor. But musb also doesn't support pipelining, so we have never more than one packet per endpoint in flight. So we go create an ID based on endpoint and device address. Signed-off-by: Gerd Hoffmann (cherry picked from commit e983395d30d1d5bfa0ed3ae9c028c130f7c498cc) Conflicts: hw/usb-ehci.c hw/usb-musb.c hw/usb-ohci.c hw/usb-uhci.c hw/usb.h hw/usb/core.c hw/usb/hcd-xhci.c [ rhel-6: only update ehci & uhci, open code id setting as we don't have usb_packet_setup() ] --- hw/usb-ehci.c | 7 +++++-- hw/usb-uhci.c | 1 + hw/usb.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) Signed-off-by: Eduardo Habkost --- hw/usb-ehci.c | 7 +++++-- hw/usb-uhci.c | 1 + hw/usb.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index b4772c9..86b187f 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -1390,6 +1390,7 @@ static int ehci_execute(EHCIQueue *q) q->packet.devep = endp; q->packet.data = q->buffer; q->packet.len = q->tbytes; + q->packet.id = q->qtdaddr; ret = usb_handle_packet(dev, &q->packet); @@ -1414,7 +1415,8 @@ static int ehci_execute(EHCIQueue *q) */ static int ehci_process_itd(EHCIState *ehci, - EHCIitd *itd) + EHCIitd *itd, + uint32_t addr) { USBPort *port; USBDevice *dev; @@ -1480,6 +1482,7 @@ static int ehci_process_itd(EHCIState *ehci, ehci->ipacket.devep = endp; ehci->ipacket.data = ehci->ibuffer; ehci->ipacket.len = len; + ehci->ipacket.id = addr; ret = usb_handle_packet(dev, &ehci->ipacket); @@ -1725,7 +1728,7 @@ static int ehci_state_fetchitd(EHCIState *ehci, int async) sizeof(EHCIitd) >> 2); ehci_trace_itd(ehci, entry, &itd); - if (ehci_process_itd(ehci, &itd) != 0) { + if (ehci_process_itd(ehci, &itd, entry) != 0) { return -1; } diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c index 9ab4154..8cfe64e 100644 --- a/hw/usb-uhci.c +++ b/hw/usb-uhci.c @@ -831,6 +831,7 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr, UHCI_TD *td, uint32_t *in async->packet.devep = (td->token >> 15) & 0xf; async->packet.data = async->buffer; async->packet.len = max_len; + async->packet.id = addr; switch(pid) { case USB_TOKEN_OUT: diff --git a/hw/usb.h b/hw/usb.h index e1b2b5e..5728208 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -279,6 +279,7 @@ typedef void USBCallback(USBPacket * packet, void *opaque); struct USBPacket { /* Data fields for use by the driver. */ int pid; + uint64_t id; uint8_t devaddr; uint8_t devep; uint8_t *data; -- 1.7.11.4