xref: /freebsd/sys/cam/README.quirks (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
1f04ea040SMatt Jacob
2808ec293SMatt Jacob                     FreeBSD Quirk Guidelines
3808ec293SMatt Jacob
4808ec293SMatt Jacob                  Nate Lawson - njl at freebsd org
5808ec293SMatt Jacob
6808ec293SMatt Jacob0. Introduction
7808ec293SMatt Jacob
8808ec293SMatt JacobFreeBSD drivers make every attempt possible to support the standards
9808ec293SMatt Jacobbehind hardware. Where possible and not in conflict with the standard,
10808ec293SMatt Jacobthey also attempt to work around hardware which doesn't strictly
11808ec293SMatt Jacobconform. However, some devices have flaws which can't be worked
12808ec293SMatt Jacobaround while keeping the driver compatible with the standard. For
13808ec293SMatt Jacobthese devices, we have created a quirks mechanism to indicate to
14808ec293SMatt Jacobthe driver that it must avoid certain commands or use them differently
15808ec293SMatt Jacobwith a specific model and/or version of hardware. This document
16808ec293SMatt Jacobfocuses on identifying and committing quirks for storage hardware
17808ec293SMatt Jacobinvolving CAM and UMASS but is applicable to other areas.
18808ec293SMatt Jacob
19808ec293SMatt JacobCAM provides a generic transport for SCSI-like devices. Many different
20808ec293SMatt Jacobtransports use SCSI command sets including parallel SCSI, firewire
21808ec293SMatt Jacob(1394), USB UMASS, fibre channel, and ATAPI. For block devices (i.e.
22808ec293SMatt Jacobhard drives, flash adapters, cameras) there are two standards, SBC
23808ec293SMatt Jacoband RBC. SCSI hard drives are usually SBC-compliant and smaller
24808ec293SMatt Jacobdevices like flash drives are usually RBC-compliant. Multimedia
25808ec293SMatt Jacobdevices including CDROMs and DVD-RW are usually MMC-compliant.
26808ec293SMatt Jacob
27808ec293SMatt JacobPlease follow these guidelines to get your device working as soon
28808ec293SMatt Jacobas possible. If you are a committer, please do NOT commit quirks
29808ec293SMatt Jacobdirectly but follow this process also.
30808ec293SMatt Jacob
31808ec293SMatt Jacob1. Determing the problem
32808ec293SMatt Jacob
33808ec293SMatt JacobThe first step is to determine what's wrong. If the device should
34808ec293SMatt Jacobbe supported but hangs while attaching, it's possible a quirk can
35808ec293SMatt Jacobhelp. The types of things a quirk can fix are:
36808ec293SMatt Jacob`
37808ec293SMatt Jacob * cam/cam_xpt.c quirks
38808ec293SMatt Jacob
39808ec293SMatt Jacob  o CAM_QUIRK_NOLUNS - do not probe luns other than 0 since device
40808ec293SMatt Jacob  responds to all inquiries with "lun present".
41808ec293SMatt Jacob
42808ec293SMatt Jacob  o CAM_QUIRK_NOSERIAL - do not send an inquiry for serial number.
43808ec293SMatt Jacob
44808ec293SMatt Jacob  o CAM_QUIRK_HILUNS - probe all luns even if some respond "not present"
45808ec293SMatt Jacob  since device has a sparse lun space.
46808ec293SMatt Jacob
47808ec293SMatt Jacob * cam/scsi/scsi_da.c quirks
48808ec293SMatt Jacob
49808ec293SMatt Jacob  o DA_Q_NO_SYNC_CACHE - The sync cache command is used to force a
50808ec293SMatt Jacob  drive to write out all changes to disk before shutting down. Some
51808ec293SMatt Jacob  drives hang when receiving this command even though it is required
52808ec293SMatt Jacob  by all SBC and RBC standards. Note that a warning message on
53808ec293SMatt Jacob  console is NOT sufficient to add this quirk. The warning messages
54808ec293SMatt Jacob  are harmless and only a device or system hang is cause for adding
55808ec293SMatt Jacob  this quirk.
56808ec293SMatt Jacob
57808ec293SMatt Jacob  o DA_Q_NO_6_BYTE - The RBC spec (see Links below) does not allow
58808ec293SMatt Jacob  for 6-byte READ/WRITE commands. Some manufacturers took that too
59808ec293SMatt Jacob  literally and crash when receiving 6-byte commands. This quirk
60808ec293SMatt Jacob  causes FreeBSD to only send 10-byte commands. Since the CAM subsystem
61808ec293SMatt Jacob  has been modified to not send 6-byte commands to USB, 1394, and
62808ec293SMatt Jacob  other transports that don't support SBC, this quirk should be very
63808ec293SMatt Jacob  rare.
64808ec293SMatt Jacob
65808ec293SMatt Jacob  o DA_Q_NO_PREVENT - Don't use the prevent/allow commands to keep a
66808ec293SMatt Jacob  removable medium from being ejected. Some systems can't handle these
67808ec293SMatt Jacob  commands (rare).
68808ec293SMatt Jacob
69808ec293SMatt Jacob * cam/scsi/scsi_cd.c quirks
70808ec293SMatt Jacob
71808ec293SMatt Jacob  o CD_Q_NO_TOUCH - not implemented
72808ec293SMatt Jacob
73808ec293SMatt Jacob  o CD_Q_BCD_TRACKS - convert start/end track to BCD
74808ec293SMatt Jacob
75808ec293SMatt Jacob  o CD_Q_NO_CHANGER - never treat as a changer
76808ec293SMatt Jacob
77808ec293SMatt Jacob  o CD_Q_CHANGER - always treat as a changer
78808ec293SMatt Jacob
79808ec293SMatt Jacob * cam/scsi/scsi_ch.c quirks
80808ec293SMatt Jacob  o CH_Q_NO_DBD - disable block descriptors in mode sense
81808ec293SMatt Jacob
82808ec293SMatt Jacob * cam/scsi/scsi_sa.c quirks
83808ec293SMatt Jacob
84808ec293SMatt Jacob  o SA_QUIRK_NOCOMP - Can't deal with compression at all
85808ec293SMatt Jacob
86808ec293SMatt Jacob  o SA_QUIRK_FIXED - Force fixed mode
87808ec293SMatt Jacob
88808ec293SMatt Jacob  o SA_QUIRK_VARIABLE - Force variable mode
89808ec293SMatt Jacob
90808ec293SMatt Jacob  o SA_QUIRK_2FM - Needs Two File Marks at EOD
91808ec293SMatt Jacob
92808ec293SMatt Jacob  o SA_QUIRK_1FM - No more than 1 File Mark at EOD
93808ec293SMatt Jacob
94808ec293SMatt Jacob  o SA_QUIRK_NODREAD - Don't try and dummy read density
95808ec293SMatt Jacob
96808ec293SMatt Jacob  o SA_QUIRK_NO_MODESEL - Don't do mode select at all
97808ec293SMatt Jacob
98808ec293SMatt Jacob  o SA_QUIRK_NO_CPAGE - Don't use DEVICE COMPRESSION page
99808ec293SMatt Jacob
100808ec293SMatt Jacob * dev/usb/umass.c quirks
101808ec293SMatt Jacob
102808ec293SMatt Jacob  o NO_TEST_UNIT_READY - The drive does not support Test Unit Ready.
103808ec293SMatt Jacob  Convert to Start Unit. This command is a simple no-op for most
104808ec293SMatt Jacob  firmware but some of them hang when this command is sent.
105808ec293SMatt Jacob
106808ec293SMatt Jacob  o RS_NO_CLEAR_UA - The drive does not reset the Unit Attention state
107808ec293SMatt Jacob  after REQUEST SENSE has been sent. The INQUIRY command does not
108808ec293SMatt Jacob  reset the UA either, and so CAM runs in circles trying to retrieve
109808ec293SMatt Jacob  the initial INQUIRY data. This quirk signifies that after a unit
110808ec293SMatt Jacob  attention condition, don't try to clear the condition with a request
111808ec293SMatt Jacob  sense command.
112808ec293SMatt Jacob
113808ec293SMatt Jacob  o NO_START_STOP - Like test unit ready, don't send this command if it hangs the device.
114808ec293SMatt Jacob
115808ec293SMatt Jacob  o FORCE_SHORT_INQUIRY - Don't ask for full inquiry data (256
116808ec293SMatt Jacob  bytes). Some drives can only handle the shorter inquiry length
117808ec293SMatt Jacob  (36 bytes).
118808ec293SMatt Jacob
119808ec293SMatt Jacob  o SHUTTLE_INIT - Needs to be initialised the Shuttle way. Haven't
120808ec293SMatt Jacob  looked into what this does but apparently it's mostly Shuttle
121808ec293SMatt Jacob  devices.
122808ec293SMatt Jacob
123808ec293SMatt Jacob  o ALT_IFACE_1 - Drive needs to be switched to alternate interface 1. Rare.
124808ec293SMatt Jacob
125808ec293SMatt Jacob  o FLOPPY_SPEED - Drive does not do 1Mb/s, but just floppy speeds (20kb/s).
126808ec293SMatt Jacob
127808ec293SMatt Jacob  o IGNORE_RESIDUE - The device can't count and gets the residue
128808ec293SMatt Jacob  of transfers wrong. This is sometimes needed for devices where
129808ec293SMatt Jacob  large transfers cause stalls.
130808ec293SMatt Jacob
131808ec293SMatt Jacob  o NO_GETMAXLUN - Get maximum LUN is a command to identify multiple
132808ec293SMatt Jacob  devices sharing the same ID. For instance, a multislot compact
133808ec293SMatt Jacob  flash reader might be on two LUNS. Some non-standard devices hang
134808ec293SMatt Jacob  when receiving this command so this quirk disables it.
135808ec293SMatt Jacob
136808ec293SMatt Jacob  o WRONG_CSWSIG - The device uses a weird CSWSIGNATURE. Rare.
137808ec293SMatt Jacob
138808ec293SMatt Jacob  o NO_INQUIRY - Device cannot handle INQUIRY so fake a generic
139808ec293SMatt Jacob  response. INQUIRY is one of the most basic commands but some
140808ec293SMatt Jacob  drives can't even handle it. (No idea how such devices even work
141808ec293SMatt Jacob  at all on other OS's.) This quirk fakes up a valid but generic
142808ec293SMatt Jacob  response for devices that can't handle INQUIRY.
143808ec293SMatt Jacob
144808ec293SMatt Jacob  o NO_INQUIRY_EVPD - Device cannot handle an extended INQUIRY
145808ec293SMatt Jacob  asking for vital product data (EVPD) so just return a "no data"
146808ec293SMatt Jacob  response (check condition) without sending the command to the
147808ec293SMatt Jacob  device.
148808ec293SMatt Jacob
149808ec293SMatt Jacob2. Testing a Quirk
150808ec293SMatt Jacob
151808ec293SMatt JacobAfter you have an idea what you want to try, edit the proper file
152808ec293SMatt Jacobabove, using wildcarding to be sure your device is matched. Here
153808ec293SMatt Jacobis a list of the common things to try. Note that some devices require
154808ec293SMatt Jacobmultiple quirks or quirks in different drivers. For example, some
155808ec293SMatt JacobUSB pen drives or flash readers require quirks in both da(4) and
156808ec293SMatt Jacobumass(4).
157808ec293SMatt Jacob
158808ec293SMatt Jacob* umass(4) device (sys/dev/usb/umass.c) -- this quirk matches an Asahi Optical device with any product ID or revision ID.
159808ec293SMatt Jacob*
160808ec293SMatt Jacob*         { USB_VENDOR_ASAHIOPTICAL, PID_WILDCARD, RID_WILDCARD,
161808ec293SMatt Jacob*           UMASS_PROTO_ATAPI | UMASS_PROTO_CBI_I,
162808ec293SMatt Jacob*           RS_NO_CLEAR_UA
163808ec293SMatt Jacob*         },
164808ec293SMatt Jacob* da(4) device (sys/cam/scsi/scsi_da.c) -- this quirk matches a Creative device with a name of "NOMAD_MUVO" and any revision.
165808ec293SMatt Jacob*
166808ec293SMatt Jacob*         {
167808ec293SMatt Jacob*                 /*
168808ec293SMatt Jacob*                  * Creative Nomad MUVO mp3 player (USB)
169808ec293SMatt Jacob*                  * PR: kern/53094
170808ec293SMatt Jacob*                  */
171808ec293SMatt Jacob*                 {T_DIRECT, SIP_MEDIA_REMOVABLE, "CREATIVE", "NOMAD_MUVO", "*"},
172808ec293SMatt Jacob*                 /*quirks*/ DA_Q_NO_SYNC_CACHE|DA_Q_NO_PREVENT
173808ec293SMatt Jacob*         },
174808ec293SMatt Jacob
175808ec293SMatt Jacob3. Filing a PR
176808ec293SMatt Jacob
177808ec293SMatt JacobAll quirk submissions MUST go through GNATS. For information on how
178808ec293SMatt Jacobto submit a PR, see this page.
179808ec293SMatt Jacob
180808ec293SMatt JacobPlease include the following in your PR:
181808ec293SMatt Jacob
182808ec293SMatt Jacob * Subject: QUIRK: FooCo USB DVD-RAM drive
183808ec293SMatt Jacob * Output of "camcontrol inquiry yourdevice"
184808ec293SMatt Jacob * Manufacturer name, model number, etc.
185808ec293SMatt Jacob * Transport type (FC, SCSI, USB, Firewire)
186808ec293SMatt Jacob * Output from dmesg for failed attach attempts
187808ec293SMatt Jacob * Output from dmesg for successful attach attempts (after quirk added)
188808ec293SMatt Jacob * Output of "usbdevs -v" with device attached
189808ec293SMatt Jacob * Valid email address
190808ec293SMatt Jacob
191808ec293SMatt JacobHere are some examples of well-formed PRs:
192808ec293SMatt Jacob
193808ec293SMatt Jacob * kern/43580
194808ec293SMatt Jacob * kern/49054
195808ec293SMatt Jacob
196808ec293SMatt Jacob4. What happens next
197808ec293SMatt Jacob
198808ec293SMatt JacobI will review your submission, respond with comments, and once the
199808ec293SMatt Jacobquirk is deemed necessary and ready for committing, I'll commit it,
200808ec293SMatt Jacobreferencing the PR. (Again, all quirks must be submitted as PRs).
201808ec293SMatt JacobQuestions? Email njl AT freebsd.org.
202808ec293SMatt Jacob
203808ec293SMatt Jacob5. Note to Committers
204808ec293SMatt Jacob
205808ec293SMatt JacobPlease insert quirks in the right section in scsi_da.c, sorted by
206808ec293SMatt JacobPR number. Always include the name and PR number for scsi_da.c (see
207808ec293SMatt Jacobabove for an example.) Please sort quirks alphabetically in umass.c.
208808ec293SMatt JacobFollow the surrounding style in all drivers. Be sure to correspond
209808ec293SMatt Jacobwith the submitter to be sure the quirk you are adding is the minimum
210808ec293SMatt Jacobnecessary, not quirking other useful features and not overly broad
211808ec293SMatt Jacob(i.e., too many wildcards).
212