a2fe54c
Path: news.gmane.org!not-for-mail
a2fe54c
From: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
a2fe54c
Newsgroups: gmane.linux.usb.general
a2fe54c
Subject: Re: USB mass-storage devices and READ CAPACITY(16)
a2fe54c
Date: Sun, 17 Jun 2012 11:26:31 -0400 (EDT)
a2fe54c
Lines: 81
a2fe54c
Approved: news@gmane.org
a2fe54c
Message-ID: <Pine.LNX.4.44L0.1206171123390.16446-100000@netrider.rowland.org>
a2fe54c
References: <Pine.LNX.4.44L0.1206151703110.1190-100000@iolanthe.rowland.org>
a2fe54c
NNTP-Posting-Host: plane.gmane.org
a2fe54c
Mime-Version: 1.0
a2fe54c
Content-Type: TEXT/PLAIN; charset=US-ASCII
a2fe54c
X-Trace: dough.gmane.org 1339946799 1694 80.91.229.3 (17 Jun 2012 15:26:39 GMT)
a2fe54c
X-Complaints-To: usenet@dough.gmane.org
a2fe54c
NNTP-Posting-Date: Sun, 17 Jun 2012 15:26:39 +0000 (UTC)
a2fe54c
Cc: Torsten Wohlfarth <towo-BOgDY73gMKaEi8DpZVb4nw@public.gmane.org>,
a2fe54c
	Sturm Flut <sturmflut-Q2DnxKCD/W3WAjrKYNhlQQ@public.gmane.org>,
a2fe54c
	Sergey <sergeyn-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
a2fe54c
	Philippe Valembois - Phil 
a2fe54c
	<lephilousophe-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
a2fe54c
	USB list <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
a2fe54c
To: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
a2fe54c
Original-X-From: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Sun Jun 17 17:26:37 2012
a2fe54c
Return-path: <linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
a2fe54c
Envelope-to: glug-linux-usb-wOFGN7rlS/M9smdsby/KFg@public.gmane.org
a2fe54c
Original-Received: from vger.kernel.org ([209.132.180.67])
a2fe54c
	by plane.gmane.org with esmtp (Exim 4.69)
a2fe54c
	(envelope-from <linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>)
a2fe54c
	id 1SgHN3-0002d5-Pq
a2fe54c
	for glug-linux-usb-wOFGN7rlS/M9smdsby/KFg@public.gmane.org; Sun, 17 Jun 2012 17:26:34 +0200
a2fe54c
Original-Received: (majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org) by vger.kernel.org via listexpand
a2fe54c
	id S1757469Ab2FQP0d (ORCPT <rfc822;glug-linux-usb@m.gmane.org>);
a2fe54c
	Sun, 17 Jun 2012 11:26:33 -0400
