[SLOF] [PATCH v2 5/5] usb: Set XHCI slot speed according to port status

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Tue Aug 2 20:26:30 AEST 2016


Thomas Huth <thuth at redhat.com> writes:

> On 02.08.2016 12:05, Nikunj A Dadhania wrote:
>> Thomas Huth <thuth at redhat.com> writes:
>> 
>>> So far, the code was always assuming SuperSpeed for all devices,
>>> which seemed to work OK with QEMU ... but let's better play safe
>>> instead and use the speed from the port status instead.
>>>
>>> Signed-off-by: Thomas Huth <thuth at redhat.com>
>>> ---
>>>  lib/libusb/usb-hub.c  | 15 ++++++++++++++-
>>>  lib/libusb/usb-xhci.c | 12 +++++++-----
>>>  lib/libusb/usb-xhci.h |  2 +-
>>>  3 files changed, 22 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/lib/libusb/usb-hub.c b/lib/libusb/usb-hub.c
>>> index 5f56630..58e552f 100644
>>> --- a/lib/libusb/usb-hub.c
>>> +++ b/lib/libusb/usb-hub.c
>>> @@ -39,6 +39,7 @@ struct usb_hub_ps {
>>>  #define HUB_PS_RESET                 (1 << 4)
>>>  #define HUB_PS_POWER                 (1 << 8)
>>>  #define HUB_PS_LOW_SPEED             (1 << 9)
>>> +#define HUB_PS_HIGH_SPEED            (1 << 10)
>>>
>>>  #define HUB_PF_CONNECTION        0
>>>  #define HUB_PF_ENABLE            1
>>> @@ -157,6 +158,17 @@ static bool usb_hub_init_dev(struct usb_dev *hub_dev, int port)
>>>  	struct usb_dev *newdev;
>>>
>>>  	if (hub_dev->hcidev->type == USB_XHCI) {
>>> +		struct usb_hub_ps ps;
>>> +		int slotspeed;
>>> +
>>> +		hub_get_port_status(hub_dev, port, &ps, sizeof(ps));
>>> +		if (le16_to_cpu(ps.wPortStatus) & HUB_PS_LOW_SPEED)
>>> +			slotspeed = SLOT_SPEED_LS;
>>> +		else if (le16_to_cpu(ps.wPortStatus) & HUB_PS_HIGH_SPEED)
>>> +			slotspeed = SLOT_SPEED_HS;
>>> +		else
>>> +			slotspeed = SLOT_SPEED_FS;
>>> +
>> 
>> That means there is no possibility to have a SLOT_SPEED_SS on the hub.
>
> Yes, the current code in usb-hub.c seems to be for USB 2.0 hubs only -
> and as far as I can see in the QEMU sources, it also only emulates an
> USB 2.0 hub (see file hw/usb/dev-hub.c) ... so I'm afraid we're
> currently bound to USB 2.0 here. Or did I miss something?

Nope, i did remember something similar, but could trace where from.

> (it shouldn't hurt much, though, I think, since QEMU does not really
> care about the speed settings and emulates things as fast as possible,
> as far as I know).

Yes.

Regards
Nikunj



More information about the SLOF mailing list