Re: [PATCH v2] storage: accept some UAS devices if streams are unavailable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 11, 2014 at 08:36:04PM +0100, oliver@xxxxxxxxxx wrote:
> From: Oliver Neukum <oneukum@xxxxxxx>
> 
> On some older XHCIs streams are not supported and the UAS driver
> will fail at probe time. For those devices storage should try
> to bind to UAS devices.
> This patch adds a flag for stream support to HCDs and evaluates
> it.

Oliver, the logic in this patch is off.  When I plug it into an Intel
Panther Point xHCI host that has hcc_params set to 0x20007181, which
translates to 2^(7+1) stream IDs, the device comes up as usb-storage,
not uas:

sarah@xanatos:~$ lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

> Signed-off-by: Oliver Neukum <oliver@xxxxxxxxxx>
> ---
>  drivers/usb/host/xhci-pci.c      | 3 +++
>  drivers/usb/host/xhci-plat.c     | 3 +++
>  drivers/usb/storage/uas-detect.h | 4 ++++
>  include/linux/usb/hcd.h          | 1 +
>  4 files changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index 73f5208..93d4895 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -223,6 +223,9 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	if (xhci->quirks & XHCI_LPM_SUPPORT)
>  		hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
>  
> +	if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> +		hcd->can_do_streams = 1;
> +
>  	return 0;

If you look at the code before that, hcd is set to the host controller
driver structure for the USB 2.0 hcd:

	/* USB 2.0 roothub is stored in the PCI device now. */
        hcd = dev_get_drvdata(&dev->dev);
        xhci = hcd_to_xhci(hcd);
        xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
                                pci_name(dev), hcd);
        if (!xhci->shared_hcd) {
                retval = -ENOMEM;
                goto dealloc_usb2_hcd;
        }

        /* Set the xHCI pointer before xhci_pci_setup() (aka hcd_driver.reset)
         * is called by usb_add_hcd().
         */
        *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;

        retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
                        IRQF_SHARED);
        if (retval)
                goto put_usb3_hcd;
        /* Roothub already marked as USB 3.0 speed */

So your patch should set xhci->shared_hcd->can_do_streams instead.

>  put_usb3_hcd:
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index d9c169f..6e328ec 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -156,6 +156,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  	 */
>  	*((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci;
>  
> +	if (HCC_MAX_PSA(xhci->hcc_params) >=4)
> +		hcd->can_do_streams = 1;
> +
>  	ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>  	if (ret)
>  		goto put_usb3_hcd;

Same here.

> diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
> index b8a02e1..bb05b98 100644
> --- a/drivers/usb/storage/uas-detect.h
> +++ b/drivers/usb/storage/uas-detect.h
> @@ -72,6 +72,7 @@ static int uas_use_uas_driver(struct usb_interface *intf,
>  {
>  	struct usb_host_endpoint *eps[4] = { };
>  	struct usb_device *udev = interface_to_usbdev(intf);
> +	struct usb_hcd *hcd = bus_to_hcd(udev->bus);
>  	unsigned long flags = id->driver_info;
>  	int r, alt;
>  
> @@ -80,6 +81,9 @@ static int uas_use_uas_driver(struct usb_interface *intf,
>  	if (flags & US_FL_IGNORE_UAS)
>  		return 0;
>  
> +	if (udev->speed >= USB_SPEED_SUPER && !hcd->can_do_streams)
> +		return 0;
> +

You probably want to add some debugging to let the user know that their
xHCI host doesn't support streams, and that's required for USB 3.0 UAS
devices.

Can you fix these issues?

Thanks,
Sarah Sharp
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux