diff options
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r-- | drivers/scsi/st.c | 245 |
1 files changed, 168 insertions, 77 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index c959bdc55f4f..7f3f317ee6ca 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -451,9 +451,23 @@ static void st_sleep_done(void *data, char *sense, int result, int resid) | |||
451 | complete(SRpnt->waiting); | 451 | complete(SRpnt->waiting); |
452 | } | 452 | } |
453 | 453 | ||
454 | static struct st_request *st_allocate_request(void) | 454 | static struct st_request *st_allocate_request(struct scsi_tape *stp) |
455 | { | 455 | { |
456 | return kzalloc(sizeof(struct st_request), GFP_KERNEL); | 456 | struct st_request *streq; |
457 | |||
458 | streq = kzalloc(sizeof(*streq), GFP_KERNEL); | ||
459 | if (streq) | ||
460 | streq->stp = stp; | ||
461 | else { | ||
462 | DEBC(printk(KERN_ERR "%s: Can't get SCSI request.\n", | ||
463 | tape_name(stp));); | ||
464 | if (signal_pending(current)) | ||
465 | stp->buffer->syscall_result = -EINTR; | ||
466 | else | ||
467 | stp->buffer->syscall_result = -EBUSY; | ||
468 | } | ||
469 | |||
470 | return streq; | ||
457 | } | 471 | } |
458 | 472 | ||
459 | static void st_release_request(struct st_request *streq) | 473 | static void st_release_request(struct st_request *streq) |
@@ -481,18 +495,10 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd | |||
481 | return NULL; | 495 | return NULL; |
482 | } | 496 | } |
483 | 497 | ||
484 | if (SRpnt == NULL) { | 498 | if (!SRpnt) { |
485 | SRpnt = st_allocate_request(); | 499 | SRpnt = st_allocate_request(STp); |
486 | if (SRpnt == NULL) { | 500 | if (!SRpnt) |
487 | DEBC( printk(KERN_ERR "%s: Can't get SCSI request.\n", | ||
488 | tape_name(STp)); ); | ||
489 | if (signal_pending(current)) | ||
490 | (STp->buffer)->syscall_result = (-EINTR); | ||
491 | else | ||
492 | (STp->buffer)->syscall_result = (-EBUSY); | ||
493 | return NULL; | 501 | return NULL; |
494 | } | ||
495 | SRpnt->stp = STp; | ||
496 | } | 502 | } |
497 | 503 | ||
498 | /* If async IO, set last_SRpnt. This ptr tells write_behind_check | 504 | /* If async IO, set last_SRpnt. This ptr tells write_behind_check |
@@ -527,6 +533,28 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd | |||
527 | return SRpnt; | 533 | return SRpnt; |
528 | } | 534 | } |
529 | 535 | ||
536 | static int st_scsi_kern_execute(struct st_request *streq, | ||
537 | const unsigned char *cmd, int data_direction, | ||
538 | void *buffer, unsigned bufflen, int timeout, | ||
539 | int retries) | ||
540 | { | ||
541 | struct scsi_tape *stp = streq->stp; | ||
542 | int ret, resid; | ||
543 | |||
544 | stp->buffer->cmdstat.have_sense = 0; | ||
545 | memcpy(streq->cmd, cmd, sizeof(streq->cmd)); | ||
546 | |||
547 | ret = scsi_execute(stp->device, cmd, data_direction, buffer, bufflen, | ||
548 | streq->sense, timeout, retries, 0, &resid); | ||
549 | if (driver_byte(ret) & DRIVER_ERROR) | ||
550 | return -EBUSY; | ||
551 | |||
552 | stp->buffer->cmdstat.midlevel_result = streq->result = ret; | ||
553 | stp->buffer->cmdstat.residual = resid; | ||
554 | stp->buffer->syscall_result = st_chk_result(stp, streq); | ||
555 | |||
556 | return 0; | ||
557 | } | ||
530 | 558 | ||
531 | /* Handle the write-behind checking (waits for completion). Returns -ENOSPC if | 559 | /* Handle the write-behind checking (waits for completion). Returns -ENOSPC if |
532 | write has been correct but EOM early warning reached, -EIO if write ended in | 560 | write has been correct but EOM early warning reached, -EIO if write ended in |
@@ -599,6 +627,7 @@ static int cross_eof(struct scsi_tape * STp, int forward) | |||
599 | { | 627 | { |
600 | struct st_request *SRpnt; | 628 | struct st_request *SRpnt; |
601 | unsigned char cmd[MAX_COMMAND_SIZE]; | 629 | unsigned char cmd[MAX_COMMAND_SIZE]; |
630 | int ret; | ||
602 | 631 | ||
603 | cmd[0] = SPACE; | 632 | cmd[0] = SPACE; |
604 | cmd[1] = 0x01; /* Space FileMarks */ | 633 | cmd[1] = 0x01; /* Space FileMarks */ |
@@ -612,19 +641,26 @@ static int cross_eof(struct scsi_tape * STp, int forward) | |||
612 | DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n", | 641 | DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n", |
613 | tape_name(STp), forward ? "forward" : "backward")); | 642 | tape_name(STp), forward ? "forward" : "backward")); |
614 | 643 | ||
615 | SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, | 644 | SRpnt = st_allocate_request(STp); |
616 | STp->device->timeout, MAX_RETRIES, 1); | ||
617 | if (!SRpnt) | 645 | if (!SRpnt) |
618 | return (STp->buffer)->syscall_result; | 646 | return STp->buffer->syscall_result; |
619 | 647 | ||
620 | st_release_request(SRpnt); | 648 | ret = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, |
621 | SRpnt = NULL; | 649 | STp->device->request_queue->rq_timeout, |
650 | MAX_RETRIES); | ||
651 | if (ret) | ||
652 | goto out; | ||
653 | |||
654 | ret = STp->buffer->syscall_result; | ||
622 | 655 | ||
623 | if ((STp->buffer)->cmdstat.midlevel_result != 0) | 656 | if ((STp->buffer)->cmdstat.midlevel_result != 0) |
624 | printk(KERN_ERR "%s: Stepping over filemark %s failed.\n", | 657 | printk(KERN_ERR "%s: Stepping over filemark %s failed.\n", |
625 | tape_name(STp), forward ? "forward" : "backward"); | 658 | tape_name(STp), forward ? "forward" : "backward"); |
626 | 659 | ||
627 | return (STp->buffer)->syscall_result; | 660 | out: |
661 | st_release_request(SRpnt); | ||
662 | |||
663 | return ret; | ||
628 | } | 664 | } |
629 | 665 | ||
630 | 666 | ||
@@ -657,7 +693,8 @@ static int st_flush_write_buffer(struct scsi_tape * STp) | |||
657 | cmd[4] = blks; | 693 | cmd[4] = blks; |
658 | 694 | ||
659 | SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE, | 695 | SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE, |
660 | STp->device->timeout, MAX_WRITE_RETRIES, 1); | 696 | STp->device->request_queue->rq_timeout, |
697 | MAX_WRITE_RETRIES, 1); | ||
661 | if (!SRpnt) | 698 | if (!SRpnt) |
662 | return (STp->buffer)->syscall_result; | 699 | return (STp->buffer)->syscall_result; |
663 | 700 | ||
@@ -844,21 +881,24 @@ static int test_ready(struct scsi_tape *STp, int do_wait) | |||
844 | int attentions, waits, max_wait, scode; | 881 | int attentions, waits, max_wait, scode; |
845 | int retval = CHKRES_READY, new_session = 0; | 882 | int retval = CHKRES_READY, new_session = 0; |
846 | unsigned char cmd[MAX_COMMAND_SIZE]; | 883 | unsigned char cmd[MAX_COMMAND_SIZE]; |
847 | struct st_request *SRpnt = NULL; | 884 | struct st_request *SRpnt; |
848 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; | 885 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; |
849 | 886 | ||
887 | SRpnt = st_allocate_request(STp); | ||
888 | if (!SRpnt) | ||
889 | return STp->buffer->syscall_result; | ||
890 | |||
850 | max_wait = do_wait ? ST_BLOCK_SECONDS : 0; | 891 | max_wait = do_wait ? ST_BLOCK_SECONDS : 0; |
851 | 892 | ||
852 | for (attentions=waits=0; ; ) { | 893 | for (attentions=waits=0; ; ) { |
853 | memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); | 894 | memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); |
854 | cmd[0] = TEST_UNIT_READY; | 895 | cmd[0] = TEST_UNIT_READY; |
855 | SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, | ||
856 | STp->long_timeout, MAX_READY_RETRIES, 1); | ||
857 | 896 | ||
858 | if (!SRpnt) { | 897 | retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, |
859 | retval = (STp->buffer)->syscall_result; | 898 | STp->long_timeout, |
899 | MAX_READY_RETRIES); | ||
900 | if (retval) | ||
860 | break; | 901 | break; |
861 | } | ||
862 | 902 | ||
863 | if (cmdstatp->have_sense) { | 903 | if (cmdstatp->have_sense) { |
864 | 904 | ||
@@ -902,8 +942,8 @@ static int test_ready(struct scsi_tape *STp, int do_wait) | |||
902 | break; | 942 | break; |
903 | } | 943 | } |
904 | 944 | ||
905 | if (SRpnt != NULL) | 945 | st_release_request(SRpnt); |
906 | st_release_request(SRpnt); | 946 | |
907 | return retval; | 947 | return retval; |
908 | } | 948 | } |
909 | 949 | ||
@@ -980,16 +1020,24 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) | |||
980 | } | 1020 | } |
981 | } | 1021 | } |
982 | 1022 | ||
1023 | SRpnt = st_allocate_request(STp); | ||
1024 | if (!SRpnt) { | ||
1025 | retval = STp->buffer->syscall_result; | ||
1026 | goto err_out; | ||
1027 | } | ||
1028 | |||
983 | if (STp->omit_blklims) | 1029 | if (STp->omit_blklims) |
984 | STp->min_block = STp->max_block = (-1); | 1030 | STp->min_block = STp->max_block = (-1); |
985 | else { | 1031 | else { |
986 | memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); | 1032 | memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); |
987 | cmd[0] = READ_BLOCK_LIMITS; | 1033 | cmd[0] = READ_BLOCK_LIMITS; |
988 | 1034 | ||
989 | SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE, | 1035 | retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE, |
990 | STp->device->timeout, MAX_READY_RETRIES, 1); | 1036 | STp->buffer->b_data, 6, |
991 | if (!SRpnt) { | 1037 | STp->device->request_queue->rq_timeout, |
992 | retval = (STp->buffer)->syscall_result; | 1038 | MAX_READY_RETRIES); |
1039 | if (retval) { | ||
1040 | st_release_request(SRpnt); | ||
993 | goto err_out; | 1041 | goto err_out; |
994 | } | 1042 | } |
995 | 1043 | ||
@@ -1013,10 +1061,12 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) | |||
1013 | cmd[0] = MODE_SENSE; | 1061 | cmd[0] = MODE_SENSE; |
1014 | cmd[4] = 12; | 1062 | cmd[4] = 12; |
1015 | 1063 | ||
1016 | SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE, | 1064 | retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE, |
1017 | STp->device->timeout, MAX_READY_RETRIES, 1); | 1065 | STp->buffer->b_data, 12, |
1018 | if (!SRpnt) { | 1066 | STp->device->request_queue->rq_timeout, |
1019 | retval = (STp->buffer)->syscall_result; | 1067 | MAX_READY_RETRIES); |
1068 | if (retval) { | ||
1069 | st_release_request(SRpnt); | ||
1020 | goto err_out; | 1070 | goto err_out; |
1021 | } | 1071 | } |
1022 | 1072 | ||
@@ -1246,10 +1296,17 @@ static int st_flush(struct file *filp, fl_owner_t id) | |||
1246 | cmd[0] = WRITE_FILEMARKS; | 1296 | cmd[0] = WRITE_FILEMARKS; |
1247 | cmd[4] = 1 + STp->two_fm; | 1297 | cmd[4] = 1 + STp->two_fm; |
1248 | 1298 | ||
1249 | SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, | 1299 | SRpnt = st_allocate_request(STp); |
1250 | STp->device->timeout, MAX_WRITE_RETRIES, 1); | ||
1251 | if (!SRpnt) { | 1300 | if (!SRpnt) { |
1252 | result = (STp->buffer)->syscall_result; | 1301 | result = STp->buffer->syscall_result; |
1302 | goto out; | ||
1303 | } | ||
1304 | |||
1305 | result = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, | ||
1306 | STp->device->request_queue->rq_timeout, | ||
1307 | MAX_WRITE_RETRIES); | ||
1308 | if (result) { | ||
1309 | st_release_request(SRpnt); | ||
1253 | goto out; | 1310 | goto out; |
1254 | } | 1311 | } |
1255 | 1312 | ||
@@ -1634,7 +1691,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
1634 | cmd[4] = blks; | 1691 | cmd[4] = blks; |
1635 | 1692 | ||
1636 | SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE, | 1693 | SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE, |
1637 | STp->device->timeout, MAX_WRITE_RETRIES, !async_write); | 1694 | STp->device->request_queue->rq_timeout, |
1695 | MAX_WRITE_RETRIES, !async_write); | ||
1638 | if (!SRpnt) { | 1696 | if (!SRpnt) { |
1639 | retval = STbp->syscall_result; | 1697 | retval = STbp->syscall_result; |
1640 | goto out; | 1698 | goto out; |
@@ -1804,7 +1862,8 @@ static long read_tape(struct scsi_tape *STp, long count, | |||
1804 | 1862 | ||
1805 | SRpnt = *aSRpnt; | 1863 | SRpnt = *aSRpnt; |
1806 | SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, | 1864 | SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, |
1807 | STp->device->timeout, MAX_RETRIES, 1); | 1865 | STp->device->request_queue->rq_timeout, |
1866 | MAX_RETRIES, 1); | ||
1808 | release_buffering(STp, 1); | 1867 | release_buffering(STp, 1); |
1809 | *aSRpnt = SRpnt; | 1868 | *aSRpnt = SRpnt; |
1810 | if (!SRpnt) | 1869 | if (!SRpnt) |
@@ -2213,7 +2272,8 @@ static int st_set_options(struct scsi_tape *STp, long options) | |||
2213 | DEBC( printk(KERN_INFO "%s: Long timeout set to %d seconds.\n", name, | 2272 | DEBC( printk(KERN_INFO "%s: Long timeout set to %d seconds.\n", name, |
2214 | (value & ~MT_ST_SET_LONG_TIMEOUT))); | 2273 | (value & ~MT_ST_SET_LONG_TIMEOUT))); |
2215 | } else { | 2274 | } else { |
2216 | STp->device->timeout = value * HZ; | 2275 | blk_queue_rq_timeout(STp->device->request_queue, |
2276 | value * HZ); | ||
2217 | DEBC( printk(KERN_INFO "%s: Normal timeout set to %d seconds.\n", | 2277 | DEBC( printk(KERN_INFO "%s: Normal timeout set to %d seconds.\n", |
2218 | name, value) ); | 2278 | name, value) ); |
2219 | } | 2279 | } |
@@ -2311,7 +2371,8 @@ static int st_set_options(struct scsi_tape *STp, long options) | |||
2311 | static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) | 2371 | static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) |
2312 | { | 2372 | { |
2313 | unsigned char cmd[MAX_COMMAND_SIZE]; | 2373 | unsigned char cmd[MAX_COMMAND_SIZE]; |
2314 | struct st_request *SRpnt = NULL; | 2374 | struct st_request *SRpnt; |
2375 | int ret; | ||
2315 | 2376 | ||
2316 | memset(cmd, 0, MAX_COMMAND_SIZE); | 2377 | memset(cmd, 0, MAX_COMMAND_SIZE); |
2317 | cmd[0] = MODE_SENSE; | 2378 | cmd[0] = MODE_SENSE; |
@@ -2320,14 +2381,17 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) | |||
2320 | cmd[2] = page; | 2381 | cmd[2] = page; |
2321 | cmd[4] = 255; | 2382 | cmd[4] = 255; |
2322 | 2383 | ||
2323 | SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_FROM_DEVICE, | 2384 | SRpnt = st_allocate_request(STp); |
2324 | STp->device->timeout, 0, 1); | 2385 | if (!SRpnt) |
2325 | if (SRpnt == NULL) | 2386 | return STp->buffer->syscall_result; |
2326 | return (STp->buffer)->syscall_result; | ||
2327 | 2387 | ||
2388 | ret = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE, | ||
2389 | STp->buffer->b_data, cmd[4], | ||
2390 | STp->device->request_queue->rq_timeout, | ||
2391 | MAX_RETRIES); | ||
2328 | st_release_request(SRpnt); | 2392 | st_release_request(SRpnt); |
2329 | 2393 | ||
2330 | return (STp->buffer)->syscall_result; | 2394 | return ret ? : STp->buffer->syscall_result; |
2331 | } | 2395 | } |
2332 | 2396 | ||
2333 | 2397 | ||
@@ -2335,9 +2399,9 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) | |||
2335 | in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */ | 2399 | in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */ |
2336 | static int write_mode_page(struct scsi_tape *STp, int page, int slow) | 2400 | static int write_mode_page(struct scsi_tape *STp, int page, int slow) |
2337 | { | 2401 | { |
2338 | int pgo; | 2402 | int pgo, timeout, ret = 0; |
2339 | unsigned char cmd[MAX_COMMAND_SIZE]; | 2403 | unsigned char cmd[MAX_COMMAND_SIZE]; |
2340 | struct st_request *SRpnt = NULL; | 2404 | struct st_request *SRpnt; |
2341 | 2405 | ||
2342 | memset(cmd, 0, MAX_COMMAND_SIZE); | 2406 | memset(cmd, 0, MAX_COMMAND_SIZE); |
2343 | cmd[0] = MODE_SELECT; | 2407 | cmd[0] = MODE_SELECT; |
@@ -2351,14 +2415,21 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow) | |||
2351 | (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP; | 2415 | (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP; |
2352 | (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; | 2416 | (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; |
2353 | 2417 | ||
2354 | SRpnt = st_do_scsi(SRpnt, STp, cmd, cmd[4], DMA_TO_DEVICE, | 2418 | SRpnt = st_allocate_request(STp); |
2355 | (slow ? STp->long_timeout : STp->device->timeout), 0, 1); | 2419 | if (!SRpnt) |
2356 | if (SRpnt == NULL) | 2420 | return ret; |
2357 | return (STp->buffer)->syscall_result; | 2421 | |
2422 | timeout = slow ? STp->long_timeout : | ||
2423 | STp->device->request_queue->rq_timeout; | ||
2424 | |||
2425 | ret = st_scsi_kern_execute(SRpnt, cmd, DMA_TO_DEVICE, | ||
2426 | STp->buffer->b_data, cmd[4], timeout, 0); | ||
2427 | if (!ret) | ||
2428 | ret = STp->buffer->syscall_result; | ||
2358 | 2429 | ||
2359 | st_release_request(SRpnt); | 2430 | st_release_request(SRpnt); |
2360 | 2431 | ||
2361 | return (STp->buffer)->syscall_result; | 2432 | return ret; |
2362 | } | 2433 | } |
2363 | 2434 | ||
2364 | 2435 | ||
@@ -2464,7 +2535,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod | |||
2464 | } | 2535 | } |
2465 | if (STp->immediate) { | 2536 | if (STp->immediate) { |
2466 | cmd[1] = 1; /* Don't wait for completion */ | 2537 | cmd[1] = 1; /* Don't wait for completion */ |
2467 | timeout = STp->device->timeout; | 2538 | timeout = STp->device->request_queue->rq_timeout; |
2468 | } | 2539 | } |
2469 | else | 2540 | else |
2470 | timeout = STp->long_timeout; | 2541 | timeout = STp->long_timeout; |
@@ -2476,13 +2547,16 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod | |||
2476 | printk(ST_DEB_MSG "%s: Loading tape.\n", name); | 2547 | printk(ST_DEB_MSG "%s: Loading tape.\n", name); |
2477 | ); | 2548 | ); |
2478 | 2549 | ||
2479 | SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, | 2550 | SRpnt = st_allocate_request(STp); |
2480 | timeout, MAX_RETRIES, 1); | ||
2481 | if (!SRpnt) | 2551 | if (!SRpnt) |
2482 | return (STp->buffer)->syscall_result; | 2552 | return STp->buffer->syscall_result; |
2553 | |||
2554 | retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, timeout, | ||
2555 | MAX_RETRIES); | ||
2556 | if (retval) | ||
2557 | goto out; | ||
2483 | 2558 | ||
2484 | retval = (STp->buffer)->syscall_result; | 2559 | retval = (STp->buffer)->syscall_result; |
2485 | st_release_request(SRpnt); | ||
2486 | 2560 | ||
2487 | if (!retval) { /* SCSI command successful */ | 2561 | if (!retval) { /* SCSI command successful */ |
2488 | 2562 | ||
@@ -2501,6 +2575,8 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod | |||
2501 | STps = &(STp->ps[STp->partition]); | 2575 | STps = &(STp->ps[STp->partition]); |
2502 | STps->drv_file = STps->drv_block = (-1); | 2576 | STps->drv_file = STps->drv_block = (-1); |
2503 | } | 2577 | } |
2578 | out: | ||
2579 | st_release_request(SRpnt); | ||
2504 | 2580 | ||
2505 | return retval; | 2581 | return retval; |
2506 | } | 2582 | } |
@@ -2638,7 +2714,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2638 | cmd[2] = (arg >> 16); | 2714 | cmd[2] = (arg >> 16); |
2639 | cmd[3] = (arg >> 8); | 2715 | cmd[3] = (arg >> 8); |
2640 | cmd[4] = arg; | 2716 | cmd[4] = arg; |
2641 | timeout = STp->device->timeout; | 2717 | timeout = STp->device->request_queue->rq_timeout; |
2642 | DEBC( | 2718 | DEBC( |
2643 | if (cmd_in == MTWEOF) | 2719 | if (cmd_in == MTWEOF) |
2644 | printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, | 2720 | printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, |
@@ -2656,7 +2732,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2656 | cmd[0] = REZERO_UNIT; | 2732 | cmd[0] = REZERO_UNIT; |
2657 | if (STp->immediate) { | 2733 | if (STp->immediate) { |
2658 | cmd[1] = 1; /* Don't wait for completion */ | 2734 | cmd[1] = 1; /* Don't wait for completion */ |
2659 | timeout = STp->device->timeout; | 2735 | timeout = STp->device->request_queue->rq_timeout; |
2660 | } | 2736 | } |
2661 | DEBC(printk(ST_DEB_MSG "%s: Rewinding tape.\n", name)); | 2737 | DEBC(printk(ST_DEB_MSG "%s: Rewinding tape.\n", name)); |
2662 | fileno = blkno = at_sm = 0; | 2738 | fileno = blkno = at_sm = 0; |
@@ -2669,7 +2745,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2669 | cmd[0] = START_STOP; | 2745 | cmd[0] = START_STOP; |
2670 | if (STp->immediate) { | 2746 | if (STp->immediate) { |
2671 | cmd[1] = 1; /* Don't wait for completion */ | 2747 | cmd[1] = 1; /* Don't wait for completion */ |
2672 | timeout = STp->device->timeout; | 2748 | timeout = STp->device->request_queue->rq_timeout; |
2673 | } | 2749 | } |
2674 | cmd[4] = 3; | 2750 | cmd[4] = 3; |
2675 | DEBC(printk(ST_DEB_MSG "%s: Retensioning tape.\n", name)); | 2751 | DEBC(printk(ST_DEB_MSG "%s: Retensioning tape.\n", name)); |
@@ -2702,7 +2778,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2702 | cmd[1] = (arg ? 1 : 0); /* Long erase with non-zero argument */ | 2778 | cmd[1] = (arg ? 1 : 0); /* Long erase with non-zero argument */ |
2703 | if (STp->immediate) { | 2779 | if (STp->immediate) { |
2704 | cmd[1] |= 2; /* Don't wait for completion */ | 2780 | cmd[1] |= 2; /* Don't wait for completion */ |
2705 | timeout = STp->device->timeout; | 2781 | timeout = STp->device->request_queue->rq_timeout; |
2706 | } | 2782 | } |
2707 | else | 2783 | else |
2708 | timeout = STp->long_timeout * 8; | 2784 | timeout = STp->long_timeout * 8; |
@@ -2754,7 +2830,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2754 | (STp->buffer)->b_data[9] = (ltmp >> 16); | 2830 | (STp->buffer)->b_data[9] = (ltmp >> 16); |
2755 | (STp->buffer)->b_data[10] = (ltmp >> 8); | 2831 | (STp->buffer)->b_data[10] = (ltmp >> 8); |
2756 | (STp->buffer)->b_data[11] = ltmp; | 2832 | (STp->buffer)->b_data[11] = ltmp; |
2757 | timeout = STp->device->timeout; | 2833 | timeout = STp->device->request_queue->rq_timeout; |
2758 | DEBC( | 2834 | DEBC( |
2759 | if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) | 2835 | if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) |
2760 | printk(ST_DEB_MSG | 2836 | printk(ST_DEB_MSG |
@@ -2776,12 +2852,15 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2776 | return (-ENOSYS); | 2852 | return (-ENOSYS); |
2777 | } | 2853 | } |
2778 | 2854 | ||
2779 | SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction, | 2855 | SRpnt = st_allocate_request(STp); |
2780 | timeout, MAX_RETRIES, 1); | ||
2781 | if (!SRpnt) | 2856 | if (!SRpnt) |
2782 | return (STp->buffer)->syscall_result; | 2857 | return (STp->buffer)->syscall_result; |
2783 | 2858 | ||
2784 | ioctl_result = (STp->buffer)->syscall_result; | 2859 | ioctl_result = st_scsi_kern_execute(SRpnt, cmd, direction, |
2860 | STp->buffer->b_data, datalen, | ||
2861 | timeout, MAX_RETRIES); | ||
2862 | if (!ioctl_result) | ||
2863 | ioctl_result = (STp->buffer)->syscall_result; | ||
2785 | 2864 | ||
2786 | if (!ioctl_result) { /* SCSI command successful */ | 2865 | if (!ioctl_result) { /* SCSI command successful */ |
2787 | st_release_request(SRpnt); | 2866 | st_release_request(SRpnt); |
@@ -2943,10 +3022,17 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti | |||
2943 | if (!logical && !STp->scsi2_logical) | 3022 | if (!logical && !STp->scsi2_logical) |
2944 | scmd[1] = 1; | 3023 | scmd[1] = 1; |
2945 | } | 3024 | } |
2946 | SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE, | 3025 | |
2947 | STp->device->timeout, MAX_READY_RETRIES, 1); | 3026 | SRpnt = st_allocate_request(STp); |
2948 | if (!SRpnt) | 3027 | if (!SRpnt) |
2949 | return (STp->buffer)->syscall_result; | 3028 | return STp->buffer->syscall_result; |
3029 | |||
3030 | result = st_scsi_kern_execute(SRpnt, scmd, DMA_FROM_DEVICE, | ||
3031 | STp->buffer->b_data, 20, | ||
3032 | STp->device->request_queue->rq_timeout, | ||
3033 | MAX_READY_RETRIES); | ||
3034 | if (result) | ||
3035 | goto out; | ||
2950 | 3036 | ||
2951 | if ((STp->buffer)->syscall_result != 0 || | 3037 | if ((STp->buffer)->syscall_result != 0 || |
2952 | (STp->device->scsi_level >= SCSI_2 && | 3038 | (STp->device->scsi_level >= SCSI_2 && |
@@ -2974,6 +3060,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti | |||
2974 | DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, | 3060 | DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, |
2975 | *block, *partition)); | 3061 | *block, *partition)); |
2976 | } | 3062 | } |
3063 | out: | ||
2977 | st_release_request(SRpnt); | 3064 | st_release_request(SRpnt); |
2978 | SRpnt = NULL; | 3065 | SRpnt = NULL; |
2979 | 3066 | ||
@@ -3045,13 +3132,17 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition | |||
3045 | } | 3132 | } |
3046 | if (STp->immediate) { | 3133 | if (STp->immediate) { |
3047 | scmd[1] |= 1; /* Don't wait for completion */ | 3134 | scmd[1] |= 1; /* Don't wait for completion */ |
3048 | timeout = STp->device->timeout; | 3135 | timeout = STp->device->request_queue->rq_timeout; |
3049 | } | 3136 | } |
3050 | 3137 | ||
3051 | SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE, | 3138 | SRpnt = st_allocate_request(STp); |
3052 | timeout, MAX_READY_RETRIES, 1); | ||
3053 | if (!SRpnt) | 3139 | if (!SRpnt) |
3054 | return (STp->buffer)->syscall_result; | 3140 | return STp->buffer->syscall_result; |
3141 | |||
3142 | result = st_scsi_kern_execute(SRpnt, scmd, DMA_NONE, NULL, 0, | ||
3143 | timeout, MAX_READY_RETRIES); | ||
3144 | if (result) | ||
3145 | goto out; | ||
3055 | 3146 | ||
3056 | STps->drv_block = STps->drv_file = (-1); | 3147 | STps->drv_block = STps->drv_file = (-1); |
3057 | STps->eof = ST_NOEOF; | 3148 | STps->eof = ST_NOEOF; |
@@ -3076,7 +3167,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition | |||
3076 | STps->drv_block = STps->drv_file = 0; | 3167 | STps->drv_block = STps->drv_file = 0; |
3077 | result = 0; | 3168 | result = 0; |
3078 | } | 3169 | } |
3079 | 3170 | out: | |
3080 | st_release_request(SRpnt); | 3171 | st_release_request(SRpnt); |
3081 | SRpnt = NULL; | 3172 | SRpnt = NULL; |
3082 | 3173 | ||
@@ -4029,7 +4120,7 @@ static int st_probe(struct device *dev) | |||
4029 | tpnt->partition = 0; | 4120 | tpnt->partition = 0; |
4030 | tpnt->new_partition = 0; | 4121 | tpnt->new_partition = 0; |
4031 | tpnt->nbr_partitions = 0; | 4122 | tpnt->nbr_partitions = 0; |
4032 | tpnt->device->timeout = ST_TIMEOUT; | 4123 | blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT); |
4033 | tpnt->long_timeout = ST_LONG_TIMEOUT; | 4124 | tpnt->long_timeout = ST_LONG_TIMEOUT; |
4034 | tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; | 4125 | tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; |
4035 | 4126 | ||