|
|
9ae3a8 |
From 2eb03118784d98cc6cd1d1cadd2badc0cfd19469 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 11 Jul 2014 14:21:08 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 28/43] usb: add usb_pick_speed
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1405088470-24115-36-git-send-email-kraxel@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 59839
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 35/37] usb: add usb_pick_speed
|
|
|
9ae3a8 |
Bugzilla: 1075846
|
|
|
9ae3a8 |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
We can pick the usb port speed in generic code, by looking at the port
|
|
|
9ae3a8 |
and device speed masks and looking for the fastest match. So add a
|
|
|
9ae3a8 |
function to do exactly that, and drop the speed setting code from
|
|
|
9ae3a8 |
usb_desc_attach as it isn't needed any more.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This way we can set the device speed before calling port->ops->attach,
|
|
|
9ae3a8 |
which fixes some xhci hotplug issues.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1046873
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit b791c3b38c7969cb9f4acda8229e19fd865a1c08)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/core.c | 21 +++++++++++++++++++++
|
|
|
9ae3a8 |
hw/usb/desc.c | 12 ------------
|
|
|
9ae3a8 |
include/hw/usb.h | 1 +
|
|
|
9ae3a8 |
3 files changed, 22 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/usb/core.c | 21 +++++++++++++++++++++
|
|
|
9ae3a8 |
hw/usb/desc.c | 12 ------------
|
|
|
9ae3a8 |
include/hw/usb.h | 1 +
|
|
|
9ae3a8 |
3 files changed, 22 insertions(+), 12 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/usb/core.c b/hw/usb/core.c
|
|
|
9ae3a8 |
index 67ba7d6..cf34755 100644
|
|
|
9ae3a8 |
--- a/hw/usb/core.c
|
|
|
9ae3a8 |
+++ b/hw/usb/core.c
|
|
|
9ae3a8 |
@@ -28,6 +28,26 @@
|
|
|
9ae3a8 |
#include "qemu/iov.h"
|
|
|
9ae3a8 |
#include "trace.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void usb_pick_speed(USBPort *port)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ static const int speeds[] = {
|
|
|
9ae3a8 |
+ USB_SPEED_SUPER,
|
|
|
9ae3a8 |
+ USB_SPEED_HIGH,
|
|
|
9ae3a8 |
+ USB_SPEED_FULL,
|
|
|
9ae3a8 |
+ USB_SPEED_LOW,
|
|
|
9ae3a8 |
+ };
|
|
|
9ae3a8 |
+ USBDevice *udev = port->dev;
|
|
|
9ae3a8 |
+ int i;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ for (i = 0; i < ARRAY_SIZE(speeds); i++) {
|
|
|
9ae3a8 |
+ if ((udev->speedmask & (1 << speeds[i])) &&
|
|
|
9ae3a8 |
+ (port->speedmask & (1 << speeds[i]))) {
|
|
|
9ae3a8 |
+ udev->speed = speeds[i];
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
void usb_attach(USBPort *port)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
USBDevice *dev = port->dev;
|
|
|
9ae3a8 |
@@ -35,6 +55,7 @@ void usb_attach(USBPort *port)
|
|
|
9ae3a8 |
assert(dev != NULL);
|
|
|
9ae3a8 |
assert(dev->attached);
|
|
|
9ae3a8 |
assert(dev->state == USB_STATE_NOTATTACHED);
|
|
|
9ae3a8 |
+ usb_pick_speed(port);
|
|
|
9ae3a8 |
port->ops->attach(port);
|
|
|
9ae3a8 |
dev->state = USB_STATE_ATTACHED;
|
|
|
9ae3a8 |
usb_device_handle_attach(dev);
|
|
|
9ae3a8 |
diff --git a/hw/usb/desc.c b/hw/usb/desc.c
|
|
|
9ae3a8 |
index f133ddb..138881f 100644
|
|
|
9ae3a8 |
--- a/hw/usb/desc.c
|
|
|
9ae3a8 |
+++ b/hw/usb/desc.c
|
|
|
9ae3a8 |
@@ -518,18 +518,6 @@ void usb_desc_init(USBDevice *dev)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void usb_desc_attach(USBDevice *dev)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- const USBDesc *desc = usb_device_get_usb_desc(dev);
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- assert(desc != NULL);
|
|
|
9ae3a8 |
- if (desc->super && (dev->port->speedmask & USB_SPEED_MASK_SUPER)) {
|
|
|
9ae3a8 |
- dev->speed = USB_SPEED_SUPER;
|
|
|
9ae3a8 |
- } else if (desc->high && (dev->port->speedmask & USB_SPEED_MASK_HIGH)) {
|
|
|
9ae3a8 |
- dev->speed = USB_SPEED_HIGH;
|
|
|
9ae3a8 |
- } else if (desc->full && (dev->port->speedmask & USB_SPEED_MASK_FULL)) {
|
|
|
9ae3a8 |
- dev->speed = USB_SPEED_FULL;
|
|
|
9ae3a8 |
- } else {
|
|
|
9ae3a8 |
- return;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
usb_desc_setdefaults(dev);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/include/hw/usb.h b/include/hw/usb.h
|
|
|
9ae3a8 |
index 000001b..ebbff47 100644
|
|
|
9ae3a8 |
--- a/include/hw/usb.h
|
|
|
9ae3a8 |
+++ b/include/hw/usb.h
|
|
|
9ae3a8 |
@@ -453,6 +453,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep);
|
|
|
9ae3a8 |
void usb_combined_input_packet_complete(USBDevice *dev, USBPacket *p);
|
|
|
9ae3a8 |
void usb_combined_packet_cancel(USBDevice *dev, USBPacket *p);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void usb_pick_speed(USBPort *port);
|
|
|
9ae3a8 |
void usb_attach(USBPort *port);
|
|
|
9ae3a8 |
void usb_detach(USBPort *port);
|
|
|
9ae3a8 |
void usb_port_reset(USBPort *port);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|