diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 152 |
1 files changed, 48 insertions, 104 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 925eb9e245d..424140c6c40 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -182,7 +182,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
182 | (sense->information[2] << 8) | | 182 | (sense->information[2] << 8) | |
183 | (sense->information[3]); | 183 | (sense->information[3]); |
184 | 184 | ||
185 | if (drive->queue->hardsect_size == 2048) | 185 | if (queue_logical_block_size(drive->queue) == 2048) |
186 | /* device sector size is 2K */ | 186 | /* device sector size is 2K */ |
187 | sector <<= 2; | 187 | sector <<= 2; |
188 | 188 | ||
@@ -206,54 +206,25 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
206 | ide_cd_log_error(drive->name, failed_command, sense); | 206 | ide_cd_log_error(drive->name, failed_command, sense); |
207 | } | 207 | } |
208 | 208 | ||
209 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | ||
210 | struct request *failed_command) | ||
211 | { | ||
212 | struct cdrom_info *info = drive->driver_data; | ||
213 | struct request *rq = &drive->request_sense_rq; | ||
214 | |||
215 | ide_debug_log(IDE_DBG_SENSE, "enter"); | ||
216 | |||
217 | if (sense == NULL) | ||
218 | sense = &info->sense_data; | ||
219 | |||
220 | /* stuff the sense request in front of our current request */ | ||
221 | blk_rq_init(NULL, rq); | ||
222 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
223 | rq->rq_disk = info->disk; | ||
224 | |||
225 | rq->data = sense; | ||
226 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | ||
227 | rq->cmd[4] = 18; | ||
228 | rq->data_len = 18; | ||
229 | |||
230 | rq->cmd_type = REQ_TYPE_SENSE; | ||
231 | rq->cmd_flags |= REQ_PREEMPT; | ||
232 | |||
233 | /* NOTE! Save the failed command in "rq->buffer" */ | ||
234 | rq->buffer = (void *) failed_command; | ||
235 | |||
236 | if (failed_command) | ||
237 | ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x", | ||
238 | failed_command->cmd[0]); | ||
239 | |||
240 | drive->hwif->rq = NULL; | ||
241 | |||
242 | elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0); | ||
243 | } | ||
244 | |||
245 | static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) | 209 | static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) |
246 | { | 210 | { |
247 | /* | 211 | /* |
248 | * For REQ_TYPE_SENSE, "rq->buffer" points to the original | 212 | * For REQ_TYPE_SENSE, "rq->special" points to the original |
249 | * failed request | 213 | * failed request. Also, the sense data should be read |
214 | * directly from rq which might be different from the original | ||
215 | * sense buffer if it got copied during mapping. | ||
250 | */ | 216 | */ |
251 | struct request *failed = (struct request *)rq->buffer; | 217 | struct request *failed = (struct request *)rq->special; |
252 | struct cdrom_info *info = drive->driver_data; | 218 | void *sense = bio_data(rq->bio); |
253 | void *sense = &info->sense_data; | ||
254 | 219 | ||
255 | if (failed) { | 220 | if (failed) { |
256 | if (failed->sense) { | 221 | if (failed->sense) { |
222 | /* | ||
223 | * Sense is always read into drive->sense_data. | ||
224 | * Copy back if the failed request has its | ||
225 | * sense pointer set. | ||
226 | */ | ||
227 | memcpy(failed->sense, sense, 18); | ||
257 | sense = failed->sense; | 228 | sense = failed->sense; |
258 | failed->sense_len = rq->sense_len; | 229 | failed->sense_len = rq->sense_len; |
259 | } | 230 | } |
@@ -428,22 +399,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat) | |||
428 | 399 | ||
429 | /* if we got a CHECK_CONDITION status, queue a request sense command */ | 400 | /* if we got a CHECK_CONDITION status, queue a request sense command */ |
430 | if (stat & ATA_ERR) | 401 | if (stat & ATA_ERR) |
431 | cdrom_queue_request_sense(drive, NULL, NULL); | 402 | return ide_queue_sense_rq(drive, NULL) ? 2 : 1; |
432 | return 1; | 403 | return 1; |
433 | 404 | ||
434 | end_request: | 405 | end_request: |
435 | if (stat & ATA_ERR) { | 406 | if (stat & ATA_ERR) { |
436 | struct request_queue *q = drive->queue; | ||
437 | unsigned long flags; | ||
438 | |||
439 | spin_lock_irqsave(q->queue_lock, flags); | ||
440 | blkdev_dequeue_request(rq); | ||
441 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
442 | |||
443 | hwif->rq = NULL; | 407 | hwif->rq = NULL; |
444 | 408 | return ide_queue_sense_rq(drive, rq) ? 2 : 1; | |
445 | cdrom_queue_request_sense(drive, rq->sense, rq); | ||
446 | return 1; | ||
447 | } else | 409 | } else |
448 | return 2; | 410 | return 2; |
449 | } | 411 | } |
@@ -503,14 +465,8 @@ static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) | |||
503 | * and some drives don't send them. Sigh. | 465 | * and some drives don't send them. Sigh. |
504 | */ | 466 | */ |
505 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && | 467 | if (rq->cmd[0] == GPCMD_REQUEST_SENSE && |
506 | cmd->nleft > 0 && cmd->nleft <= 5) { | 468 | cmd->nleft > 0 && cmd->nleft <= 5) |
507 | unsigned int ofs = cmd->nbytes - cmd->nleft; | 469 | cmd->nleft = 0; |
508 | |||
509 | while (cmd->nleft > 0) { | ||
510 | *((u8 *)rq->data + ofs++) = 0; | ||
511 | cmd->nleft--; | ||
512 | } | ||
513 | } | ||
514 | } | 470 | } |
515 | 471 | ||
516 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, | 472 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, |
@@ -543,14 +499,18 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, | |||
543 | rq->cmd_flags |= cmd_flags; | 499 | rq->cmd_flags |= cmd_flags; |
544 | rq->timeout = timeout; | 500 | rq->timeout = timeout; |
545 | if (buffer) { | 501 | if (buffer) { |
546 | rq->data = buffer; | 502 | error = blk_rq_map_kern(drive->queue, rq, buffer, |
547 | rq->data_len = *bufflen; | 503 | *bufflen, GFP_NOIO); |
504 | if (error) { | ||
505 | blk_put_request(rq); | ||
506 | return error; | ||
507 | } | ||
548 | } | 508 | } |
549 | 509 | ||
550 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); | 510 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); |
551 | 511 | ||
552 | if (buffer) | 512 | if (buffer) |
553 | *bufflen = rq->data_len; | 513 | *bufflen = rq->resid_len; |
554 | 514 | ||
555 | flags = rq->cmd_flags; | 515 | flags = rq->cmd_flags; |
556 | blk_put_request(rq); | 516 | blk_put_request(rq); |
@@ -608,7 +568,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
608 | struct request *rq = hwif->rq; | 568 | struct request *rq = hwif->rq; |
609 | ide_expiry_t *expiry = NULL; | 569 | ide_expiry_t *expiry = NULL; |
610 | int dma_error = 0, dma, thislen, uptodate = 0; | 570 | int dma_error = 0, dma, thislen, uptodate = 0; |
611 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors; | 571 | int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0; |
612 | int sense = blk_sense_request(rq); | 572 | int sense = blk_sense_request(rq); |
613 | unsigned int timeout; | 573 | unsigned int timeout; |
614 | u16 len; | 574 | u16 len; |
@@ -738,13 +698,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
738 | 698 | ||
739 | out_end: | 699 | out_end: |
740 | if (blk_pc_request(rq) && rc == 0) { | 700 | if (blk_pc_request(rq) && rc == 0) { |
741 | unsigned int dlen = rq->data_len; | 701 | rq->resid_len = 0; |
742 | 702 | blk_end_request_all(rq, 0); | |
743 | rq->data_len = 0; | ||
744 | |||
745 | if (blk_end_request(rq, 0, dlen)) | ||
746 | BUG(); | ||
747 | |||
748 | hwif->rq = NULL; | 703 | hwif->rq = NULL; |
749 | } else { | 704 | } else { |
750 | if (sense && uptodate) | 705 | if (sense && uptodate) |
@@ -762,21 +717,13 @@ out_end: | |||
762 | ide_cd_error_cmd(drive, cmd); | 717 | ide_cd_error_cmd(drive, cmd); |
763 | 718 | ||
764 | /* make sure it's fully ended */ | 719 | /* make sure it's fully ended */ |
765 | if (blk_pc_request(rq)) | ||
766 | nsectors = (rq->data_len + 511) >> 9; | ||
767 | else | ||
768 | nsectors = rq->hard_nr_sectors; | ||
769 | |||
770 | if (nsectors == 0) | ||
771 | nsectors = 1; | ||
772 | |||
773 | if (blk_fs_request(rq) == 0) { | 720 | if (blk_fs_request(rq) == 0) { |
774 | rq->data_len -= (cmd->nbytes - cmd->nleft); | 721 | rq->resid_len -= cmd->nbytes - cmd->nleft; |
775 | if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) | 722 | if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) |
776 | rq->data_len += cmd->last_xfer_len; | 723 | rq->resid_len += cmd->last_xfer_len; |
777 | } | 724 | } |
778 | 725 | ||
779 | ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9); | 726 | ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq)); |
780 | 727 | ||
781 | if (sense && rc == 2) | 728 | if (sense && rc == 2) |
782 | ide_error(drive, "request sense failure", stat); | 729 | ide_error(drive, "request sense failure", stat); |
@@ -790,7 +737,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
790 | struct request_queue *q = drive->queue; | 737 | struct request_queue *q = drive->queue; |
791 | int write = rq_data_dir(rq) == WRITE; | 738 | int write = rq_data_dir(rq) == WRITE; |
792 | unsigned short sectors_per_frame = | 739 | unsigned short sectors_per_frame = |
793 | queue_hardsect_size(q) >> SECTOR_BITS; | 740 | queue_logical_block_size(q) >> SECTOR_BITS; |
794 | 741 | ||
795 | ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, " | 742 | ide_debug_log(IDE_DBG_RQ, "rq->cmd[0]: 0x%x, rq->cmd_flags: 0x%x, " |
796 | "secs_per_frame: %u", | 743 | "secs_per_frame: %u", |
@@ -809,8 +756,8 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
809 | } | 756 | } |
810 | 757 | ||
811 | /* fs requests *must* be hardware frame aligned */ | 758 | /* fs requests *must* be hardware frame aligned */ |
812 | if ((rq->nr_sectors & (sectors_per_frame - 1)) || | 759 | if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) || |
813 | (rq->sector & (sectors_per_frame - 1))) | 760 | (blk_rq_pos(rq) & (sectors_per_frame - 1))) |
814 | return ide_stopped; | 761 | return ide_stopped; |
815 | 762 | ||
816 | /* use DMA, if possible */ | 763 | /* use DMA, if possible */ |
@@ -838,15 +785,10 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
838 | drive->dma = 0; | 785 | drive->dma = 0; |
839 | 786 | ||
840 | /* sg request */ | 787 | /* sg request */ |
841 | if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { | 788 | if (rq->bio) { |
842 | struct request_queue *q = drive->queue; | 789 | struct request_queue *q = drive->queue; |
790 | char *buf = bio_data(rq->bio); | ||
843 | unsigned int alignment; | 791 | unsigned int alignment; |
844 | char *buf; | ||
845 | |||
846 | if (rq->bio) | ||
847 | buf = bio_data(rq->bio); | ||
848 | else | ||
849 | buf = rq->data; | ||
850 | 792 | ||
851 | drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); | 793 | drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); |
852 | 794 | ||
@@ -858,7 +800,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
858 | */ | 800 | */ |
859 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; | 801 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; |
860 | if ((unsigned long)buf & alignment | 802 | if ((unsigned long)buf & alignment |
861 | || rq->data_len & q->dma_pad_mask | 803 | || blk_rq_bytes(rq) & q->dma_pad_mask |
862 | || object_is_on_stack(buf)) | 804 | || object_is_on_stack(buf)) |
863 | drive->dma = 0; | 805 | drive->dma = 0; |
864 | } | 806 | } |
@@ -896,6 +838,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
896 | goto out_end; | 838 | goto out_end; |
897 | } | 839 | } |
898 | 840 | ||
841 | /* prepare sense request for this command */ | ||
842 | ide_prep_sense(drive, rq); | ||
843 | |||
899 | memset(&cmd, 0, sizeof(cmd)); | 844 | memset(&cmd, 0, sizeof(cmd)); |
900 | 845 | ||
901 | if (rq_data_dir(rq)) | 846 | if (rq_data_dir(rq)) |
@@ -903,15 +848,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
903 | 848 | ||
904 | cmd.rq = rq; | 849 | cmd.rq = rq; |
905 | 850 | ||
906 | if (blk_fs_request(rq) || rq->data_len) { | 851 | if (blk_fs_request(rq) || blk_rq_bytes(rq)) { |
907 | ide_init_sg_cmd(&cmd, blk_fs_request(rq) ? (rq->nr_sectors << 9) | 852 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
908 | : rq->data_len); | ||
909 | ide_map_sg(drive, &cmd); | 853 | ide_map_sg(drive, &cmd); |
910 | } | 854 | } |
911 | 855 | ||
912 | return ide_issue_pc(drive, &cmd); | 856 | return ide_issue_pc(drive, &cmd); |
913 | out_end: | 857 | out_end: |
914 | nsectors = rq->hard_nr_sectors; | 858 | nsectors = blk_rq_sectors(rq); |
915 | 859 | ||
916 | if (nsectors == 0) | 860 | if (nsectors == 0) |
917 | nsectors = 1; | 861 | nsectors = 1; |
@@ -1077,8 +1021,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1077 | /* save a private copy of the TOC capacity for error handling */ | 1021 | /* save a private copy of the TOC capacity for error handling */ |
1078 | drive->probed_capacity = toc->capacity * sectors_per_frame; | 1022 | drive->probed_capacity = toc->capacity * sectors_per_frame; |
1079 | 1023 | ||
1080 | blk_queue_hardsect_size(drive->queue, | 1024 | blk_queue_logical_block_size(drive->queue, |
1081 | sectors_per_frame << SECTOR_BITS); | 1025 | sectors_per_frame << SECTOR_BITS); |
1082 | 1026 | ||
1083 | /* first read just the header, so we know how long the TOC is */ | 1027 | /* first read just the header, so we know how long the TOC is */ |
1084 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, | 1028 | stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, |
@@ -1394,9 +1338,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1394 | /* standard prep_rq_fn that builds 10 byte cmds */ | 1338 | /* standard prep_rq_fn that builds 10 byte cmds */ |
1395 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) | 1339 | static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) |
1396 | { | 1340 | { |
1397 | int hard_sect = queue_hardsect_size(q); | 1341 | int hard_sect = queue_logical_block_size(q); |
1398 | long block = (long)rq->hard_sector / (hard_sect >> 9); | 1342 | long block = (long)blk_rq_pos(rq) / (hard_sect >> 9); |
1399 | unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9); | 1343 | unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9); |
1400 | 1344 | ||
1401 | memset(rq->cmd, 0, BLK_MAX_CDB); | 1345 | memset(rq->cmd, 0, BLK_MAX_CDB); |
1402 | 1346 | ||
@@ -1599,7 +1543,7 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
1599 | 1543 | ||
1600 | nslots = ide_cdrom_probe_capabilities(drive); | 1544 | nslots = ide_cdrom_probe_capabilities(drive); |
1601 | 1545 | ||
1602 | blk_queue_hardsect_size(q, CD_FRAMESIZE); | 1546 | blk_queue_logical_block_size(q, CD_FRAMESIZE); |
1603 | 1547 | ||
1604 | if (ide_cdrom_register(drive, nslots)) { | 1548 | if (ide_cdrom_register(drive, nslots)) { |
1605 | printk(KERN_ERR PFX "%s: %s failed to register device with the" | 1549 | printk(KERN_ERR PFX "%s: %s failed to register device with the" |