3.13-rc1 regression: Scatter-gather list issues at SuperSpeed only

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

 



When testing 3.14-rc1 with a USB 3.0 Lexar flash drive, the drive fails
to be mounted.  I added a bit of debugging to the USB core:

diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9ff665f1322f..eff59ac37865 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -430,9 +430,16 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
                struct scatterlist *sg;
                int i;
 
-               for_each_sg(urb->sg, sg, urb->num_sgs - 1, i)
-                       if (sg->length % max)
+               for_each_sg(urb->sg, sg, urb->num_sgs - 1, i) {
+                       if (sg->length % max) {
+                               dev_dbg(&dev->dev,
+                                               "URB sg entry %d of %d, size %d not a multiple of ep%d%s max packet %d\n",
+                                               i, urb->num_sgs, sg->length,
+                                               usb_endpoint_num(&ep->desc),
+                                               is_out ? "out" : "in", max);
                                return -EINVAL;
+                       }
+               }
        }

That revealed the SCSI request fails because the USB core is rejecting a
scatter-gather list with an entry that isn't aligned to the max packet size:

Feb 28 09:45:28 xanatos kernel: [  374.351963] scsi 7:0:0:0: Direct-Access     Lexar    JumpDrive        1.00 PQ: 0 ANSI: 6
Feb 28 09:45:28 xanatos kernel: [  374.352751] sd 7:0:0:0: Attached scsi generic sg1 type 0
Feb 28 09:45:28 xanatos kernel: [  374.352847] sd 7:0:0:0: [sdb] 15667200 512-byte logical blocks: (8.02 GB/7.47 GiB)
Feb 28 09:45:28 xanatos kernel: [  374.353014] sd 7:0:0:0: [sdb] Write Protect is off
Feb 28 09:45:28 xanatos kernel: [  374.353021] sd 7:0:0:0: [sdb] Mode Sense: 23 00 00 00
Feb 28 09:45:28 xanatos kernel: [  374.353187] sd 7:0:0:0: [sdb] Write cache: disabled, read cache: disabled, doesn't support DPO or FUA
Feb 28 09:45:28 xanatos kernel: [  374.358458]  sdb: sdb1
Feb 28 09:45:28 xanatos kernel: [  374.359358] sd 7:0:0:0: [sdb] Attached SCSI removable disk
Feb 28 09:45:30 xanatos kernel: [  376.369999] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
Feb 28 09:45:30 xanatos kernel: [  376.449316] usb 2-2: URB sg entry 0 of 17, size 1536 not a multiple of ep1in max packet 1024
Feb 28 09:45:30 xanatos kernel: [  376.561395] usb 2-2: reset SuperSpeed USB device number 3 using xhci_hcd
Feb 28 09:45:30 xanatos kernel: [  376.577350] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff880115f9f9c0
Feb 28 09:45:30 xanatos kernel: [  376.577355] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff880115f9f980
Feb 28 09:45:30 xanatos kernel: [  376.577804] sd 7:0:0:0: [sdb] Unhandled error code
Feb 28 09:45:30 xanatos kernel: [  376.577807] sd 7:0:0:0: [sdb]  
Feb 28 09:45:30 xanatos kernel: [  376.577808] Result: hostbyte=DID_ERROR driverbyte=DRIVER_OK
Feb 28 09:45:30 xanatos kernel: [  376.577809] sd 7:0:0:0: [sdb] CDB: 
Feb 28 09:45:30 xanatos kernel: [  376.577810] Read(10): 28 00 00 00 08 bd 00 00 80 00
Feb 28 09:45:30 xanatos kernel: [  376.577816] end_request: I/O error, dev sdb, sector 2237
Feb 28 09:45:48 xanatos kernel: [  394.569635] usb 2-2: USB disconnect, device number 3
Feb 28 09:46:01 xanatos kernel: [  407.165252] sd 7:0:0:0: [sdb] Unhandled error code
Feb 28 09:46:01 xanatos kernel: [  407.165260] sd 7:0:0:0: [sdb]  
Feb 28 09:46:01 xanatos kernel: [  407.165264] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Feb 28 09:46:01 xanatos kernel: [  407.165267] sd 7:0:0:0: [sdb] CDB: 
Feb 28 09:46:01 xanatos kernel: [  407.165269] Read(10): 28 00 00 00 08 be 00 00 7f 00
Feb 28 09:46:01 xanatos kernel: [  407.165287] end_request: I/O error, dev sdb, sector 2238
Feb 28 09:46:01 xanatos kernel: [  407.165404] FAT-fs (sdb1): FAT read failed (blocknr 2109)
Feb 28 09:46:01 xanatos kernel: [  407.165413] sd 7:0:0:0: [sdb] Unhandled error code
Feb 28 09:46:01 xanatos kernel: [  407.165419] sd 7:0:0:0: [sdb]  
Feb 28 09:46:01 xanatos kernel: [  407.165424] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Feb 28 09:46:01 xanatos kernel: [  407.165429] sd 7:0:0:0: [sdb] CDB: 
Feb 28 09:46:01 xanatos kernel: [  407.165434] Read(10): 28 00 00 00 09 3d 00 00 7d 00
Feb 28 09:46:01 xanatos kernel: [  407.165469] end_request: I/O error, dev sdb, sector 2365
Feb 28 09:46:01 xanatos kernel: [  407.233418] FAT-fs (sdb1): Directory bread(block 32640) failed

It's failing because of commit 247bf557273d "xhci 1.0: Limit
arbitrarily-aligned scatter gather."  That commit clears the
hcd->self.no_sg_constraint flag if the host is a 1.0 host (which my
Panther Point host is).  It was put in to avoid TD fragment issues on
1.0 hosts with ethernet devices.  (Note, this also means that David
Laight's potential work-around patch [1] wouldn't help if
arbitrary-length scatter gather bigger than a ring segment was
submitted.)

The behavior for reproducing this is odd.  I can only reproduce this on
my Ubuntu 13.10 laptop with Intel Panther Point xHCI, when the device is
running at SuperSpeed.  If I plug the device into an EHCI port, or
behind a USB 2.0 hub plugged into an xHCI port, I never see these
arbitrary-length scatter-gather list entries.  Dan can't reproduce this
on his Intel Haswell machine running Fedora at all.

The only speed-based decision I see usb-storage making is whether to
clear the US_FLOW_GO_SLOW flag.  Changing that to set the flag for
SuperSpeed devices as well didn't help:

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 1c0b89f2a138..85aac92ee0f1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -572,10 +572,10 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id,
        }
 
        /*
-        * This flag is only needed when we're in high-speed, so let's
-        * disable it if we're in full-speed
+        * This flag is only needed when we're in high-speed or SuperSpeed,
+        * so let's disable it otherwise
         */
-       if (dev->speed != USB_SPEED_HIGH)
+       if (dev->speed == USB_SPEED_LOW || dev->speed == USB_SPEED_FULL)
                us->fflags &= ~US_FL_GO_SLOW;
 
        if (us->fflags)

I'm stumped as to why we get arbitrary-length scatter-gather for
SuperSpeed devices only, and only under Ubuntu.  Perhaps this comes
directly from userspace?

If we can't figure out how to get max-packet sized scatter-gather list
entries from the mass storage driver, Mathias is going to need to:

revert commit 3804fad45411 USBNET: ax88179_178a: enable tso if usb host supports sg dma
revert commit 247bf557273d xhci 1.0: Limit arbitrarily-aligned scatter gather.

And we'll need to focus on getting the TD fragments supported in 3.16.

Sarah Sharp

[1] http://marc.info/?l=linux-usb&m=139048455603357&w=2
--
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