Bug 195372 - [PATCH] USB quirk for 64GB Lexar Jumpdrive
Summary: [PATCH] USB quirk for 64GB Lexar Jumpdrive
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 10.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks: 210544
  Show dependency treegraph
 
Reported: 2014-11-25 17:51 UTC by Pierre Beyssac
Modified: 2016-06-24 22:37 UTC (History)
2 users (show)

See Also:


Attachments
patch for 10-STABLE kernel (1.11 KB, patch)
2014-11-25 17:51 UTC, Pierre Beyssac
no flags Details | Diff
patch for 10-STABLE or 11-current kernel (1.10 KB, patch)
2014-11-26 10:25 UTC, Pierre Beyssac
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Beyssac 2014-11-25 17:51:11 UTC
Created attachment 149834 [details]
patch for 10-STABLE kernel

The Lexar Jumpdrive key is unusable out of the box, can't disk size, wrongly assumes 0 block.

The attached patch allows the USB drive to be correctly recognized and used.
Comment 1 Miroslav Lachman 2014-11-25 23:47:38 UTC
I have the same problem with Lexar Jump Drive 32GB, so it should be made more generic fix:

kernel: ugen1.6: <Lexar> at usbus1
kernel: umass0: <Lexar USB Flash Drive, class 0/0, rev 2.10/11.00, addr 6> on usbus1
kernel: umass0:  SCSI over Bulk-Only; quirks = 0x0100
kernel: umass0:2:0:-1: Attached to scbus2
kernel: da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
kernel: da0: <Lexar USB Flash Drive 1100> Removable Direct Access SCSI-6 device
kernel: da0: Serial Number AA33JJ7ZJFJG8N3C9RM7
kernel: da0: 40.000MB/s transfers
kernel: da0: 0MB (1 512 byte sectors: 64H 32S/T 0C)
kernel: da0: quirks=0x2<NO_6_BYTE>
kernel: GEOM_PART: integrity check failed (da0, MBR)
kernel: GEOM_PART: integrity check failed (diskid/DISK-AA33JJ7ZJFJG8N3C9RM7, MBR)
volmand: CREATE da0 


