USB serial regression 2.6.31.1 -> 2.6.31.2 [PATCH]
Subsystems (2)
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_SENSEflag
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
Benjamin Herrenschmidt
Tested-byQuoted 5 lines · Ben Efros
No I don't think its a good idea to turn off
SANE_SENSEin this situation. Here is a patch similar to Ben Herrenschmidt's but will not turn offSANE_SENSEjust because a transport failure.Retry with short sense when
SANE_SENSEfails.
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
Signed-off-by Ben Efros <[email protected]>
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/
Alan Stern
maintainerQuoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines · Ben Efros
No I don't think its a good idea to turn off
SANE_SENSEin this situation. Here is a patch similar to Ben Herrenschmidt's but will not turn offSANE_SENSEjust because a transport failure.Retry with short sense when
SANE_SENSEfails.
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_SENSEvs. not clearing it. If we clear it, we probably want to keep it cleared (via anINSANE_SENSEflag ?). But on the other hand, I don't think that always going for a retry when aSANE_SENSEfails 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
Signed-off-by Ben Efros <[email protected]>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.
Quoted 28 lines · ----- "Alan Stern
Quoted 5 lines
Quoted 1 line
Signed-off-by Ben Efros <[email protected]>Quoted 1 line
---
linux-2.6.31.1/drivers/usb/storage/transport.c2009-09-24 08:45:25.000000000 -0700Quoted 1 line
Quoted 1 line
+++
linux-2.6.31.1.new/drivers/usb/storage/transport.c2009-10-11 08:06:26.000000000 -0700Quoted 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
-1if (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 withoutSANE_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 iftemp_result==USB_STOR_TRANSPORT_ERROR.
Agreed.
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_SENSEand 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_SENSEvs. not clearing it. If we clear it, we probably want to keep it cleared (via anINSANE_SENSEflag ?). But on the other hand, I don't think that always going for a retry when aSANE_SENSEfails 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
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 iftemp_result==USB_STOR_TRANSPORT_ERROR.Alan Stern
P.S.: In case you don't already know...TRANSPORT_FAILUREmeans we were able to communicate with the device, and it told us that it couldn't carry out the command.TRANSPORT_ERRORmeans 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.
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
@@ -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" );
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_SENSEwas 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]>
Signed-off-by Benjamin Herrenschmidt <[email protected]>
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_SENSEwas 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]>
Signed-off-by Benjamin Herrenschmidt <[email protected]>Acked-by Alan Stern <[email protected]>
Cool. Who's going to commit it ? Greg ? Or should I send it to Linus ?
Cheers,
Ben
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_SENSEwas 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]>
Signed-off-by Benjamin Herrenschmidt <[email protected]>Acked-by Alan Stern <[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