Re: [usb-storage] Re: usb3 fails to write when using usb3 hub in usb3 port

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

 



On Tue, 25 Sep 2012, Sarah Sharp wrote:

> Alan, I'm wondering if the xHCI ring expansion is causing issues with
> USB hard drives under xHCI.  Testing with a Buffalo USB 3.0 hard drive
> with an NEC uPD720200 xHCI host, I see that the usb-storage and SCSI
> initialization produces I/O errors on random sectors in 3.4.0, 3.4.6,
> and 3.5.0.  I can't get those errors to be reproduced in 3.3.1.
> 
> The xHCI ring expansion was added in 3.4, and we changed the xHCI's
> sg_tablesize:
> 
> int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
> {
> ...
>         /* Accept arbitrarily long scatter-gather lists */
>         hcd->self.sg_tablesize = ~0;
> 
> The usb-storage driver sets the tablesize thus:
> 
> static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
> {
>         struct usb_device *usb_dev = interface_to_usbdev(intf);
> 
>         if (usb_dev->bus->sg_tablesize) {
>                 return usb_dev->bus->sg_tablesize;
>         }
>         return SG_ALL;
> }
> 
> I notice that SG_ALL is set to SCSI_MAX_SG_SEGMENTS, which is only 128.
> Should we be passing an arbitrarily large number to the SCSI core?

Yes, there's no reason not to.  The block layer will make sure that
each individual request has a sufficiently small number of segments.

> There's some wording in include/scsi/scsi.h about also limiting the
> number of chained sgs to 2048.  I'm wondering if we're hitting some bugs
> in the SCSI layer because we're setting the sg_tablesize so high.

I doubt it.  Anyway, this stuff is handled by the block layer now, not
the SCSI layer.  If you look through drivers/scsi, you'll see that 
SG_ALL is used only in various SCSI interface drivers, not in the core.

> Alternately, we could be hitting bugs in the USB 3.0 firmware when we
> attempt to issue a read or write that's too big.  The read on Adrian's
> hard drive failed on a bigger read request (122880 bytes).  It would be
> interesting to see if it works fine if the xHCI sg_tablesize is limited.
> I'm going to try that with my own drive on 3.5.4 and see if it helps.

There were examples in the earlier usbmon traces where 122880-byte 
reads succeeded, for whatever that's worth...

I doubt very much that you are anywhere close to hitting that limit.  
If a 120-KB transfer has more than 128 SG segments then on average each
segment would be under 1024 bytes, a lot smaller than a page, which
seems unlikely.  I don't think I've ever seen a transfer needing more
than about 8 segments.

Alan Stern

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux