2 #include <linux/blkdev.h>
3 #include <linux/init.h>
4 #include <linux/kernel.h>
5 #include <linux/module.h>
6 #include <linux/moduleparam.h>
7 #include <linux/proc_fs.h>
8 #include <linux/seq_file.h>
10 #include <scsi/scsi_device.h>
11 #include <scsi/scsi_devinfo.h>
13 #include "scsi_priv.h"
17 * scsi_dev_info_list: structure to hold black/white listed devices.
19 struct scsi_dev_info_list {
20 struct list_head dev_info_list;
24 unsigned compatible; /* for use with scsi_static_device_list entries */
28 static const char spaces[] = " "; /* 16 of them */
29 static unsigned scsi_default_dev_flags;
30 static LIST_HEAD(scsi_dev_info_list);
31 static __initdata char scsi_dev_flags[256];
34 * scsi_static_device_list: deprecated list of devices that require
35 * settings that differ from the default, includes black-listed (broken)
36 * devices. The entries here are added to the tail of scsi_dev_info_list
37 * via scsi_dev_info_list_init.
39 * Do not add to this list, use the command line or proc interface to add
40 * to the scsi_dev_info_list. This table will eventually go away.
45 char *revision; /* revision known to be bad, unused */
47 } scsi_static_device_list[] __initdata = {
49 * The following devices are known not to tolerate a lun != 0 scan
50 * for one reason or another. Some will respond to all luns,
51 * others will lock up.
53 {"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN}, /* locks up */
54 {"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN}, /* locks up */
55 {"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN}, /* locks up */
56 {"DENON", "DRD-25X", "V", BLIST_NOLUN}, /* locks up */
57 {"HITACHI", "DK312C", "CM81", BLIST_NOLUN}, /* responds to all lun */
58 {"HITACHI", "DK314C", "CR21", BLIST_NOLUN}, /* responds to all lun */
59 {"IMS", "CDD521/10", "2.06", BLIST_NOLUN}, /* locks up */
60 {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN}, /* locks up */
61 {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN}, /* locks up */
62 {"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN}, /* locks up */
63 {"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN}, /* locks up */
64 {"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN}, /* locks up */
65 {"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN}, /* responds to all lun */
66 {"MICROTEK", "ScanMakerIII", "2.30", BLIST_NOLUN}, /* responds to all lun */
67 {"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN},/* locks up */
68 {"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN}, /* responds to all lun */
69 {"RODIME", "RO3000S", "2.33", BLIST_NOLUN}, /* locks up */
70 {"SUN", "SENA", NULL, BLIST_NOLUN}, /* responds to all luns */
72 * The following causes a failed REQUEST SENSE on lun 1 for
73 * aha152x controller, which causes SCSI code to reset bus.
75 {"SANYO", "CRD-250S", "1.20", BLIST_NOLUN},
77 * The following causes a failed REQUEST SENSE on lun 1 for
78 * aha152x controller, which causes SCSI code to reset bus.
80 {"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN},
81 {"SEAGATE", "ST296", "921", BLIST_NOLUN}, /* responds to all lun */
82 {"SEAGATE", "ST1581", "6538", BLIST_NOLUN}, /* responds to all lun */
83 {"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN},
84 {"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN},
85 {"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN},
86 {"SONY", "CD-ROM CDU-8012", NULL, BLIST_NOLUN},
87 {"SONY", "SDT-5000", "3.17", BLIST_SELECT_NO_ATN},
88 {"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN}, /* locks up */
89 {"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN}, /* locks up */
91 * The following causes a failed REQUEST SENSE on lun 1 for
92 * seagate controller, which causes SCSI code to reset bus.
94 {"TEAC", "CD-ROM", "1.06", BLIST_NOLUN},
95 {"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN}, /* responds to all lun */
97 * The following causes a failed REQUEST SENSE on lun 1 for
98 * seagate controller, which causes SCSI code to reset bus.
100 {"HP", "C1750A", "3226", BLIST_NOLUN}, /* scanjet iic */
101 {"HP", "C1790A", "", BLIST_NOLUN}, /* scanjet iip */
102 {"HP", "C2500A", "", BLIST_NOLUN}, /* scanjet iicx */
103 {"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN}, /* locks up */
104 {"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN}, /* responds to all lun */
105 {"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN}, /* locks up */
106 {"NEC", "D3856", "0009", BLIST_NOLUN},
107 {"QUANTUM", "LPS525S", "3110", BLIST_NOLUN}, /* locks up */
108 {"QUANTUM", "PD1225S", "3110", BLIST_NOLUN}, /* locks up */
109 {"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN}, /* locks up */
110 {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */
111 {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */
112 {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN},
113 {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */
114 {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */
115 {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */
116 {"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN}, /* locks up */
119 * Other types of devices that have special flags.
120 * Note that all USB devices should have the BLIST_INQUIRY_36 flag.
122 {"3PARdata", "VV", NULL, BLIST_REPORTLUN2},
123 {"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN},
124 {"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN},
125 {"AFT PRO", "-IX CF", "0.0>", BLIST_FORCELUN},
126 {"BELKIN", "USB 2 HS-CF", "1.95", BLIST_FORCELUN | BLIST_INQUIRY_36},
127 {"CANON", "IPUBJD", NULL, BLIST_SPARSELUN},
128 {"CBOX3", "USB Storage-SMC", "300A", BLIST_FORCELUN | BLIST_INQUIRY_36},
129 {"CMD", "CRA-7280", NULL, BLIST_SPARSELUN}, /* CMD RAID Controller */
130 {"CNSI", "G7324", NULL, BLIST_SPARSELUN}, /* Chaparral G7324 RAID */
131 {"CNSi", "G8324", NULL, BLIST_SPARSELUN}, /* Chaparral G8324 RAID */
132 {"COMPAQ", "LOGICAL VOLUME", NULL, BLIST_FORCELUN},
133 {"COMPAQ", "CR3500", NULL, BLIST_FORCELUN},
134 {"COMPAQ", "MSA1000", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD},
135 {"COMPAQ", "MSA1000 VOLUME", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD},
136 {"COMPAQ", "HSV110", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
137 {"DDN", "SAN DataDirector", "*", BLIST_SPARSELUN},
138 {"DEC", "HSG80", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD},
139 {"DELL", "PV660F", NULL, BLIST_SPARSELUN},
140 {"DELL", "PV660F PSEUDO", NULL, BLIST_SPARSELUN},
141 {"DELL", "PSEUDO DEVICE .", NULL, BLIST_SPARSELUN}, /* Dell PV 530F */
142 {"DELL", "PV530F", NULL, BLIST_SPARSELUN},
143 {"DELL", "PERCRAID", NULL, BLIST_FORCELUN},
144 {"DGC", "RAID", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, storage on LUN 0 */
145 {"DGC", "DISK", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, no storage on LUN 0 */
146 {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
147 {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN},
148 {"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
149 {"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36},
150 {"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN | BLIST_INQUIRY_36},
151 {"Generic", "USB Storage-SMC", "0207", BLIST_FORCELUN | BLIST_INQUIRY_36},
152 {"HITACHI", "DF400", "*", BLIST_SPARSELUN},
153 {"HITACHI", "DF500", "*", BLIST_SPARSELUN},
154 {"HITACHI", "DF600", "*", BLIST_SPARSELUN},
155 {"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP VA7400 */
156 {"HP", "OPEN-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP XP Arrays */
157 {"HP", "NetRAID-4M", NULL, BLIST_FORCELUN},
158 {"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD},
159 {"HP", "C1557A", NULL, BLIST_FORCELUN},
160 {"HP", "C3323-300", "4269", BLIST_NOTQ},
161 {"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN},
162 {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
163 {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
164 {"IOMEGA", "Io20S *F", NULL, BLIST_KEY},
165 {"INSITE", "Floptical F*8I", NULL, BLIST_KEY},
166 {"INSITE", "I325VM", NULL, BLIST_KEY},
167 {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
168 {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
169 {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
170 {"MATSHITA", "DMC-LC5", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
171 {"MATSHITA", "DMC-LC40", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
172 {"Medion", "Flash XL MMC/SD", "2.6D", BLIST_FORCELUN},
173 {"MegaRAID", "LD", NULL, BLIST_FORCELUN},
174 {"MICROP", "4110", NULL, BLIST_NOTQ},
175 {"MYLEX", "DACARMRB", "*", BLIST_REPORTLUN2},
176 {"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN},
177 {"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
178 {"NAKAMICH", "MJ-5.16S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
179 {"NEC", "PD-1 ODX654P", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
180 {"NRC", "MBR-7", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
181 {"NRC", "MBR-7.4", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
182 {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
183 {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
184 {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
185 {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
186 {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
187 {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */
188 {"SEAGATE", "ST3390N", "9546", BLIST_NOTQ},
189 {"SGI", "RAID3", "*", BLIST_SPARSELUN},
190 {"SGI", "RAID5", "*", BLIST_SPARSELUN},
191 {"SGI", "TP9100", "*", BLIST_REPORTLUN2},
192 {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
193 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
194 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
195 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */
196 {"SUN", "T300", "*", BLIST_SPARSELUN},
197 {"SUN", "T4", "*", BLIST_SPARSELUN},
198 {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN},
199 {"TOSHIBA", "CDROM", NULL, BLIST_ISROM},
200 {"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
201 {"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN | BLIST_INQUIRY_36},
202 {"WangDAT", "Model 2600", "01.7", BLIST_SELECT_NO_ATN},
203 {"WangDAT", "Model 3200", "02.2", BLIST_SELECT_NO_ATN},
204 {"WangDAT", "Model 1300", "02.4", BLIST_SELECT_NO_ATN},
205 {"XYRATEX", "RS", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
206 {"Zzyzx", "RocketStor 500S", NULL, BLIST_SPARSELUN},
207 {"Zzyzx", "RocketStor 2000", NULL, BLIST_SPARSELUN},
208 { NULL, NULL, NULL, 0 },
212 * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into
213 * devinfo vendor and model strings.
215 static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length,
216 char *from, int compatible)
220 from_length = strlen(from);
221 strncpy(to, from, min(to_length, from_length));
222 if (from_length < to_length) {
225 * NUL terminate the string if it is short.
227 to[from_length] = '\0';
230 * space pad the string if it is short.
232 strncpy(&to[from_length], spaces,
233 to_length - from_length);
236 if (from_length > to_length)
237 printk(KERN_WARNING "%s: %s string '%s' is too long\n",
238 __FUNCTION__, name, from);
242 * scsi_dev_info_list_add: add one dev_info list entry.
243 * @vendor: vendor string
244 * @model: model (product) string
245 * @strflags: integer string
246 * @flag: if strflags NULL, use this flag value
249 * Create and add one dev_info entry for @vendor, @model, @strflags or
250 * @flag. If @compatible, add to the tail of the list, do not space
251 * pad, and set devinfo->compatible. The scsi_static_device_list entries
252 * are added with @compatible 1 and @clfags NULL.
254 * Returns: 0 OK, -error on failure.
256 static int scsi_dev_info_list_add(int compatible, char *vendor, char *model,
257 char *strflags, int flags)
259 struct scsi_dev_info_list *devinfo;
261 devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL);
263 printk(KERN_ERR "%s: no memory\n", __FUNCTION__);
267 scsi_strcpy_devinfo("vendor", devinfo->vendor, sizeof(devinfo->vendor),
269 scsi_strcpy_devinfo("model", devinfo->model, sizeof(devinfo->model),
273 devinfo->flags = simple_strtoul(strflags, NULL, 0);
275 devinfo->flags = flags;
277 devinfo->compatible = compatible;
280 list_add_tail(&devinfo->dev_info_list, &scsi_dev_info_list);
282 list_add(&devinfo->dev_info_list, &scsi_dev_info_list);
288 * scsi_dev_info_list_add_str: parse dev_list and add to the
289 * scsi_dev_info_list.
290 * @dev_list: string of device flags to add
293 * Parse dev_list, and add entries to the scsi_dev_info_list.
294 * dev_list is of the form "vendor:product:flag,vendor:product:flag".
295 * dev_list is modified via strsep. Can be called for command line
296 * addition, for proc or mabye a sysfs interface.
298 * Returns: 0 if OK, -error on failure.
300 static int scsi_dev_info_list_add_str(char *dev_list)
302 char *vendor, *model, *strflags, *next;
307 if (next && next[0] == '"') {
309 * Ignore both the leading and trailing quote.
318 * For the leading and trailing '"' case, the for loop comes
319 * through the last time with vendor[0] == '\0'.
321 for (vendor = strsep(&next, ":"); vendor && (vendor[0] != '\0')
322 && (res == 0); vendor = strsep(&next, ":")) {
324 model = strsep(&next, ":");
326 strflags = strsep(&next, next_check);
327 if (!model || !strflags) {
328 printk(KERN_ERR "%s: bad dev info string '%s' '%s'"
329 " '%s'\n", __FUNCTION__, vendor, model,
333 res = scsi_dev_info_list_add(0 /* compatible */, vendor,
340 * get_device_flags - get device specific flags from the dynamic device
341 * list. Called during scan time.
342 * @vendor: vendor name
346 * Search the scsi_dev_info_list for an entry matching @vendor and
347 * @model, if found, return the matching flags value, else return
348 * the host or global default settings.
350 int scsi_get_device_flags(struct scsi_device *sdev, unsigned char *vendor,
351 unsigned char *model)
353 struct scsi_dev_info_list *devinfo;
356 bflags = sdev->sdev_bflags;
358 bflags = scsi_default_dev_flags;
360 list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
361 if (devinfo->compatible) {
363 * Behave like the older version of get_device_flags.
367 * XXX why skip leading spaces? If an odd INQUIRY
368 * value, that should have been part of the
369 * scsi_static_device_list[] entry, such as " FOO"
370 * rather than "FOO". Since this code is already
371 * here, and we don't know what device it is
372 * trying to work with, leave it as-is.
374 max = 8; /* max length of vendor */
375 while ((max > 0) && *vendor == ' ') {
380 * XXX removing the following strlen() would be
381 * good, using it means that for a an entry not in
382 * the list, we scan every byte of every vendor
383 * listed in scsi_static_device_list[], and never match
384 * a single one (and still have to compare at
385 * least the first byte of each vendor).
387 if (memcmp(devinfo->vendor, vendor,
388 min(max, strlen(devinfo->vendor))))
393 max = 16; /* max length of model */
394 while ((max > 0) && *model == ' ') {
398 if (memcmp(devinfo->model, model,
399 min(max, strlen(devinfo->model))))
401 return devinfo->flags;
403 if (!memcmp(devinfo->vendor, vendor,
404 sizeof(devinfo->vendor)) &&
405 !memcmp(devinfo->model, model,
406 sizeof(devinfo->model)))
407 return devinfo->flags;
413 #ifdef CONFIG_SCSI_PROC_FS
415 * proc_scsi_dev_info_read: dump the scsi_dev_info_list via
416 * /proc/scsi/device_info
418 static int proc_scsi_devinfo_read(char *buffer, char **start,
419 off_t offset, int length)
421 struct scsi_dev_info_list *devinfo;
426 list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) {
427 size = sprintf(buffer + len, "'%.8s' '%.16s' 0x%x\n",
428 devinfo->vendor, devinfo->model, devinfo->flags);
435 if (pos > offset + length)
440 *start = buffer + (offset - begin); /* Start of wanted data */
441 len -= (offset - begin); /* Start slop */
443 len = length; /* Ending slop */
448 * proc_scsi_dev_info_write: allow additions to the scsi_dev_info_list via
451 * Use: echo "vendor:model:flag" > /proc/scsi/device_info
453 * To add a black/white list entry for vendor and model with an integer
454 * value of flag to the scsi device info list.
456 static int proc_scsi_devinfo_write(struct file *file, const char __user *buf,
457 unsigned long length, void *data)
462 if (!buf || length>PAGE_SIZE)
464 if (!(buffer = (char *) __get_free_page(GFP_KERNEL)))
466 if (copy_from_user(buffer, buf, length)) {
471 if (length < PAGE_SIZE)
472 buffer[length] = '\0';
473 else if (buffer[PAGE_SIZE-1]) {
478 scsi_dev_info_list_add_str(buffer);
481 free_page((unsigned long)buffer);
484 #endif /* CONFIG_SCSI_PROC_FS */
486 module_param_string(dev_flags, scsi_dev_flags, sizeof(scsi_dev_flags), 0);
487 MODULE_PARM_DESC(dev_flags,
488 "Given scsi_dev_flags=vendor:model:flags[,v:m:f] add black/white"
489 " list entries for vendor and model with an integer value of flags"
490 " to the scsi device info list");
492 module_param_named(default_dev_flags, scsi_default_dev_flags, int, S_IRUGO|S_IWUSR);
493 MODULE_PARM_DESC(default_dev_flags,
494 "scsi default device flag integer value");
497 * scsi_dev_info_list_delete: called from scsi.c:exit_scsi to remove
498 * the scsi_dev_info_list.
500 void scsi_exit_devinfo(void)
502 struct list_head *lh, *lh_next;
503 struct scsi_dev_info_list *devinfo;
505 #ifdef CONFIG_SCSI_PROC_FS
506 remove_proc_entry("scsi/device_info", NULL);
509 list_for_each_safe(lh, lh_next, &scsi_dev_info_list) {
510 devinfo = list_entry(lh, struct scsi_dev_info_list,
517 * scsi_dev_list_init: set up the dynamic device list.
518 * @dev_list: string of device flags to add
521 * Add command line @dev_list entries, then add
522 * scsi_static_device_list entries to the scsi device info list.
524 int __init scsi_init_devinfo(void)
526 #ifdef CONFIG_SCSI_PROC_FS
527 struct proc_dir_entry *p;
531 error = scsi_dev_info_list_add_str(scsi_dev_flags);
535 for (i = 0; scsi_static_device_list[i].vendor; i++) {
536 error = scsi_dev_info_list_add(1 /* compatibile */,
537 scsi_static_device_list[i].vendor,
538 scsi_static_device_list[i].model,
540 scsi_static_device_list[i].flags);
545 #ifdef CONFIG_SCSI_PROC_FS
546 p = create_proc_entry("scsi/device_info", 0, NULL);
552 p->owner = THIS_MODULE;
553 p->get_info = proc_scsi_devinfo_read;
554 p->write_proc = proc_scsi_devinfo_write;
555 #endif /* CONFIG_SCSI_PROC_FS */