|
|
1.1 ! root 1: /* ! 2: * scsi.h Copyright (C) 1992 Drew Eckhardt ! 3: * Copyright (C) 1993, 1994, 1995 Eric Youngdale ! 4: * generic SCSI package header file by ! 5: * Initial versions: Drew Eckhardt ! 6: * Subsequent revisions: Eric Youngdale ! 7: * ! 8: * <[email protected]> ! 9: * ! 10: * Modified by Eric Youngdale [email protected] to ! 11: * add scatter-gather, multiple outstanding request, and other ! 12: * enhancements. ! 13: */ ! 14: ! 15: #ifndef _SCSI_H ! 16: #define _SCSI_H ! 17: ! 18: /* ! 19: * Some of the public constants are being moved to this file. ! 20: * We include it here so that what came from where is transparent. ! 21: */ ! 22: #include <scsi/scsi.h> ! 23: ! 24: #include <linux/random.h> ! 25: ! 26: ! 27: /* ! 28: * Some defs, in case these are not defined elsewhere. ! 29: */ ! 30: #ifndef TRUE ! 31: # define TRUE 1 ! 32: #endif ! 33: #ifndef FALSE ! 34: # define FALSE 0 ! 35: #endif ! 36: ! 37: ! 38: extern void scsi_make_blocked_list(void); ! 39: extern volatile int in_scan_scsis; ! 40: extern const unsigned char scsi_command_size[8]; ! 41: #define COMMAND_SIZE(opcode) scsi_command_size[((opcode) >> 5) & 7] ! 42: #define IDENTIFY_BASE 0x80 ! 43: #define IDENTIFY(can_disconnect, lun) (IDENTIFY_BASE |\ ! 44: ((can_disconnect) ? 0x40 : 0) |\ ! 45: ((lun) & 0x07)) ! 46: #define MAX_SCSI_DEVICE_CODE 10 ! 47: extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; ! 48: ! 49: ! 50: ! 51: /* ! 52: * the return of the status word will be in the following format : ! 53: * The low byte is the status returned by the SCSI command, ! 54: * with vendor specific bits masked. ! 55: * ! 56: * The next byte is the message which followed the SCSI status. ! 57: * This allows a stos to be used, since the Intel is a little ! 58: * endian machine. ! 59: * ! 60: * The final byte is a host return code, which is one of the following. ! 61: * ! 62: * IE ! 63: * lsb msb ! 64: * status msg host code ! 65: * ! 66: * Our errors returned by OUR driver, NOT SCSI message. Or'd with ! 67: * SCSI message passed back to driver <IF any>. ! 68: */ ! 69: ! 70: ! 71: #define DID_OK 0x00 /* NO error */ ! 72: #define DID_NO_CONNECT 0x01 /* Couldn't connect before timeout period */ ! 73: #define DID_BUS_BUSY 0x02 /* BUS stayed busy through time out period */ ! 74: #define DID_TIME_OUT 0x03 /* TIMED OUT for other reason */ ! 75: #define DID_BAD_TARGET 0x04 /* BAD target. */ ! 76: #define DID_ABORT 0x05 /* Told to abort for some other reason */ ! 77: #define DID_PARITY 0x06 /* Parity error */ ! 78: #define DID_ERROR 0x07 /* Internal error */ ! 79: #define DID_RESET 0x08 /* Reset by somebody. */ ! 80: #define DID_BAD_INTR 0x09 /* Got an interrupt we weren't expecting. */ ! 81: #define DRIVER_OK 0x00 /* Driver status */ ! 82: ! 83: /* ! 84: * These indicate the error that occurred, and what is available. ! 85: */ ! 86: ! 87: #define DRIVER_BUSY 0x01 ! 88: #define DRIVER_SOFT 0x02 ! 89: #define DRIVER_MEDIA 0x03 ! 90: #define DRIVER_ERROR 0x04 ! 91: ! 92: #define DRIVER_INVALID 0x05 ! 93: #define DRIVER_TIMEOUT 0x06 ! 94: #define DRIVER_HARD 0x07 ! 95: #define DRIVER_SENSE 0x08 ! 96: ! 97: #define SUGGEST_RETRY 0x10 ! 98: #define SUGGEST_ABORT 0x20 ! 99: #define SUGGEST_REMAP 0x30 ! 100: #define SUGGEST_DIE 0x40 ! 101: #define SUGGEST_SENSE 0x80 ! 102: #define SUGGEST_IS_OK 0xff ! 103: ! 104: #define DRIVER_MASK 0x0f ! 105: #define SUGGEST_MASK 0xf0 ! 106: ! 107: #define MAX_COMMAND_SIZE 12 ! 108: ! 109: /* ! 110: * SCSI command sets ! 111: */ ! 112: ! 113: #define SCSI_UNKNOWN 0 ! 114: #define SCSI_1 1 ! 115: #define SCSI_1_CCS 2 ! 116: #define SCSI_2 3 ! 117: ! 118: /* ! 119: * Every SCSI command starts with a one byte OP-code. ! 120: * The next byte's high three bits are the LUN of the ! 121: * device. Any multi-byte quantities are stored high byte ! 122: * first, and may have a 5 bit MSB in the same byte ! 123: * as the LUN. ! 124: */ ! 125: ! 126: /* ! 127: * Manufacturers list ! 128: */ ! 129: ! 130: #define SCSI_MAN_UNKNOWN 0 ! 131: #define SCSI_MAN_NEC 1 ! 132: #define SCSI_MAN_TOSHIBA 2 ! 133: #define SCSI_MAN_NEC_OLDCDR 3 ! 134: #define SCSI_MAN_SONY 4 ! 135: #define SCSI_MAN_PIONEER 5 ! 136: ! 137: /* ! 138: * As the scsi do command functions are intelligent, and may need to ! 139: * redo a command, we need to keep track of the last command ! 140: * executed on each one. ! 141: */ ! 142: ! 143: #define WAS_RESET 0x01 ! 144: #define WAS_TIMEDOUT 0x02 ! 145: #define WAS_SENSE 0x04 ! 146: #define IS_RESETTING 0x08 ! 147: #define IS_ABORTING 0x10 ! 148: #define ASKED_FOR_SENSE 0x20 ! 149: ! 150: /* ! 151: * The scsi_device struct contains what we know about each given scsi ! 152: * device. ! 153: */ ! 154: ! 155: typedef struct scsi_device { ! 156: struct scsi_device * next; /* Used for linked list */ ! 157: ! 158: unsigned char id, lun, channel; ! 159: ! 160: unsigned int manufacturer; /* Manufacturer of device, for using ! 161: * vendor-specific cmd's */ ! 162: int attached; /* # of high level drivers attached to ! 163: * this */ ! 164: int access_count; /* Count of open channels/mounts */ ! 165: struct wait_queue * device_wait;/* Used to wait if device is busy */ ! 166: struct Scsi_Host * host; ! 167: void (*scsi_request_fn)(void); /* Used to jumpstart things after an ! 168: * ioctl */ ! 169: struct scsi_cmnd *device_queue; /* queue of SCSI Command structures */ ! 170: void *hostdata; /* available to low-level driver */ ! 171: char type; ! 172: char scsi_level; ! 173: char vendor[8], model[16], rev[4]; ! 174: unsigned char current_tag; /* current tag */ ! 175: unsigned char sync_min_period; /* Not less than this period */ ! 176: unsigned char sync_max_offset; /* Not greater than this offset */ ! 177: unsigned char queue_depth; /* How deep a queue to use */ ! 178: ! 179: unsigned writeable:1; ! 180: unsigned removable:1; ! 181: unsigned random:1; ! 182: unsigned has_cmdblocks:1; ! 183: unsigned changed:1; /* Data invalid due to media change */ ! 184: unsigned busy:1; /* Used to prevent races */ ! 185: unsigned lockable:1; /* Able to prevent media removal */ ! 186: unsigned borken:1; /* Tell the Seagate driver to be ! 187: * painfully slow on this device */ ! 188: unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ ! 189: unsigned tagged_queue:1; /* SCSI-II tagged queuing enabled */ ! 190: unsigned disconnect:1; /* can disconnect */ ! 191: unsigned soft_reset:1; /* Uses soft reset option */ ! 192: unsigned sync:1; /* Negotiate for sync transfers */ ! 193: unsigned single_lun:1; /* Indicates we should only allow I/O to ! 194: * one of the luns for the device at a ! 195: * time. */ ! 196: unsigned was_reset:1; /* There was a bus reset on the bus for ! 197: * this device */ ! 198: unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN ! 199: * because we did a bus reset. */ ! 200: } Scsi_Device; ! 201: ! 202: /* ! 203: * Use these to separate status msg and our bytes ! 204: */ ! 205: ! 206: #define status_byte(result) (((result) >> 1) & 0x1f) ! 207: #define msg_byte(result) (((result) >> 8) & 0xff) ! 208: #define host_byte(result) (((result) >> 16) & 0xff) ! 209: #define driver_byte(result) (((result) >> 24) & 0xff) ! 210: #define suggestion(result) (driver_byte(result) & SUGGEST_MASK) ! 211: ! 212: #define sense_class(sense) (((sense) >> 4) & 0x7) ! 213: #define sense_error(sense) ((sense) & 0xf) ! 214: #define sense_valid(sense) ((sense) & 0x80); ! 215: ! 216: /* ! 217: * These are the SCSI devices available on the system. ! 218: */ ! 219: ! 220: extern Scsi_Device * scsi_devices; ! 221: ! 222: extern struct hd_struct * sd; ! 223: ! 224: #if defined(MAJOR_NR) && (MAJOR_NR == SCSI_DISK_MAJOR) ! 225: extern struct hd_struct * sd; ! 226: #endif ! 227: ! 228: /* ! 229: * Initializes all SCSI devices. This scans all scsi busses. ! 230: */ ! 231: ! 232: extern int scsi_dev_init (void); ! 233: ! 234: struct scatterlist { ! 235: char * address; /* Location data is to be transferred to */ ! 236: char * alt_address; /* Location of actual if address is a ! 237: * dma indirect buffer. NULL otherwise */ ! 238: unsigned int length; ! 239: }; ! 240: ! 241: #ifdef __alpha__ ! 242: # define ISA_DMA_THRESHOLD (~0UL) ! 243: #else ! 244: # define ISA_DMA_THRESHOLD (0x00ffffff) ! 245: #endif ! 246: #define CONTIGUOUS_BUFFERS(X,Y) ((X->b_data+X->b_size) == Y->b_data) ! 247: ! 248: ! 249: /* ! 250: * These are the return codes for the abort and reset functions. The mid-level ! 251: * code uses these to decide what to do next. Each of the low level abort ! 252: * and reset functions must correctly indicate what it has done. ! 253: * The descriptions are written from the point of view of the mid-level code, ! 254: * so that the return code is telling the mid-level drivers exactly what ! 255: * the low level driver has already done, and what remains to be done. ! 256: */ ! 257: ! 258: /* We did not do anything. ! 259: * Wait some more for this command to complete, and if this does not work, ! 260: * try something more serious. */ ! 261: #define SCSI_ABORT_SNOOZE 0 ! 262: ! 263: /* This means that we were able to abort the command. We have already ! 264: * called the mid-level done function, and do not expect an interrupt that ! 265: * will lead to another call to the mid-level done function for this command */ ! 266: #define SCSI_ABORT_SUCCESS 1 ! 267: ! 268: /* We called for an abort of this command, and we should get an interrupt ! 269: * when this succeeds. Thus we should not restore the timer for this ! 270: * command in the mid-level abort function. */ ! 271: #define SCSI_ABORT_PENDING 2 ! 272: ! 273: /* Unable to abort - command is currently on the bus. Grin and bear it. */ ! 274: #define SCSI_ABORT_BUSY 3 ! 275: ! 276: /* The command is not active in the low level code. Command probably ! 277: * finished. */ ! 278: #define SCSI_ABORT_NOT_RUNNING 4 ! 279: ! 280: /* Something went wrong. The low level driver will indicate the correct ! 281: * error condition when it calls scsi_done, so the mid-level abort function ! 282: * can simply wait until this comes through */ ! 283: #define SCSI_ABORT_ERROR 5 ! 284: ! 285: /* We do not know how to reset the bus, or we do not want to. Bummer. ! 286: * Anyway, just wait a little more for the command in question, and hope that ! 287: * it eventually finishes. If it never finishes, the SCSI device could ! 288: * hang, so use this with caution. */ ! 289: #define SCSI_RESET_SNOOZE 0 ! 290: ! 291: /* We do not know how to reset the bus, or we do not want to. Bummer. ! 292: * We have given up on this ever completing. The mid-level code will ! 293: * request sense information to decide how to proceed from here. */ ! 294: #define SCSI_RESET_PUNT 1 ! 295: ! 296: /* This means that we were able to reset the bus. We have restarted all of ! 297: * the commands that should be restarted, and we should be able to continue ! 298: * on normally from here. We do not expect any interrupts that will return ! 299: * DID_RESET to any of the other commands in the host_queue, and the mid-level ! 300: * code does not need to do anything special to keep the commands alive. ! 301: * If a hard reset was performed then all outstanding commands on the ! 302: * bus have been restarted. */ ! 303: #define SCSI_RESET_SUCCESS 2 ! 304: ! 305: /* We called for a reset of this bus, and we should get an interrupt ! 306: * when this succeeds. Each command should get its own status ! 307: * passed up to scsi_done, but this has not happened yet. ! 308: * If a hard reset was performed, then we expect an interrupt ! 309: * for *each* of the outstanding commands that will have the ! 310: * effect of restarting the commands. ! 311: */ ! 312: #define SCSI_RESET_PENDING 3 ! 313: ! 314: /* We did a reset, but do not expect an interrupt to signal DID_RESET. ! 315: * This tells the upper level code to request the sense info, and this ! 316: * should keep the command alive. */ ! 317: #define SCSI_RESET_WAKEUP 4 ! 318: ! 319: /* The command is not active in the low level code. Command probably ! 320: finished. */ ! 321: #define SCSI_RESET_NOT_RUNNING 5 ! 322: ! 323: /* Something went wrong, and we do not know how to fix it. */ ! 324: #define SCSI_RESET_ERROR 6 ! 325: ! 326: #define SCSI_RESET_SYNCHRONOUS 0x01 ! 327: #define SCSI_RESET_ASYNCHRONOUS 0x02 ! 328: #define SCSI_RESET_SUGGEST_BUS_RESET 0x04 ! 329: #define SCSI_RESET_SUGGEST_HOST_RESET 0x08 ! 330: /* ! 331: * This is a bitmask that is ored with one of the above codes. ! 332: * It tells the mid-level code that we did a hard reset. ! 333: */ ! 334: #define SCSI_RESET_BUS_RESET 0x100 ! 335: /* ! 336: * This is a bitmask that is ored with one of the above codes. ! 337: * It tells the mid-level code that we did a host adapter reset. ! 338: */ ! 339: #define SCSI_RESET_HOST_RESET 0x200 ! 340: /* ! 341: * Used to mask off bits and to obtain the basic action that was ! 342: * performed. ! 343: */ ! 344: #define SCSI_RESET_ACTION 0xff ! 345: ! 346: void * scsi_malloc(unsigned int); ! 347: int scsi_free(void *, unsigned int); ! 348: extern unsigned int dma_free_sectors; /* How much room do we have left */ ! 349: extern unsigned int need_isa_buffer; /* True if some devices need indirection ! 350: * buffers */ ! 351: ! 352: /* ! 353: * The Scsi_Cmnd structure is used by scsi.c internally, and for communication ! 354: * with low level drivers that support multiple outstanding commands. ! 355: */ ! 356: typedef struct scsi_pointer { ! 357: char * ptr; /* data pointer */ ! 358: int this_residual; /* left in this buffer */ ! 359: struct scatterlist *buffer; /* which buffer */ ! 360: int buffers_residual; /* how many buffers left */ ! 361: ! 362: volatile int Status; ! 363: volatile int Message; ! 364: volatile int have_data_in; ! 365: volatile int sent_command; ! 366: volatile int phase; ! 367: } Scsi_Pointer; ! 368: ! 369: typedef struct scsi_cmnd { ! 370: struct Scsi_Host * host; ! 371: Scsi_Device * device; ! 372: unsigned char target, lun, channel; ! 373: unsigned char cmd_len; ! 374: unsigned char old_cmd_len; ! 375: struct scsi_cmnd *next, *prev, *device_next, *reset_chain; ! 376: ! 377: /* These elements define the operation we are about to perform */ ! 378: unsigned char cmnd[12]; ! 379: unsigned request_bufflen; /* Actual request size */ ! 380: ! 381: void * request_buffer; /* Actual requested buffer */ ! 382: ! 383: /* These elements define the operation we ultimately want to perform */ ! 384: unsigned char data_cmnd[12]; ! 385: unsigned short old_use_sg; /* We save use_sg here when requesting ! 386: * sense info */ ! 387: unsigned short use_sg; /* Number of pieces of scatter-gather */ ! 388: unsigned short sglist_len; /* size of malloc'd scatter-gather list */ ! 389: unsigned short abort_reason;/* If the mid-level code requests an ! 390: * abort, this is the reason. */ ! 391: unsigned bufflen; /* Size of data buffer */ ! 392: void *buffer; /* Data buffer */ ! 393: ! 394: unsigned underflow; /* Return error if less than this amount is ! 395: * transfered */ ! 396: ! 397: unsigned transfersize; /* How much we are guaranteed to transfer with ! 398: * each SCSI transfer (ie, between disconnect / ! 399: * reconnects. Probably == sector size */ ! 400: ! 401: ! 402: struct request request; /* A copy of the command we are working on */ ! 403: ! 404: unsigned char sense_buffer[16]; /* Sense for this command, if needed */ ! 405: ! 406: /* ! 407: A SCSI Command is assigned a nonzero serial_number when internal_cmnd ! 408: passes it to the driver's queue command function. The serial_number ! 409: is cleared when scsi_done is entered indicating that the command has ! 410: been completed. If a timeout occurs, the serial number at the moment ! 411: of timeout is copied into serial_number_at_timeout. By subsequently ! 412: comparing the serial_number and serial_number_at_timeout fields ! 413: during abort or reset processing, we can detect whether the command ! 414: has already completed. This also detects cases where the command has ! 415: completed and the SCSI Command structure has already being reused ! 416: for another command, so that we can avoid incorrectly aborting or ! 417: resetting the new command. ! 418: */ ! 419: ! 420: unsigned long serial_number; ! 421: unsigned long serial_number_at_timeout; ! 422: ! 423: int retries; ! 424: int allowed; ! 425: int timeout_per_command, timeout_total, timeout; ! 426: ! 427: /* ! 428: * We handle the timeout differently if it happens when a reset, ! 429: * abort, etc are in process. ! 430: */ ! 431: unsigned volatile char internal_timeout; ! 432: ! 433: unsigned flags; ! 434: ! 435: /* These variables are for the cdrom only. Once we have variable size ! 436: * buffers in the buffer cache, they will go away. */ ! 437: int this_count; ! 438: /* End of special cdrom variables */ ! 439: ! 440: /* Low-level done function - can be used by low-level driver to point ! 441: * to completion function. Not used by mid/upper level code. */ ! 442: void (*scsi_done)(struct scsi_cmnd *); ! 443: void (*done)(struct scsi_cmnd *); /* Mid-level done function */ ! 444: ! 445: /* ! 446: * The following fields can be written to by the host specific code. ! 447: * Everything else should be left alone. ! 448: */ ! 449: ! 450: Scsi_Pointer SCp; /* Scratchpad used by some host adapters */ ! 451: ! 452: unsigned char * host_scribble; /* The host adapter is allowed to ! 453: * call scsi_malloc and get some memory ! 454: * and hang it here. The host adapter ! 455: * is also expected to call scsi_free ! 456: * to release this memory. (The memory ! 457: * obtained by scsi_malloc is guaranteed ! 458: * to be at an address < 16Mb). */ ! 459: ! 460: int result; /* Status code from lower level driver */ ! 461: ! 462: unsigned char tag; /* SCSI-II queued command tag */ ! 463: unsigned long pid; /* Process ID, starts at 0 */ ! 464: } Scsi_Cmnd; ! 465: ! 466: /* ! 467: * scsi_abort aborts the current command that is executing on host host. ! 468: * The error code, if non zero is returned in the host byte, otherwise ! 469: * DID_ABORT is returned in the hostbyte. ! 470: */ ! 471: ! 472: extern int scsi_abort (Scsi_Cmnd *, int code); ! 473: ! 474: extern void scsi_do_cmd (Scsi_Cmnd *, const void *cmnd , ! 475: void *buffer, unsigned bufflen, ! 476: void (*done)(struct scsi_cmnd *), ! 477: int timeout, int retries); ! 478: ! 479: ! 480: extern Scsi_Cmnd * allocate_device(struct request **, Scsi_Device *, int); ! 481: ! 482: extern Scsi_Cmnd * request_queueable(struct request *, Scsi_Device *); ! 483: extern int scsi_reset (Scsi_Cmnd *, unsigned int); ! 484: ! 485: extern int max_scsi_hosts; ! 486: ! 487: extern void proc_print_scsidevice(Scsi_Device *, char *, int *, int); ! 488: ! 489: extern void print_command(unsigned char *); ! 490: extern void print_sense(const char *, Scsi_Cmnd *); ! 491: extern void print_driverbyte(int scsiresult); ! 492: extern void print_hostbyte(int scsiresult); ! 493: ! 494: extern void scsi_mark_host_reset(struct Scsi_Host *Host); ! 495: extern void scsi_mark_bus_reset(struct Scsi_Host *Host, int channel); ! 496: ! 497: #if defined(MAJOR_NR) && (MAJOR_NR != SCSI_TAPE_MAJOR) ! 498: #include "hosts.h" ! 499: ! 500: static Scsi_Cmnd * end_scsi_request(Scsi_Cmnd * SCpnt, int uptodate, int sectors) ! 501: { ! 502: struct request * req; ! 503: struct buffer_head * bh; ! 504: ! 505: req = &SCpnt->request; ! 506: req->errors = 0; ! 507: if (!uptodate) { ! 508: #if defined(MAJOR_NR) && (MAJOR_NR == SCSI_DISK_MAJOR) ! 509: printk(DEVICE_NAME " I/O error: dev %s, sector %lu, absolute sector %lu\n", ! 510: kdevname(req->rq_dev), req->sector, ! 511: req->sector + sd[MINOR(SCpnt->request.rq_dev)].start_sect); ! 512: #else ! 513: printk(DEVICE_NAME " I/O error: dev %s, sector %lu\n", ! 514: kdevname(req->rq_dev), req->sector); ! 515: #endif ! 516: } ! 517: ! 518: do { ! 519: if ((bh = req->bh) != NULL) { ! 520: req->bh = bh->b_reqnext; ! 521: req->nr_sectors -= bh->b_size >> 9; ! 522: req->sector += bh->b_size >> 9; ! 523: bh->b_reqnext = NULL; ! 524: /* ! 525: * This is our 'MD IO has finished' event handler. ! 526: * note that b_state should be cached in a register ! 527: * anyways, so the overhead if this checking is almost ! 528: * zero. But anyways .. we never get OO for free :) ! 529: */ ! 530: if (test_bit(BH_MD, &bh->b_state)) { ! 531: struct md_personality * pers=(struct md_personality *)bh->personality; ! 532: pers->end_request(bh,uptodate); ! 533: } ! 534: /* ! 535: * the normal (nonmirrored and no RAID5) case: ! 536: */ ! 537: else { ! 538: mark_buffer_uptodate(bh, uptodate); ! 539: unlock_buffer(bh); ! 540: } ! 541: sectors -= bh->b_size >> 9; ! 542: if ((bh = req->bh) != NULL) { ! 543: req->current_nr_sectors = bh->b_size >> 9; ! 544: if (req->nr_sectors < req->current_nr_sectors) { ! 545: req->nr_sectors = req->current_nr_sectors; ! 546: printk("end_scsi_request: buffer-list destroyed\n"); ! 547: } ! 548: } ! 549: } ! 550: } while(sectors && bh); ! 551: if (req->bh){ ! 552: req->buffer = bh->b_data; ! 553: return SCpnt; ! 554: } ! 555: DEVICE_OFF(req->rq_dev); ! 556: if (req->sem != NULL) { ! 557: up(req->sem); ! 558: } ! 559: add_blkdev_randomness(MAJOR(req->rq_dev)); ! 560: ! 561: if (SCpnt->host->block) { ! 562: struct Scsi_Host * next; ! 563: ! 564: for (next = SCpnt->host->block; next != SCpnt->host; ! 565: next = next->block) ! 566: wake_up(&next->host_wait); ! 567: } ! 568: ! 569: req->rq_status = RQ_INACTIVE; ! 570: wake_up(&wait_for_request); ! 571: wake_up(&SCpnt->device->device_wait); ! 572: return NULL; ! 573: } ! 574: ! 575: ! 576: /* This is just like INIT_REQUEST, but we need to be aware of the fact ! 577: * that an interrupt may start another request, so we run this with interrupts ! 578: * turned off ! 579: */ ! 580: #define INIT_SCSI_REQUEST \ ! 581: if (!CURRENT) { \ ! 582: CLEAR_INTR; \ ! 583: restore_flags(flags); \ ! 584: return; \ ! 585: } \ ! 586: if (MAJOR(CURRENT->rq_dev) != MAJOR_NR) \ ! 587: panic(DEVICE_NAME ": request list destroyed");\ ! 588: if (CURRENT->bh) { \ ! 589: if (!buffer_locked(CURRENT->bh)) \ ! 590: panic(DEVICE_NAME ": block not locked"); \ ! 591: } ! 592: #endif ! 593: ! 594: #ifdef MACH ! 595: #define SCSI_SLEEP(QUEUE, CONDITION) { \ ! 596: if (CONDITION) { \ ! 597: struct wait_queue wait = { NULL, NULL}; \ ! 598: add_wait_queue(QUEUE, &wait); \ ! 599: for(;;) { \ ! 600: if (CONDITION) { \ ! 601: if (intr_count) \ ! 602: panic("scsi: trying to call schedule() in interrupt" \ ! 603: ", file %s, line %d.\n", __FILE__, __LINE__); \ ! 604: schedule(); \ ! 605: } \ ! 606: else \ ! 607: break; \ ! 608: } \ ! 609: remove_wait_queue(QUEUE, &wait);\ ! 610: }; } ! 611: #else /* !MACH */ ! 612: #define SCSI_SLEEP(QUEUE, CONDITION) { \ ! 613: if (CONDITION) { \ ! 614: struct wait_queue wait = { current, NULL}; \ ! 615: add_wait_queue(QUEUE, &wait); \ ! 616: for(;;) { \ ! 617: current->state = TASK_UNINTERRUPTIBLE; \ ! 618: if (CONDITION) { \ ! 619: if (intr_count) \ ! 620: panic("scsi: trying to call schedule() in interrupt" \ ! 621: ", file %s, line %d.\n", __FILE__, __LINE__); \ ! 622: schedule(); \ ! 623: } \ ! 624: else \ ! 625: break; \ ! 626: } \ ! 627: remove_wait_queue(QUEUE, &wait);\ ! 628: current->state = TASK_RUNNING; \ ! 629: }; } ! 630: #endif /* !MACH */ ! 631: #endif ! 632: ! 633: /* ! 634: * Overrides for Emacs so that we follow Linus's tabbing style. ! 635: * Emacs will notice this stuff at the end of the file and automatically ! 636: * adjust the settings for this buffer only. This must remain at the end ! 637: * of the file. ! 638: * --------------------------------------------------------------------------- ! 639: * Local variables: ! 640: * c-indent-level: 4 ! 641: * c-brace-imaginary-offset: 0 ! 642: * c-brace-offset: -4 ! 643: * c-argdecl-indent: 4 ! 644: * c-label-offset: -4 ! 645: * c-continued-statement-offset: 4 ! 646: * c-continued-brace-offset: 0 ! 647: * indent-tabs-mode: nil ! 648: * tab-width: 8 ! 649: * End: ! 650: */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.