Re: [usb-storage] Re: External USB3 disk fails with Invalid field in cdb

2014-06-30 Thread Michael Büsch
On Fri, 27 Jun 2014 21:52:35 +0200
Michael Büsch m...@bues.ch wrote:

 On Fri, 27 Jun 2014 15:23:42 -0400 (EDT)
 Alan Stern st...@rowland.harvard.edu wrote:
  Does the patch below do what you and James want?
 
 Yes, this does work. Thanks!
 
 You can add my
 Tested-by: Michael Büsch m...@bues.ch


Does somebody pick this up for inclusion?
It'd also be good, if this hit stable.


-- 
Michael


signature.asc
Description: PGP signature


Re: [usb-storage] Re: External USB3 disk fails with Invalid field in cdb

2014-06-30 Thread James Bottomley
On Fri, 2014-06-27 at 15:23 -0400, Alan Stern wrote:
 On Fri, 27 Jun 2014, Michael Büsch wrote:
 
  On Fri, 27 Jun 2014 14:42:01 -0400 (EDT)
  Alan Stern st...@rowland.harvard.edu wrote:
  
   Michael, can you post the lsusb -v output for this device?  I see it 
   is made by JMicron; they are notorious for buggy USB-ATA bridges.
  
  Of course. Here you go:
  
  Bus 004 Device 009: ID 152d:0567 JMicron Technology Corp. / JMicron USA 
  Technology Corp. 
  Device Descriptor:
bLength18
bDescriptorType 1
bcdUSB   3.00
bDeviceClass0 (Defined at Interface level)
bDeviceSubClass 0 
bDeviceProtocol 0 
bMaxPacketSize0 9
idVendor   0x152d JMicron Technology Corp. / JMicron USA 
  Technology Corp.
idProduct  0x0567 
bcdDevice1.14
iManufacturer   1 JMicron
iProduct2 USB to ATA/ATAPI Bridge
iSerial 3 xxx
bNumConfigurations  1
Configuration Descriptor:
  bLength 9
  bDescriptorType 2
  wTotalLength  121
  bNumInterfaces  1
  bConfigurationValue 1
  iConfiguration  4 USB Mass Storage
  bmAttributes 0xc0
Self Powered
  MaxPower2mA
 ...
 
  MaxPower=2mA is a nice guess for a hard disk. ;)
 
 That refers to the amount of power the device draws from the USB bus.  
 Since the disk drive is self-powered, it doesn't use much bus power.
 
 Does the patch below do what you and James want?

Yes, that's the usual annoying additions to our blacklist.  You can add
my acked-by and could you cc stable?

Thanks,

James



--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb-storage] Re: External USB3 disk fails with Invalid field in cdb

2014-06-30 Thread Alan Stern
On Mon, 30 Jun 2014, James Bottomley wrote:

  Does the patch below do what you and James want?
 
 Yes, that's the usual annoying additions to our blacklist.  You can add
 my acked-by and could you cc stable?

Will do.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb-storage] Re: External USB3 disk fails with Invalid field in cdb

2014-06-27 Thread Alan Stern
On Fri, 27 Jun 2014, Michael Büsch wrote:

 On Fri, 27 Jun 2014 14:42:01 -0400 (EDT)
 Alan Stern st...@rowland.harvard.edu wrote:
 
  Michael, can you post the lsusb -v output for this device?  I see it 
  is made by JMicron; they are notorious for buggy USB-ATA bridges.
 
 Of course. Here you go:
 
 Bus 004 Device 009: ID 152d:0567 JMicron Technology Corp. / JMicron USA 
 Technology Corp. 
 Device Descriptor:
   bLength18
   bDescriptorType 1
   bcdUSB   3.00
   bDeviceClass0 (Defined at Interface level)
   bDeviceSubClass 0 
   bDeviceProtocol 0 
   bMaxPacketSize0 9
   idVendor   0x152d JMicron Technology Corp. / JMicron USA Technology 
 Corp.
   idProduct  0x0567 
   bcdDevice1.14
   iManufacturer   1 JMicron
   iProduct2 USB to ATA/ATAPI Bridge
   iSerial 3 xxx
   bNumConfigurations  1
   Configuration Descriptor:
 bLength 9
 bDescriptorType 2
 wTotalLength  121
 bNumInterfaces  1
 bConfigurationValue 1
 iConfiguration  4 USB Mass Storage
 bmAttributes 0xc0
   Self Powered
 MaxPower2mA
...

 MaxPower=2mA is a nice guess for a hard disk. ;)

That refers to the amount of power the device draws from the USB bus.  
Since the disk drive is self-powered, it doesn't use much bus power.

