On Mon, Jun 28, 2010 at 10:43:22AM +0200, Rodolfo Giometti wrote: > On Sun, Jun 27, 2010 at 04:57:30PM +0200, Andrea Righi wrote: > > On Wed, Jun 23, 2010 at 01:08:43PM -0400, Alan Stern wrote: > > > On Wed, 23 Jun 2010, Andrea Righi wrote: > > > > > > > ffff88007a862cc0 2028329666 S Bi:2:002:1 -115 4096 < > > > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > device stalls here (in this case with a large URB)... > > > > > > > > ffff88007a862cc0 2058694464 C Bi:2:002:1 -104 0 > > > > > > > > > > > > > I'm about out of ideas. You could look at the qh status values in the > > > > > "async" debugging file while waiting for the URB to time out, but they > > > > > probably won't tell you anything new. > > > > > > > > for this last case: > > > > > > > > $ cat /sys/kernel/debug/usb/ehci/oxu210hp_sph/async > > > > qh/ffff88007b051800 dev2 hs ep1 42002102 40000000 (90008d80* data1 nak0) > > > > ffffc90005001120*in len=4096 10008d80 urb ffff88007a862cc0 > > > > > > Nothing stands out as significant. The values indicate that the > > > controller hasn't received any data from the device, but that's > > > probably not true in reality. > > > > I did many tests in these past days, unfortunately without any > > significant result. :( > > > > The only "bad" thing I've found is that the communication via > > usb_stor_bulk_transfer_sglist() seems to fail only with "large" > > transfers (even 192 is sufficient to trigger the problem, while small > > transfers seems to work fine): > > > > $ dmesg | grep "Status code\|bulk_transfer" > > [ 3199.220552] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.220761] usb-storage: Status code 0; transferred 31/31 > > [ 3199.220767] usb-storage: usb_stor_bulk_transfer_sglist: xfer 36 bytes, 1 entries > > [ 3199.257161] usb-storage: Status code 0; transferred 36/36 > > [ 3199.257168] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.257380] usb-storage: Status code 0; transferred 13/13 > > [ 3199.269690] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.269896] usb-storage: Status code 0; transferred 31/31 > > [ 3199.269903] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.270141] usb-storage: Status code 0; transferred 13/13 > > [ 3199.270173] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.270390] usb-storage: Status code 0; transferred 31/31 > > [ 3199.270396] usb-storage: usb_stor_bulk_transfer_sglist: xfer 18 bytes, 1 entries > > [ 3199.647916] usb-storage: Status code 0; transferred 18/18 > > [ 3199.647924] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.648143] usb-storage: Status code 0; transferred 13/13 > > [ 3199.648223] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.648393] usb-storage: Status code 0; transferred 31/31 > > [ 3199.648399] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.648642] usb-storage: Status code 0; transferred 13/13 > > [ 3199.648702] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.648892] usb-storage: Status code 0; transferred 31/31 > > [ 3199.648897] usb-storage: usb_stor_bulk_transfer_sglist: xfer 8 bytes, 1 entries > > [ 3199.649648] usb-storage: Status code 0; transferred 8/8 > > [ 3199.649655] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.649891] usb-storage: Status code 0; transferred 13/13 > > [ 3199.649952] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.658891] usb-storage: Status code 0; transferred 31/31 > > [ 3199.658897] usb-storage: usb_stor_bulk_transfer_sglist: xfer 192 bytes, 1 entries > > [ 3199.659233] usb-storage: Status code -121; transferred 36/192 > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > [ 3199.659240] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.659401] usb-storage: Status code 0; transferred 13/13 > > [ 3199.659544] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.659787] usb-storage: Status code 0; transferred 31/31 > > [ 3199.659794] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.660054] usb-storage: Status code 0; transferred 13/13 > > [ 3199.660914] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.661184] usb-storage: Status code 0; transferred 31/31 > > [ 3199.661191] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.661793] usb-storage: Status code 0; transferred 13/13 > > [ 3199.661824] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.662027] usb-storage: Status code 0; transferred 31/31 > > [ 3199.662032] usb-storage: usb_stor_bulk_transfer_sglist: xfer 18 bytes, 1 entries > > [ 3199.662289] usb-storage: Status code 0; transferred 18/18 > > [ 3199.662296] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.662526] usb-storage: Status code 0; transferred 13/13 > > [ 3199.662614] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.662775] usb-storage: Status code 0; transferred 31/31 > > [ 3199.662782] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.663025] usb-storage: Status code 0; transferred 13/13 > > [ 3199.663086] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.663273] usb-storage: Status code 0; transferred 31/31 > > [ 3199.663279] usb-storage: usb_stor_bulk_transfer_sglist: xfer 8 bytes, 1 entries > > [ 3199.664035] usb-storage: Status code 0; transferred 8/8 > > [ 3199.664042] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.664277] usb-storage: Status code 0; transferred 13/13 > > [ 3199.664338] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.664522] usb-storage: Status code 0; transferred 31/31 > > [ 3199.664528] usb-storage: usb_stor_bulk_transfer_sglist: xfer 192 bytes, 1 entries > > [ 3199.664840] usb-storage: Status code -121; transferred 36/192 > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > [ 3199.664848] usb-storage: usb_stor_bulk_transfer_buf: xfer 13 bytes > > [ 3199.665043] usb-storage: Status code 0; transferred 13/13 > > [ 3199.665149] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes > > [ 3199.665273] usb-storage: Status code 0; transferred 31/31 > > [ 3199.665279] usb-storage: usb_stor_bulk_transfer_sglist: xfer 4096 bytes, 1 entries > > [ 3230.081270] usb-storage: Status code -104; transferred 0/4096 > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > The error pattern seems quite clear looking at this particular log. > > > > Maybe the controller is just buggy and it's not able to handle "large" > > bulk transfers... I don't see a quick way to limit the size of bulk > > transfers, so I'd like to do a test adding an intermediate layer to > > split large bulk transfers into smaller one. > > That was exactly my problem, that's why I used the mini-URB (the layer > you wish adding). mmmh.. I'm not yet convinced that the mini-URB layer is the solution for this problem. As a simple proof-of-concept I tried to truncate the URBs greater than 512 bytes (see the patch below): ... [ 80.826404] usb-storage: Command READ_10 (10 bytes) [ 80.826406] usb-storage: 28 00 00 00 00 00 00 00 08 00 [ 80.826423] usb-storage: Bulk Command S 0x43425355 T 0xd L 4096 F 0 Trg 0 LUN 0 CL 0 [ 80.826425] usb-storage: usb_stor_bulk_transfer_buf: xfer 31 bytes [ 80.826439] oxu210hp-ehci 0000:04:09.0: submit_async 1 urb ffff88007991cf00 ep2out len 31, qtd ffffc90006501180 [qh ffff8800792cb9c0] [ 80.826636] oxu210hp-ehci 0000:04:09.0: irq status 48089 Async FLR INT [ 80.826655] oxu210hp-ehci 0000:04:09.0: ehci_urb_done 1 urb ffff88007991cf00 ep2out status 0 len 31/31 [ 80.826663] usb-storage: Status code 0; transferred 31/31 [ 80.826665] usb-storage: -- transfer complete [ 80.826667] usb-storage: Bulk command transfer result=0 [ 80.826669] usb-storage: usb_stor_bulk_transfer_sglist: xfer 4096 bytes, 1 entries ... the 4096 xfer is truncated to 512 bytes: [ 80.826904] oxu210hp-ehci 0000:04:09.0: submit_async 1 urb ffff88007991c540 ep1in len 512, qtd ffffc90006501060 [qh ffff880079a170c0] [ 80.840030] oxu210hp-ehci 0000:04:09.0: irq status 480a8 Async IAA FLR [ 111.080017] usb-storage: command_abort called [ 111.080022] usb-storage: usb_stor_stop_transport called [ 111.080024] usb-storage: -- cancelling sg request [ 111.080037] oxu210hp-ehci 0000:04:09.0: irq status 480a8 Async IAA FLR [ 111.080061] oxu210hp-ehci 0000:04:09.0: ehci_urb_done 1 urb ffff88007991c540 ep1in status -115 len 0/512 [ 111.080206] usb-storage: Status code -104; transferred 0/4096 [ 111.080208] usb-storage: -- transfer cancelled ... and, again, no reply from the device. :( Signed-off-by: Andrea Righi <arighi@xxxxxxxxxxx> --- drivers/usb/core/hcd.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 69ddb72..ea87191 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1413,6 +1413,8 @@ static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, return ret; } +#define MAX_URB_SIZE 512 + /*-------------------------------------------------------------------------*/ /* may be called in any context with a valid urb->dev usecount @@ -1425,6 +1427,9 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) int status; struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); + if (urb->transfer_buffer_length > MAX_URB_SIZE) + urb->transfer_buffer_length = MAX_URB_SIZE; + /* increment urb's reference count as part of giving it to the HCD * (which will control it). HCD guarantees that it either returns * an error or calls giveback(), but not both. -- 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