Skip to contentSkip to conversation

usb-strage not working in the latest kernel 2.4

DISCUSSION Tomita, Haruo 3 participants 5 messages Sep 7, 2003 – Sep 9, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Alan,

Thank you for your help and useful comment.

Alan wrote:

Haruo> I tested using kernel 2.4.22-bk6. It failed by the Haruo> following two patterns.
Haruo> 1. Bulk command transfer result=-104 Haruo> 2. usb_stor_bulk_msg() returned -32

Alan> This was two different failures on two separate runs?

Yes. I tested separately.
It is because it is hard to generate an error in testing two simultaneously. When testing simultaneously, much time is required by the time it generates an error. The reason is not known.

Haruo> 1. Bulk command transfer result=-104

[skip]

Alan> This was the same sort of pattern we saw before. No data was Alan> transferred from the drive, and the command timed out Alan> and was aborted.

I am also looking at this pattern repeatedly.
It seems that a device does not answer in the case of kernel 2.4. However, when operating by kernel 2.6 and two or more devices are connected simultaneously, it operates.
I cannot think the error of a device.

[skip]

Haruo> hub.c: port 1, portstatus 503, change 10, 480 Mb/s Haruo> usb.c: ignoring set_interface for dev 3, iface 0, alt 0 Haruo> usb-storage: Examinging driver usb-storage...skipping ourselves. Haruo> usb-storage: bus_reset() complete

Alan> This time the bus_reset() routine worked, which is an Alan> improvement over
Alan> what you were seeing before. But the device still didn't respond:

If a device becomes an error, it seems that reset is not effective. Using ioctl (fd, USBDEVFS_RESET, 0) and this device,
Is checking whether a device can reset correctly by performing effective?

[skip]

Haruo> scsi: device set offline - not ready or command retry Haruo> failed after bus reset: host 0 channel 0 id 0 lun 0 Haruo> SCSI cdrom error : host 0 channel 0 id 0 lun 0 return code = 50000

Haruo>  I/O error: dev 0b:00, sector 473224
Haruo>  I/O error: dev 0b:00, sector 473228
Haruo>  I/O error: dev 0b:00, sector 473476
Haruo>  I/O error: dev 0b:00, sector 473224

Alan> Once that happened there were no error recovery procedures Alan> left to try, so
Alan> the driver gave up and marked the device offline.

Doesn't a device receive any commands?

Alan> There's something a little strange I just noticed in the log. It's Alan> probably not related to your problem, but we should check it Alan> out anyway.
Alan> Please send a copy of /proc/bus/usb/devices, with the drive Alan> plugged in.

OK.

Quoted 1 line
Quoted 1 line

2. usb_stor_bulk_msg() returned -32

Alan> Under what circumstances did this error occur? It must have Alan> been quite different from the other error.

The used device(Logitec LCW-WIN40U2) is different. It is the same circumstances except a device.

Haruo> usb-storage: usb_stor_transfer_partial(): xfer 2048 bytes Haruo> usb-storage: usb_stor_bulk_msg() returned -32 xferred 0/2048 Haruo> usb-storage: -- code: 0x70, key: 0x2, ASC: 0x4, ASCQ: 0x1 Haruo> usb-storage: Not Ready: LUN in process of becoming ready

Alan> That's normal. It means that the drive was just turned on or Alan> reset, and it's not yet ready to execute commands.

I see.

Haruo> usb-storage: Unit Attention: not ready to ready transition

Haruo> More of the same. This means that the drive just finished its Haruo> initialization and now it's ready to operate. Haruo> usb-storage: scsi cmd done, result=0x2
Haruo> usb-storage: *** thread sleeping.

Haruo>  I/O error: dev 0b:00, sector 804236
Haruo>  I/O error: dev 0b:00, sector 804240
Haruo>  I/O error: dev 0b:00, sector 804492
Haruo>  I/O error: dev 0b:00, sector 804236

Alan> But apparently at this point the SCSI driver got tired of Alan> waiting and set
Alan> the drive offline. This should be fixed in the SCSI driver.

If a SCSI driver performs retry,
is it that usb-storage can also restart processing?

Alan> That's why
Alan> it's important to know what you were doing when the error occurred.

