[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:05:47 AEST 2016


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.

> @@ -572,7 +572,7 @@ static bool xhci_alloc_dev(struct xhci_hcd *xhcd, struct usb_dev *hub,
>  		rootport = dev->port;
>  	}
>  	val >>= 4;			/* Remove root hub ID from the string */
> -	val |= LAST_CONTEXT(1) | SLOT_SPEED_SS;  /* FIXME speed, read from PS */
> +	val |= LAST_CONTEXT(1) | slotspeed;
>  	slot->field1 = cpu_to_le32(val);
>  	slot->field2 = cpu_to_le32(ROOT_HUB_PORT(rootport));
>

Regards
Nikunj



More information about the SLOF mailing list