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 {"DEC","HSG80","*", BLIST_FORCELUN
},
137 {"COMPAQ","LOGICAL VOLUME","*", BLIST_FORCELUN
},
138 {"NEC", "PD-1 ODX654P", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
139 {"MATSHITA", "PD-1", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
140 {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ
| BLIST_NOLUN
},
141 {"TOSHIBA","CDROM","*", BLIST_ISROM
},
142 {"MegaRAID", "LD", "*", BLIST_FORCELUN
},
143 {"DGC", "RAID", "*", BLIST_SPARSELUN
}, // Dell PV 650F (tgt @ LUN 0)
144 {"DGC", "DISK", "*", BLIST_SPARSELUN
}, // Dell PV 650F (no tgt @ LUN 0)
145 {"DELL", "PV530F", "*", BLIST_SPARSELUN
}, // Dell PV 530F
146 {"SONY", "TSL", "*", BLIST_FORCELUN
}, // DDS3 & DDS4 autoloaders
147 {"DELL", "PERCRAID", "*", BLIST_FORCELUN
},
148 {"HP", "NetRAID-4M", "*", BLIST_FORCELUN
},
151 * Must be at end of list...
156 #ifdef CONFIG_SCSI_MULTI_LUN
157 static int max_scsi_luns
= 8;
159 static int max_scsi_luns
= 1;
164 MODULE_PARM(max_scsi_luns
, "i");
165 MODULE_PARM_DESC(max_scsi_luns
, "last scsi LUN (should be between 1 and 8)");
169 static int __init
scsi_luns_setup(char *str
)
173 if (get_option(&str
, &tmp
) == 1) {
177 printk("scsi_luns_setup : usage max_scsi_luns=n "
178 "(n should be between 1 and 8)\n");
183 __setup("max_scsi_luns=", scsi_luns_setup
);
187 static void print_inquiry(unsigned char *data
)
192 for (i
= 8; i
< 16; i
++) {
193 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
194 printk("%c", data
[i
]);
200 for (i
= 16; i
< 32; i
++) {
201 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
202 printk("%c", data
[i
]);
208 for (i
= 32; i
< 36; i
++) {
209 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
210 printk("%c", data
[i
]);
220 i
< MAX_SCSI_DEVICE_CODE
? scsi_device_types
[i
] : "Unknown ");
221 printk(" ANSI SCSI revision: %02x", data
[2] & 0x07);
222 if ((data
[2] & 0x07) == 1 && (data
[3] & 0x0f) == 1)
228 static int get_device_flags(unsigned char *response_data
)
232 for (i
= 0; 1; i
++) {
233 if (device_list
[i
].vendor
== NULL
)
235 pnt
= &response_data
[8];
236 while (*pnt
&& *pnt
== ' ')
238 if (memcmp(device_list
[i
].vendor
, pnt
,
239 strlen(device_list
[i
].vendor
)))
241 pnt
= &response_data
[16];
242 while (*pnt
&& *pnt
== ' ')
244 if (memcmp(device_list
[i
].model
, pnt
,
245 strlen(device_list
[i
].model
)))
247 return device_list
[i
].flags
;
253 * Detecting SCSI devices :
254 * We scan all present host adapter's busses, from ID 0 to ID (max_id).
255 * We use the INQUIRY command, determine device type, and pass the ID /
256 * lun address of all sequential devices to the tape driver, all random
257 * devices to the disk driver.
259 void scan_scsis(struct Scsi_Host
*shpnt
,
269 unsigned char *scsi_result
;
270 unsigned char scsi_result0
[256];
277 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
),
280 memset(SDpnt
, 0, sizeof(Scsi_Device
));
282 * Register the queue for the device. All I/O requests will
283 * come in through here. We also need to register a pointer to
284 * ourselves, since the queue handler won't know what device
285 * the queue actually represents. We could look it up, but it
288 scsi_initialize_queue(SDpnt
, shpnt
);
289 SDpnt
->request_queue
.queuedata
= (void *) SDpnt
;
290 /* Make sure we have something that is valid for DMA purposes */
291 scsi_result
= ((!shpnt
->unchecked_isa_dma
)
292 ? &scsi_result0
[0] : kmalloc(512, GFP_DMA
));
295 if (scsi_result
== NULL
) {
296 printk("Unable to obtain scsi_result buffer\n");
300 * We must chain ourself in the host_queue, so commands can time out
302 SDpnt
->queue_depth
= 1;
304 SDpnt
->online
= TRUE
;
306 initialize_merge_fn(SDpnt
);
309 * Initialize the object that we will use to wait for command blocks.
311 init_waitqueue_head(&SDpnt
->scpnt_wait
);
314 * Next, hook the device to the host in question.
318 if (shpnt
->host_queue
!= NULL
) {
319 SDtail
= shpnt
->host_queue
;
320 while (SDtail
->next
!= NULL
)
321 SDtail
= SDtail
->next
;
323 SDtail
->next
= SDpnt
;
324 SDpnt
->prev
= SDtail
;
326 shpnt
->host_queue
= SDpnt
;
330 * We need to increment the counter for this one device so we can track when
333 if (hardcoded
== 1) {
334 Scsi_Device
*oldSDpnt
= SDpnt
;
335 struct Scsi_Device_Template
*sdtpnt
;
337 if (channel
> shpnt
->max_channel
)
340 if (dev
>= shpnt
->max_id
)
343 if (lun
>= shpnt
->max_lun
)
345 scan_scsis_single(channel
, dev
, lun
, &max_dev_lun
, &sparse_lun
,
346 &SDpnt
, shpnt
, scsi_result
);
347 if (SDpnt
!= oldSDpnt
) {
349 /* it could happen the blockdevice hasn't yet been inited */
350 /* queue_depth() moved from scsi_proc_info() so that
351 it is called before scsi_build_commandblocks() */
352 if (shpnt
->select_queue_depths
!= NULL
)
353 (shpnt
->select_queue_depths
)(shpnt
,
356 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
)
357 if (sdtpnt
->init
&& sdtpnt
->dev_noticed
)
360 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
361 if (sdtpnt
->attach
) {
362 (*sdtpnt
->attach
) (oldSDpnt
);
363 if (oldSDpnt
->attached
) {
364 scsi_build_commandblocks(oldSDpnt
);
365 if (0 == oldSDpnt
->has_cmdblocks
) {
366 printk("scan_scsis: DANGER, no command blocks\n");
367 /* What to do now ?? */
372 scsi_resize_dma_pool();
374 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
375 if (sdtpnt
->finish
&& sdtpnt
->nr_dev
) {
376 (*sdtpnt
->finish
) ();
381 /* Actual LUN. PC ordering is 0->n IBM/spec ordering is n->0 */
384 for (channel
= 0; channel
<= shpnt
->max_channel
; channel
++) {
385 for (dev
= 0; dev
< shpnt
->max_id
; ++dev
) {
386 if (shpnt
->reverse_ordering
)
387 /* Shift to scanning 15,14,13... or 7,6,5,4, */
388 order_dev
= shpnt
->max_id
- dev
- 1;
392 if (shpnt
->this_id
!= order_dev
) {
395 * We need the for so our continue, etc. work fine. We put this in
396 * a variable so that we can override it during the scan if we
397 * detect a device *KNOWN* to have multiple logical units.
399 max_dev_lun
= (max_scsi_luns
< shpnt
->max_lun
?
400 max_scsi_luns
: shpnt
->max_lun
);
402 for (lun
= 0; lun
< max_dev_lun
; ++lun
) {
403 if (!scan_scsis_single(channel
, order_dev
, lun
, &max_dev_lun
,
404 &sparse_lun
, &SDpnt
, shpnt
,
407 break; /* break means don't probe further for luns!=0 */
409 } /* if this_id != id ends */
411 } /* for channel ends */
412 } /* if/else hardcoded */
416 { /* Unchain SRpnt from host_queue */
417 Scsi_Device
*prev
, *next
;
420 for (dqptr
= shpnt
->host_queue
; dqptr
!= SDpnt
; dqptr
= dqptr
->next
)
428 shpnt
->host_queue
= next
;
434 /* Last device block does not exist. Free memory. */
436 blk_cleanup_queue(&SDpnt
->request_queue
);
437 kfree((char *) SDpnt
);
440 /* If we allocated a buffer so we could do DMA, free it now */
441 if (scsi_result
!= &scsi_result0
[0] && scsi_result
!= NULL
) {
447 SCSI_LOG_SCAN_BUS(4, printk("Host status for host %p:\n", shpnt
));
448 for (sdev
= shpnt
->host_queue
; sdev
; sdev
= sdev
->next
) {
449 SCSI_LOG_SCAN_BUS(4, printk("Device %d %p: ", sdev
->id
, sdev
));
450 for (scmd
= sdev
->device_queue
; scmd
; scmd
= scmd
->next
) {
451 SCSI_LOG_SCAN_BUS(4, printk("%p ", scmd
));
453 SCSI_LOG_SCAN_BUS(4, printk("\n"));
459 * The worker for scan_scsis.
460 * Returning 0 means Please don't ask further for lun!=0, 1 means OK go on.
461 * Global variables used : scsi_devices(linked list)
463 static int scan_scsis_single(int channel
, int dev
, int lun
, int *max_dev_lun
,
464 int *sparse_lun
, Scsi_Device
** SDpnt2
,
465 struct Scsi_Host
*shpnt
, char *scsi_result
)
468 unsigned char scsi_cmd
[MAX_COMMAND_SIZE
];
469 struct Scsi_Device_Template
*sdtpnt
;
470 Scsi_Device
*SDtail
, *SDpnt
= *SDpnt2
;
471 Scsi_Request
* SRpnt
;
472 int bflags
, type
= -1;
473 extern devfs_handle_t scsi_devfs_handle
;
478 SDpnt
->channel
= channel
;
479 SDpnt
->online
= TRUE
;
481 scsi_build_commandblocks(SDpnt
);
483 /* Some low level driver could use device->type (DB) */
487 * Assume that the device will have handshaking problems, and then fix this
488 * field later if it turns out it doesn't
491 SDpnt
->was_reset
= 0;
492 SDpnt
->expecting_cc_ua
= 0;
495 SRpnt
= scsi_allocate_request(SDpnt
);
498 * We used to do a TEST_UNIT_READY before the INQUIRY but that was
499 * not really necessary. Spec recommends using INQUIRY to scan for
500 * devices (and TEST_UNIT_READY to poll for media change). - Paul G.
503 SCSI_LOG_SCAN_BUS(3, printk("scsi: performing INQUIRY\n"));
505 * Build an INQUIRY command block.
507 scsi_cmd
[0] = INQUIRY
;
508 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
513 SRpnt
->sr_cmd_len
= 0;
514 SRpnt
->sr_data_direction
= SCSI_DATA_READ
;
516 scsi_wait_req (SRpnt
, (void *) scsi_cmd
,
517 (void *) scsi_result
,
518 256, SCSI_TIMEOUT
+4*HZ
, 3);
520 SCSI_LOG_SCAN_BUS(3, printk("scsi: INQUIRY %s with code 0x%x\n",
521 SRpnt
->sr_result
? "failed" : "successful", SRpnt
->sr_result
));
523 if (SRpnt
->sr_result
) {
524 scsi_release_request(SRpnt
);
525 return 0; /* assume no peripheral if any sort of error */
529 * Check the peripheral qualifier field - this tells us whether LUNS
530 * are supported here or not.
532 if ((scsi_result
[0] >> 5) == 3) {
533 scsi_release_request(SRpnt
);
534 return 0; /* assume no peripheral if any sort of error */
538 * Get any flags for this device.
540 bflags
= get_device_flags (scsi_result
);
543 /* The Toshiba ROM was "gender-changed" here as an inline hack.
544 This is now much more generic.
545 This is a mess: What we really want is to leave the scsi_result
546 alone, and just change the SDpnt structure. And the SDpnt is what
547 we want print_inquiry to print. -- REW
549 if (bflags
& BLIST_ISDISK
) {
550 scsi_result
[0] = TYPE_DISK
;
551 scsi_result
[1] |= 0x80; /* removable */
554 if (bflags
& BLIST_ISROM
) {
555 scsi_result
[0] = TYPE_ROM
;
556 scsi_result
[1] |= 0x80; /* removable */
559 memcpy(SDpnt
->vendor
, scsi_result
+ 8, 8);
560 memcpy(SDpnt
->model
, scsi_result
+ 16, 16);
561 memcpy(SDpnt
->rev
, scsi_result
+ 32, 4);
563 SDpnt
->removable
= (0x80 & scsi_result
[1]) >> 7;
564 /* Use the peripheral qualifier field to determine online/offline */
565 if (((scsi_result
[0] >> 5) & 7) == 1) SDpnt
->online
= FALSE
;
566 else SDpnt
->online
= TRUE
;
567 SDpnt
->lockable
= SDpnt
->removable
;
569 SDpnt
->access_count
= 0;
571 SDpnt
->has_cmdblocks
= 0;
573 * Currently, all sequential devices are assumed to be tapes, all random
574 * devices disk, with the appropriate read only flags set for ROM / WORM
577 switch (type
= (scsi_result
[0] & 0x1f)) {
583 case TYPE_MEDIUM_CHANGER
:
586 SDpnt
->writeable
= 1;
590 SDpnt
->writeable
= 0;
593 printk("scsi: unknown type %d\n", type
);
596 SDpnt
->device_blocked
= FALSE
;
597 SDpnt
->device_busy
= 0;
598 SDpnt
->single_lun
= 0;
600 (scsi_result
[7] & 1) && ((scsi_result
[3] & 7) == 2);
601 SDpnt
->random
= (type
== TYPE_TAPE
) ? 0 : 1;
602 SDpnt
->type
= (type
& 0x1f);
604 print_inquiry(scsi_result
);
606 sprintf (devname
, "host%d/bus%d/target%d/lun%d",
607 SDpnt
->host
->host_no
, SDpnt
->channel
, SDpnt
->id
, SDpnt
->lun
);
608 if (SDpnt
->de
) printk ("DEBUG: dir: \"%s\" already exists\n", devname
);
609 else SDpnt
->de
= devfs_mk_dir (scsi_devfs_handle
, devname
, NULL
);
611 for (sdtpnt
= scsi_devicelist
; sdtpnt
;
612 sdtpnt
= sdtpnt
->next
)
615 (*sdtpnt
->detect
) (SDpnt
);
617 SDpnt
->scsi_level
= scsi_result
[2] & 0x07;
618 if (SDpnt
->scsi_level
>= 2 ||
619 (SDpnt
->scsi_level
== 1 &&
620 (scsi_result
[3] & 0x0f) == 1))
624 * Accommodate drivers that want to sleep when they should be in a polling
627 SDpnt
->disconnect
= 0;
631 * Set the tagged_queue flag for SCSI-II devices that purport to support
632 * tagged queuing in the INQUIRY data.
634 SDpnt
->tagged_queue
= 0;
635 if ((SDpnt
->scsi_level
>= SCSI_2
) &&
636 (scsi_result
[7] & 2) &&
637 !(bflags
& BLIST_NOTQ
)) {
638 SDpnt
->tagged_supported
= 1;
639 SDpnt
->current_tag
= 0;
642 * Some revisions of the Texel CD ROM drives have handshaking problems when
643 * used with the Seagate controllers. Before we know what type of device
644 * we're talking to, we assume it's borken and then change it here if it
645 * turns out that it isn't a TEXEL drive.
647 if ((bflags
& BLIST_BORKEN
) == 0)
651 * If we want to only allow I/O to one of the luns attached to this device
652 * at a time, then we set this flag.
654 if (bflags
& BLIST_SINGLELUN
)
655 SDpnt
->single_lun
= 1;
658 * These devices need this "key" to unlock the devices so we can use it
660 if ((bflags
& BLIST_KEY
) != 0) {
661 printk("Unlocked floptical drive.\n");
663 scsi_cmd
[0] = MODE_SENSE
;
664 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
669 SRpnt
->sr_cmd_len
= 0;
670 SRpnt
->sr_data_direction
= SCSI_DATA_READ
;
671 scsi_wait_req (SRpnt
, (void *) scsi_cmd
,
672 (void *) scsi_result
, 0x2a,
676 scsi_release_request(SRpnt
);
679 scsi_release_commandblocks(SDpnt
);
682 * This device was already hooked up to the host in question,
683 * so at this point we just let go of it and it should be fine. We do need to
684 * allocate a new one and attach it to the host so that we can further scan the bus.
686 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
), GFP_ATOMIC
);
688 printk("scsi: scan_scsis_single: Cannot malloc\n");
691 memset(SDpnt
, 0, sizeof(Scsi_Device
));
694 SDpnt
->queue_depth
= 1;
696 SDpnt
->online
= TRUE
;
699 * Register the queue for the device. All I/O requests will come
700 * in through here. We also need to register a pointer to
701 * ourselves, since the queue handler won't know what device
702 * the queue actually represents. We could look it up, but it
705 scsi_initialize_queue(SDpnt
, shpnt
);
707 initialize_merge_fn(SDpnt
);
710 * Mark this device as online, or otherwise we won't be able to do much with it.
712 SDpnt
->online
= TRUE
;
715 * Initialize the object that we will use to wait for command blocks.
717 init_waitqueue_head(&SDpnt
->scpnt_wait
);
720 * Since we just found one device, there had damn well better be one in the list
723 if (shpnt
->host_queue
== NULL
)
724 panic("scan_scsis_single: Host queue == NULL\n");
726 SDtail
= shpnt
->host_queue
;
727 while (SDtail
->next
) {
728 SDtail
= SDtail
->next
;
731 /* Add this device to the linked list at the end */
732 SDtail
->next
= SDpnt
;
733 SDpnt
->prev
= SDtail
;
737 * Some scsi devices cannot be polled for lun != 0 due to firmware bugs
739 if (bflags
& BLIST_NOLUN
)
740 return 0; /* break; */
743 * If this device is known to support sparse multiple units, override the
744 * other settings, and scan all of them.
746 if (bflags
& BLIST_SPARSELUN
) {
752 * If this device is known to support multiple units, override the other
753 * settings, and scan all of them.
755 if (bflags
& BLIST_FORCELUN
) {
760 * REGAL CDC-4X: avoid hang after LUN 4
762 if (bflags
& BLIST_MAX5LUN
) {
768 * We assume the device can't handle lun!=0 if: - it reports scsi-0
769 * (ANSI SCSI Revision 0) (old drives like MAXTOR XT-3280) or - it
770 * reports scsi-1 (ANSI SCSI Revision 1) and Response Data Format 0
772 if (((scsi_result
[2] & 0x07) == 0)
774 ((scsi_result
[2] & 0x07) == 1 &&
775 (scsi_result
[3] & 0x0f) == 0))