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
41 #define BLIST_GHOST 0x400
43 static void print_inquiry(unsigned char *data
);
44 static int scan_scsis_single(int channel
, int dev
, int lun
, int *max_scsi_dev
,
45 int *sparse_lun
, Scsi_Device
** SDpnt
,
46 struct Scsi_Host
*shpnt
, char *scsi_result
);
51 const char *revision
; /* Latest revision known to be bad. Not used yet */
56 * This is what was previously known as the blacklist. The concept
57 * has been expanded so that we can specify other types of things we
58 * need to be aware of.
60 static struct dev_info device_list
[] =
62 {"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
63 {"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
64 {"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
65 {"DENON", "DRD-25X", "V", BLIST_NOLUN
}, /* Locks up if probed for lun != 0 */
66 {"HITACHI", "DK312C", "CM81", BLIST_NOLUN
}, /* Responds to all lun - dtg */
67 {"HITACHI", "DK314C", "CR21", BLIST_NOLUN
}, /* responds to all lun */
68 {"IMS", "CDD521/10", "2.06", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
69 {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
70 {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
71 {"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN
}, /* Locks up when LUN>0 polled */
72 {"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN
}, /* Locks-up sometimes when LUN>0 polled. */
73 {"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN
}, /* guess what? */
74 {"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN
}, /*Responds to all lun */
75 {"MICROP", "4110", "*", BLIST_NOTQ
}, /* Buggy Tagged Queuing */
76 {"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN
}, /* Locks-up when LUN>0 polled. */
77 {"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN
}, /* Responds to all lun */
78 {"RODIME", "RO3000S", "2.33", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
79 {"SANYO", "CRD-250S", "1.20", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
80 * for aha152x controller, which causes
81 * SCSI code to reset bus.*/
82 {"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
83 * for aha152x controller, which causes
84 * SCSI code to reset bus.*/
85 {"SEAGATE", "ST296", "921", BLIST_NOLUN
}, /* Responds to all lun */
86 {"SEAGATE", "ST1581", "6538", BLIST_NOLUN
}, /* Responds to all lun */
87 {"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN
},
88 {"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN
},
89 {"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN
},
90 {"SONY", "CD-ROM CDU-8012", "*", BLIST_NOLUN
},
91 {"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
92 {"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
93 {"TEAC", "CD-ROM", "1.06", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
94 * for seagate controller, which causes
95 * SCSI code to reset bus.*/
96 {"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN
}, /* Responds to all lun */
97 {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN
}, /* causes failed REQUEST SENSE on lun 1
98 * for seagate controller, which causes
99 * SCSI code to reset bus.*/
100 {"QUANTUM", "LPS525S", "3110", BLIST_NOLUN
}, /* Locks sometimes if polled for lun != 0 */
101 {"QUANTUM", "PD1225S", "3110", BLIST_NOLUN
}, /* Locks sometimes if polled for lun != 0 */
102 {"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN
}, /* Locks up when polled for lun != 0 */
103 {"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
104 {"SANKYO", "CP525", "6.64", BLIST_NOLUN
}, /* causes failed REQ SENSE, extra reset */
105 {"HP", "C1750A", "3226", BLIST_NOLUN
}, /* scanjet iic */
106 {"HP", "C1790A", "", BLIST_NOLUN
}, /* scanjet iip */
107 {"HP", "C2500A", "", BLIST_NOLUN
}, /* scanjet iicx */
108 {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN
}, /* Locks up if polled for lun != 0 */
109 {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN
}, /* Locks up if polled for lun != 0
111 {"RELISYS", "Scorpio", "*", BLIST_NOLUN
}, /* responds to all LUN */
112 {"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN
}, /* responds to all LUN */
115 * Other types of devices that have special flags.
117 {"SONY", "CD-ROM CDU-8001", "*", BLIST_BORKEN
},
118 {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN
},
119 {"IOMEGA", "Io20S *F", "*", BLIST_KEY
},
120 {"INSITE", "Floptical F*8I", "*", BLIST_KEY
},
121 {"INSITE", "I325VM", "*", BLIST_KEY
},
122 {"LASOUND","CDX7405","3.10", BLIST_MAX5LUN
| BLIST_SINGLELUN
},
123 {"NRC", "MBR-7", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
124 {"NRC", "MBR-7.4", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
125 {"REGAL", "CDC-4X", "*", BLIST_MAX5LUN
| BLIST_SINGLELUN
},
126 {"NAKAMICH", "MJ-4.8S", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
127 {"NAKAMICH", "MJ-5.16S", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
128 {"PIONEER", "CD-ROM DRM-600", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
129 {"PIONEER", "CD-ROM DRM-602X", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
130 {"PIONEER", "CD-ROM DRM-604X", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
131 {"EMULEX", "MD21/S2 ESDI", "*", BLIST_SINGLELUN
},
132 {"CANON", "IPUBJD", "*", BLIST_SPARSELUN
},
133 {"nCipher", "Fastness Crypto", "*", BLIST_FORCELUN
},
134 {"NEC", "PD-1 ODX654P", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
135 {"MATSHITA", "PD-1", "*", BLIST_FORCELUN
| BLIST_SINGLELUN
},
136 {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ
| BLIST_NOLUN
},
137 {"CREATIVE","DVD-RAM RAM","*", BLIST_GHOST
},
138 {"MATSHITA","PD-2 LF-D100","*", BLIST_GHOST
},
139 {"HITACHI", "GF-1050","*", BLIST_GHOST
}, /* Hitachi SCSI DVD-RAM */
140 {"TOSHIBA","CDROM","*", BLIST_ISROM
},
141 {"TOSHIBA","DVD-RAM SD-W1101","*", BLIST_GHOST
},
142 {"TOSHIBA","DVD-RAM SD-W1111","*", BLIST_GHOST
},
145 * Must be at end of list...
150 #ifdef CONFIG_SCSI_MULTI_LUN
151 static int max_scsi_luns
= 8;
153 static int max_scsi_luns
= 1;
158 MODULE_PARM(max_scsi_luns
, "i");
159 MODULE_PARM_DESC(max_scsi_luns
, "last scsi LUN (should be between 1 and 8)");
163 static int __init
scsi_luns_setup(char *str
)
167 if (get_option(&str
, &tmp
) == 1) {
171 printk("scsi_luns_setup : usage max_scsi_luns=n "
172 "(n should be between 1 and 8)\n");
177 __setup("max_scsi_luns=", scsi_luns_setup
);
181 static void print_inquiry(unsigned char *data
)
186 for (i
= 8; i
< 16; i
++) {
187 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
188 printk("%c", data
[i
]);
194 for (i
= 16; i
< 32; i
++) {
195 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
196 printk("%c", data
[i
]);
202 for (i
= 32; i
< 36; i
++) {
203 if (data
[i
] >= 0x20 && i
< data
[4] + 5)
204 printk("%c", data
[i
]);
214 i
< MAX_SCSI_DEVICE_CODE
? scsi_device_types
[i
] : "Unknown ");
215 printk(" ANSI SCSI revision: %02x", data
[2] & 0x07);
216 if ((data
[2] & 0x07) == 1 && (data
[3] & 0x0f) == 1)
222 static int get_device_flags(unsigned char *response_data
)
226 for (i
= 0; 1; i
++) {
227 if (device_list
[i
].vendor
== NULL
)
229 pnt
= &response_data
[8];
230 while (*pnt
&& *pnt
== ' ')
232 if (memcmp(device_list
[i
].vendor
, pnt
,
233 strlen(device_list
[i
].vendor
)))
235 pnt
= &response_data
[16];
236 while (*pnt
&& *pnt
== ' ')
238 if (memcmp(device_list
[i
].model
, pnt
,
239 strlen(device_list
[i
].model
)))
241 return device_list
[i
].flags
;
247 * Detecting SCSI devices :
248 * We scan all present host adapter's busses, from ID 0 to ID (max_id).
249 * We use the INQUIRY command, determine device type, and pass the ID /
250 * lun address of all sequential devices to the tape driver, all random
251 * devices to the disk driver.
253 void scan_scsis(struct Scsi_Host
*shpnt
,
263 unsigned char *scsi_result
;
264 unsigned char scsi_result0
[256];
271 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
),
274 memset(SDpnt
, 0, sizeof(Scsi_Device
));
276 * Register the queue for the device. All I/O requests will come
277 * in through here. We also need to register a pointer to
278 * ourselves, since the queue handler won't know what device
279 * the queue actually represents. We could look it up, but it
282 scsi_initialize_queue(SDpnt
, shpnt
);
283 blk_queue_headactive(&SDpnt
->request_queue
, 0);
284 SDpnt
->request_queue
.queuedata
= (void *) SDpnt
;
285 /* Make sure we have something that is valid for DMA purposes */
286 scsi_result
= ((!shpnt
->unchecked_isa_dma
)
287 ? &scsi_result0
[0] : kmalloc(512, GFP_DMA
));
290 if (scsi_result
== NULL
) {
291 printk("Unable to obtain scsi_result buffer\n");
295 * We must chain ourself in the host_queue, so commands can time out
297 SDpnt
->queue_depth
= 1;
299 SDpnt
->online
= TRUE
;
301 scsi_build_commandblocks(SDpnt
);
303 initialize_merge_fn(SDpnt
);
306 * Initialize the object that we will use to wait for command blocks.
308 init_waitqueue_head(&SDpnt
->scpnt_wait
);
311 * Next, hook the device to the host in question.
315 if (shpnt
->host_queue
!= NULL
) {
316 SDtail
= shpnt
->host_queue
;
317 while (SDtail
->next
!= NULL
)
318 SDtail
= SDtail
->next
;
320 SDtail
->next
= SDpnt
;
321 SDpnt
->prev
= SDtail
;
323 shpnt
->host_queue
= SDpnt
;
327 * We need to increment the counter for this one device so we can track when
330 if (hardcoded
== 1) {
331 Scsi_Device
*oldSDpnt
= SDpnt
;
332 struct Scsi_Device_Template
*sdtpnt
;
334 if (channel
> shpnt
->max_channel
)
337 if (dev
>= shpnt
->max_id
)
340 if (lun
>= shpnt
->max_lun
)
342 scan_scsis_single(channel
, dev
, lun
, &max_dev_lun
, &sparse_lun
,
343 &SDpnt
, shpnt
, scsi_result
);
344 if (SDpnt
!= oldSDpnt
) {
346 /* it could happen the blockdevice hasn't yet been inited */
347 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
)
348 if (sdtpnt
->init
&& sdtpnt
->dev_noticed
)
351 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
352 if (sdtpnt
->attach
) {
353 (*sdtpnt
->attach
) (oldSDpnt
);
354 if (oldSDpnt
->attached
) {
355 scsi_build_commandblocks(oldSDpnt
);
356 if (0 == oldSDpnt
->has_cmdblocks
) {
357 printk("scan_scsis: DANGER, no command blocks\n");
358 /* What to do now ?? */
363 scsi_resize_dma_pool();
365 for (sdtpnt
= scsi_devicelist
; sdtpnt
; sdtpnt
= sdtpnt
->next
) {
366 if (sdtpnt
->finish
&& sdtpnt
->nr_dev
) {
367 (*sdtpnt
->finish
) ();
372 /* Actual LUN. PC ordering is 0->n IBM/spec ordering is n->0 */
375 for (channel
= 0; channel
<= shpnt
->max_channel
; channel
++) {
376 for (dev
= 0; dev
< shpnt
->max_id
; ++dev
) {
377 if (shpnt
->reverse_ordering
)
378 /* Shift to scanning 15,14,13... or 7,6,5,4, */
379 order_dev
= shpnt
->max_id
- dev
- 1;
383 if (shpnt
->this_id
!= order_dev
) {
386 * We need the for so our continue, etc. work fine. We put this in
387 * a variable so that we can override it during the scan if we
388 * detect a device *KNOWN* to have multiple logical units.
390 max_dev_lun
= (max_scsi_luns
< shpnt
->max_lun
?
391 max_scsi_luns
: shpnt
->max_lun
);
393 for (lun
= 0; lun
< max_dev_lun
; ++lun
) {
394 if (!scan_scsis_single(channel
, order_dev
, lun
, &max_dev_lun
,
395 &sparse_lun
, &SDpnt
, shpnt
,
398 break; /* break means don't probe further for luns!=0 */
400 } /* if this_id != id ends */
402 } /* for channel ends */
403 } /* if/else hardcoded */
407 { /* Unchain SCpnt from host_queue */
408 Scsi_Device
*prev
, *next
;
411 for (dqptr
= shpnt
->host_queue
; dqptr
!= SDpnt
; dqptr
= dqptr
->next
)
419 shpnt
->host_queue
= next
;
425 scsi_release_commandblocks(SDpnt
);
427 /* Last device block does not exist. Free memory. */
429 kfree((char *) SDpnt
);
431 /* If we allocated a buffer so we could do DMA, free it now */
432 if (scsi_result
!= &scsi_result0
[0] && scsi_result
!= NULL
) {
438 SCSI_LOG_SCAN_BUS(4, printk("Host status for host %p:\n", shpnt
));
439 for (sdev
= shpnt
->host_queue
; sdev
; sdev
= sdev
->next
) {
440 SCSI_LOG_SCAN_BUS(4, printk("Device %d %p: ", sdev
->id
, sdev
));
441 for (scmd
= sdev
->device_queue
; scmd
; scmd
= scmd
->next
) {
442 SCSI_LOG_SCAN_BUS(4, printk("%p ", scmd
));
444 SCSI_LOG_SCAN_BUS(4, printk("\n"));
450 * The worker for scan_scsis.
451 * Returning 0 means Please don't ask further for lun!=0, 1 means OK go on.
452 * Global variables used : scsi_devices(linked list)
454 static int scan_scsis_single(int channel
, int dev
, int lun
, int *max_dev_lun
,
455 int *sparse_lun
, Scsi_Device
** SDpnt2
,
456 struct Scsi_Host
*shpnt
, char *scsi_result
)
459 unsigned char scsi_cmd
[MAX_COMMAND_SIZE
];
460 struct Scsi_Device_Template
*sdtpnt
;
461 Scsi_Device
*SDtail
, *SDpnt
= *SDpnt2
;
463 int bflags
, type
= -1;
464 static int ghost_channel
=-1, ghost_dev
=-1;
466 extern devfs_handle_t scsi_devfs_handle
;
471 SDpnt
->channel
= channel
;
472 SDpnt
->online
= TRUE
;
475 if ((channel
== ghost_channel
) && (dev
== ghost_dev
) && (lun
== 1)) {
478 ghost_channel
= ghost_dev
= -1;
482 /* Some low level driver could use device->type (DB) */
486 * Assume that the device will have handshaking problems, and then fix this
487 * field later if it turns out it doesn't
490 SDpnt
->was_reset
= 0;
491 SDpnt
->expecting_cc_ua
= 0;
494 scsi_cmd
[0] = TEST_UNIT_READY
;
495 scsi_cmd
[1] = lun
<< 5;
496 scsi_cmd
[2] = scsi_cmd
[3] = scsi_cmd
[4] = scsi_cmd
[5] = 0;
498 SCpnt
= scsi_allocate_device(SDpnt
, 0, 0);
500 SCpnt
->host
= SDpnt
->host
;
501 SCpnt
->device
= SDpnt
;
502 SCpnt
->target
= SDpnt
->id
;
503 SCpnt
->lun
= SDpnt
->lun
;
504 SCpnt
->channel
= SDpnt
->channel
;
505 SCpnt
->sc_data_direction
= SCSI_DATA_NONE
;
507 scsi_wait_cmd (SCpnt
, (void *) scsi_cmd
,
509 0, SCSI_TIMEOUT
+ 4 * HZ
, 5);
511 SCSI_LOG_SCAN_BUS(3, printk("scsi: scan_scsis_single id %d lun %d. Return code 0x%08x\n",
512 dev
, lun
, SCpnt
->result
));
513 SCSI_LOG_SCAN_BUS(3, print_driverbyte(SCpnt
->result
));
514 SCSI_LOG_SCAN_BUS(3, print_hostbyte(SCpnt
->result
));
515 SCSI_LOG_SCAN_BUS(3, printk("\n"));
518 if (((driver_byte(SCpnt
->result
) & DRIVER_SENSE
) ||
519 (status_byte(SCpnt
->result
) & CHECK_CONDITION
)) &&
520 ((SCpnt
->sense_buffer
[0] & 0x70) >> 4) == 7) {
521 if (((SCpnt
->sense_buffer
[2] & 0xf) != NOT_READY
) &&
522 ((SCpnt
->sense_buffer
[2] & 0xf) != UNIT_ATTENTION
) &&
523 ((SCpnt
->sense_buffer
[2] & 0xf) != ILLEGAL_REQUEST
|| lun
> 0)) {
524 scsi_release_command(SCpnt
);
528 scsi_release_command(SCpnt
);
532 SCSI_LOG_SCAN_BUS(3, printk("scsi: performing INQUIRY\n"));
534 * Build an INQUIRY command block.
536 scsi_cmd
[0] = INQUIRY
;
537 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
543 SCpnt
->sc_data_direction
= SCSI_DATA_READ
;
545 scsi_wait_cmd (SCpnt
, (void *) scsi_cmd
,
546 (void *) scsi_result
,
547 256, SCSI_TIMEOUT
, 3);
549 SCSI_LOG_SCAN_BUS(3, printk("scsi: INQUIRY %s with code 0x%x\n",
550 SCpnt
->result
? "failed" : "successful", SCpnt
->result
));
553 scsi_release_command(SCpnt
);
554 return 0; /* assume no peripheral if any sort of error */
558 * Check the peripheral qualifier field - this tells us whether LUNS
559 * are supported here or not.
561 if ((scsi_result
[0] >> 5) == 3) {
562 scsi_release_command(SCpnt
);
563 return 0; /* assume no peripheral if any sort of error */
567 * Get any flags for this device.
569 bflags
= get_device_flags (scsi_result
);
572 /* The Toshiba ROM was "gender-changed" here as an inline hack.
573 This is now much more generic.
574 This is a mess: What we really want is to leave the scsi_result
575 alone, and just change the SDpnt structure. And the SDpnt is what
576 we want print_inquiry to print. -- REW
578 if (bflags
& BLIST_ISDISK
) {
579 scsi_result
[0] = TYPE_DISK
;
580 scsi_result
[1] |= 0x80; /* removable */
583 if (bflags
& BLIST_ISROM
) {
584 scsi_result
[0] = TYPE_ROM
;
585 scsi_result
[1] |= 0x80; /* removable */
588 if (bflags
& BLIST_GHOST
) {
589 if ((ghost_channel
== channel
) && (ghost_dev
== dev
) && (org_lun
== 1)) {
592 ghost_channel
= channel
;
594 scsi_result
[0] = TYPE_MOD
;
595 scsi_result
[1] |= 0x80; /* removable */
600 memcpy(SDpnt
->vendor
, scsi_result
+ 8, 8);
601 memcpy(SDpnt
->model
, scsi_result
+ 16, 16);
602 memcpy(SDpnt
->rev
, scsi_result
+ 32, 4);
604 SDpnt
->removable
= (0x80 & scsi_result
[1]) >> 7;
605 SDpnt
->online
= TRUE
;
606 SDpnt
->lockable
= SDpnt
->removable
;
608 SDpnt
->access_count
= 0;
610 SDpnt
->has_cmdblocks
= 0;
612 * Currently, all sequential devices are assumed to be tapes, all random
613 * devices disk, with the appropriate read only flags set for ROM / WORM
616 switch (type
= (scsi_result
[0] & 0x1f)) {
622 case TYPE_MEDIUM_CHANGER
:
624 SDpnt
->writeable
= 1;
628 SDpnt
->writeable
= 0;
631 printk("scsi: unknown type %d\n", type
);
634 SDpnt
->device_blocked
= FALSE
;
635 SDpnt
->device_busy
= 0;
636 SDpnt
->single_lun
= 0;
638 (scsi_result
[7] & 1) && ((scsi_result
[3] & 7) == 2);
639 SDpnt
->random
= (type
== TYPE_TAPE
) ? 0 : 1;
640 SDpnt
->type
= (type
& 0x1f);
642 print_inquiry(scsi_result
);
644 sprintf (devname
, "host%d/bus%d/target%d/lun%d",
645 SDpnt
->host
->host_no
, SDpnt
->channel
, SDpnt
->id
, SDpnt
->lun
);
646 if (SDpnt
->de
) printk ("DEBUG: dir: \"%s\" already exists\n", devname
);
647 else SDpnt
->de
= devfs_mk_dir (scsi_devfs_handle
, devname
, 0, NULL
);
649 for (sdtpnt
= scsi_devicelist
; sdtpnt
;
650 sdtpnt
= sdtpnt
->next
)
653 (*sdtpnt
->detect
) (SDpnt
);
655 SDpnt
->scsi_level
= scsi_result
[2] & 0x07;
656 if (SDpnt
->scsi_level
>= 2 ||
657 (SDpnt
->scsi_level
== 1 &&
658 (scsi_result
[3] & 0x0f) == 1))
662 * Accommodate drivers that want to sleep when they should be in a polling
665 SDpnt
->disconnect
= 0;
669 * Set the tagged_queue flag for SCSI-II devices that purport to support
670 * tagged queuing in the INQUIRY data.
672 SDpnt
->tagged_queue
= 0;
673 if ((SDpnt
->scsi_level
>= SCSI_2
) &&
674 (scsi_result
[7] & 2) &&
675 !(bflags
& BLIST_NOTQ
)) {
676 SDpnt
->tagged_supported
= 1;
677 SDpnt
->current_tag
= 0;
680 * Some revisions of the Texel CD ROM drives have handshaking problems when
681 * used with the Seagate controllers. Before we know what type of device
682 * we're talking to, we assume it's borken and then change it here if it
683 * turns out that it isn't a TEXEL drive.
685 if ((bflags
& BLIST_BORKEN
) == 0)
689 * If we want to only allow I/O to one of the luns attached to this device
690 * at a time, then we set this flag.
692 if (bflags
& BLIST_SINGLELUN
)
693 SDpnt
->single_lun
= 1;
696 * These devices need this "key" to unlock the devices so we can use it
698 if ((bflags
& BLIST_KEY
) != 0) {
699 printk("Unlocked floptical drive.\n");
701 scsi_cmd
[0] = MODE_SENSE
;
702 scsi_cmd
[1] = (lun
<< 5) & 0xe0;
708 SCpnt
->sc_data_direction
= SCSI_DATA_NONE
;
709 scsi_wait_cmd (SCpnt
, (void *) scsi_cmd
,
710 (void *) scsi_result
, 0x2a,
714 scsi_release_command(SCpnt
);
717 scsi_release_commandblocks(SDpnt
);
720 * This device was already hooked up to the host in question,
721 * so at this point we just let go of it and it should be fine. We do need to
722 * allocate a new one and attach it to the host so that we can further scan the bus.
724 SDpnt
= (Scsi_Device
*) kmalloc(sizeof(Scsi_Device
), GFP_ATOMIC
);
726 printk("scsi: scan_scsis_single: Cannot malloc\n");
729 memset(SDpnt
, 0, sizeof(Scsi_Device
));
732 SDpnt
->queue_depth
= 1;
734 SDpnt
->online
= TRUE
;
736 scsi_build_commandblocks(SDpnt
);
739 * Register the queue for the device. All I/O requests will come
740 * in through here. We also need to register a pointer to
741 * ourselves, since the queue handler won't know what device
742 * the queue actually represents. We could look it up, but it
745 scsi_initialize_queue(SDpnt
, shpnt
);
746 blk_queue_headactive(&SDpnt
->request_queue
, 0);
747 SDpnt
->request_queue
.queuedata
= (void *) SDpnt
;
749 initialize_merge_fn(SDpnt
);
752 * Mark this device as online, or otherwise we won't be able to do much with it.
754 SDpnt
->online
= TRUE
;
757 * Initialize the object that we will use to wait for command blocks.
759 init_waitqueue_head(&SDpnt
->scpnt_wait
);
762 * Since we just found one device, there had damn well better be one in the list
765 if (shpnt
->host_queue
== NULL
)
766 panic("scan_scsis_single: Host queue == NULL\n");
768 SDtail
= shpnt
->host_queue
;
769 while (SDtail
->next
) {
770 SDtail
= SDtail
->next
;
773 /* Add this device to the linked list at the end */
774 SDtail
->next
= SDpnt
;
775 SDpnt
->prev
= SDtail
;
779 * Some scsi devices cannot be polled for lun != 0 due to firmware bugs
781 if (bflags
& BLIST_NOLUN
)
782 return 0; /* break; */
785 * If this device is known to support sparse multiple units, override the
786 * other settings, and scan all of them.
788 if (bflags
& BLIST_SPARSELUN
) {
794 * If this device is known to support multiple units, override the other
795 * settings, and scan all of them.
797 if (bflags
& BLIST_FORCELUN
) {
802 * REGAL CDC-4X: avoid hang after LUN 4
804 if (bflags
& BLIST_MAX5LUN
) {
810 * If this device is Ghosted, scan upto two luns. (It physically only
813 if (bflags
& BLIST_GHOST
) {
820 * We assume the device can't handle lun!=0 if: - it reports scsi-0 (ANSI
821 * SCSI Revision 0) (old drives like MAXTOR XT-3280) or - it reports scsi-1
822 * (ANSI SCSI Revision 1) and Response Data Format 0
824 if (((scsi_result
[2] & 0x07) == 0)
826 ((scsi_result
[2] & 0x07) == 1 &&
827 (scsi_result
[3] & 0x0f) == 0))