This source file includes following definitions.
- blacklisted
- restart_all
- scan_scsis_done
- scsi_luns_setup
- scan_scsis
- scsi_times_out
- request_queueable
- allocate_device
- internal_cmnd
- scsi_request_sense
- scsi_do_cmd
- reset
- check_sense
- scsi_done
- scsi_abort
- scsi_reset
- scsi_main_timeout
- update_timeout
- scsi_malloc
- scsi_free
- scsi_init_malloc
- scsi_init_free
- scsi_dev_init
- print_inquiry
- scsi_register_host
- scsi_unregister_host
- scsi_register_module
- scsi_unregister_module
- scsi_dump_status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <asm/system.h>
21 #include <linux/sched.h>
22 #include <linux/timer.h>
23 #include <linux/string.h>
24 #include <linux/malloc.h>
25 #include <asm/irq.h>
26
27 #include "../block/blk.h"
28 #include "scsi.h"
29 #include "hosts.h"
30 #include "constants.h"
31
32
33
34
35
36
37 const unsigned char scsi_command_size[8] = { 6, 10, 10, 12, 12, 12, 10, 10 };
38
39 #define INTERNAL_ERROR (panic ("Internal error in file %s, line %d.\n", __FILE__, __LINE__))
40
41 static void scsi_done (Scsi_Cmnd *SCpnt);
42 static int update_timeout (Scsi_Cmnd *, int);
43 static void print_inquiry(unsigned char *data);
44 static void scsi_times_out (Scsi_Cmnd * SCpnt, int pid);
45
46 static int time_start;
47 static int time_elapsed;
48 static int scsi_maybe_deadlocked = 0;
49 static int max_active = 0;
50 static struct Scsi_Host * host_active = NULL;
51 static struct Scsi_Host * host_next = NULL;
52
53 #define MAX_SCSI_DEVICE_CODE 10
54 const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE] =
55 {
56 "Direct-Access ",
57 "Sequential-Access",
58 "Printer ",
59 "Processor ",
60 "WORM ",
61 "CD-ROM ",
62 "Scanner ",
63 "Optical Device ",
64 "Medium Changer ",
65 "Communications "
66 };
67
68
69
70
71
72
73
74
75 Scsi_Device * scsi_devices = NULL;
76
77
78 unsigned long scsi_pid = 0;
79
80 static unsigned char generic_sense[6] = {REQUEST_SENSE, 0,0,0, 255, 0};
81
82
83 Scsi_Cmnd * last_cmnd = NULL;
84
85
86
87
88
89
90
91 #define WAS_RESET 0x01
92 #define WAS_TIMEDOUT 0x02
93 #define WAS_SENSE 0x04
94 #define IS_RESETTING 0x08
95 #define IS_ABORTING 0x10
96 #define ASKED_FOR_SENSE 0x20
97
98
99
100
101
102
103
104
105
106
107
108 #ifdef DEBUG_TIMEOUT
109 static void scsi_dump_status(void);
110 #endif
111
112
113 #ifdef DEBUG
114 #define SCSI_TIMEOUT 500
115 #else
116 #define SCSI_TIMEOUT 100
117 #endif
118
119 #ifdef DEBUG
120 #define SENSE_TIMEOUT SCSI_TIMEOUT
121 #define ABORT_TIMEOUT SCSI_TIMEOUT
122 #define RESET_TIMEOUT SCSI_TIMEOUT
123 #else
124 #define SENSE_TIMEOUT 50
125 #define RESET_TIMEOUT 50
126 #define ABORT_TIMEOUT 50
127 #define MIN_RESET_DELAY 100
128 #endif
129
130
131
132
133
134 struct blist{
135 char * vendor;
136 char * model;
137 char * revision;
138 };
139
140 static struct blist blacklist[] =
141 {
142 {"CHINON","CD-ROM CDS-431","H42"},
143 {"CHINON","CD-ROM CDS-535","Q14"},
144 {"DENON","DRD-25X","V"},
145 {"IMS", "CDD521/10","2.06"},
146 {"MAXTOR","XT-3280","PR02"},
147 {"MAXTOR","XT-4380S","B3C"},
148 {"MAXTOR","MXT-1240S","I1.2"},
149 {"MAXTOR","XT-4170S","B5A"},
150 {"MAXTOR","XT-8760S","B7B"},
151 {"NEC","CD-ROM DRIVE:841","1.0"},
152 {"RODIME","RO3000S","2.33"},
153 {"SEAGATE", "ST157N", "\004|j"},
154
155 {"SEAGATE", "ST296","921"},
156 {"SONY","CD-ROM CDU-541","4.3d"},
157 {"SONY","CD-ROM CDU-55S","1.0i"},
158 {"TANDBERG","TDC 3600","U07"},
159 {"TEAC","CD-ROM","1.06"},
160
161 {"TEXEL","CD-ROM","1.06"},
162
163 {"QUANTUM","LPS525S","3110"},
164 {"QUANTUM","PD1225S","3110"},
165 {"MEDIAVIS","CDR-H93MV","1.31"},
166 {"SANKYO", "CP525","6.64"},
167 {"HP", "C1750A", "3226"},
168 {"HP", "C1790A", ""},
169 {"HP", "C2500A", ""},
170 {NULL, NULL, NULL}};
171
172 static int blacklisted(unsigned char * response_data){
173 int i = 0;
174 unsigned char * pnt;
175 for(i=0; 1; i++){
176 if(blacklist[i].vendor == NULL) return 0;
177 pnt = &response_data[8];
178 while(*pnt && *pnt == ' ') pnt++;
179 if(memcmp(blacklist[i].vendor, pnt,
180 strlen(blacklist[i].vendor))) continue;
181 pnt = &response_data[16];
182 while(*pnt && *pnt == ' ') pnt++;
183 if(memcmp(blacklist[i].model, pnt,
184 strlen(blacklist[i].model))) continue;
185 return 1;
186 };
187 };
188
189
190
191
192
193
194
195
196
197
198 volatile int in_scan_scsis = 0;
199 static int the_result;
200
201 static void restart_all(void) {
202
203
204
205
206 struct Scsi_Device_Template * sdtpnt;
207
208 for (sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
209
210 if (sdtpnt->blk && blk_dev[sdtpnt->major].request_fn)
211 (*blk_dev[sdtpnt->major].request_fn)();
212
213 }
214
215 static void scan_scsis_done (Scsi_Cmnd * SCpnt)
216 {
217
218 #ifdef DEBUG
219 printk ("scan_scsis_done(%d, %06x)\n", SCpnt->host, SCpnt->result);
220 #endif
221 SCpnt->request.dev = 0xfffe;
222 }
223
224 #ifdef NO_MULTI_LUN
225 static int max_scsi_luns = 1;
226 #else
227 static int max_scsi_luns = 8;
228 #endif
229
230 void scsi_luns_setup(char *str, int *ints) {
231 if (ints[0] != 1)
232 printk("scsi_luns_setup : usage max_scsi_luns=n (n should be between 1 and 8)\n");
233 else
234 max_scsi_luns = ints[1];
235 }
236
237
238
239
240
241
242
243
244
245 static void scan_scsis (struct Scsi_Host * shpnt)
246 {
247 int dev, lun, type;
248 unsigned char scsi_cmd [12];
249 unsigned char scsi_result [256];
250 Scsi_Device * SDpnt, *SDtail;
251 struct Scsi_Device_Template * sdtpnt;
252 Scsi_Cmnd SCmd;
253
254 ++in_scan_scsis;
255 lun = 0;
256 type = -1;
257 SCmd.next = NULL;
258 SCmd.prev = NULL;
259 SDpnt = (Scsi_Device *) scsi_init_malloc(sizeof (Scsi_Device));
260 SDtail = scsi_devices;
261 if(scsi_devices) {
262 while(SDtail->next) SDtail = SDtail->next;
263 }
264
265 shpnt->host_queue = &SCmd;
266
267 for (dev = 0; dev < 8; ++dev)
268 if (shpnt->this_id != dev)
269
270
271
272
273 for (lun = 0; lun < max_scsi_luns; ++lun)
274 {
275 SDpnt->host = shpnt;
276 SDpnt->id = dev;
277 SDpnt->lun = lun;
278 SDpnt->device_wait = NULL;
279 SDpnt->next = NULL;
280 SDpnt->attached = 0;
281
282
283
284
285 SDpnt->borken = 1;
286
287 scsi_cmd[0] = TEST_UNIT_READY;
288 scsi_cmd[1] = lun << 5;
289 scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
290 scsi_cmd[4] = 0;
291
292 SCmd.host = shpnt;
293 SCmd.target = dev;
294 SCmd.lun = lun;
295
296 SCmd.request.sem = NULL;
297 SCmd.request.dev = 0xffff;
298 SCmd.use_sg = 0;
299 SCmd.cmd_len = 0;
300 SCmd.old_use_sg = 0;
301 SCmd.transfersize = 0;
302 SCmd.underflow = 0;
303
304 scsi_do_cmd (&SCmd,
305 (void *) scsi_cmd, (void *)
306 scsi_result, 256, scan_scsis_done,
307 SCSI_TIMEOUT + 400, 5);
308
309 while (SCmd.request.dev != 0xfffe);
310 #if defined(DEBUG) || defined(DEBUG_INIT)
311 printk("scsi: scan SCSIS id %d lun %d\n", dev, lun);
312 printk("scsi: return code %08x\n", SCmd.result);
313 #endif
314
315
316 if(SCmd.result) {
317 if ((driver_byte(SCmd.result) & DRIVER_SENSE) &&
318 ((SCmd.sense_buffer[0] & 0x70) >> 4) == 7) {
319 if (SCmd.sense_buffer[2] &0xe0)
320 continue;
321 if(((SCmd.sense_buffer[2] & 0xf) != NOT_READY) &&
322 ((SCmd.sense_buffer[2] & 0xf) != UNIT_ATTENTION))
323 continue;
324 }
325 else
326 break;
327 };
328
329 #if defined (DEBUG) || defined(DEBUG_INIT)
330 printk("scsi: performing INQUIRY\n");
331 #endif
332
333
334
335
336
337 scsi_cmd[0] = INQUIRY;
338 scsi_cmd[1] = (lun << 5) & 0xe0;
339 scsi_cmd[2] = 0;
340 scsi_cmd[3] = 0;
341 scsi_cmd[4] = 255;
342 scsi_cmd[5] = 0;
343
344 SCmd.request.dev = 0xffff;
345 SCmd.cmd_len = 0;
346
347 scsi_do_cmd (&SCmd,
348 (void *) scsi_cmd, (void *)
349 scsi_result, 256, scan_scsis_done,
350 SCSI_TIMEOUT, 3);
351
352 while (SCmd.request.dev != 0xfffe);
353
354 the_result = SCmd.result;
355
356 #if defined(DEBUG) || defined(DEBUG_INIT)
357 if (!the_result)
358 printk("scsi: INQUIRY successful\n");
359 else
360 printk("scsi: INQUIRY failed with code %08x\n", the_result);
361 #endif
362
363 if(the_result) break;
364
365
366
367 if (!the_result)
368 {
369
370 if (!strncmp(scsi_result+8,"TOSHIBA",7) &&
371 !strncmp(scsi_result+16,"CD-ROM",6) &&
372 scsi_result[0] == TYPE_DISK) {
373 scsi_result[0] = TYPE_ROM;
374 scsi_result[1] |= 0x80;
375 }
376
377 SDpnt->manufacturer = SCSI_MAN_UNKNOWN;
378 if (!strncmp(scsi_result+8,"NEC",3))
379 SDpnt->manufacturer = SCSI_MAN_NEC;
380 if (!strncmp(scsi_result+8,"TOSHIBA",7))
381 SDpnt->manufacturer = SCSI_MAN_TOSHIBA;
382
383 SDpnt->removable = (0x80 &
384 scsi_result[1]) >> 7;
385 SDpnt->lockable = SDpnt->removable;
386 SDpnt->changed = 0;
387 SDpnt->access_count = 0;
388 SDpnt->busy = 0;
389
390
391
392
393
394
395 switch (type = (scsi_result[0] & 0x1f))
396 {
397 case TYPE_TAPE :
398 case TYPE_DISK :
399 case TYPE_MOD :
400 case TYPE_PROCESSOR :
401 case TYPE_SCANNER :
402 SDpnt->writeable = 1;
403 break;
404 case TYPE_WORM :
405 case TYPE_ROM :
406 SDpnt->writeable = 0;
407 break;
408 default :
409 #if 0
410 #ifdef DEBUG
411 printk("scsi: unknown type %d\n", type);
412 print_inquiry(scsi_result);
413 #endif
414 type = -1;
415 #endif
416 }
417
418 SDpnt->soft_reset =
419 (scsi_result[7] & 1) && ((scsi_result[3] & 7) == 2);
420 SDpnt->random = (type == TYPE_TAPE) ? 0 : 1;
421 SDpnt->type = (type & 0x1f);
422
423 if (type != -1)
424 {
425 print_inquiry(scsi_result);
426
427 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
428 if(sdtpnt->detect) SDpnt->attached +=
429 (*sdtpnt->detect)(SDpnt);
430
431 SDpnt->scsi_level = scsi_result[2] & 0x07;
432 if (SDpnt->scsi_level >= 2 ||
433 (SDpnt->scsi_level == 1 &&
434 (scsi_result[3] & 0x0f) == 1))
435 SDpnt->scsi_level++;
436
437
438
439
440
441 SDpnt->tagged_queue = 0;
442
443 if ((SDpnt->scsi_level >= SCSI_2) &&
444 (scsi_result[7] & 2)) {
445 SDpnt->tagged_supported = 1;
446 SDpnt->current_tag = 0;
447 }
448
449
450
451
452
453
454 SDpnt->disconnect = 0;
455
456
457
458
459
460
461
462
463
464 if(strncmp("TEXEL", (char *) &scsi_result[8], 5) != 0 ||
465 strncmp("CD-ROM", (char *) &scsi_result[16], 6) != 0
466
467
468
469
470
471
472 #ifdef notyet
473 || (strncmp("1.06", (char *) &scsi_result[[, 4) != 0)))
474 #endif
475 )
476 SDpnt->borken = 0;
477
478
479
480
481 if(memcmp("INSITE", &scsi_result[8], 6) == 0 &&
482 (memcmp("Floptical F*8I", &scsi_result[16], 16) == 0
483 || memcmp("I325VM", &scsi_result[16], 6) == 0)) {
484 printk("Unlocked floptical drive.\n");
485 SDpnt->lockable = 0;
486 scsi_cmd[0] = MODE_SENSE;
487 scsi_cmd[1] = (lun << 5) & 0xe0;
488 scsi_cmd[2] = 0x2e;
489 scsi_cmd[3] = 0;
490 scsi_cmd[4] = 0x2a;
491 scsi_cmd[5] = 0;
492
493 SCmd.request.dev = 0xffff;
494 SCmd.cmd_len = 0;
495
496 scsi_do_cmd (&SCmd,
497 (void *) scsi_cmd, (void *)
498 scsi_result, 0x2a, scan_scsis_done,
499 SCSI_TIMEOUT, 3);
500
501 while (SCmd.request.dev != 0xfffe);
502 };
503
504 if(SDtail)
505 SDtail->next = SDpnt;
506 else
507 scsi_devices = SDpnt;
508 SDtail = SDpnt;
509
510 SDpnt = (Scsi_Device *) scsi_init_malloc(sizeof (Scsi_Device));
511
512
513 if(blacklisted(scsi_result)) break;
514
515 if ((scsi_result[2] & 0x07) == 0)
516 break;
517
518
519 if((scsi_result[2] & 0x07) == 1 &&
520 (scsi_result[3] & 0x0f) == 0) break;
521 }
522 }
523 }
524 shpnt->host_queue = NULL;
525
526 printk("scsi : detected ");
527 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
528 if(sdtpnt->dev_noticed && sdtpnt->name)
529 printk("%d SCSI %s%s ", sdtpnt->dev_noticed, sdtpnt->name,
530 (sdtpnt->dev_noticed != 1) ? "s" : "");
531
532 printk("total.\n");
533
534
535 scsi_init_free((char *) SDpnt, sizeof(Scsi_Device));
536
537 in_scan_scsis = 0;
538 }
539
540
541
542
543
544 #define NORMAL_TIMEOUT 0
545 #define IN_ABORT 1
546 #define IN_RESET 2
547
548
549
550
551
552
553 static void scsi_times_out (Scsi_Cmnd * SCpnt, int pid)
554 {
555
556 switch (SCpnt->internal_timeout & (IN_ABORT | IN_RESET))
557 {
558 case NORMAL_TIMEOUT:
559 if (!in_scan_scsis) {
560 #ifdef DEBUG_TIMEOUT
561 scsi_dump_status();
562 #endif
563 }
564
565 if (!scsi_abort (SCpnt, DID_TIME_OUT, pid))
566 return;
567 case IN_ABORT:
568 printk("SCSI host %d abort() timed out - resetting\n",
569 SCpnt->host->host_no);
570 if (!scsi_reset (SCpnt))
571 return;
572 case IN_RESET:
573 case (IN_ABORT | IN_RESET):
574
575
576
577 printk("Unable to reset scsi host %d - ",SCpnt->host->host_no);
578 printk("probably a SCSI bus hang.\n");
579 return;
580
581 default:
582 INTERNAL_ERROR;
583 }
584
585 }
586
587
588
589
590
591
592
593
594 Scsi_Cmnd * request_queueable (struct request * req, Scsi_Device * device)
595 {
596 Scsi_Cmnd * SCpnt = NULL;
597 int tablesize;
598 struct buffer_head * bh, *bhp;
599
600 if (!device)
601 panic ("No device passed to request_queueable().\n");
602
603 if (req && req->dev <= 0)
604 panic("Invalid device in request_queueable");
605
606 SCpnt = device->host->host_queue;
607 while(SCpnt){
608 if(SCpnt->target == device->id &&
609 SCpnt->lun == device->lun)
610 if(SCpnt->request.dev < 0) break;
611 SCpnt = SCpnt->next;
612 };
613
614 if (!SCpnt) return NULL;
615
616 if (device->host->can_queue &&
617 ((device->host->block && host_active && device->host != host_active) ||
618 (device->host->block && host_next && device->host != host_next) ||
619 device->host->host_busy >= device->host->can_queue)) {
620
621 if (device->host->block && !host_next && host_active
622 && device->host != host_active)
623 host_next = device->host;
624
625 return NULL;
626 }
627
628 if (req) {
629 memcpy(&SCpnt->request, req, sizeof(struct request));
630 tablesize = device->host->sg_tablesize;
631 bhp = bh = req->bh;
632 if(!tablesize) bh = NULL;
633
634
635 while(req->nr_sectors && bh){
636 bhp = bhp->b_reqnext;
637 if(!bhp || !CONTIGUOUS_BUFFERS(bh,bhp)) tablesize--;
638 req->nr_sectors -= bh->b_size >> 9;
639 req->sector += bh->b_size >> 9;
640 if(!tablesize) break;
641 bh = bhp;
642 };
643 if(req->nr_sectors && bh && bh->b_reqnext){
644 SCpnt->request.bhtail = bh;
645 req->bh = bh->b_reqnext;
646 bh->b_reqnext = NULL;
647 bh = req->bh;
648
649
650 SCpnt->request.nr_sectors -= req->nr_sectors;
651 req->current_nr_sectors = bh->b_size >> 9;
652 req->buffer = bh->b_data;
653 SCpnt->request.sem = NULL;
654 } else {
655 req->dev = -1;
656 wake_up(&wait_for_request);
657 };
658 } else {
659 SCpnt->request.dev = 0xffff;
660 SCpnt->request.sem = NULL;
661 };
662
663 SCpnt->use_sg = 0;
664 SCpnt->old_use_sg = 0;
665 SCpnt->transfersize = 0;
666 SCpnt->underflow = 0;
667 SCpnt->cmd_len = 0;
668 return SCpnt;
669 }
670
671
672
673
674
675
676
677
678
679
680 Scsi_Cmnd * allocate_device (struct request ** reqp, Scsi_Device * device,
681 int wait)
682 {
683 int dev = -1;
684 struct request * req = NULL;
685 int tablesize;
686 struct buffer_head * bh, *bhp;
687 struct Scsi_Host * host;
688 Scsi_Cmnd * SCpnt = NULL;
689 Scsi_Cmnd * SCwait = NULL;
690
691 if (!device)
692 panic ("No device passed to allocate_device().\n");
693
694 if (reqp) req = *reqp;
695
696
697 if (req && (dev = req->dev) <= 0) return NULL;
698
699 host = device->host;
700
701 if (intr_count && host->can_queue &&
702 ((host->block && host_active && host != host_active) ||
703 (host->block && host_next && host != host_next) ||
704 host->host_busy >= host->can_queue)) {
705
706 scsi_maybe_deadlocked = 1;
707
708 if (host->block && !host_next && host_active && host != host_active)
709 host_next = host;
710
711 return NULL;
712 }
713
714 while (1==1){
715 SCpnt = host->host_queue;
716 while(SCpnt){
717 if(SCpnt->target == device->id &&
718 SCpnt->lun == device->lun) {
719 SCwait = SCpnt;
720 if(SCpnt->request.dev < 0) break;
721 };
722 SCpnt = SCpnt->next;
723 };
724 cli();
725
726 if (req && ((req->dev < 0) || (req->dev != dev))) {
727 sti();
728 return NULL;
729 };
730 if (!SCpnt || SCpnt->request.dev >= 0)
731 {
732 sti();
733 if(!wait) return NULL;
734 if (!SCwait) {
735 printk("Attempt to allocate device target %d, lun %d\n",
736 device->id ,device->lun);
737 panic("No device found in allocate_device\n");
738 };
739 SCSI_SLEEP(&device->device_wait,
740 (SCwait->request.dev > 0));
741 } else {
742 if (req) {
743 memcpy(&SCpnt->request, req, sizeof(struct request));
744 tablesize = device->host->sg_tablesize;
745 bhp = bh = req->bh;
746 if(!tablesize) bh = NULL;
747
748
749 while(req->nr_sectors && bh){
750 bhp = bhp->b_reqnext;
751 if(!bhp || !CONTIGUOUS_BUFFERS(bh,bhp)) tablesize--;
752 req->nr_sectors -= bh->b_size >> 9;
753 req->sector += bh->b_size >> 9;
754 if(!tablesize) break;
755 bh = bhp;
756 };
757 if(req->nr_sectors && bh && bh->b_reqnext){
758 SCpnt->request.bhtail = bh;
759 req->bh = bh->b_reqnext;
760 bh->b_reqnext = NULL;
761 bh = req->bh;
762
763 SCpnt->request.nr_sectors -= req->nr_sectors;
764 req->current_nr_sectors = bh->b_size >> 9;
765 req->buffer = bh->b_data;
766 SCpnt->request.sem = NULL;
767 }
768 else
769 {
770 req->dev = -1;
771 *reqp = req->next;
772 wake_up(&wait_for_request);
773 };
774 } else {
775 SCpnt->request.dev = 0xffff;
776 SCpnt->request.sem = NULL;
777 };
778 sti();
779 break;
780 };
781 };
782
783 SCpnt->use_sg = 0;
784 SCpnt->old_use_sg = 0;
785 SCpnt->transfersize = 0;
786 SCpnt->cmd_len = 0;
787 SCpnt->underflow = 0;
788 return SCpnt;
789 }
790
791
792
793
794
795 inline void internal_cmnd (Scsi_Cmnd * SCpnt)
796 {
797 int temp;
798 struct Scsi_Host * host;
799 #ifdef DEBUG_DELAY
800 int clock;
801 #endif
802
803 if ((unsigned long) &SCpnt < current->kernel_stack_page)
804 panic("Kernel stack overflow.");
805
806 host = SCpnt->host;
807
808
809
810
811
812 temp = host->last_reset;
813 while (jiffies < temp);
814
815 update_timeout(SCpnt, SCpnt->timeout_per_command);
816
817
818
819
820
821 #ifdef DEBUG
822 printk("internal_cmnd (host = %d, target = %d, command = %08x, buffer = %08x, \n"
823 "bufflen = %d, done = %08x)\n", SCpnt->host->host_no, SCpnt->target, SCpnt->cmnd, SCpnt->buffer, SCpnt->bufflen, SCpnt->done);
824 #endif
825
826 if (host->can_queue)
827 {
828 #ifdef DEBUG
829 printk("queuecommand : routine at %08x\n",
830 host->hostt->queuecommand);
831 #endif
832
833
834
835
836
837
838
839
840 if(!intr_count && SCpnt->host->irq)
841 disable_irq(SCpnt->host->irq);
842
843 host->hostt->queuecommand (SCpnt, scsi_done);
844
845 if(!intr_count && SCpnt->host->irq)
846 enable_irq(SCpnt->host->irq);
847 }
848 else
849 {
850
851 #ifdef DEBUG
852 printk("command() : routine at %08x\n", host->hostt->command);
853 #endif
854 temp=host->hostt->command (SCpnt);
855 SCpnt->result = temp;
856 #ifdef DEBUG_DELAY
857 clock = jiffies + 400;
858 while (jiffies < clock);
859 printk("done(host = %d, result = %04x) : routine at %08x\n", host->host_no, temp, done);
860 #endif
861 scsi_done(SCpnt);
862 }
863 #ifdef DEBUG
864 printk("leaving internal_cmnd()\n");
865 #endif
866 }
867
868 static void scsi_request_sense (Scsi_Cmnd * SCpnt)
869 {
870 cli();
871 SCpnt->flags |= WAS_SENSE | ASKED_FOR_SENSE;
872 update_timeout(SCpnt, SENSE_TIMEOUT);
873 sti();
874
875
876 memcpy ((void *) SCpnt->cmnd , (void *) generic_sense,
877 sizeof(generic_sense));
878
879 SCpnt->cmnd[1] = SCpnt->lun << 5;
880 SCpnt->cmnd[4] = sizeof(SCpnt->sense_buffer);
881
882 SCpnt->request_buffer = &SCpnt->sense_buffer;
883 SCpnt->request_bufflen = sizeof(SCpnt->sense_buffer);
884 SCpnt->use_sg = 0;
885 SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
886 internal_cmnd (SCpnt);
887 }
888
889
890
891
892
893
894
895
896
897
898 void scsi_do_cmd (Scsi_Cmnd * SCpnt, const void *cmnd ,
899 void *buffer, unsigned bufflen, void (*done)(Scsi_Cmnd *),
900 int timeout, int retries
901 )
902 {
903 struct Scsi_Host * host = SCpnt->host;
904
905 #ifdef DEBUG
906 {
907 int i;
908 int target = SCpnt->target;
909 printk ("scsi_do_cmd (host = %d, target = %d, buffer =%08x, "
910 "bufflen = %d, done = %08x, timeout = %d, retries = %d)\n"
911 "command : " , host->host_no, target, buffer, bufflen, done, timeout, retries);
912 for (i = 0; i < 10; ++i)
913 printk ("%02x ", ((unsigned char *) cmnd)[i]);
914 printk("\n");
915 };
916 #endif
917
918 if (!host)
919 {
920 panic ("Invalid or not present host.\n");
921 }
922
923
924
925
926
927
928
929
930
931
932 SCpnt->pid = scsi_pid++;
933
934 for(;;) {
935
936 cli();
937
938 if (host->can_queue &&
939 ((host->block && host_active && host != host_active) ||
940 (host->block && host_next && host != host_next) ||
941 host->host_busy >= host->can_queue)) {
942
943 if (intr_count)
944 panic("scsi: queueing to inactive host while in interrupt.\n");
945
946 if (host->block && !host_next && host_active
947 && host != host_active)
948 host_next = host;
949
950 sti();
951 SCSI_SLEEP(&host->host_wait,
952 ((host->block && host_active && host != host_active) ||
953 (host->block && host_next && host != host_next) ||
954 host->host_busy >= host->can_queue));
955 }
956
957 else {
958 host->host_busy++;
959
960 if (host->block) {
961
962 if (!host_active) {
963 max_active = 0;
964 host_active = host;
965 host_next = NULL;
966 }
967 else if (max_active > 7 && !host_next)
968 host_next = host->block;
969
970 max_active++;
971 }
972
973 sti();
974 break;
975 }
976 }
977
978
979
980
981
982
983
984
985 memcpy ((void *) SCpnt->data_cmnd , (void *) cmnd, 12);
986 #if 0
987 SCpnt->host = host;
988 SCpnt->target = target;
989 SCpnt->lun = (SCpnt->data_cmnd[1] >> 5);
990 #endif
991 SCpnt->bufflen = bufflen;
992 SCpnt->buffer = buffer;
993 SCpnt->flags=0;
994 SCpnt->retries=0;
995 SCpnt->allowed=retries;
996 SCpnt->done = done;
997 SCpnt->timeout_per_command = timeout;
998
999 memcpy ((void *) SCpnt->cmnd , (void *) cmnd, 12);
1000
1001
1002 memset ((void *) SCpnt->sense_buffer, 0, sizeof SCpnt->sense_buffer);
1003 SCpnt->request_buffer = buffer;
1004 SCpnt->request_bufflen = bufflen;
1005 SCpnt->old_use_sg = SCpnt->use_sg;
1006 if (SCpnt->cmd_len == 0)
1007 SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
1008 SCpnt->old_cmd_len = SCpnt->cmd_len;
1009
1010
1011
1012 SCpnt->internal_timeout = 0;
1013 SCpnt->abort_reason = 0;
1014 internal_cmnd (SCpnt);
1015
1016 #ifdef DEBUG
1017 printk ("Leaving scsi_do_cmd()\n");
1018 #endif
1019 }
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029 static void reset (Scsi_Cmnd * SCpnt)
1030 {
1031 #ifdef DEBUG
1032 printk("scsi: reset(%d)\n", SCpnt->host->host_no);
1033 #endif
1034
1035 SCpnt->flags |= (WAS_RESET | IS_RESETTING);
1036 scsi_reset(SCpnt);
1037
1038 #ifdef DEBUG
1039 printk("performing request sense\n");
1040 #endif
1041
1042 #if 0
1043 if(SCpnt->flags & NEEDS_JUMPSTART) {
1044 SCpnt->flags &= ~NEEDS_JUMPSTART;
1045 scsi_request_sense (SCpnt);
1046 };
1047 #endif
1048 }
1049
1050
1051
1052 static int check_sense (Scsi_Cmnd * SCpnt)
1053 {
1054
1055
1056
1057 if (((SCpnt->sense_buffer[0] & 0x70) >> 4) != 7) {
1058 if(!(SCpnt->flags & ASKED_FOR_SENSE))
1059 return SUGGEST_SENSE;
1060 else
1061 return SUGGEST_RETRY;
1062 }
1063
1064 SCpnt->flags &= ~ASKED_FOR_SENSE;
1065
1066 #ifdef DEBUG_INIT
1067 printk("scsi%d : ", SCpnt->host->host_no);
1068 print_sense("", SCpnt);
1069 printk("\n");
1070 #endif
1071 if (SCpnt->sense_buffer[2] &0xe0)
1072 return SUGGEST_ABORT;
1073
1074 switch (SCpnt->sense_buffer[2] & 0xf)
1075 {
1076 case NO_SENSE:
1077 return 0;
1078 case RECOVERED_ERROR:
1079 if (SCpnt->device->type == TYPE_TAPE)
1080 return SUGGEST_IS_OK;
1081 else
1082 return 0;
1083
1084 case ABORTED_COMMAND:
1085 return SUGGEST_RETRY;
1086 case NOT_READY:
1087 case UNIT_ATTENTION:
1088 return SUGGEST_ABORT;
1089
1090
1091 case COPY_ABORTED:
1092 case VOLUME_OVERFLOW:
1093 case MISCOMPARE:
1094
1095 case MEDIUM_ERROR:
1096 return SUGGEST_REMAP;
1097 case BLANK_CHECK:
1098 case DATA_PROTECT:
1099 case HARDWARE_ERROR:
1100 case ILLEGAL_REQUEST:
1101 default:
1102 return SUGGEST_ABORT;
1103 }
1104 }
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127 static void scsi_done (Scsi_Cmnd * SCpnt)
1128 {
1129 int status=0;
1130 int exit=0;
1131 int checked;
1132 int oldto;
1133 struct Scsi_Host * host = SCpnt->host;
1134 int result = SCpnt->result;
1135 oldto = update_timeout(SCpnt, 0);
1136
1137 #ifdef DEBUG_TIMEOUT
1138 if(result) printk("Non-zero result in scsi_done %x %d:%d\n",
1139 result, SCpnt->target, SCpnt->lun);
1140 #endif
1141
1142
1143
1144 if(host_byte(result) == DID_ABORT && SCpnt->abort_reason)
1145 SCpnt->result = result = (result & 0xff00ffff) |
1146 (SCpnt->abort_reason << 16);
1147
1148
1149 #define FINISHED 0
1150 #define MAYREDO 1
1151 #define REDO 3
1152 #define PENDING 4
1153
1154 #ifdef DEBUG
1155 printk("In scsi_done(host = %d, result = %06x)\n", host->host_no, result);
1156 #endif
1157
1158 if(SCpnt->flags & WAS_SENSE)
1159 {
1160 SCpnt->use_sg = SCpnt->old_use_sg;
1161 SCpnt->cmd_len = SCpnt->old_cmd_len;
1162 }
1163
1164 switch (host_byte(result))
1165 {
1166 case DID_OK:
1167 if (status_byte(result) && (SCpnt->flags & WAS_SENSE))
1168
1169 {
1170 SCpnt->flags &= ~WAS_SENSE;
1171 SCpnt->internal_timeout &= ~SENSE_TIMEOUT;
1172
1173 if (!(SCpnt->flags & WAS_RESET))
1174 {
1175 printk("scsi%d : target %d lun %d request sense failed, performing reset.\n",
1176 SCpnt->host->host_no, SCpnt->target, SCpnt->lun);
1177 reset(SCpnt);
1178 return;
1179 }
1180 else
1181 {
1182 exit = (DRIVER_HARD | SUGGEST_ABORT);
1183 status = FINISHED;
1184 }
1185 }
1186 else switch(msg_byte(result))
1187 {
1188 case COMMAND_COMPLETE:
1189 switch (status_byte(result))
1190 {
1191 case GOOD:
1192 if (SCpnt->flags & WAS_SENSE)
1193 {
1194 #ifdef DEBUG
1195 printk ("In scsi_done, GOOD status, COMMAND COMPLETE, parsing sense information.\n");
1196 #endif
1197
1198 SCpnt->flags &= ~WAS_SENSE;
1199 SCpnt->internal_timeout &= ~SENSE_TIMEOUT;
1200
1201 switch (checked = check_sense(SCpnt))
1202 {
1203 case SUGGEST_SENSE:
1204 case 0:
1205 #ifdef DEBUG
1206 printk("NO SENSE. status = REDO\n");
1207 #endif
1208
1209 update_timeout(SCpnt, oldto);
1210 status = REDO;
1211 break;
1212 case SUGGEST_IS_OK:
1213 break;
1214 case SUGGEST_REMAP:
1215 case SUGGEST_RETRY:
1216 #ifdef DEBUG
1217 printk("SENSE SUGGEST REMAP or SUGGEST RETRY - status = MAYREDO\n");
1218 #endif
1219
1220 status = MAYREDO;
1221 exit = DRIVER_SENSE | SUGGEST_RETRY;
1222 break;
1223 case SUGGEST_ABORT:
1224 #ifdef DEBUG
1225 printk("SENSE SUGGEST ABORT - status = FINISHED");
1226 #endif
1227
1228 status = FINISHED;
1229 exit = DRIVER_SENSE | SUGGEST_ABORT;
1230 break;
1231 default:
1232 printk ("Internal error %s %d \n", __FILE__,
1233 __LINE__);
1234 }
1235 }
1236 else
1237 {
1238 #ifdef DEBUG
1239 printk("COMMAND COMPLETE message returned, status = FINISHED. \n");
1240 #endif
1241
1242 exit = DRIVER_OK;
1243 status = FINISHED;
1244 }
1245 break;
1246
1247 case CHECK_CONDITION:
1248 switch (check_sense(SCpnt))
1249 {
1250 case 0:
1251 update_timeout(SCpnt, oldto);
1252 status = REDO;
1253 break;
1254 case SUGGEST_REMAP:
1255 case SUGGEST_RETRY:
1256 status = MAYREDO;
1257 exit = DRIVER_SENSE | SUGGEST_RETRY;
1258 break;
1259 case SUGGEST_ABORT:
1260 status = FINISHED;
1261 exit = DRIVER_SENSE | SUGGEST_ABORT;
1262 break;
1263 case SUGGEST_SENSE:
1264 scsi_request_sense (SCpnt);
1265 status = PENDING;
1266 break;
1267 }
1268 break;
1269
1270 case CONDITION_GOOD:
1271 case INTERMEDIATE_GOOD:
1272 case INTERMEDIATE_C_GOOD:
1273 break;
1274
1275 case BUSY:
1276 update_timeout(SCpnt, oldto);
1277 status = REDO;
1278 break;
1279
1280 case RESERVATION_CONFLICT:
1281 printk("scsi%d : RESERVATION CONFLICT performing reset.\n",
1282 SCpnt->host->host_no);
1283 reset(SCpnt);
1284 return;
1285 #if 0
1286 exit = DRIVER_SOFT | SUGGEST_ABORT;
1287 status = MAYREDO;
1288 break;
1289 #endif
1290 default:
1291 printk ("Internal error %s %d \n"
1292 "status byte = %d \n", __FILE__,
1293 __LINE__, status_byte(result));
1294
1295 }
1296 break;
1297 default:
1298 panic("scsi: unsupported message byte %d received\n", msg_byte(result));
1299 }
1300 break;
1301 case DID_TIME_OUT:
1302 #ifdef DEBUG
1303 printk("Host returned DID_TIME_OUT - ");
1304 #endif
1305
1306 if (SCpnt->flags & WAS_TIMEDOUT)
1307 {
1308 #ifdef DEBUG
1309 printk("Aborting\n");
1310 #endif
1311 exit = (DRIVER_TIMEOUT | SUGGEST_ABORT);
1312 }
1313 else
1314 {
1315 #ifdef DEBUG
1316 printk ("Retrying.\n");
1317 #endif
1318 SCpnt->flags |= WAS_TIMEDOUT;
1319 SCpnt->internal_timeout &= ~IN_ABORT;
1320 status = REDO;
1321 }
1322 break;
1323 case DID_BUS_BUSY:
1324 case DID_PARITY:
1325 status = REDO;
1326 break;
1327 case DID_NO_CONNECT:
1328 #ifdef DEBUG
1329 printk("Couldn't connect.\n");
1330 #endif
1331 exit = (DRIVER_HARD | SUGGEST_ABORT);
1332 break;
1333 case DID_ERROR:
1334 status = MAYREDO;
1335 exit = (DRIVER_HARD | SUGGEST_ABORT);
1336 break;
1337 case DID_BAD_TARGET:
1338 case DID_ABORT:
1339 exit = (DRIVER_INVALID | SUGGEST_ABORT);
1340 break;
1341 case DID_RESET:
1342 if (SCpnt->flags & IS_RESETTING)
1343 {
1344 SCpnt->flags &= ~IS_RESETTING;
1345 status = REDO;
1346 break;
1347 }
1348
1349 if(msg_byte(result) == GOOD &&
1350 status_byte(result) == CHECK_CONDITION) {
1351 switch (check_sense(SCpnt)) {
1352 case 0:
1353 update_timeout(SCpnt, oldto);
1354 status = REDO;
1355 break;
1356 case SUGGEST_REMAP:
1357 case SUGGEST_RETRY:
1358 status = MAYREDO;
1359 exit = DRIVER_SENSE | SUGGEST_RETRY;
1360 break;
1361 case SUGGEST_ABORT:
1362 status = FINISHED;
1363 exit = DRIVER_SENSE | SUGGEST_ABORT;
1364 break;
1365 case SUGGEST_SENSE:
1366 scsi_request_sense (SCpnt);
1367 status = PENDING;
1368 break;
1369 }
1370 } else {
1371 status=REDO;
1372 exit = SUGGEST_RETRY;
1373 }
1374 break;
1375 default :
1376 exit = (DRIVER_ERROR | SUGGEST_DIE);
1377 }
1378
1379 switch (status)
1380 {
1381 case FINISHED:
1382 case PENDING:
1383 break;
1384 case MAYREDO:
1385
1386 #ifdef DEBUG
1387 printk("In MAYREDO, allowing %d retries, have %d\n",
1388 SCpnt->allowed, SCpnt->retries);
1389 #endif
1390
1391 if ((++SCpnt->retries) < SCpnt->allowed)
1392 {
1393 if ((SCpnt->retries >= (SCpnt->allowed >> 1))
1394 && !(SCpnt->flags & WAS_RESET))
1395 {
1396 printk("scsi%d : resetting for second half of retries.\n",
1397 SCpnt->host->host_no);
1398 reset(SCpnt);
1399 break;
1400 }
1401
1402 }
1403 else
1404 {
1405 status = FINISHED;
1406 break;
1407 }
1408
1409
1410 case REDO:
1411
1412 if (host->block) scsi_maybe_deadlocked = 1;
1413
1414 if (SCpnt->flags & WAS_SENSE)
1415 scsi_request_sense(SCpnt);
1416 else
1417 {
1418 memcpy ((void *) SCpnt->cmnd,
1419 (void*) SCpnt->data_cmnd,
1420 sizeof(SCpnt->data_cmnd));
1421 SCpnt->request_buffer = SCpnt->buffer;
1422 SCpnt->request_bufflen = SCpnt->bufflen;
1423 SCpnt->use_sg = SCpnt->old_use_sg;
1424 SCpnt->cmd_len = SCpnt->old_cmd_len;
1425 internal_cmnd (SCpnt);
1426 };
1427 break;
1428 default:
1429 INTERNAL_ERROR;
1430 }
1431
1432
1433 if (status == FINISHED) {
1434 #ifdef DEBUG
1435 printk("Calling done function - at address %08x\n", SCpnt->done);
1436 #endif
1437 host->host_busy--;
1438
1439 if (host->block && host->host_busy == 0) {
1440 struct Scsi_Host * block;
1441
1442 block = host_next;
1443 host_active = NULL;
1444
1445 if (block) wake_up(&block->host_wait);
1446
1447 for (block = host->block; block != host; block = block->block)
1448 wake_up(&block->host_wait);
1449
1450 host_next = NULL;
1451
1452 if (scsi_maybe_deadlocked) {
1453 scsi_maybe_deadlocked = 0;
1454 restart_all();
1455 }
1456
1457 }
1458
1459 wake_up(&host->host_wait);
1460 SCpnt->result = result | ((exit & 0xff) << 24);
1461 SCpnt->use_sg = SCpnt->old_use_sg;
1462 SCpnt->cmd_len = SCpnt->old_cmd_len;
1463 SCpnt->done (SCpnt);
1464 }
1465
1466 #undef FINISHED
1467 #undef REDO
1468 #undef MAYREDO
1469 #undef PENDING
1470 }
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488 int scsi_abort (Scsi_Cmnd * SCpnt, int why, int pid)
1489 {
1490 int oldto;
1491 struct Scsi_Host * host = SCpnt->host;
1492
1493 while(1)
1494 {
1495 cli();
1496
1497
1498
1499
1500
1501 if (SCpnt->request.dev == -1 || pid != SCpnt->pid) {
1502 sti();
1503 return 0;
1504 }
1505
1506 if (SCpnt->internal_timeout & IN_ABORT)
1507 {
1508 sti();
1509 while (SCpnt->internal_timeout & IN_ABORT);
1510 }
1511 else
1512 {
1513 SCpnt->internal_timeout |= IN_ABORT;
1514 oldto = update_timeout(SCpnt, ABORT_TIMEOUT);
1515
1516 if ((SCpnt->flags & IS_RESETTING) &&
1517 SCpnt->device->soft_reset) {
1518
1519
1520 printk("Stale command on %d:%d appears to have died when"
1521 " the bus was reset\n", SCpnt->target, SCpnt->lun);
1522 }
1523
1524 sti();
1525 if (!host->host_busy) {
1526 SCpnt->internal_timeout &= ~IN_ABORT;
1527 update_timeout(SCpnt, oldto);
1528 return 0;
1529 }
1530 printk("scsi : aborting command due to timeout : pid %lu, scsi%d, id %d, lun %d ",
1531 SCpnt->pid, SCpnt->host->host_no, (int) SCpnt->target, (int)
1532 SCpnt->lun);
1533 print_command (SCpnt->cmnd);
1534 if (SCpnt->request.dev == -1 || pid != SCpnt->pid)
1535 return 0;
1536 SCpnt->abort_reason = why;
1537 switch(host->hostt->abort(SCpnt)) {
1538
1539
1540
1541
1542 case SCSI_ABORT_BUSY:
1543
1544 case SCSI_ABORT_SNOOZE:
1545 if(why == DID_TIME_OUT) {
1546 cli();
1547 SCpnt->internal_timeout &= ~IN_ABORT;
1548 if(SCpnt->flags & WAS_TIMEDOUT) {
1549 sti();
1550 return 1;
1551
1552
1553 } else {
1554 SCpnt->flags |= WAS_TIMEDOUT;
1555 oldto = SCpnt->timeout_per_command;
1556 update_timeout(SCpnt, oldto);
1557 }
1558 sti();
1559 }
1560 return 0;
1561 case SCSI_ABORT_PENDING:
1562 if(why != DID_TIME_OUT) {
1563 cli();
1564 update_timeout(SCpnt, oldto);
1565 sti();
1566 }
1567 return 0;
1568 case SCSI_ABORT_SUCCESS:
1569
1570
1571 case SCSI_ABORT_NOT_RUNNING:
1572 SCpnt->internal_timeout &= ~IN_ABORT;
1573 update_timeout(SCpnt, 0);
1574 return 0;
1575 case SCSI_ABORT_ERROR:
1576 default:
1577 SCpnt->internal_timeout &= ~IN_ABORT;
1578 return 1;
1579 }
1580 }
1581 }
1582 }
1583
1584 int scsi_reset (Scsi_Cmnd * SCpnt)
1585 {
1586 int temp, oldto;
1587 Scsi_Cmnd * SCpnt1;
1588 struct Scsi_Host * host = SCpnt->host;
1589
1590 #ifdef DEBUG
1591 printk("Danger Will Robinson! - SCSI bus for host %d is being reset.\n",host->host_no);
1592 #endif
1593 while (1) {
1594 cli();
1595 if (SCpnt->internal_timeout & IN_RESET)
1596 {
1597 sti();
1598 while (SCpnt->internal_timeout & IN_RESET);
1599 }
1600 else
1601 {
1602 SCpnt->internal_timeout |= IN_RESET;
1603 oldto = update_timeout(SCpnt, RESET_TIMEOUT);
1604
1605 if (host->host_busy)
1606 {
1607 sti();
1608 SCpnt1 = host->host_queue;
1609 while(SCpnt1) {
1610 if (SCpnt1->request.dev > 0) {
1611 #if 0
1612 if (!(SCpnt1->flags & IS_RESETTING) &&
1613 !(SCpnt1->internal_timeout & IN_ABORT))
1614 scsi_abort(SCpnt1, DID_RESET, SCpnt->pid);
1615 #endif
1616 SCpnt1->flags |= IS_RESETTING;
1617 }
1618 SCpnt1 = SCpnt1->next;
1619 };
1620
1621 temp = host->hostt->reset(SCpnt);
1622 }
1623 else
1624 {
1625 host->host_busy++;
1626
1627 if (host->block) {
1628 host_active = host;
1629 host_next = NULL;
1630 }
1631
1632 sti();
1633 temp = host->hostt->reset(SCpnt);
1634 host->last_reset = jiffies;
1635 host->host_busy--;
1636
1637 }
1638
1639 if (host->block && host->host_busy == 0) {
1640 host_active = NULL;
1641 host_next = NULL;
1642 restart_all();
1643 }
1644
1645
1646 #ifdef DEBUG
1647 printk("scsi reset function returned %d\n", temp);
1648 #endif
1649 switch(temp) {
1650 case SCSI_RESET_SUCCESS:
1651 cli();
1652 SCpnt->internal_timeout &= ~IN_RESET;
1653 update_timeout(SCpnt, oldto);
1654 sti();
1655 return 0;
1656 case SCSI_RESET_PENDING:
1657 return 0;
1658 case SCSI_RESET_PUNT:
1659 case SCSI_RESET_WAKEUP:
1660 SCpnt->internal_timeout &= ~IN_RESET;
1661 scsi_request_sense (SCpnt);
1662 return 0;
1663 case SCSI_RESET_SNOOZE:
1664
1665
1666
1667
1668 cli();
1669 SCpnt->internal_timeout &= ~IN_RESET;
1670 update_timeout(SCpnt, 0);
1671 sti();
1672
1673 case SCSI_RESET_ERROR:
1674 default:
1675 return 1;
1676 }
1677
1678 return temp;
1679 }
1680 }
1681 }
1682
1683
1684 static void scsi_main_timeout(void)
1685 {
1686
1687
1688
1689
1690 int timed_out, pid;
1691 struct Scsi_Host * host;
1692 Scsi_Cmnd * SCpnt = NULL;
1693
1694 do {
1695 cli();
1696
1697 update_timeout(NULL, 0);
1698
1699
1700
1701
1702
1703 timed_out = 0;
1704 for(host = scsi_hostlist; host; host = host->next) {
1705 for(SCpnt = host->host_queue; SCpnt; SCpnt = SCpnt->next)
1706 if (SCpnt->timeout == -1)
1707 {
1708 SCpnt->timeout = 0;
1709 pid = SCpnt->pid;
1710 sti();
1711 scsi_times_out(SCpnt, pid);
1712 ++timed_out;
1713 cli();
1714 }
1715 };
1716 } while (timed_out);
1717 sti();
1718 }
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728 static int update_timeout(Scsi_Cmnd * SCset, int timeout)
1729 {
1730 unsigned int least, used;
1731 unsigned int oldto;
1732 struct Scsi_Host * host;
1733 Scsi_Cmnd * SCpnt = NULL;
1734
1735 cli();
1736
1737
1738
1739
1740
1741 used = (time_start) ? (jiffies - time_start) : 0;
1742
1743
1744
1745
1746
1747
1748
1749 oldto = 0;
1750
1751 if(SCset){
1752 oldto = SCset->timeout - used;
1753 SCset->timeout = timeout + used;
1754 };
1755
1756 least = 0xffffffff;
1757
1758 for(host = scsi_hostlist; host; host = host->next)
1759 for(SCpnt = host->host_queue; SCpnt; SCpnt = SCpnt->next)
1760 if (SCpnt->timeout > 0) {
1761 SCpnt->timeout -= used;
1762 if(SCpnt->timeout <= 0) SCpnt->timeout = -1;
1763 if(SCpnt->timeout > 0 && SCpnt->timeout < least)
1764 least = SCpnt->timeout;
1765 };
1766
1767
1768
1769
1770
1771
1772 if (least != 0xffffffff)
1773 {
1774 time_start = jiffies;
1775 timer_table[SCSI_TIMER].expires = (time_elapsed = least) + jiffies;
1776 timer_active |= 1 << SCSI_TIMER;
1777 }
1778 else
1779 {
1780 timer_table[SCSI_TIMER].expires = time_start = time_elapsed = 0;
1781 timer_active &= ~(1 << SCSI_TIMER);
1782 }
1783 sti();
1784 return oldto;
1785 }
1786
1787
1788 static unsigned short * dma_malloc_freelist = NULL;
1789 static unsigned int dma_sectors = 0;
1790 unsigned int dma_free_sectors = 0;
1791 unsigned int need_isa_buffer = 0;
1792 static unsigned char * dma_malloc_buffer = NULL;
1793
1794 void *scsi_malloc(unsigned int len)
1795 {
1796 unsigned int nbits, mask;
1797 unsigned long flags;
1798 int i, j;
1799 if((len & 0x1ff) || len > 8192)
1800 return NULL;
1801
1802 save_flags(flags);
1803 cli();
1804 nbits = len >> 9;
1805 mask = (1 << nbits) - 1;
1806
1807 for(i=0;i < (dma_sectors >> 4); i++)
1808 for(j=0; j<17-nbits; j++){
1809 if ((dma_malloc_freelist[i] & (mask << j)) == 0){
1810 dma_malloc_freelist[i] |= (mask << j);
1811 restore_flags(flags);
1812 dma_free_sectors -= nbits;
1813 #ifdef DEBUG
1814 printk("SMalloc: %d %x ",len, dma_malloc_buffer + (i << 13) + (j << 9));
1815 #endif
1816 return (void *) ((unsigned long) dma_malloc_buffer + (i << 13) + (j << 9));
1817 };
1818 };
1819 restore_flags(flags);
1820 return NULL;
1821 }
1822
1823 int scsi_free(void *obj, unsigned int len)
1824 {
1825 int offset;
1826 int page, sector, nbits, mask;
1827 unsigned long flags;
1828
1829 #ifdef DEBUG
1830 printk("Sfree %x %d\n",obj, len);
1831 #endif
1832
1833 offset = ((int) obj) - ((int) dma_malloc_buffer);
1834
1835 if (offset < 0) panic("Bad offset");
1836 page = offset >> 13;
1837 sector = offset >> 9;
1838 if(sector >= dma_sectors) panic ("Bad page");
1839
1840 sector = (offset >> 9) & 15;
1841 nbits = len >> 9;
1842 mask = (1 << nbits) - 1;
1843
1844 if ((mask << sector) > 0xffff) panic ("Bad memory alignment");
1845
1846 save_flags(flags);
1847 cli();
1848 if(dma_malloc_freelist[page] & (mask << sector) != (mask<<sector))
1849 panic("Trying to free unused memory");
1850
1851 dma_free_sectors += nbits;
1852 dma_malloc_freelist[page] &= ~(mask << sector);
1853 restore_flags(flags);
1854 return 0;
1855 }
1856
1857
1858
1859
1860
1861
1862 static unsigned int scsi_init_memory_start = 0;
1863 int scsi_loadable_module_flag;
1864
1865 void * scsi_init_malloc(unsigned int size)
1866 {
1867 unsigned int retval;
1868 if(scsi_loadable_module_flag) {
1869 retval = (unsigned int) kmalloc(size, GFP_ATOMIC);
1870 } else {
1871 retval = scsi_init_memory_start;
1872 scsi_init_memory_start += size;
1873 }
1874 return (void *) retval;
1875 }
1876
1877
1878 void scsi_init_free(char * ptr, unsigned int size)
1879 {
1880
1881 if((unsigned int) ptr < scsi_loadable_module_flag) {
1882 kfree(ptr);
1883 } else {
1884 if(((unsigned int) ptr) + size == scsi_init_memory_start)
1885 scsi_init_memory_start = (unsigned int) ptr;
1886 }
1887 }
1888
1889
1890
1891
1892
1893
1894
1895 unsigned long scsi_dev_init (unsigned long memory_start,unsigned long memory_end)
1896 {
1897 struct Scsi_Host * host = NULL;
1898 Scsi_Device * SDpnt;
1899 struct Scsi_Host * shpnt;
1900 struct Scsi_Device_Template * sdtpnt;
1901 Scsi_Cmnd * SCpnt;
1902 #ifdef FOO_ON_YOU
1903 return;
1904 #endif
1905
1906
1907 scsi_loadable_module_flag = 0;
1908 scsi_init_memory_start = memory_start;
1909
1910 timer_table[SCSI_TIMER].fn = scsi_main_timeout;
1911 timer_table[SCSI_TIMER].expires = 0;
1912
1913
1914 scsi_init();
1915
1916 scsi_devices = (Scsi_Device *) NULL;
1917
1918 for (shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next)
1919 scan_scsis(shpnt);
1920
1921 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
1922 if(sdtpnt->init && sdtpnt->dev_noticed) (*sdtpnt->init)();
1923
1924 for (SDpnt=scsi_devices; SDpnt; SDpnt = SDpnt->next) {
1925 int j;
1926 SDpnt->scsi_request_fn = NULL;
1927 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
1928 if(sdtpnt->attach) (*sdtpnt->attach)(SDpnt);
1929 if(SDpnt->type != -1){
1930 for(j=0;j<SDpnt->host->cmd_per_lun;j++){
1931 SCpnt = (Scsi_Cmnd *) scsi_init_malloc(sizeof(Scsi_Cmnd));
1932 SCpnt->host = SDpnt->host;
1933 SCpnt->device = SDpnt;
1934 SCpnt->target = SDpnt->id;
1935 SCpnt->lun = SDpnt->lun;
1936 SCpnt->request.dev = -1;
1937 SCpnt->use_sg = 0;
1938 SCpnt->old_use_sg = 0;
1939 SCpnt->old_cmd_len = 0;
1940 SCpnt->timeout = 0;
1941 SCpnt->underflow = 0;
1942 SCpnt->transfersize = 0;
1943 SCpnt->host_scribble = NULL;
1944 host = SDpnt->host;
1945 if(host->host_queue)
1946 host->host_queue->prev = SCpnt;
1947 SCpnt->next = host->host_queue;
1948 SCpnt->prev = NULL;
1949 host->host_queue = SCpnt;
1950 };
1951 };
1952 };
1953
1954 if (scsi_devicelist)
1955 dma_sectors = 16;
1956
1957 for (SDpnt=scsi_devices; SDpnt; SDpnt = SDpnt->next) {
1958 host = SDpnt->host;
1959
1960 if(SDpnt->type != TYPE_TAPE)
1961 dma_sectors += ((host->sg_tablesize *
1962 sizeof(struct scatterlist) + 511) >> 9) *
1963 host->cmd_per_lun;
1964
1965 if(host->unchecked_isa_dma &&
1966 memory_end - 1 > ISA_DMA_THRESHOLD &&
1967 SDpnt->type != TYPE_TAPE) {
1968 dma_sectors += (PAGE_SIZE >> 9) * host->sg_tablesize *
1969 host->cmd_per_lun;
1970 need_isa_buffer++;
1971 };
1972 };
1973
1974 dma_sectors = (dma_sectors + 15) & 0xfff0;
1975 dma_free_sectors = dma_sectors;
1976
1977 scsi_init_memory_start = (scsi_init_memory_start + 3) & 0xfffffffc;
1978 dma_malloc_freelist = (unsigned short *)
1979 scsi_init_malloc(dma_sectors >> 3);
1980 memset(dma_malloc_freelist, 0, dma_sectors >> 3);
1981
1982
1983 if(scsi_init_memory_start & 1) scsi_init_memory_start++;
1984
1985 dma_malloc_buffer = (unsigned char *)
1986 scsi_init_malloc(dma_sectors << 9);
1987
1988
1989
1990 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
1991 if(sdtpnt->finish && sdtpnt->nr_dev)
1992 (*sdtpnt->finish)();
1993
1994 scsi_loadable_module_flag = 1;
1995 return scsi_init_memory_start;
1996 }
1997
1998 static void print_inquiry(unsigned char *data)
1999 {
2000 int i;
2001
2002 printk(" Vendor: ");
2003 for (i = 8; i < 16; i++)
2004 {
2005 if (data[i] >= 0x20 && i < data[4] + 5)
2006 printk("%c", data[i]);
2007 else
2008 printk(" ");
2009 }
2010
2011 printk(" Model: ");
2012 for (i = 16; i < 32; i++)
2013 {
2014 if (data[i] >= 0x20 && i < data[4] + 5)
2015 printk("%c", data[i]);
2016 else
2017 printk(" ");
2018 }
2019
2020 printk(" Rev: ");
2021 for (i = 32; i < 36; i++)
2022 {
2023 if (data[i] >= 0x20 && i < data[4] + 5)
2024 printk("%c", data[i]);
2025 else
2026 printk(" ");
2027 }
2028
2029 printk("\n");
2030
2031 i = data[0] & 0x1f;
2032
2033 printk(" Type: %s ",
2034 i < MAX_SCSI_DEVICE_CODE ? scsi_device_types[i] : "Unknown " );
2035 printk(" ANSI SCSI revision: %02x", data[2] & 0x07);
2036 if ((data[2] & 0x07) == 1 && (data[3] & 0x0f) == 1)
2037 printk(" CCS\n");
2038 else
2039 printk("\n");
2040 }
2041
2042 #ifdef NOT_YET
2043
2044
2045
2046
2047 static int scsi_register_host(Scsi_Host_Template * tpnt)
2048 {
2049 int pcount;
2050 struct Scsi_Host * shpnt;
2051 struct Scsi_Host * host = NULL;
2052 Scsi_Device * SDpnt;
2053 Scsi_Cmnd * SCpnt;
2054 struct Scsi_Device_Template * sdtpnt;
2055 int j, i;
2056 char * name;
2057
2058 if (tpnt->next || !tpnt->detect) return 1;
2059
2060 pcount = next_scsi_host;
2061 if ((tpnt->present = tpnt->detect(tpnt)))
2062 {
2063 if(pcount == next_scsi_host) {
2064 if(tpnt->present > 1) {
2065 printk("Failure to register low-level scsi driver");
2066 scsi_unregister_host(tpnt);
2067 return 1;
2068 }
2069
2070
2071 scsi_register(tpnt,0);
2072 }
2073 tpnt->next = scsi_hosts;
2074 scsi_hosts = tpnt;
2075
2076 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
2077 if(shpnt->hostt == tpnt)
2078 {
2079 if(tpnt->info)
2080 name = tpnt->info(shpnt);
2081 else
2082 name = tpnt->name;
2083 printk ("scsi%d : %s\n",
2084 shpnt->host_no, name);
2085 }
2086
2087
2088
2089 for(shpnt=scsi_hostlist; shpnt; shpnt = shpnt->next)
2090 if(shpnt->hostt == tpnt) scan_scsis(shpnt);
2091
2092 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
2093 if(sdtpnt->init && sdtpnt->dev_noticed) (*sdtpnt->init)();
2094
2095
2096
2097 for(SDpnt = scsi_devices; SDpnt; SDpnt = SDpnt->next)
2098 if(SDpnt->host->hostt == tpnt)
2099 {
2100 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
2101 if(sdtpnt->attach) (*sdtpnt->attach)(SDpnt);
2102 if(SDpnt->attached){
2103 for(j=0;j<SDpnt->host->cmd_per_lun;j++){
2104 SCpnt = (Scsi_Cmnd *) scsi_init_malloc(sizeof(Scsi_Cmnd), GFP_ATOMIC);
2105 SCpnt->host = SDpnt->host;
2106 SCpnt->device = SDpnt;
2107 SCpnt->target = SDpnt->id;
2108 SCpnt->lun = SDpnt->lun;
2109 SCpnt->request.dev = -1;
2110 SCpnt->request.sem = NULL;
2111 SCpnt->use_sg = 0;
2112 SCpnt->old_use_sg = 0;
2113 SCpnt->underflow = 0;
2114 SCpnt->timeout = 0;
2115 SCpnt->transfersize = 0;
2116 SCpnt->host_scribble = NULL;
2117 host = SDpnt->host;
2118 SCpnt->next = host->host_queue;
2119 SCpnt->prev = NULL;
2120 host->host_queue = SCpnt;
2121 if(host->host_queue)
2122 host->host_queue->prev = SCpnt;
2123 };
2124 };
2125 }
2126
2127 {
2128 unsigned char * new_dma_malloc_freelist = NULL;
2129 unsigned int new_dma_sectors = 0;
2130 unsigned int new_need_isa_buffer = 0;
2131 unsigned char ** new_dma_malloc_pages = NULL;
2132
2133 if (scsi_devicelist)
2134 new_dma_sectors = 16;
2135
2136 for (SDpnt=scsi_devices; SDpnt; SDpnt = SDpnt->next) {
2137 host = SDpnt->host;
2138
2139 if(SDpnt->type != TYPE_TAPE)
2140 new_dma_sectors += ((host->sg_tablesize *
2141 sizeof(struct scatterlist) + 511) >> 9) *
2142 host->cmd_per_lun;
2143
2144 if(host->unchecked_isa_dma &&
2145 scsi_need_isa_bounce_buffers &&
2146 SDpnt->type != TYPE_TAPE) {
2147 new_dma_sectors += (PAGE_SIZE >> 9) * host->sg_tablesize *
2148 host->cmd_per_lun;
2149 new_need_isa_buffer++;
2150 };
2151 };
2152
2153 new_dma_sectors = (new_dma_sectors + 15) & 0xfff0;
2154
2155 new_dma_malloc_freelist = (unsigned char *)
2156 scsi_init_malloc(new_dma_sectors >> 3, GFP_ATOMIC);
2157 memset(new_dma_malloc_freelist, 0, new_dma_sectors >> 3);
2158
2159 new_dma_malloc_pages = (unsigned char **)
2160 scsi_init_malloc(new_dma_sectors >> 1, GFP_ATOMIC);
2161 memset(new_dma_malloc_pages, 0, new_dma_sectors >> 1);
2162
2163 for(i=dma_sectors >> 3; i< new_dma_sectors >> 3; i++)
2164 new_dma_malloc_pages[i] = (unsigned char *)
2165 scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
2166
2167
2168
2169 cli();
2170 memcpy(new_dma_malloc_freelist, dma_malloc_freelist, dma_sectors >> 3);
2171 scsi_init_free(dma_malloc_freelist, dma_sectors>>3);
2172 dma_malloc_freelist = new_dma_malloc_freelist;
2173
2174 memcpy(new_dma_malloc_pages, dma_malloc_pages, dma_sectors >> 1);
2175 scsi_init_free((char *) dma_malloc_pages, dma_sectors>>1);
2176
2177 dma_free_sectors += new_dma_sectors - dma_sectors;
2178 dma_malloc_pages = new_dma_malloc_pages;
2179 dma_sectors = new_dma_sectors;
2180 need_isa_buffer = new_need_isa_buffer;
2181 sti();
2182
2183
2184 }
2185
2186 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
2187 if(sdtpnt->finish) (*sdtpnt->finish)();
2188 }
2189 return 0;
2190 }
2191
2192
2193
2194
2195
2196 static void scsi_unregister_host(Scsi_Host_Template * tpnt)
2197 {
2198 Scsi_Host_Template * SHT, *SHTp;
2199 Scsi_Device *sdpnt, * sdppnt, * sdpnt1;
2200 Scsi_Cmnd * SCpnt;
2201 struct Scsi_Device_Template * sdtpnt;
2202 struct Scsi_Host * shpnt, *sh1;
2203 int pcount;
2204
2205
2206
2207
2208 for(sdpnt = scsi_devices; sdpnt; sdpnt = sdpnt->next)
2209 if(sdpnt->host->hostt == tpnt && *sdpnt->host->hostt->usage_count) return;
2210
2211 for(shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next)
2212 {
2213 if (shpnt->hostt != tpnt) continue;
2214 for(SCpnt = shpnt->host_queue; SCpnt; SCpnt = SCpnt->next)
2215 {
2216 cli();
2217 if(SCpnt->request.dev != -1) {
2218 sti();
2219 for(SCpnt = shpnt->host_queue; SCpnt; SCpnt = SCpnt->next)
2220 if(SCpnt->request.dev == 0xffe0) SCpnt->request.dev = -1;
2221 printk("Device busy???\n");
2222 return;
2223 }
2224 SCpnt->request.dev = 0xffe0;
2225 }
2226 }
2227
2228
2229 for(sdpnt = scsi_devices; sdpnt; sdpnt = sdpnt->next)
2230 if(sdpnt->host->hostt == tpnt)
2231 {
2232 for(sdtpnt = scsi_devicelist; sdtpnt; sdtpnt = sdtpnt->next)
2233 if(sdtpnt->detach) (*sdtpnt->detach)(sdpnt);
2234
2235 if (sdpnt->attached) {
2236 printk("Attached usage count = %d\n", sdpnt->attached);
2237 return;
2238 }
2239 }
2240
2241
2242
2243 for(sdpnt = scsi_devices; sdpnt; sdpnt = sdpnt->next)
2244 if(sdpnt->host->hostt == tpnt)
2245 while (sdpnt->host->host_queue) {
2246 SCpnt = sdpnt->host->host_queue->next;
2247 scsi_init_free((char *) sdpnt->host->host_queue, sizeof(Scsi_Cmnd));
2248 sdpnt->host->host_queue = SCpnt;
2249 if (SCpnt) SCpnt->prev = NULL;
2250 }
2251
2252
2253
2254 sdppnt = NULL;
2255 for(sdpnt = scsi_devices; sdpnt; sdpnt = sdpnt1)
2256 {
2257 sdpnt1 = sdpnt->next;
2258 if (sdpnt->host->hostt == tpnt) {
2259 if (sdppnt)
2260 sdppnt->next = sdpnt->next;
2261 else
2262 scsi_devices = sdpnt->next;
2263 scsi_init_free((char *) sdpnt, sizeof (Scsi_Device));
2264 } else
2265 sdppnt = sdpnt;
2266 }
2267
2268
2269
2270
2271 shpnt = scsi_hostlist;
2272 while(shpnt) {
2273 sh1 = shpnt->next;
2274 if(shpnt->hostt == tpnt) {
2275 if(shpnt->loaded_as_module) {
2276 pcount = next_scsi_host;
2277 if(tpnt->release)
2278 (*tpnt->release)(shpnt);
2279 else {
2280
2281
2282 if (shpnt->irq) free_irq(shpnt->irq);
2283 if (shpnt->dma_channel != 0xff) free_dma(shpnt->dma_channel);
2284 if (shpnt->io_port && shpnt->n_io_port)
2285 release_region(shpnt->io_port, shpnt->n_io_port);
2286 }
2287 if(pcount == next_scsi_host) scsi_unregister(shpnt);
2288 tpnt->present--;
2289 }
2290 }
2291 shpnt = sh1;
2292 }
2293
2294
2295
2296 if (tpnt->present) return;
2297
2298
2299
2300 for(SHTp=NULL, SHT=scsi_hosts; SHT; SHTp=SHT, SHT=SHT->next)
2301 if(SHT == tpnt) {
2302 if(SHTp)
2303 SHTp->next = SHT->next;
2304 else
2305 scsi_hosts = SHT->next;
2306 SHT->next = NULL;
2307 break;
2308 }
2309 }
2310
2311 int scsi_register_module(int module_type, void * ptr)
2312 {
2313 switch(module_type){
2314 case MODULE_SCSI_HA:
2315 return scsi_register_host((Scsi_Host_Template *) ptr);
2316
2317
2318
2319 case MODULE_SCSI_CONST:
2320
2321
2322
2323 case MODULE_SCSI_IOCTL:
2324
2325
2326 case MODULE_SCSI_DEV:
2327 default:
2328 return 1;
2329 }
2330 }
2331
2332 void scsi_unregister_module(int module_type, void * ptr)
2333 {
2334 switch(module_type) {
2335 case MODULE_SCSI_HA:
2336 scsi_unregister_host((Scsi_Host_Template *) ptr);
2337 break;
2338
2339 case MODULE_SCSI_CONST:
2340 case MODULE_SCSI_IOCTL:
2341 case MODULE_SCSI_DEV:
2342 default:
2343 }
2344 return;
2345 }
2346 #endif
2347
2348 #ifdef DEBUG_TIMEOUT
2349 static void
2350 scsi_dump_status(void)
2351 {
2352 int i;
2353 struct Scsi_Host * shpnt;
2354 Scsi_Cmnd * SCpnt;
2355 printk("Dump of scsi parameters:\n");
2356 i = 0;
2357 for(shpnt = scsi_hostlist; shpnt; shpnt = shpnt->next)
2358 for(SCpnt=shpnt->host_queue; SCpnt; SCpnt = SCpnt->next)
2359 {
2360
2361 printk("(%d) %d:%d:%d (%4.4x %ld %ld %ld %ld) (%d %d %x) (%d %d %d) %x %x %x\n",
2362 i++, SCpnt->host->host_no,
2363 SCpnt->target,
2364 SCpnt->lun,
2365 SCpnt->request.dev,
2366 SCpnt->request.sector,
2367 SCpnt->request.nr_sectors,
2368 SCpnt->request.current_nr_sectors,
2369 SCpnt->use_sg,
2370 SCpnt->retries,
2371 SCpnt->allowed,
2372 SCpnt->flags,
2373 SCpnt->timeout_per_command,
2374 SCpnt->timeout,
2375 SCpnt->internal_timeout,
2376 SCpnt->cmnd[0],
2377 SCpnt->sense_buffer[2],
2378 SCpnt->result);
2379 };
2380 printk("wait_for_request = %p\n", wait_for_request);
2381
2382 printk("Dump of pending block device requests\n");
2383 for(i=0; i<MAX_BLKDEV; i++)
2384 if(blk_dev[i].current_request)
2385 {
2386 struct request * req;
2387 printk("%d: ", i);
2388 req = blk_dev[i].current_request;
2389 while(req) {
2390 printk("(%x %d %ld %ld %ld) ",
2391 req->dev,
2392 req->cmd,
2393 req->sector,
2394 req->nr_sectors,
2395 req->current_nr_sectors);
2396 req = req->next;
2397 }
2398 printk("\n");
2399 }
2400 }
2401 #endif
2402
2403