Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754275AbZJMEzt (ORCPT ); Tue, 13 Oct 2009 00:55:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753246AbZJMEzs (ORCPT ); Tue, 13 Oct 2009 00:55:48 -0400 Received: from gate.crashing.org ([63.228.1.57]:43219 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753244AbZJMEzr (ORCPT ); Tue, 13 Oct 2009 00:55:47 -0400 Subject: Re: USB serial regression 2.6.31.1 -> 2.6.31.2 [PATCH] From: Benjamin Herrenschmidt To: Alan Stern Cc: Ben Efros , Josua Dietze , fangxiaozhi , Greg KH , Kernel development list , USB list , Hugh Blemings In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Tue, 13 Oct 2009 15:53:47 +1100 Message-Id: <1255409627.2192.172.camel@pasglop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2210 Lines: 60 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 Signed-off-by: Benjamin Herrenschmidt --- 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"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/