What more should I provide for this flashdisk?
Comment 2 Pierre Beyssac 2014-11-26 00:14:43 UTC
(In reply to Miroslav Lachman from comment #1)
> kernel: GEOM_PART: integrity check failed (da0, MBR)
> kernel: GEOM_PART: integrity check failed (diskid/DISK-AA33JJ7ZJFJG8N3C9RM7,
> MBR)
> volmand: CREATE da0 
> 
> 
> What more should I provide for this flashdisk?


Use:

usbconfig -d 1.6 dump_device_desc

Then give idProduct, idVendor so the device can be added to usbdevs.

Note that you can add a dynamic quirk to check if the same quirk works with your key:

usbconfig -d 1.6 add_quirk UQ_MSC_NO_INQUIRY
Comment 3 Miroslav Lachman 2014-11-26 01:23:59 UTC
~/> usbconfig -d 1.5 dump_device_desc
ugen1.5: <USB Flash Drive Lexar> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0210 
  bDeviceClass = 0x0000 
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x05dc 
  idProduct = 0xa833 
  bcdDevice = 0x1100 
  iManufacturer = 0x0001  <Lexar>
  iProduct = 0x0002  <USB Flash Drive>
  iSerialNumber = 0x0003  <AA33JJ7ZJFJG8N3C9RM7>
  bNumConfigurations = 0x0001


~/> sudo usbconfig -d 1.5 add_quirk UQ_MSC_NO_INQUIRY

And now it is correctly identified as 30GB

kernel: ugen1.5: <Lexar> at usbus1
kernel: umass0: <Lexar USB Flash Drive, class 0/0, rev 2.10/11.00, addr 5> on usbus1
kernel: umass0:  SCSI over Bulk-Only; quirks = 0x0500
kernel: umass0:2:0:-1: Attached to scbus2
kernel: da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
kernel: da0: <  > Removable Direct Access SCSI-2 device 
kernel: da0: 40.000MB/s transfers
kernel: da0: 30560MB (62586880 512 byte sectors: 255H 63S/T 3895C)
kernel: da0: quirks=0x2<NO_6_BYTE>
volmand: CREATE da0
volmand: CREATE da0s1
volmand: CREATE msdosfs/Lexar


It works in USB 3.0 port too:

kernel: ugen0.2: <Lexar> at usbus0
kernel: umass0: <Lexar USB Flash Drive, class 0/0, rev 3.00/11.00, addr 4> on usbus0
kernel: umass0:  SCSI over Bulk-Only; quirks = 0x0500
kernel: umass0:2:0:-1: Attached to scbus2
kernel: da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
kernel: da0: <  > Removable Direct Access SCSI-2 device
kernel: da0: 400.000MB/s transfers
kernel: da0: 30560MB (62586880 512 byte sectors: 255H 63S/T 3895C)
kernel: da0: quirks=0x2<NO_6_BYTE>

Thank you very much!
Comment 4 Hans Petter Selasky freebsd_committer freebsd_triage 2014-11-26 08:06:56 UTC
Do you think this quirk applies to all Lexar products? It is possible to mask away the idProduct match and only match the idVendor.

--HPS
Comment 5 Pierre Beyssac 2014-11-26 08:59:30 UTC
(In reply to Hans Petter Selasky from comment #4)
> Do you think this quirk applies to all Lexar products? It is possible to
> mask away the idProduct match and only match the idVendor.
> 
> --HPS

I'm not sure, but I don't fully understand how the quirks templates match works.

Note that the idProduct for Miroslav's 32 GB key is the same as for my 64 GB key (0xa833), so we can assume it's the same for all their Jumpstart flash keys.

Apparently Lexar has other umass products which work with different quirks already in usb_quirk.c (see CF_READER).
Comment 6 Hans Petter Selasky freebsd_committer freebsd_triage 2014-11-26 10:02:45 UTC
Hi,

Can you make a complete patch adding the quirks you need to:

sys/dev/usb/usb_quirk.c and sys/dev/usb/usbdevs

?

Use the ones already there as example!

--HPS
Comment 7 Hans Petter Selasky freebsd_committer freebsd_triage 2014-11-26 10:07:18 UTC
Should be:
sys/dev/usb/quirk/usb_quirk.c
Comment 8 Pierre Beyssac 2014-11-26 10:25:31 UTC
Created attachment 149877 [details]
patch for 10-STABLE or 11-current kernel
Comment 9 Pierre Beyssac 2014-11-26 10:26:37 UTC
(In reply to Hans Petter Selasky from comment #6)
> Hi,
> 
> Can you make a complete patch adding the quirks you need to:
> 
> sys/dev/usb/usb_quirk.c and sys/dev/usb/usbdevs
> 
> ?
> 
> Use the ones already there as example!
> 
> --HPS

I already had attached a patch for 10-STABLE in my initial report but I have adapted it for 32 GB key (removed the "64" suffix in the label) and it applies cleanly on -current.
Comment 10 commit-hook freebsd_committer freebsd_triage 2014-11-26 10:58:21 UTC
A commit references this bug:

Author: hselasky
Date: Wed Nov 26 10:58:09 UTC 2014
New revision: 275110
URL: https://svnweb.freebsd.org/changeset/base/275110

Log:
  Add new USB quirk.

  MFC after:	1 week
  PR:		195372

Changes:
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/usbdevs
Comment 11 Hans Petter Selasky freebsd_committer freebsd_triage 2014-11-26 10:59:16 UTC
Can you verify the patch above?
Comment 12 Pierre Beyssac 2014-11-26 14:37:32 UTC
(In reply to Hans Petter Selasky from comment #11)
> Can you verify the patch above?

Seems ok.

Note, I don't have a -current system at the moment. Working on that.

The patch was tested successfully on FreeBSD 10.1-STABLE with a 64 GB key.
Comment 13 Pierre Beyssac 2014-11-27 14:48:06 UTC
(In reply to Hans Petter Selasky from comment #11)
> Can you verify the patch above?

Works (tested on 10.1-STABLE/amd64 and 11-CURRENT/i386)
Comment 14 commit-hook freebsd_committer freebsd_triage 2014-12-03 09:14:37 UTC
A commit references this bug:

Author: hselasky
Date: Wed Dec  3 09:14:15 UTC 2014
New revision: 275450
URL: https://svnweb.freebsd.org/changeset/base/275450

Log:
  MFC r275110:
  Add new USB quirk.

  PR:		195372

Changes:
_U  stable/10/
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Comment 15 commit-hook freebsd_committer freebsd_triage 2014-12-03 09:16:40 UTC
A commit references this bug:

Author: hselasky
Date: Wed Dec  3 09:16:03 UTC 2014
New revision: 275451
URL: https://svnweb.freebsd.org/changeset/base/275451

Log:
  MFC r275110:
  Add new USB quirk.

  PR:		195372

Changes:
_U  stable/9/sys/
_U  stable/9/sys/dev/
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/usbdevs
Comment 16 commit-hook freebsd_committer freebsd_triage 2014-12-26 11:17:46 UTC
A commit references this bug:

Author: hselasky
Date: Fri Dec 26 11:17:00 UTC 2014
New revision: 276241
URL: https://svnweb.freebsd.org/changeset/base/276241

Log:
  MFC r259675, r262128, r262129, r275605, r276239 and r276240:
  Add more USB quirks.

  PR:	178771
  PR:	180617
  PR:	195372

Changes:
_U  stable/10/
  stable/10/sys/dev/usb/quirk/usb_quirk.c
  stable/10/sys/dev/usb/usbdevs
Comment 17 commit-hook freebsd_committer freebsd_triage 2014-12-26 11:26:52 UTC
A commit references this bug:

Author: hselasky
Date: Fri Dec 26 11:25:57 UTC 2014
New revision: 276242
URL: https://svnweb.freebsd.org/changeset/base/276242

Log:
  MFC r262128, r262129, r275605, r276239 and r276240:
  Add more USB quirks.

  PR:	178771
  PR:	180617
  PR:	195372

Changes:
_U  stable/9/sys/
_U  stable/9/sys/dev/
  stable/9/sys/dev/usb/quirk/usb_quirk.c
  stable/9/sys/dev/usb/usbdevs