Ok, echo is put into a script, and as processing can be distinguished, test it.

Thanks again,
Haruo
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#1 lore raw
Quoted 5 lines · Haruo

I am also looking at this pattern repeatedly.
It seems that a device does not answer in the case of kernel 2.4. However, when operating by kernel 2.6 and two or more devices are connected simultaneously, it operates.
I cannot think the error of a device.

Don't be too sure. It could be that 2.4 and 2.6 are sending different data to the device, but for both systems the data is correct and the device _should_ work correctly. Maybe it's a device error that causes it to work okay with the data from 2.6 but not the data from 2.4.

Quoted 8 lines

Alan> This time the bus_reset() routine worked, which is an Alan> improvement over
Alan> what you were seeing before. But the device still didn't respond:

If a device becomes an error, it seems that reset is not effective. Using ioctl (fd, USBDEVFS_RESET, 0) and this device,
Is checking whether a device can reset correctly by performing effective?

Go ahead and try it. I expect it will reset correctly when you test it like this, but it won't reset correctly after one of those errors occurs and the device stops responding. That's just a guess.

Quoted 5 lines

Alan> Once that happened there were no error recovery procedures Alan> left to try, so
Alan> the driver gave up and marked the device offline.

Doesn't a device receive any commands?

The system sent commands, but the device didn't respond to them. However, it's possible that this patch will help. Try it out and see what happens.

drivers/usb/storage/protocol.c renamed from drivers/usb/storage/protocol.c.orig +4 -0
@@ -237,6 +237,10 @@
 	 * a unsigned char cmnd[12], so we know we have storage available
 	 */
 
+	/* Pad the ATAPI command with zeros */
+	for (; srb->cmd_len<12; srb->cmd_len++)
+		srb->cmnd[srb->cmd_len] = 0;
+
 	/* set command length to 12 bytes (this affects the transport layer) */
 	srb->cmd_len = 12;
 
Quoted 7 lines
Quoted 1 line
Quoted 1 line

2. usb_stor_bulk_msg() returned -32

Alan> Under what circumstances did this error occur? It must have Alan> been quite different from the other error.

The used device(Logitec LCW-WIN40U2) is different. It is the same circumstances except a device.

But when the error occurred, had you just plugged in the drive? Or had it been running already for some time? What were you doing when the error occurred? Was there some reason that the drive returned an error code meaning it had just been reset?

Quoted 2 lines

If a SCSI driver performs retry,
is it that usb-storage can also restart processing?

usb-storage doesn't do its own retries. Only the SCSI driver does. But when the SCSI driver retries a command, it sends a new copy of the command to usb-storage, so usb-storage sends the new copy of the command to the device.

Alan Stern

#2 lore raw
In reply to Tomita, Haruo
Quoted 3 lines · Haruo

It is because it is hard to generate an error in testing two simultaneously. When testing simultaneously, much time is required by the time it generates an error.

This is basically a good thing: the root causes are getting fixed one by one, so it needs more time before one of the remaining problems appears.

Of course, that means it's harder to find/fix whatever problem you're hitting ... :(

Quoted 10 lines

The reason is not known.

Haruo> 1. Bulk command transfer result=-104

[skip]

Alan> This was the same sort of pattern we saw before. No data was Alan> transferred from the drive, and the command timed out

Quoted 1 line

and was aborted.

I am also looking at this pattern repeatedly.

Some sort of USB-level trace would be very useful here, such as from a CATC capture.

Quoted 3 lines

It seems that a device does not answer in the case of kernel 2.4. However, when operating by kernel 2.6 and two or more devices
are connected simultaneously, it operates. I cannot think the error of a device.

I'd almost agree, except that the device stops responding; and seems to stop responding to anything except (cases I've seen) that it'll accept more OUT packets ... maybe treating them as data to write to the disk (one hypothesis).

When a device stops responding, it's hard to think the problem is anything other than with the device. (Though I still don't see where the storage class-specific reset gets sent by usb-storage, maybe that'd clean up better.)

What's curious is that "two or more devices connected" behavior. Are they both doing I/O at the same time? Having a second active device would change a few things:

- The EHCI controller will switch between endpoints, doing some transfers from one device then the next.

