diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 99 |
1 files changed, 16 insertions, 83 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 5daa4dd1b018..1a7410f88249 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -53,14 +53,6 @@ | |||
53 | 53 | ||
54 | #include "ide-cd.h" | 54 | #include "ide-cd.h" |
55 | 55 | ||
56 | #define IDECD_DEBUG_LOG 1 | ||
57 | |||
58 | #if IDECD_DEBUG_LOG | ||
59 | #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) | ||
60 | #else | ||
61 | #define ide_debug_log(lvl, fmt, args...) do {} while (0) | ||
62 | #endif | ||
63 | |||
64 | static DEFINE_MUTEX(idecd_ref_mutex); | 56 | static DEFINE_MUTEX(idecd_ref_mutex); |
65 | 57 | ||
66 | static void ide_cd_release(struct kref *); | 58 | static void ide_cd_release(struct kref *); |
@@ -519,37 +511,8 @@ end_request: | |||
519 | return 1; | 511 | return 1; |
520 | } | 512 | } |
521 | 513 | ||
522 | static int cdrom_timer_expiry(ide_drive_t *drive) | 514 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *); |
523 | { | 515 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); |
524 | struct request *rq = HWGROUP(drive)->rq; | ||
525 | unsigned long wait = 0; | ||
526 | |||
527 | ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd[0]: 0x%x\n", __func__, | ||
528 | rq->cmd[0]); | ||
529 | |||
530 | /* | ||
531 | * Some commands are *slow* and normally take a long time to complete. | ||
532 | * Usually we can use the ATAPI "disconnect" to bypass this, but not all | ||
533 | * commands/drives support that. Let ide_timer_expiry keep polling us | ||
534 | * for these. | ||
535 | */ | ||
536 | switch (rq->cmd[0]) { | ||
537 | case GPCMD_BLANK: | ||
538 | case GPCMD_FORMAT_UNIT: | ||
539 | case GPCMD_RESERVE_RZONE_TRACK: | ||
540 | case GPCMD_CLOSE_TRACK: | ||
541 | case GPCMD_FLUSH_CACHE: | ||
542 | wait = ATAPI_WAIT_PC; | ||
543 | break; | ||
544 | default: | ||
545 | if (!(rq->cmd_flags & REQ_QUIET)) | ||
546 | printk(KERN_INFO PFX "cmd 0x%x timed out\n", | ||
547 | rq->cmd[0]); | ||
548 | wait = 0; | ||
549 | break; | ||
550 | } | ||
551 | return wait; | ||
552 | } | ||
553 | 516 | ||
554 | /* | 517 | /* |
555 | * Set up the device registers for transferring a packet command on DEV, | 518 | * Set up the device registers for transferring a packet command on DEV, |
@@ -559,11 +522,13 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
559 | * called when the interrupt from the drive arrives. Otherwise, HANDLER | 522 | * called when the interrupt from the drive arrives. Otherwise, HANDLER |
560 | * will be called immediately after the drive is prepared for the transfer. | 523 | * will be called immediately after the drive is prepared for the transfer. |
561 | */ | 524 | */ |
562 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | 525 | static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive) |
563 | int xferlen, | ||
564 | ide_handler_t *handler) | ||
565 | { | 526 | { |
566 | ide_hwif_t *hwif = drive->hwif; | 527 | ide_hwif_t *hwif = drive->hwif; |
528 | struct request *rq = hwif->hwgroup->rq; | ||
529 | int xferlen; | ||
530 | |||
531 | xferlen = ide_cd_get_xferlen(rq); | ||
567 | 532 | ||
568 | ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); | 533 | ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); |
569 | 534 | ||
@@ -581,13 +546,14 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
581 | drive->waiting_for_dma = 0; | 546 | drive->waiting_for_dma = 0; |
582 | 547 | ||
583 | /* packet command */ | 548 | /* packet command */ |
584 | ide_execute_command(drive, ATA_CMD_PACKET, handler, | 549 | ide_execute_command(drive, ATA_CMD_PACKET, |
585 | ATAPI_WAIT_PC, cdrom_timer_expiry); | 550 | cdrom_transfer_packet_command, |
551 | ATAPI_WAIT_PC, ide_cd_expiry); | ||
586 | return ide_started; | 552 | return ide_started; |
587 | } else { | 553 | } else { |
588 | ide_execute_pkt_cmd(drive); | 554 | ide_execute_pkt_cmd(drive); |
589 | 555 | ||
590 | return (*handler) (drive); | 556 | return cdrom_transfer_packet_command(drive); |
591 | } | 557 | } |
592 | } | 558 | } |
593 | 559 | ||
@@ -598,11 +564,10 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
598 | * there's data ready. | 564 | * there's data ready. |
599 | */ | 565 | */ |
600 | #define ATAPI_MIN_CDB_BYTES 12 | 566 | #define ATAPI_MIN_CDB_BYTES 12 |
601 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | 567 | static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive) |
602 | struct request *rq, | ||
603 | ide_handler_t *handler) | ||
604 | { | 568 | { |
605 | ide_hwif_t *hwif = drive->hwif; | 569 | ide_hwif_t *hwif = drive->hwif; |
570 | struct request *rq = hwif->hwgroup->rq; | ||
606 | int cmd_len; | 571 | int cmd_len; |
607 | ide_startstop_t startstop; | 572 | ide_startstop_t startstop; |
608 | 573 | ||
@@ -629,7 +594,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
629 | } | 594 | } |
630 | 595 | ||
631 | /* arm the interrupt handler */ | 596 | /* arm the interrupt handler */ |
632 | ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); | 597 | ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, ide_cd_expiry); |
633 | 598 | ||
634 | /* ATAPI commands get padded out to 12 bytes minimum */ | 599 | /* ATAPI commands get padded out to 12 bytes minimum */ |
635 | cmd_len = COMMAND_SIZE(rq->cmd[0]); | 600 | cmd_len = COMMAND_SIZE(rq->cmd[0]); |
@@ -717,8 +682,6 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
717 | return 1; | 682 | return 1; |
718 | } | 683 | } |
719 | 684 | ||
720 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | ||
721 | |||
722 | static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, | 685 | static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, |
723 | struct request *rq) | 686 | struct request *rq) |
724 | { | 687 | { |
@@ -761,20 +724,6 @@ static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, | |||
761 | } | 724 | } |
762 | 725 | ||
763 | /* | 726 | /* |
764 | * Routine to send a read/write packet command to the drive. This is usually | ||
765 | * called directly from cdrom_start_{read,write}(). However, for drq_interrupt | ||
766 | * devices, it is called from an interrupt when the drive is ready to accept | ||
767 | * the command. | ||
768 | */ | ||
769 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | ||
770 | { | ||
771 | struct request *rq = drive->hwif->hwgroup->rq; | ||
772 | |||
773 | /* send the command to the drive and return */ | ||
774 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | ||
775 | } | ||
776 | |||
777 | /* | ||
778 | * Fix up a possibly partially-processed request so that we can start it over | 727 | * Fix up a possibly partially-processed request so that we can start it over |
779 | * entirely, or even put it back on the request queue. | 728 | * entirely, or even put it back on the request queue. |
780 | */ | 729 | */ |
@@ -1096,7 +1045,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1096 | } else { | 1045 | } else { |
1097 | timeout = ATAPI_WAIT_PC; | 1046 | timeout = ATAPI_WAIT_PC; |
1098 | if (!blk_fs_request(rq)) | 1047 | if (!blk_fs_request(rq)) |
1099 | expiry = cdrom_timer_expiry; | 1048 | expiry = ide_cd_expiry; |
1100 | } | 1049 | } |
1101 | 1050 | ||
1102 | ide_set_handler(drive, cdrom_newpc_intr, timeout, expiry); | 1051 | ide_set_handler(drive, cdrom_newpc_intr, timeout, expiry); |
@@ -1163,13 +1112,6 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1163 | return ide_started; | 1112 | return ide_started; |
1164 | } | 1113 | } |
1165 | 1114 | ||
1166 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) | ||
1167 | { | ||
1168 | struct request *rq = HWGROUP(drive)->rq; | ||
1169 | |||
1170 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | ||
1171 | } | ||
1172 | |||
1173 | static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | 1115 | static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) |
1174 | { | 1116 | { |
1175 | 1117 | ||
@@ -1214,18 +1156,12 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1214 | static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | 1156 | static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, |
1215 | sector_t block) | 1157 | sector_t block) |
1216 | { | 1158 | { |
1217 | ide_handler_t *fn; | ||
1218 | int xferlen; | ||
1219 | |||
1220 | ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, " | 1159 | ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, " |
1221 | "rq->cmd_type: 0x%x, block: %llu\n", | 1160 | "rq->cmd_type: 0x%x, block: %llu\n", |
1222 | __func__, rq->cmd[0], rq->cmd_type, | 1161 | __func__, rq->cmd[0], rq->cmd_type, |
1223 | (unsigned long long)block); | 1162 | (unsigned long long)block); |
1224 | 1163 | ||
1225 | if (blk_fs_request(rq)) { | 1164 | if (blk_fs_request(rq)) { |
1226 | xferlen = 32768; | ||
1227 | fn = cdrom_start_rw_cont; | ||
1228 | |||
1229 | if (cdrom_start_rw(drive, rq) == ide_stopped) | 1165 | if (cdrom_start_rw(drive, rq) == ide_stopped) |
1230 | return ide_stopped; | 1166 | return ide_stopped; |
1231 | 1167 | ||
@@ -1233,9 +1169,6 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1233 | return ide_stopped; | 1169 | return ide_stopped; |
1234 | } else if (blk_sense_request(rq) || blk_pc_request(rq) || | 1170 | } else if (blk_sense_request(rq) || blk_pc_request(rq) || |
1235 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1171 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
1236 | xferlen = rq->data_len; | ||
1237 | fn = cdrom_do_newpc_cont; | ||
1238 | |||
1239 | if (!rq->timeout) | 1172 | if (!rq->timeout) |
1240 | rq->timeout = ATAPI_WAIT_PC; | 1173 | rq->timeout = ATAPI_WAIT_PC; |
1241 | 1174 | ||
@@ -1250,7 +1183,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
1250 | return ide_stopped; | 1183 | return ide_stopped; |
1251 | } | 1184 | } |
1252 | 1185 | ||
1253 | return cdrom_start_packet_command(drive, xferlen, fn); | 1186 | return cdrom_start_packet_command(drive); |
1254 | } | 1187 | } |
1255 | 1188 | ||
1256 | /* | 1189 | /* |