Does the patch below do what you and James want?

Alan Stern



Index: usb-3.16/include/linux/usb_usual.h
===
--- usb-3.16.orig/include/linux/usb_usual.h
+++ usb-3.16/include/linux/usb_usual.h
@@ -70,7 +70,9 @@
US_FLAG(NEEDS_CAP16,0x0040) \
/* cannot handle READ_CAPACITY_10 */\
US_FLAG(IGNORE_UAS, 0x0080) \
-   /* Device advertises UAS but it is broken */
+   /* Device advertises UAS but it is broken */\
+   US_FLAG(BROKEN_FUA, 0x0100) \
+   /* Cannot handle FUA in WRITE CDBs */   \
 
 #define US_FLAG(name, value)   US_FL_##name = value ,
 enum { US_DO_ALL_FLAGS };
Index: usb-3.16/include/scsi/scsi_device.h
===
--- usb-3.16.orig/include/scsi/scsi_device.h
+++ usb-3.16/include/scsi/scsi_device.h
@@ -173,6 +173,7 @@ struct scsi_device {
unsigned is_visible:1;  /* is the device visible in sysfs */
unsigned wce_default_on:1;  /* Cache is ON by default */
unsigned no_dif:1;  /* T10 PI (DIF) should be disabled */
+   unsigned broken_fua:1;  /* Don't set FUA bit */
 
atomic_t disk_events_disable_depth; /* disable depth for disk events */
 
Index: usb-3.16/drivers/usb/storage/unusual_devs.h
===
--- usb-3.16.orig/drivers/usb/storage/unusual_devs.h
+++ usb-3.16/drivers/usb/storage/unusual_devs.h
@@ -1936,6 +1936,13 @@ UNUSUAL_DEV(  0x14cd, 0x6600, 0x0201, 0x
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
 
+/* Reported by Michael Büsch m...@bues.ch */
+UNUSUAL_DEV(  0x152d, 0x0567, 0x0114, 0x0114,
+   JMicron,
+   USB to ATA/ATAPI Bridge,
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_BROKEN_FUA ),
+
 /* Reported by Alexandre Oliva ol...@lsd.ic.unicamp.br
  * JMicron responds to USN and several other SCSI ioctls with a
  * residue that causes subsequent I/O requests to fail.  */
Index: usb-3.16/drivers/usb/storage/scsiglue.c
===
--- usb-3.16.orig/drivers/usb/storage/scsiglue.c
+++ usb-3.16/drivers/usb/storage/scsiglue.c
@@ -256,6 +256,10 @@ static int slave_configure(struct scsi_d
if (us-fflags  US_FL_WRITE_CACHE)
sdev-wce_default_on = 1;
 
+   /* A few buggy USB-ATA bridges don't understand FUA */
+   if (us-fflags  US_FL_BROKEN_FUA)
+   sdev-broken_fua = 1;
+
} else {
 
/* Non-disk-type devices don't need to blacklist any pages
Index: usb-3.16/drivers/scsi/sd.c
===
--- usb-3.16.orig/drivers/scsi/sd.c
+++ usb-3.16/drivers/scsi/sd.c
@@ -2441,7 +2441,10 @@ sd_read_cache_type(struct scsi_disk *sdk
}
 
sdkp-DPOFUA = (data.device_specific  0x10) != 0;
-   if (sdkp-DPOFUA  !sdkp-device-use_10_for_rw) {
+   if (sdp-broken_fua) {
+   sd_first_printk(KERN_NOTICE, sdkp, Disabling FUA\n);
+   sdkp-DPOFUA = 0;
+   } else if (sdkp-DPOFUA  !sdkp-device-use_10_for_rw) {
sd_first_printk(KERN_NOTICE, sdkp,
   

Re: [usb-storage] Re: External USB3 disk fails with Invalid field in cdb

2014-06-27 Thread Michael Büsch
On Fri, 27 Jun 2014 15:23:42 -0400 (EDT)
Alan Stern st...@rowland.harvard.edu wrote:

  MaxPower=2mA is a nice guess for a hard disk. ;)
 
 That refers to the amount of power the device draws from the USB bus.  
 Since the disk drive is self-powered, it doesn't use much bus power.

Unless the device uses free energy or some other perpetual motion power source,
it seems that it actually is bus-powered.
So the self-powered from the descriptor is a lie, too.

 Does the patch below do what you and James want?

Yes, this does work. Thanks!

You can add my
Tested-by: Michael Büsch m...@bues.ch

-- 
Michael


signature.asc
Description: PGP signature