public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ben Efros <ben@pc-doctor.com>,
	Josua Dietze <digidietze@draisberghof.de>,
	fangxiaozhi <huananhu@huawei.com>, Greg KH <greg@kroah.com>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	USB list <linux-usb@vger.kernel.org>,
	Hugh Blemings <hugh@blemings.org>
Subject: Re: USB serial regression 2.6.31.1 -> 2.6.31.2 [PATCH]
Date: Tue, 13 Oct 2009 15:53:47 +1100	[thread overview]
Message-ID: <1255409627.2192.172.camel@pasglop> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0910121052550.11420-100000@netrider.rowland.org>

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 <ben@pc-doctor.com>

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

This should also be applied to 2.6.31 stable

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
--- linux-source-2.6.31-11-benh/drivers/usb/storage/transport.c	2009-09-10 08:13:59.000000000 +1000
+++ linux-source-2.6.31-12-benh/drivers/usb/storage/transport.c	2009-10-13 15:44:57.117722653 +1100
@@ -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");
 



  parent reply	other threads:[~2009-10-13  4:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <26767470.564301255277612694.JavaMail.root@mail.pc-doctor.com>
2009-10-11 16:16 ` USB serial regression 2.6.31.1 -> 2.6.31.2 [PATCH] Ben Efros
2009-10-12  5:44   ` Benjamin Herrenschmidt
2009-10-12 14:58     ` Alan Stern
2009-10-12 15:12       ` Matthew Dharm
2009-10-12 15:18       ` Ben Efros
2009-10-12 21:19       ` Benjamin Herrenschmidt
2009-10-13  4:53       ` Benjamin Herrenschmidt [this message]
2009-10-13 14:03         ` Alan Stern
2009-10-13 23:30           ` Benjamin Herrenschmidt
2009-10-14  2:29             ` Greg KH
     [not found] <19395543.564391255279074897.JavaMail.root@mail.pc-doctor.com>
2009-10-11 16:38 ` Ben Efros
2009-10-11 20:51   ` Benjamin Herrenschmidt
2009-10-12  1:54     ` Alan Stern
2009-10-12  3:28       ` Benjamin Herrenschmidt
2009-10-12 14:27         ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255409627.2192.172.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=ben@pc-doctor.com \
    --cc=digidietze@draisberghof.de \
    --cc=greg@kroah.com \
    --cc=huananhu@huawei.com \
    --cc=hugh@blemings.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox