Skip to contentSkip to conversation

USB serial regression 2.6.31.1 -> 2.6.31.2 [PATCH]

DISCUSSION Ben Efros 5 participants 10 messages Oct 11, 2009 – Oct 14, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ben Efros

author
#1 lore raw
Quoted 18 lines · ----- "Alan Stern
Quoted 2 lines · Benjamin Herrenschmidt
Quoted 2 lines

Further REQUEST SENSE commands therefore requested 96 bytes of

data

Quoted 1 line
Quoted 1 line

instead of the standard 18 bytes. With LUN 0 this worked okay.

But

Quoted 3 lines
Quoted 3 lines

with LUN 1 it didn't; the device reported a failure of the REQUEST

SENSE. This is what caused usb-storage to issue the device

reset.

Quoted 2 lines
Quoted 2 lines

After the reset usb-storage continued to ask for 96 bytes of

sense

Quoted 1 line
Quoted 1 line

data, and LUN 1 continued to fail the commands. Hence the

repeated

Quoted 2 lines
Quoted 1 line

resets.

Quoted 7 lines
Quoted 1 line

Maybe a better approach would be to go back to 18 bytes when it

fails,

Quoted 1 line

what do you think ?

We certainly could do that. But should we turn off the SANE_SENSE flag
at the same time?

No I don't think its a good idea to turn off SANE_SENSE in this situation. Here is a patch similar to Ben Herrenschmidt's but will not turn off SANE_SENSE just because a transport failure.

Retry with short sense when SANE_SENSE fails.

drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +7 -1
@@ -696,7 +696,7 @@ void usb_stor_invoke_transport(struct sc
                 /* device supports and needs bigger sense buffer */
                 if (us->fflags & US_FL_SANE_SENSE)
                         sense_size = ~0;
-
+Retry_Sense:
                 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
 
                 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
@@ -723,6 +723,12 @@ void usb_stor_invoke_transport(struct sc
                 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
                         US_DEBUGP("-- auto-sense failure\n");
 
+                        if ((us->fflags & US_FL_SANE_SENSE) &&
+                            sense_size != US_SENSE_SIZE) {
+                                sense_size = US_SENSE_SIZE;
+                                US_DEBUGP("-- retry without SANE_SENSE\n");
+                                goto Retry_Sense;
+                        }
                         /* we skip the reset if this happens to be a
                          * multi-target device, since failure of an
                          * auto-sense is perfectly valid
#2 lore raw
Quoted 5 lines · Ben Efros

No I don't think its a good idea to turn off SANE_SENSE in this situation. Here is a patch similar to Ben Herrenschmidt's but will not turn off SANE_SENSE just because a transport failure.

Retry with short sense when SANE_SENSE fails.

Works for me too.

Alan, what do you think ? I definitely don't like Ben E's most recent patch with a quirk for all devices, it's simply a lot more code for something that will come back and bite again when somebody does the same mistake again. I'd rather have the request sense code be more robust. But this patch is fine, as was my previous one.

So it boils down on clearing SANE_SENSE vs. not clearing it. If we clear it, we probably want to keep it cleared (via an INSANE_SENSE flag ?). But on the other hand, I don't think that always going for a retry when a SANE_SENSE fails is going to hurt and sounds like the robust thing to do, so I don't mind that simple patch from Ben. So up to you :-)

Cheers,
Ben.

Quoted 1 line
Quoted 31 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +7 -2
@@ -696,7 +696,7 @@ void usb_stor_invoke_transport(struct sc
                 /* device supports and needs bigger sense buffer */
                 if (us->fflags & US_FL_SANE_SENSE)
                         sense_size = ~0;
-
+Retry_Sense:
                 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
 
                 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
@@ -723,6 +723,12 @@ void usb_stor_invoke_transport(struct sc
                 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
                         US_DEBUGP("-- auto-sense failure\n");
 
+                        if ((us->fflags & US_FL_SANE_SENSE) &&
+                            sense_size != US_SENSE_SIZE) {
+                                sense_size = US_SENSE_SIZE;
+                                US_DEBUGP("-- retry without SANE_SENSE\n");
+                                goto Retry_Sense;
+                        }
                         /* we skip the reset if this happens to be a
                          * multi-target device, since failure of an
                          * auto-sense is perfectly valid
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

maintainer
#3 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines · Ben Efros

No I don't think its a good idea to turn off SANE_SENSE in this situation. Here is a patch similar to Ben Herrenschmidt's but will not turn off SANE_SENSE just because a transport failure.

Retry with short sense when SANE_SENSE fails.

Quoted 7 lines

Works for me too.

Alan, what do you think ? I definitely don't like Ben E's most recent patch with a quirk for all devices, it's simply a lot more code for something that will come back and bite again when somebody does the same mistake again. I'd rather have the request sense code be more robust. But this patch is fine, as was my previous one.

I agree that it seems silly to have a flag _for_ SANE_SENSE and another flag _against_ SANE_SENSE. Retrying seems easier and more robust.

Quoted 6 lines

So it boils down on clearing SANE_SENSE vs. not clearing it. If we clear it, we probably want to keep it cleared (via an INSANE_SENSE flag ?). But on the other hand, I don't think that always going for a retry when a SANE_SENSE fails is going to hurt and sounds like the robust thing to do, so I don't mind that simple patch from Ben. So up to you :-)

I agree; it won't hurt much and only if the device is buggy to begin with.

Quoted 22 lines

Cheers,
Ben.

Quoted 1 line
Quoted 15 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +1 -1
@@ -696,7 +696,7 @@ void usb_stor_invoke_transport(struct sc
                 /* device supports and needs bigger sense buffer */
                 if (us->fflags & US_FL_SANE_SENSE)
                         sense_size = ~0;
-
+Retry_Sense:
                 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
 
                 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
@@ -723,6 +723,12 @@ void usb_stor_invoke_transport(struct sc
                 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
                         US_DEBUGP("-- auto-sense failure\n");
 
Quoted 6 lines

drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 void usb_stor_invoke_transport(struct sc · line 731

Quoted 6 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +6 -0
+                        if ((us->fflags & US_FL_SANE_SENSE) &&
+                            sense_size != US_SENSE_SIZE) {
+                                sense_size = US_SENSE_SIZE;
+                                US_DEBUGP("-- retry without SANE_SENSE\n");
+                                goto Retry_Sense;
+                        }

Except that this is wrong. We can retry if temp_result == USB_STOR_TRANSPORT_FAILURE, but we should not retry if temp_result == USB_STOR_TRANSPORT_ERROR.

Alan Stern

P.S.: In case you don't already know... TRANSPORT_FAILURE means we were able to communicate with the device, and it told us that it couldn't carry out the command. TRANSPORT_ERROR means we weren't able to communicate with the device.

author
#4 lore raw
Quoted 28 lines · ----- "Alan Stern
Quoted 5 lines
Quoted 1 line
Quoted 1 line

--- linux-2.6.31.1/drivers/usb/storage/transport.c

2009-09-24 08:45:25.000000000 -0700
Quoted 1 line
Quoted 1 line

+++ linux-2.6.31.1.new/drivers/usb/storage/transport.c

2009-10-11 08:06:26.000000000 -0700
Quoted 2 lines

Review void usb_stor_invoke_transport(struct sc · line 696

Quoted 2 lines
(quoted diff) +0 -0
@@ -696,7 +696,7 @@ void usb_stor_invoke_transport(struct sc
                 /* device supports and needs bigger sense buffer

*/

Quoted 7 lines

drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 void usb_stor_invoke_transport(struct sc

Quoted 7 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +1 -1
                 if (us->fflags & US_FL_SANE_SENSE)
                         sense_size = ~0;
-
+Retry_Sense:
                 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
 
                 scsi_eh_prep_cmnd(srb, &ses, NULL, 0,

sense_size);

Quoted 8 lines

drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 void usb_stor_invoke_transport(struct sc · line 729

Quoted 8 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +4 -0
@@ -723,6 +723,12 @@ void usb_stor_invoke_transport(struct sc
                 if (temp_result != USB_STOR_TRANSPORT_GOOD) {
                         US_DEBUGP("-- auto-sense failure\n");
 
+                        if ((us->fflags & US_FL_SANE_SENSE) &&
+                            sense_size != US_SENSE_SIZE) {
+                                sense_size = US_SENSE_SIZE;
+                                US_DEBUGP("-- retry without

SANE_SENSE\n");

Quoted 7 lines
Quoted 2 lines

drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 void usb_stor_invoke_transport(struct sc · line 731

Quoted 2 lines
drivers/usb/storage/transport.c 2009-10-11 08:06:26.000000000 -0700 renamed from drivers/usb/storage/transport.c 2009-09-24 08:45:25.000000000 -0700 +2 -0
+                                goto Retry_Sense;
+                        }

Except that this is wrong. We can retry if temp_result == USB_STOR_TRANSPORT_FAILURE, but we should not retry if temp_result == USB_STOR_TRANSPORT_ERROR.

Agreed.

#5 lore raw
In reply to Alan Stern
Quoted 10 lines · Alan Stern
Quoted 6 lines · Benjamin Herrenschmidt

Alan, what do you think ? I definitely don't like Ben E's most recent patch with a quirk for all devices, it's simply a lot more code for something that will come back and bite again when somebody does the same mistake again. I'd rather have the request sense code be more robust. But this patch is fine, as was my previous one.

I agree that it seems silly to have a flag _for_ SANE_SENSE and another flag _against_ SANE_SENSE. Retrying seems easier and more robust.

Dualing flags, where one is auto-set and the other quirked, is almost guaranteed to get us into a maintance nightmare.

Quoted 9 lines
Quoted 6 lines

So it boils down on clearing SANE_SENSE vs. not clearing it. If we clear it, we probably want to keep it cleared (via an INSANE_SENSE flag ?). But on the other hand, I don't think that always going for a retry when a SANE_SENSE fails is going to hurt and sounds like the robust thing to do, so I don't mind that simple patch from Ben. So up to you :-)

I agree; it won't hurt much and only if the device is buggy to begin with.

I agree; the extra retry is more robust, more straightforward, and more maintainable long-term.

Matt

Signature · 7 lines
Matthew Dharm                              Home: [email protected] 
Maintainer, Linux USB Mass Storage Driver

My mother not mind to die for stoppink Windows NT!  She is rememberink 
Stalin!
					-- Pitr
User Friendly, 9/6/1998
#6 lore raw
In reply to Alan Stern
Quoted 10 lines · Alan Stern

Except that this is wrong. We can retry if temp_result == USB_STOR_TRANSPORT_FAILURE, but we should not retry if temp_result == USB_STOR_TRANSPORT_ERROR.

Alan Stern

P.S.: In case you don't already know... TRANSPORT_FAILURE means we were able to communicate with the device, and it told us that it couldn't carry out the command. TRANSPORT_ERROR means we weren't able to communicate with the device.

Ah good, I was wondering about precisely that (discriminating the errors more intelligently). No point retrying if the device was yanked or went totally dead.

Cheers,
Ben.

#7 lore raw
In reply to Alan Stern

usb-storage: Workaround devices with bogus sense size

Some devices, such as Huawei E169, advertise more than the standard amount of sense data, causing us to set US_FL_SANE_SENSE, assuming they support it. However, they subsequently fail the request sense with that size.

This works around it generically. When a sense request fails due to a device returning an error, US_FL_SANE_SENSE was set, and that sense request used a larger sense size, we retry with a smaller size before giving up.

Based on an original patch by Ben Efros <[email protected]>

---

This should also be applied to 2.6.31 stable

drivers/usb/storage/transport.c +16 -1
diff -urN linux-source-2.6.31-11-benh/drivers/usb/storage/transport.c linux-source-2.6.31-12-benh/drivers/usb/storage/transport.c
@@ -696,7 +696,7 @@
 		/* device supports and needs bigger sense buffer */
 		if (us->fflags & US_FL_SANE_SENSE)
 			sense_size = ~0;
-
+Retry_Sense:
 		US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
 
 		scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
@@ -720,6 +720,21 @@
 			srb->result = DID_ABORT << 16;
 			goto Handle_Errors;
 		}
+
+		/* Some devices claim to support larger sense but fail when
+		 * trying to request it. When a transport failure happens
+		 * using US_FS_SANE_SENSE, we always retry with a standard
+		 * (small) sense request. This fixes some USB GSM modems
+		 */
+		if (temp_result == USB_STOR_TRANSPORT_FAILED &&
+		    (us->fflags & US_FL_SANE_SENSE) &&
+		    sense_size != US_SENSE_SIZE) {
+			US_DEBUGP("-- auto-sense failure, retry small sense\n");
+			sense_size = US_SENSE_SIZE;
+			goto Retry_Sense;
+		}
+
+		/* Other failures */
 		if (temp_result != USB_STOR_TRANSPORT_GOOD) {
 			US_DEBUGP("-- auto-sense failure\n");
 
maintainer Acked-by
#8 lore raw
Quoted 7 lines · Benjamin Herrenschmidt

usb-storage: Workaround devices with bogus sense size

Some devices, such as Huawei E169, advertise more than the standard amount of sense data, causing us to set US_FL_SANE_SENSE, assuming they support it. However, they subsequently fail the request sense with that size.

Quoted 8 lines

This works around it generically. When a sense request fails due to a device returning an error, US_FL_SANE_SENSE was set, and that sense request used a larger sense size, we retry with a smaller size before giving up.

Based on an original patch by Ben Efros <[email protected]>

#9 lore raw
Quoted 14 lines · Alan Stern
Quoted 12 lines · Benjamin Herrenschmidt

usb-storage: Workaround devices with bogus sense size

Some devices, such as Huawei E169, advertise more than the standard amount of sense data, causing us to set US_FL_SANE_SENSE, assuming they support it. However, they subsequently fail the request sense with that size.

This works around it generically. When a sense request fails due to a device returning an error, US_FL_SANE_SENSE was set, and that sense request used a larger sense size, we retry with a smaller size before giving up.

Quoted 5 lines
Quoted 3 lines

Based on an original patch by Ben Efros <[email protected]>

Cool. Who's going to commit it ? Greg ? Or should I send it to Linus ?

Cheers,
Ben

#10 lore raw
Quoted 15 lines · Benjamin Herrenschmidt
Quoted 14 lines · Alan Stern
Quoted 12 lines · Benjamin Herrenschmidt

usb-storage: Workaround devices with bogus sense size

Some devices, such as Huawei E169, advertise more than the standard amount of sense data, causing us to set US_FL_SANE_SENSE, assuming they support it. However, they subsequently fail the request sense with that size.

This works around it generically. When a sense request fails due to a device returning an error, US_FL_SANE_SENSE was set, and that sense request used a larger sense size, we retry with a smaller size before giving up.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Based on an original patch by Ben Efros <[email protected]>

Cool. Who's going to commit it ? Greg ? Or should I send it to Linus ?

I will, I'll send it off tomorrow.

thanks,

greg k-h