2 * scsi_scan.c Copyright (C) 2000 Eric Youngdale
6 * This used to live in scsi.c, but that file was just a laundry basket
7 * full of misc stuff. This got separated out in order to make things
11 #define __NO_VERSION__
12 #include <linux/config.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
16 #include <linux/blk.h>
20 #include "constants.h"
23 #include <linux/kmod.h>
26 /* The following devices are known not to tolerate a lun != 0 scan for
27 * one reason or another. Some will respond to all luns, others will
31 #define BLIST_NOLUN 0x001
32 #define BLIST_FORCELUN 0x002
33 #define BLIST_BORKEN 0x004
34 #define BLIST_KEY 0x008
35 #define BLIST_SINGLELUN 0x010
36 #define BLIST_NOTQ 0x020
37 #define BLIST_SPARSELUN 0x040
38 #define BLIST_MAX5LUN 0x080
39 #define BLIST_ISDISK 0x100
40 #define BLIST_ISROM 0x200
42 static void print_inquiry(unsigned char *data
);
43 static int scan_scsis_single(int channel
, int dev
, int lun
, int *max_scsi_dev
,
44 int *sparse_lun
, Scsi_Device
** SDpnt
,
45 struct Scsi_Host
*shpnt
, char *scsi_result
);
50 const char *revision
; /* Latest revision known to be bad. Not used yet */
55 * This is what was previously known as the blacklist. The concept
56 * has been expanded so that we can specify other types of things we
57 * need to be aware of.
59 static struct dev_info device_list
[] =
61 {"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
62 {"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
63 {"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
64 {"DENON", "DRD-25X", "V", BLIST_NOLUN
}, /* Locks up if probed for lun != 0 */
65 {"HITACHI", "DK312C", "CM81", BLIST_NOLUN
}, /* Responds to all lun - dtg */
66 {"HITACHI", "DK314C", "CR21", BLIST_NOLUN
}, /* responds to all lun */
67 {"IMS", "CDD521/10", "2.06", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
68 {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
69 {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
70 {"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN
}, /* Locks up when LUN>0 polled */
71 {"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN
}, /* Locks-up sometimes when LUN>0 polled. */
72 {"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN
}, /* guess what? */
73 {"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN
}, /*Responds to all lun */
74 {"MICROP", "4110", "*", BLIST_NOTQ
}, /* Buggy Tagged Queuing */
75 {"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
76 {"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN
}, /* Responds to all lun */
77 {"RODIME", "RO3000S", "2.33", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
78 {"SANYO", "CRD-250S", "1.20", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
79 * for aha152x controller, which causes
80 * SCSI code to reset bus.*/
81 {"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
82 * for aha152x controller, which causes
83 * SCSI code to reset bus.*/
84 {"SEAGATE", "ST296", "921", BLIST_NOLUN
}, /* Responds to all lun */
85 {"SEAGATE", "ST1581", "6538", BLIST_NOLUN
}, /* Responds to all lun */
86 {"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN
},
87 {"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN
},
88 {"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN
},
89 {"SONY", "CD-ROM CDU-8012", "*", BLIST_NOLUN
},
90 {"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
91 {"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
92 {"TEAC", "CD-ROM", "1.06", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
93 * for seagate controller, which causes
94 * SCSI code to reset bus.*/
95 {"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN
}, /* Responds to all lun */
96 {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
97 * for seagate controller, which causes
98 * SCSI code to reset bus.*/
99 {"QUANTUM", "LPS525S", "3110", BLIST_NOLUN
}, /* Locks sometimes if polled for lun != 0 */
100 {"QUANTUM", "PD1225S", "3110", BLIST_NOLUN
}, /* Locks sometimes if polled for lun != 0 */
101 {"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN
}, /* Locks up when polled for lun != 0 */
102 {"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
103 {"SANKYO", "CP525", "6.64", BLIST_NOLUN
}, /* causes failed REQ SENSE, extra reset */
104 {"HP", "C1750A", "3226", BLIST_NOLUN
}, /* scanjet iic */
105 {"HP", "C1790A", "", BLIST_NOLUN
}, /* scanjet iip */
106 {"HP", "C2500A", "", BLIST_NOLUN
}, /* scanjet iicx */
107 {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
108 {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN
}, /* Locks up if polled for lun != 0
110 {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
111 {"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
112 {"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
113 {"RELISYS", "Scorpio", "*", BLIST_NOLUN
}, /* responds to all LUN */
114 {"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN
}, /* responds to all LUN */
117 * Other types of devices that have special flags.
119 {"SONY", "CD-ROM CDU-8001", "*", BLIST_BORKEN
},
120 {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN
},
121 {"IOMEGA", "Io20S *F", "*", BLIST_KEY
},
122 {"INSITE", "Floptical F*8I", "*", BLIST_KEY
},
123 {"INSITE", "I325VM", "*", BLIST_KEY
},
124 {"LASOUND","CDX7405","3.10", BLIST_MAX5LUN
| BLIST_SINGLELUN
},
125 {"NRC", "MBR-7", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
126 {"NRC", "MBR-7.4", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
127 {"REGAL", "CDC-4X", "*", BLIST_MAX5LUN
| BLIST_SINGLELUN
},
128 {"NAKAMICH", "MJ-4.8S", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
129 {"NAKAMICH", "MJ-5.16S", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
130 {"PIONEER", "CD-ROM DRM-600", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
131 {"PIONEER", "CD-ROM DRM-602X", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
132 {"PIONEER", "CD-ROM DRM-604X", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
133 {"EMULEX", "MD21/S2 ESDI", "*", BLIST_SINGLELUN
},
134 {"CANON", "IPUBJD", "*", BLIST_SPARSELUN
},
135 {"nCipher", "Fastness Crypto", "*", BLIST_FORCELUN
},
136 {"NEC", "PD-1 ODX654P", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
137 {"MATSHITA", "PD-1", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
138 {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ
| BLIST_NOLUN
},
139 {"TOSHIBA","CDROM","*", BLIST_ISROM
},
140 {"MegaRAID", "LD", "*", BLIST_FORCELUN
},
141 {"DGC", "RAID", "*", BLIST_SPARSELUN
}, // Dell PV 650F (tgt @ LUN 0)
142 {"DGC", "DISK", "*", BLIST_SPARSELUN
}, // Dell PV 650F (no tgt @ LUN 0)
143 {"DELL", "PV530F", "*", BLIST_SPARSELUN
}, // Dell PV 530F
144 {"SONY", "TSL", "*", BLIST_FORCELUN
}, // DDS3 & DDS4 autoloaders
147 * Must be at end of list...
152 #ifdef CONFIG_SCSI_MULTI_LUN
153 static int max_scsi_luns
= 8;
155 static int max_scsi_luns
= 1;
160 MODULE_PARM(max_scsi_luns
, "i");
161 MODULE_PARM_DESC(max_scsi_luns
, "last scsi LUN (should be between 1 and 8)");
165 static int __init
scsi_luns_setup(char *str
)
169 if (get_option(&str
, &tmp
) == 1) {
173 printk("scsi_luns_setup : usage max_scsi_luns=n "
174 "(n should be between 1 and 8)\n");
179 __setup("max_scsi_luns=", scsi_luns_setup
);
183 static void print_inquiry(unsigned char *data
)
188 for (i
= 8; i
< 16; i
++) {
189 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
190 printk("%c", data
[i
]);
196 for (i
= 16; i
< 32; i
++) {
197 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
198 printk("%c", data
[i
]);
204 for (i
= 32; i
< 36; i
++) {
205 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
206 printk("%c", data
[i
]);
216 i
< MAX_SCSI_DEVICE_CODE
? scsi_device_types
[i
] : "Unknown ");
217 printk(" ANSI SCSI revision: %02x", data
[2] & 0x07);
218 if ((data
[2] & 0x07) == 1 && (data
[3] & 0x0f) == 1)
224 static int get_device_flags(unsigned char *response_data
)
228 for (i
= 0; 1; i
++) {
229 if (device_list
[i
].vendor
== NULL
)
231 pnt
= &response_data
[8];
232 while (*pnt
&& *pnt
== ' ')
234 if (memcmp(device_list
[i
].vendor
, pnt
,
235 strlen(device_list
[i
].vendor
)))
237 pnt
= &response_data
[16];
238 while (*pnt
&& *pnt
== ' ')
240 if (memcmp(device_list
[i
].model
, pnt
,
241 strlen(device_list
[i
].model
)))
243 return device_list
[i
].flags
;
249 * Detecting SCSI devices :
250 * We scan all present host adapter's busses, from ID 0 to ID (max_id).
251 * We use the INQUIRY command, determine device type, and pass the ID /
252 * lun address of all sequential devices to the tape driver, all random
253 * devices to the disk driver.
255 void scan_scsis(struct Scsi_Host
*shpnt
,
265 unsigned char *scsi_result
;
266 unsigned char scsi_result0
[256];
273 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
),
276 memset(SDpnt
, 0, sizeof(Scsi_Device
));
278 * Register the queue for the device. All I/O requests will
279 * come in through here. We also need to register a pointer to
280 * ourselves, since the queue handler won't know what device
281 * the queue actually represents. We could look it up, but it
284 scsi_initialize_queue(SDpnt
, shpnt
);
285 SDpnt
->request_queue
.queuedata
= (void *) SDpnt
;
286 /* Make sure we have something that is valid for DMA purposes */
287 scsi_result
= ((!shpnt
->unchecked_isa_dma
)
288 ? &scsi_result0
[0] : kmalloc(512, GFP_DMA
));
291 if (scsi_result
== NULL
) {
292 printk("Unable to obtain scsi_result buffer\n");
296 * We must chain ourself in the host_queue, so commands can time out
298 SDpnt
->queue_depth
= 1;
300 SDpnt
->online
= TRUE
;
302 initialize_merge_fn(SDpnt
);
305 * Initialize the object that we will use to wait for command blocks.
307 init_waitqueue_head(&SDpnt
->scpnt_wait
);
310 * Next, hook the device to the host in question.
314 if (shpnt
->host_queue
!= NULL
) {
315 SDtail
= shpnt
->host_queue
;
316 while (SDtail
->next
!= NULL
)
317 SDtail
= SDtail
->next
;
319 SDtail
->next
= SDpnt
;
320 SDpnt
->prev
= SDtail
;
322 shpnt
->host_queue
= SDpnt
;
326 * We need to increment the counter for this one device so we can track when
329 if (hardcoded
== 1) {
330 Scsi_Device
*oldSDpnt
= SDpnt
;
331 struct Scsi_Device_Template
*sdtpnt
;
333 if (channel
> shpnt
->max_channel
)
336 if (dev
>= shpnt
->max_id
)
339 if (lun
>= shpnt
->max_lun
)
341 scan_scsis_single(channel
, dev
, lun
, &max_dev_lun
, &sparse_lun
,
342 &SDpnt
, shpnt
, scsi_result
);
343 if (SDpnt
!= oldSDpnt
) {
345 /* it could happen the blockdevice hasn't yet been inited */
346 /* queue_depth() moved from scsi_proc_info() so that
347 it is called before scsi_build_commandblocks() */
348 if (shpnt
->select_queue_depths
!= NULL
)
349 (shpnt
->select_queue_depths
)(shpnt
,
352 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
)
353 if (sdtpnt
->init
&& sdtpnt
->dev_noticed
)
356 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
357 if (sdtpnt
->attach
) {
358 (*sdtpnt
->attach
) (oldSDpnt
);
359 if (oldSDpnt
->attached
) {
360 scsi_build_commandblocks(oldSDpnt
);
361 if (0 == oldSDpnt
->has_cmdblocks
) {
362 printk("scan_scsis: DANGER, no command blocks\n");
363 /* What to do now ?? */
368 scsi_resize_dma_pool();
370 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
371 if (sdtpnt
->finish
&& sdtpnt
->nr_dev
) {
372 (*sdtpnt
->finish
) ();
377 /* Actual LUN. PC ordering is 0->n IBM/spec ordering is n->0 */
380 for (channel
= 0; channel
<= shpnt
->max_channel
; channel
++) {
381 for (dev
= 0; dev
< shpnt
->max_id
; ++dev
) {
382 if (shpnt
->reverse_ordering
)
383 /* Shift to scanning 15,14,13... or 7,6,5,4, */
384 order_dev
= shpnt
->max_id
- dev
- 1;
388 if (shpnt
->this_id
!= order_dev
) {
391 * We need the for so our continue, etc. work fine. We put this in
392 * a variable so that we can override it during the scan if we
393 * detect a device *KNOWN* to have multiple logical units.
395 max_dev_lun
= (max_scsi_luns
< shpnt
->max_lun
?
396 max_scsi_luns
: shpnt
->max_lun
);
398 for (lun
= 0; lun
< max_dev_lun
; ++lun
) {
399 if (!scan_scsis_single(channel
, order_dev
, lun
, &max_dev_lun
,
400 &sparse_lun
, &SDpnt
, shpnt
,
403 break; /* break means don't probe further for luns!=0 */
405 } /* if this_id != id ends */
407 } /* for channel ends */
408 } /* if/else hardcoded */
412 { /* Unchain SRpnt from host_queue */
413 Scsi_Device
*prev
, *next
;
416 for (dqptr
= shpnt
->host_queue
; dqptr
!= SDpnt
; dqptr
= dqptr
->next
)
424 shpnt
->host_queue
= next
;
430 /* Last device block does not exist. Free memory. */
432 blk_cleanup_queue(&SDpnt
->request_queue
);
433 kfree((char *) SDpnt
);
436 /* If we allocated a buffer so we could do DMA, free it now */
437 if (scsi_result
!= &scsi_result0
[0] && scsi_result
!= NULL
) {
443 SCSI_LOG_SCAN_BUS(4, printk("Host status for host %p:\n", shpnt
));
444 for (sdev
= shpnt
->host_queue
; sdev
; sdev
= sdev
->next
) {
445 SCSI_LOG_SCAN_BUS(4, printk("Device %d %p: ", sdev
->id
, sdev
));
446 for (scmd
= sdev
->device_queue
; scmd
; scmd
= scmd
->next
) {
447 SCSI_LOG_SCAN_BUS(4, printk("%p ", scmd
));
449 SCSI_LOG_SCAN_BUS(4, printk("\n"));
455 * The worker for scan_scsis.
456 * Returning 0 means Please don't ask further for lun!=0, 1 means OK go on.
457 * Global variables used : scsi_devices(linked list)
459 static int scan_scsis_single(int channel
, int dev
, int lun
, int *max_dev_lun
,
460 int *sparse_lun
, Scsi_Device
** SDpnt2
,
461 struct Scsi_Host
*shpnt
, char *scsi_result
)
464 unsigned char scsi_cmd
[MAX_COMMAND_SIZE
];
465 struct Scsi_Device_Template
*sdtpnt
;
466 Scsi_Device
*SDtail
, *SDpnt
= *SDpnt2
;
467 Scsi_Request
* SRpnt
;
468 int bflags
, type
= -1;
469 extern devfs_handle_t scsi_devfs_handle
;
474 SDpnt
->channel
= channel
;
475 SDpnt
->online
= TRUE
;
477 scsi_build_commandblocks(SDpnt
);
479 /* Some low level driver could use device->type (DB) */
483 * Assume that the device will have handshaking problems, and then fix this
484 * field later if it turns out it doesn't
487 SDpnt
->was_reset
= 0;
488 SDpnt
->expecting_cc_ua
= 0;
491 SRpnt
= scsi_allocate_request(SDpnt
);
494 * We used to do a TEST_UNIT_READY before the INQUIRY but that was
495 * not really necessary. Spec recommends using INQUIRY to scan for
496 * devices (and TEST_UNIT_READY to poll for media change). - Paul G.
499 SCSI_LOG_SCAN_BUS(3, printk("scsi: performing INQUIRY\n"));
501 * Build an INQUIRY command block.
503 scsi_cmd
[0] = INQUIRY
;
504 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
509 SRpnt
->sr_cmd_len
= 0;
510 SRpnt
->sr_data_direction
= SCSI_DATA_READ
;
512 scsi_wait_req (SRpnt
, (void *) scsi_cmd
,
513 (void *) scsi_result
,
514 256, SCSI_TIMEOUT
+4*HZ
, 3);
516 SCSI_LOG_SCAN_BUS(3, printk("scsi: INQUIRY %s with code 0x%x\n",
517 SRpnt
->sr_result
? "failed" : "successful", SRpnt
->sr_result
));
519 if (SRpnt
->sr_result
) {
520 scsi_release_request(SRpnt
);
521 return 0; /* assume no peripheral if any sort of error */
525 * Check the peripheral qualifier field - this tells us whether LUNS
526 * are supported here or not.
528 if ((scsi_result
[0] >> 5) == 3) {
529 scsi_release_request(SRpnt
);
530 return 0; /* assume no peripheral if any sort of error */
534 * Get any flags for this device.
536 bflags
= get_device_flags (scsi_result
);
539 /* The Toshiba ROM was "gender-changed" here as an inline hack.
540 This is now much more generic.
541 This is a mess: What we really want is to leave the scsi_result
542 alone, and just change the SDpnt structure. And the SDpnt is what
543 we want print_inquiry to print. -- REW
545 if (bflags
& BLIST_ISDISK
) {
546 scsi_result
[0] = TYPE_DISK
;
547 scsi_result
[1] |= 0x80; /* removable */
550 if (bflags
& BLIST_ISROM
) {
551 scsi_result
[0] = TYPE_ROM
;
552 scsi_result
[1] |= 0x80; /* removable */
555 memcpy(SDpnt
->vendor
, scsi_result
+ 8, 8);
556 memcpy(SDpnt
->model
, scsi_result
+ 16, 16);
557 memcpy(SDpnt
->rev
, scsi_result
+ 32, 4);
559 SDpnt
->removable
= (0x80 & scsi_result
[1]) >> 7;
560 /* Use the peripheral qualifier field to determine online/offline */
561 if (((scsi_result
[0] >> 5) & 7) == 1) SDpnt
->online
= FALSE
;
562 else SDpnt
->online
= TRUE
;
563 SDpnt
->lockable
= SDpnt
->removable
;
565 SDpnt
->access_count
= 0;
567 SDpnt
->has_cmdblocks
= 0;
569 * Currently, all sequential devices are assumed to be tapes, all random
570 * devices disk, with the appropriate read only flags set for ROM / WORM
573 switch (type
= (scsi_result
[0] & 0x1f)) {
579 case TYPE_MEDIUM_CHANGER
:
582 SDpnt
->writeable
= 1;
586 SDpnt
->writeable
= 0;
589 printk("scsi: unknown type %d\n", type
);
592 SDpnt
->device_blocked
= FALSE
;
593 SDpnt
->device_busy
= 0;
594 SDpnt
->single_lun
= 0;
596 (scsi_result
[7] & 1) && ((scsi_result
[3] & 7) == 2);
597 SDpnt
->random
= (type
== TYPE_TAPE
) ? 0 : 1;
598 SDpnt
->type
= (type
& 0x1f);
600 print_inquiry(scsi_result
);
602 sprintf (devname
, "host%d/bus%d/target%d/lun%d",
603 SDpnt
->host
->host_no
, SDpnt
->channel
, SDpnt
->id
, SDpnt
->lun
);
604 if (SDpnt
->de
) printk ("DEBUG: dir: \"%s\" already exists\n", devname
);
605 else SDpnt
->de
= devfs_mk_dir (scsi_devfs_handle
, devname
, NULL
);
607 for (sdtpnt
= scsi_devicelist
; sdtpnt
;
608 sdtpnt
= sdtpnt
->next
)
611 (*sdtpnt
->detect
) (SDpnt
);
613 SDpnt
->scsi_level
= scsi_result
[2] & 0x07;
614 if (SDpnt
->scsi_level
>= 2 ||
615 (SDpnt
->scsi_level
== 1 &&
616 (scsi_result
[3] & 0x0f) == 1))
620 * Accommodate drivers that want to sleep when they should be in a polling
623 SDpnt
->disconnect
= 0;
627 * Set the tagged_queue flag for SCSI-II devices that purport to support
628 * tagged queuing in the INQUIRY data.
630 SDpnt
->tagged_queue
= 0;
631 if ((SDpnt
->scsi_level
>= SCSI_2
) &&
632 (scsi_result
[7] & 2) &&
633 !(bflags
& BLIST_NOTQ
)) {
634 SDpnt
->tagged_supported
= 1;
635 SDpnt
->current_tag
= 0;
638 * Some revisions of the Texel CD ROM drives have handshaking problems when
639 * used with the Seagate controllers. Before we know what type of device
640 * we're talking to, we assume it's borken and then change it here if it
641 * turns out that it isn't a TEXEL drive.
643 if ((bflags
& BLIST_BORKEN
) == 0)
647 * If we want to only allow I/O to one of the luns attached to this device
648 * at a time, then we set this flag.
650 if (bflags
& BLIST_SINGLELUN
)
651 SDpnt
->single_lun
= 1;
654 * These devices need this "key" to unlock the devices so we can use it
656 if ((bflags
& BLIST_KEY
) != 0) {
657 printk("Unlocked floptical drive.\n");
659 scsi_cmd
[0] = MODE_SENSE
;
660 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
665 SRpnt
->sr_cmd_len
= 0;
666 SRpnt
->sr_data_direction
= SCSI_DATA_READ
;
667 scsi_wait_req (SRpnt
, (void *) scsi_cmd
,
668 (void *) scsi_result
, 0x2a,
672 scsi_release_request(SRpnt
);
675 scsi_release_commandblocks(SDpnt
);
678 * This device was already hooked up to the host in question,
679 * so at this point we just let go of it and it should be fine. We do need to
680 * allocate a new one and attach it to the host so that we can further scan the bus.
682 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
), GFP_ATOMIC
);
684 printk("scsi: scan_scsis_single: Cannot malloc\n");
687 memset(SDpnt
, 0, sizeof(Scsi_Device
));
690 SDpnt
->queue_depth
= 1;
692 SDpnt
->online
= TRUE
;
695 * Register the queue for the device. All I/O requests will come
696 * in through here. We also need to register a pointer to
697 * ourselves, since the queue handler won't know what device
698 * the queue actually represents. We could look it up, but it
701 scsi_initialize_queue(SDpnt
, shpnt
);
703 initialize_merge_fn(SDpnt
);
706 * Mark this device as online, or otherwise we won't be able to do much with it.
708 SDpnt
->online
= TRUE
;
711 * Initialize the object that we will use to wait for command blocks.
713 init_waitqueue_head(&SDpnt
->scpnt_wait
);
716 * Since we just found one device, there had damn well better be one in the list
719 if (shpnt
->host_queue
== NULL
)
720 panic("scan_scsis_single: Host queue == NULL\n");
722 SDtail
= shpnt
->host_queue
;
723 while (SDtail
->next
) {
724 SDtail
= SDtail
->next
;
727 /* Add this device to the linked list at the end */
728 SDtail
->next
= SDpnt
;
729 SDpnt
->prev
= SDtail
;
733 * Some scsi devices cannot be polled for lun != 0 due to firmware bugs
735 if (bflags
& BLIST_NOLUN
)
736 return 0; /* break; */
739 * If this device is known to support sparse multiple units, override the
740 * other settings, and scan all of them.
742 if (bflags
& BLIST_SPARSELUN
) {
748 * If this device is known to support multiple units, override the other
749 * settings, and scan all of them.
751 if (bflags
& BLIST_FORCELUN
) {
756 * REGAL CDC-4X: avoid hang after LUN 4
758 if (bflags
& BLIST_MAX5LUN
) {
764 * We assume the device can't handle lun!=0 if: - it reports scsi-0
765 * (ANSI SCSI Revision 0) (old drives like MAXTOR XT-3280) or - it
766 * reports scsi-1 (ANSI SCSI Revision 1) and Response Data Format 0
768 if (((scsi_result
[2] & 0x07) == 0)
770 ((scsi_result
[2] & 0x07) == 1 &&
771 (scsi_result
[3] & 0x0f) == 0))