A second active device means longer gaps between packets going to the device ... so if one of those devices can't handle continuous streaming of high speed packets, it may lock up except when that second device increases those gaps.

Yes, we DO seem to have started seeing such storage adapters. Ones from GeneSys appear to have that problem with fast EHCI controllers, like the one in NForce2 (which can issue two or more back-to-back transfers using the "park" mechanism).

- Since usb-storage on 2.4 doesn't stream usb-storage transfers (64 writes of one page, vs one big write of 64 pages), the EHCI controller spends lots of time unlinking bulk endpoints (QHs) from its i/o queue and linking them right back again.

The VIA chips have been very sensitive, even buggy, in how they handle this logic. I've been unable to convince myself the current EHCI driver has a bug in this area -- though maybe it's possible someone else would have better luck finding one.

If this is a factor, then you should be able to change the behavior by increasing EHCI_SHRINK_JIFFIES (top of ehci-hcd.c), maybe to HZ/100 or so. I know that increasing that from zero was a big win in some VT6202 (stability) and VT8235 (performance on 2.4) testing, but the other EHCI silicon didn't much care.

That's about all the insight I have to share on this at the moment.

- Dave

maintainer
#3 lore raw
Quoted 10 lines · David Brownell
Quoted 4 lines

It seems that a device does not answer in the case of kernel 2.4. However, when operating by kernel 2.6 and two or more devices are connected simultaneously, it operates.
I cannot think the error of a device.

I'd almost agree, except that the device stops responding; and seems to stop responding to anything except (cases I've seen) that it'll accept more OUT packets ... maybe treating them as data to write to the disk (one hypothesis).

Quoted 4 lines

When a device stops responding, it's hard to think the problem is anything other than with the device. (Though I still don't see where the storage class-specific reset gets sent by usb-storage, maybe that'd clean up better.)

The reset was sent three times. Twice in response to command aborts and once at the express request of the SCSI layer. You can see it in the logs:

usb-storage: *** thread awakened.
usb-storage: Command READ_10 (10 bytes)
usb-storage: 28 00 00 01 ce 22 00 00 3f 00 00 00
usb-storage: Bulk command S 0x43425355 T 0x93534f Trg 0 LUN 0 L 129024 F 128 CL 12
usb-storage: command_abort() called
usb-storage: Bulk command transfer result=-104
usb-storage: -- transport indicates command was aborted

Here's one:
usb-storage: Bulk reset requested
usb_control/bulk_msg: timeout
usb-storage: Bulk soft reset failed -110
usb-storage: scsi command aborted
usb-storage: *** thread sleeping.
usb-storage: queuecommand() called
usb-storage: *** thread awakened.
usb-storage: Command TEST_UNIT_READY (6 bytes)
usb-storage: 00 00 00 00 00 00 00 00 3f 00 00 00
usb-storage: Bulk command S 0x43425355 T 0x935350 Trg 0 LUN 0 L 0 F 0 CL 12
usb-storage: Bulk command transfer result=0
usb-storage: Attempting to get CSW...
usb-storage: command_abort() called
usb-storage: -- transport indicates command was aborted

Here's another:
usb-storage: Bulk reset requested
usb_control/bulk_msg: timeout
usb-storage: Bulk soft reset failed -110
usb-storage: scsi command aborted
usb-storage: *** thread sleeping.

Here's the third:
usb-storage: device_reset() called
usb-storage: Bulk reset requested
usb_control/bulk_msg: timeout
usb-storage: Bulk soft reset failed -110

Those "Bulk reset requested" messages refer to the class-specific device reset command, not a clear-halt for a bulk pipe.

Alan Stern

#4 lore raw
Quoted 9 lines · Alan Stern
Quoted 4 lines · David Brownell

When a device stops responding, it's hard to think the problem is anything other than with the device. (Though I still don't see where the storage class-specific reset gets sent by usb-storage, maybe that'd clean up better.)

Quoted 3 lines

The reset was sent three times. Twice in response to command aborts and once at the express request of the SCSI layer. You can see it in the logs:

OK, I must have missed it when I was scanning for that control request ... likely because this one's using the usbcore method, not the usb-storage one I grepped for.

So I'm back to "hard to think the problem is anything other than with the device".

- Dave