a2fe54c
Original-Received: from netrider.rowland.org ([192.131.102.5]:55086 "HELO
a2fe54c
	netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
a2fe54c
	with SMTP id S1757447Ab2FQP0c (ORCPT
a2fe54c
	<rfc822;linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>); Sun, 17 Jun 2012 11:26:32 -0400
a2fe54c
Original-Received: (qmail 16789 invoked by uid 500); 17 Jun 2012 11:26:31 -0400
a2fe54c
Original-Received: from localhost (sendmail-bs-savSHZN5Fh8qMp+WYRx65w@public.gmane.org)
a2fe54c
  by localhost with SMTP; 17 Jun 2012 11:26:31 -0400
a2fe54c
X-X-Sender: stern-pYrvlCTfrz9XsRXLowluHWD2FQJk+8+b@public.gmane.org
a2fe54c
In-Reply-To: <Pine.LNX.4.44L0.1206151703110.1190-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
a2fe54c
Original-Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
a2fe54c
Precedence: bulk
a2fe54c
List-ID: <linux-usb.vger.kernel.org>
a2fe54c
X-Mailing-List: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
a2fe54c
Xref: news.gmane.org gmane.linux.usb.general:65976
a2fe54c
Archived-At: <http://permalink.gmane.org/gmane.linux.usb.general/65976>
a2fe54c
a2fe54c
On Fri, 15 Jun 2012, Alan Stern wrote:
a2fe54c
a2fe54c
> On Fri, 15 Jun 2012, Hans de Goede wrote:
a2fe54c
> 
a2fe54c
> > Hi,
a2fe54c
> > 
a2fe54c
> > On 06/15/2012 08:20 PM, Alan Stern wrote:
a2fe54c
> > > As we can see from recent bug reports, a lot of USB mass-storage
a2fe54c
> > > devices cannot handle READ CAPACITY(16) commands properly.  They send
a2fe54c
> > > back garbage and are unusable as a result.
a2fe54c
> > >
a2fe54c
> > > Should we go ahead and set a flag on all these devices, telling the sd
a2fe54c
> > > driver to try READ CAPACITY(10) first?  That's a lot easier than adding
a2fe54c
> > > more and more entries to unusual_devs.h.
a2fe54c
> > 
a2fe54c
> > That certainly sound reasonable to me. Note that the 071b:3203 really
a2fe54c
> > needs the US_FL_NO_READ_CAPACITY_16 flag though, as it wrongly reports
a2fe54c
> > a capacity of -1 when there is no sd card in its slot, and in response
a2fe54c
> > to that the kernel tries READ CAPACITY(16) and things go downhill
a2fe54c
> > from there...
a2fe54c
> 
a2fe54c
> Yes, we need to be able to have both flags set for the same device.  
a2fe54c
> For that card reader they would mean try READ CAPACITY(10) first, and 
a2fe54c
> if it fails, don't try READ CAPACITY(16).
a2fe54c
a2fe54c
In other words, I'm suggesting we adopt this patch and get rid Hans's 
a2fe54c
new unusual_devs entry.
a2fe54c
a2fe54c
Alan Stern
a2fe54c
a2fe54c
a2fe54c
a2fe54c
a2fe54c
Index: usb-3.4/include/scsi/scsi_device.h
a2fe54c
===================================================================
a2fe54c
--- usb-3.4.orig/include/scsi/scsi_device.h
a2fe54c
+++ usb-3.4/include/scsi/scsi_device.h
a2fe54c
@@ -151,6 +151,7 @@ struct scsi_device {
a2fe54c
 					   SD_LAST_BUGGY_SECTORS */
a2fe54c
 	unsigned no_read_disc_info:1;	/* Avoid READ_DISC_INFO cmds */
a2fe54c
 	unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
a2fe54c
+	unsigned try_rc_10_first:1;	/* Try READ_CAPACACITY_10 first */
a2fe54c
 	unsigned is_visible:1;	/* is the device visible in sysfs */
a2fe54c
 
a2fe54c
 	DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
a2fe54c
Index: usb-3.4/drivers/scsi/sd.c
a2fe54c
===================================================================
a2fe54c
--- usb-3.4.orig/drivers/scsi/sd.c
a2fe54c
+++ usb-3.4/drivers/scsi/sd.c
a2fe54c
@@ -1899,6 +1899,8 @@ static int sd_try_rc16_first(struct scsi
a2fe54c
 {
a2fe54c
 	if (sdp->host->max_cmd_len < 16)
a2fe54c
 		return 0;
a2fe54c
+	if (sdp->try_rc_10_first)
a2fe54c
+		return 0;
a2fe54c
 	if (sdp->scsi_level > SCSI_SPC_2)
a2fe54c
 		return 1;
a2fe54c
 	if (scsi_device_protection(sdp))
a2fe54c
Index: usb-3.4/drivers/usb/storage/scsiglue.c
a2fe54c
===================================================================
a2fe54c
--- usb-3.4.orig/drivers/usb/storage/scsiglue.c
a2fe54c
+++ usb-3.4/drivers/usb/storage/scsiglue.c
a2fe54c
@@ -202,6 +202,12 @@ static int slave_configure(struct scsi_d
a2fe54c
 		if (us->fflags & US_FL_NO_READ_CAPACITY_16)
a2fe54c
 			sdev->no_read_capacity_16 = 1;
a2fe54c
 
a2fe54c
+		/*
a2fe54c
+		 * Many devices do not respond properly to READ_CAPACITY_16.
a2fe54c
+		 * Tell the SCSI layer to try READ_CAPACITY_10 first.
a2fe54c
+		 */
a2fe54c
+		sdev->try_rc_10_first = 1;
a2fe54c
+
a2fe54c
 		/* assume SPC3 or latter devices support sense size > 18 */
a2fe54c
 		if (sdev->scsi_level > SCSI_SPC_2)
a2fe54c
 			us->fflags |= US_FL_SANE_SENSE;
a2fe54c
a2fe54c
--
a2fe54c
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
a2fe54c
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
a2fe54c
More majordomo info at  http://vger.kernel.org/majordomo-info.html
a2fe54c