On Fri, 15 Jun 2012, Alan Stern wrote: > On Fri, 15 Jun 2012, Hans de Goede wrote: > > > Hi, > > > > On 06/15/2012 08:20 PM, Alan Stern wrote: > > > As we can see from recent bug reports, a lot of USB mass-storage > > > devices cannot handle READ CAPACITY(16) commands properly. They send > > > back garbage and are unusable as a result. > > > > > > Should we go ahead and set a flag on all these devices, telling the sd > > > driver to try READ CAPACITY(10) first? That's a lot easier than adding > > > more and more entries to unusual_devs.h. > > > > That certainly sound reasonable to me. Note that the 071b:3203 really > > needs the US_FL_NO_READ_CAPACITY_16 flag though, as it wrongly reports > > a capacity of -1 when there is no sd card in its slot, and in response > > to that the kernel tries READ CAPACITY(16) and things go downhill > > from there... > > Yes, we need to be able to have both flags set for the same device. > For that card reader they would mean try READ CAPACITY(10) first, and > if it fails, don't try READ CAPACITY(16). In other words, I'm suggesting we adopt this patch and get rid Hans's new unusual_devs entry. Alan Stern Index: usb-3.4/include/scsi/scsi_device.h =================================================================== --- usb-3.4.orig/include/scsi/scsi_device.h +++ usb-3.4/include/scsi/scsi_device.h @@ -151,6 +151,7 @@ struct scsi_device { SD_LAST_BUGGY_SECTORS */ unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */ unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */ + unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */ unsigned is_visible:1; /* is the device visible in sysfs */ DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ Index: usb-3.4/drivers/scsi/sd.c =================================================================== --- usb-3.4.orig/drivers/scsi/sd.c +++ usb-3.4/drivers/scsi/sd.c @@ -1899,6 +1899,8 @@ static int sd_try_rc16_first(struct scsi { if (sdp->host->max_cmd_len < 16) return 0; + if (sdp->try_rc_10_first) + return 0; if (sdp->scsi_level > SCSI_SPC_2) return 1; if (scsi_device_protection(sdp)) Index: usb-3.4/drivers/usb/storage/scsiglue.c =================================================================== --- usb-3.4.orig/drivers/usb/storage/scsiglue.c +++ usb-3.4/drivers/usb/storage/scsiglue.c @@ -202,6 +202,12 @@ static int slave_configure(struct scsi_d if (us->fflags & US_FL_NO_READ_CAPACITY_16) sdev->no_read_capacity_16 = 1; + /* + * Many devices do not respond properly to READ_CAPACITY_16. + * Tell the SCSI layer to try READ_CAPACITY_10 first. + */ + sdev->try_rc_10_first = 1; + /* assume SPC3 or latter devices support sense size > 18 */ if (sdev->scsi_level > SCSI_SPC_2) us->fflags |= US_FL_SANE_SENSE; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html