aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-atapi.c21
-rw-r--r--drivers/ide/ide-cd.c64
-rw-r--r--drivers/ide/ide-disk.c10
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-floppy.c10
-rw-r--r--drivers/ide/ide-io.c43
-rw-r--r--drivers/ide/ide-lib.c2
-rw-r--r--drivers/ide/ide-tape.c12
-rw-r--r--drivers/ide/ide-taskfile.c2
-rw-r--r--drivers/ide/pdc202xx_old.c2
-rw-r--r--drivers/ide/tc86c001.c2
-rw-r--r--drivers/ide/tx4939ide.c2
12 files changed, 88 insertions, 84 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index afe5a4323879..757e5956b132 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -246,6 +246,7 @@ EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
246 */ 246 */
247void ide_retry_pc(ide_drive_t *drive) 247void ide_retry_pc(ide_drive_t *drive)
248{ 248{
249 struct request *failed_rq = drive->hwif->rq;
249 struct request *sense_rq = &drive->sense_rq; 250 struct request *sense_rq = &drive->sense_rq;
250 struct ide_atapi_pc *pc = &drive->request_sense_pc; 251 struct ide_atapi_pc *pc = &drive->request_sense_pc;
251 252
@@ -255,13 +256,22 @@ void ide_retry_pc(ide_drive_t *drive)
255 ide_init_pc(pc); 256 ide_init_pc(pc);
256 memcpy(pc->c, sense_rq->cmd, 12); 257 memcpy(pc->c, sense_rq->cmd, 12);
257 pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */ 258 pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */
258 pc->req_xfer = sense_rq->data_len; 259 pc->req_xfer = blk_rq_bytes(sense_rq);
259 260
260 if (drive->media == ide_tape) 261 if (drive->media == ide_tape)
261 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 262 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
262 263
263 if (ide_queue_sense_rq(drive, pc)) 264 /*
264 ide_complete_rq(drive, -EIO, blk_rq_bytes(drive->hwif->rq)); 265 * Push back the failed request and put request sense on top
266 * of it. The failed command will be retried after sense data
267 * is acquired.
268 */
269 blk_requeue_request(failed_rq->q, failed_rq);
270 drive->hwif->rq = NULL;
271 if (ide_queue_sense_rq(drive, pc)) {
272 blk_start_request(failed_rq);
273 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
274 }
265} 275}
266EXPORT_SYMBOL_GPL(ide_retry_pc); 276EXPORT_SYMBOL_GPL(ide_retry_pc);
267 277
@@ -303,7 +313,7 @@ int ide_cd_get_xferlen(struct request *rq)
303 return 32768; 313 return 32768;
304 else if (blk_sense_request(rq) || blk_pc_request(rq) || 314 else if (blk_sense_request(rq) || blk_pc_request(rq) ||
305 rq->cmd_type == REQ_TYPE_ATA_PC) 315 rq->cmd_type == REQ_TYPE_ATA_PC)
306 return rq->data_len; 316 return blk_rq_bytes(rq);
307 else 317 else
308 return 0; 318 return 0;
309} 319}
@@ -367,7 +377,6 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
367 /* No more interrupts */ 377 /* No more interrupts */
368 if ((stat & ATA_DRQ) == 0) { 378 if ((stat & ATA_DRQ) == 0) {
369 int uptodate, error; 379 int uptodate, error;
370 unsigned int done;
371 380
372 debug_log("Packet command completed, %d bytes transferred\n", 381 debug_log("Packet command completed, %d bytes transferred\n",
373 pc->xferred); 382 pc->xferred);
@@ -431,7 +440,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
431 error = uptodate ? 0 : -EIO; 440 error = uptodate ? 0 : -EIO;
432 } 441 }
433 442
434 ide_complete_rq(drive, error, done); 443 ide_complete_rq(drive, error, blk_rq_bytes(rq));
435 return ide_stopped; 444 return ide_stopped;
436 } 445 }
437 446
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index a75e4ee1cd17..424140c6c400 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
@@ -404,15 +404,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
404 404
405end_request: 405end_request:
406 if (stat & ATA_ERR) { 406 if (stat & ATA_ERR) {
407 struct request_queue *q = drive->queue;
408 unsigned long flags;
409
410 spin_lock_irqsave(q->queue_lock, flags);
411 blkdev_dequeue_request(rq);
412 spin_unlock_irqrestore(q->queue_lock, flags);
413
414 hwif->rq = NULL; 407 hwif->rq = NULL;
415
416 return ide_queue_sense_rq(drive, rq) ? 2 : 1; 408 return ide_queue_sense_rq(drive, rq) ? 2 : 1;
417 } else 409 } else
418 return 2; 410 return 2;
@@ -518,7 +510,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
518 error = blk_execute_rq(drive->queue, info->disk, rq, 0); 510 error = blk_execute_rq(drive->queue, info->disk, rq, 0);
519 511
520 if (buffer) 512 if (buffer)
521 *bufflen = rq->data_len; 513 *bufflen = rq->resid_len;
522 514
523 flags = rq->cmd_flags; 515 flags = rq->cmd_flags;
524 blk_put_request(rq); 516 blk_put_request(rq);
@@ -576,7 +568,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
576 struct request *rq = hwif->rq; 568 struct request *rq = hwif->rq;
577 ide_expiry_t *expiry = NULL; 569 ide_expiry_t *expiry = NULL;
578 int dma_error = 0, dma, thislen, uptodate = 0; 570 int dma_error = 0, dma, thislen, uptodate = 0;
579 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0, nsectors; 571 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
580 int sense = blk_sense_request(rq); 572 int sense = blk_sense_request(rq);
581 unsigned int timeout; 573 unsigned int timeout;
582 u16 len; 574 u16 len;
@@ -706,13 +698,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
706 698
707out_end: 699out_end:
708 if (blk_pc_request(rq) && rc == 0) { 700 if (blk_pc_request(rq) && rc == 0) {
709 unsigned int dlen = rq->data_len; 701 rq->resid_len = 0;
710 702 blk_end_request_all(rq, 0);
711 rq->data_len = 0;
712
713 if (blk_end_request(rq, 0, dlen))
714 BUG();
715
716 hwif->rq = NULL; 703 hwif->rq = NULL;
717 } else { 704 } else {
718 if (sense && uptodate) 705 if (sense && uptodate)
@@ -730,21 +717,13 @@ out_end:
730 ide_cd_error_cmd(drive, cmd); 717 ide_cd_error_cmd(drive, cmd);
731 718
732 /* make sure it's fully ended */ 719 /* make sure it's fully ended */
733 if (blk_pc_request(rq))
734 nsectors = (rq->data_len + 511) >> 9;
735 else
736 nsectors = rq->hard_nr_sectors;
737
738 if (nsectors == 0)
739 nsectors = 1;
740
741 if (blk_fs_request(rq) == 0) { 720 if (blk_fs_request(rq) == 0) {
742 rq->data_len -= (cmd->nbytes - cmd->nleft); 721 rq->resid_len -= cmd->nbytes - cmd->nleft;
743 if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE)) 722 if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
744 rq->data_len += cmd->last_xfer_len; 723 rq->resid_len += cmd->last_xfer_len;
745 } 724 }
746 725
747 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9); 726 ide_complete_rq(drive, uptodate ? 0 : -EIO, blk_rq_bytes(rq));
748 727
749 if (sense && rc == 2) 728 if (sense && rc == 2)
750 ide_error(drive, "request sense failure", stat); 729 ide_error(drive, "request sense failure", stat);
@@ -758,7 +737,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
758 struct request_queue *q = drive->queue; 737 struct request_queue *q = drive->queue;
759 int write = rq_data_dir(rq) == WRITE; 738 int write = rq_data_dir(rq) == WRITE;
760 unsigned short sectors_per_frame = 739 unsigned short sectors_per_frame =
761 queue_hardsect_size(q) >> SECTOR_BITS; 740 queue_logical_block_size(q) >> SECTOR_BITS;
762 741
763 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, "
764 "secs_per_frame: %u", 743 "secs_per_frame: %u",
@@ -777,8 +756,8 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
777 } 756 }
778 757
779 /* fs requests *must* be hardware frame aligned */ 758 /* fs requests *must* be hardware frame aligned */
780 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 759 if ((blk_rq_sectors(rq) & (sectors_per_frame - 1)) ||
781 (rq->sector & (sectors_per_frame - 1))) 760 (blk_rq_pos(rq) & (sectors_per_frame - 1)))
782 return ide_stopped; 761 return ide_stopped;
783 762
784 /* use DMA, if possible */ 763 /* use DMA, if possible */
@@ -821,7 +800,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
821 */ 800 */
822 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 801 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
823 if ((unsigned long)buf & alignment 802 if ((unsigned long)buf & alignment
824 || rq->data_len & q->dma_pad_mask 803 || blk_rq_bytes(rq) & q->dma_pad_mask
825 || object_is_on_stack(buf)) 804 || object_is_on_stack(buf))
826 drive->dma = 0; 805 drive->dma = 0;
827 } 806 }
@@ -869,15 +848,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
869 848
870 cmd.rq = rq; 849 cmd.rq = rq;
871 850
872 if (blk_fs_request(rq) || rq->data_len) { 851 if (blk_fs_request(rq) || blk_rq_bytes(rq)) {
873 ide_init_sg_cmd(&cmd, blk_fs_request(rq) ? (rq->nr_sectors << 9) 852 ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
874 : rq->data_len);
875 ide_map_sg(drive, &cmd); 853 ide_map_sg(drive, &cmd);
876 } 854 }
877 855
878 return ide_issue_pc(drive, &cmd); 856 return ide_issue_pc(drive, &cmd);
879out_end: 857out_end:
880 nsectors = rq->hard_nr_sectors; 858 nsectors = blk_rq_sectors(rq);
881 859
882 if (nsectors == 0) 860 if (nsectors == 0)
883 nsectors = 1; 861 nsectors = 1;
@@ -1043,8 +1021,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1043 /* save a private copy of the TOC capacity for error handling */ 1021 /* save a private copy of the TOC capacity for error handling */
1044 drive->probed_capacity = toc->capacity * sectors_per_frame; 1022 drive->probed_capacity = toc->capacity * sectors_per_frame;
1045 1023
1046 blk_queue_hardsect_size(drive->queue, 1024 blk_queue_logical_block_size(drive->queue,
1047 sectors_per_frame << SECTOR_BITS); 1025 sectors_per_frame << SECTOR_BITS);
1048 1026
1049 /* 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 */
1050 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, 1028 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
@@ -1360,9 +1338,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1360/* standard prep_rq_fn that builds 10 byte cmds */ 1338/* standard prep_rq_fn that builds 10 byte cmds */
1361static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) 1339static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
1362{ 1340{
1363 int hard_sect = queue_hardsect_size(q); 1341 int hard_sect = queue_logical_block_size(q);
1364 long block = (long)rq->hard_sector / (hard_sect >> 9); 1342 long block = (long)blk_rq_pos(rq) / (hard_sect >> 9);
1365 unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9); 1343 unsigned long blocks = blk_rq_sectors(rq) / (hard_sect >> 9);
1366 1344
1367 memset(rq->cmd, 0, BLK_MAX_CDB); 1345 memset(rq->cmd, 0, BLK_MAX_CDB);
1368 1346
@@ -1565,7 +1543,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1565 1543
1566 nslots = ide_cdrom_probe_capabilities(drive); 1544 nslots = ide_cdrom_probe_capabilities(drive);
1567 1545
1568 blk_queue_hardsect_size(q, CD_FRAMESIZE); 1546 blk_queue_logical_block_size(q, CD_FRAMESIZE);
1569 1547
1570 if (ide_cdrom_register(drive, nslots)) { 1548 if (ide_cdrom_register(drive, nslots)) {
1571 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"
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index c2438804d3c4..c6f7fcfb9d67 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -82,7 +82,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
82 sector_t block) 82 sector_t block)
83{ 83{
84 ide_hwif_t *hwif = drive->hwif; 84 ide_hwif_t *hwif = drive->hwif;
85 u16 nsectors = (u16)rq->nr_sectors; 85 u16 nsectors = (u16)blk_rq_sectors(rq);
86 u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); 86 u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48);
87 u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 87 u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
88 struct ide_cmd cmd; 88 struct ide_cmd cmd;
@@ -90,7 +90,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
90 ide_startstop_t rc; 90 ide_startstop_t rc;
91 91
92 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) { 92 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) {
93 if (block + rq->nr_sectors > 1ULL << 28) 93 if (block + blk_rq_sectors(rq) > 1ULL << 28)
94 dma = 0; 94 dma = 0;
95 else 95 else
96 lba48 = 0; 96 lba48 = 0;
@@ -195,9 +195,9 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
195 195
196 ledtrig_ide_activity(); 196 ledtrig_ide_activity();
197 197
198 pr_debug("%s: %sing: block=%llu, sectors=%lu, buffer=0x%08lx\n", 198 pr_debug("%s: %sing: block=%llu, sectors=%u, buffer=0x%08lx\n",
199 drive->name, rq_data_dir(rq) == READ ? "read" : "writ", 199 drive->name, rq_data_dir(rq) == READ ? "read" : "writ",
200 (unsigned long long)block, rq->nr_sectors, 200 (unsigned long long)block, blk_rq_sectors(rq),
201 (unsigned long)rq->buffer); 201 (unsigned long)rq->buffer);
202 202
203 if (hwif->rw_disk) 203 if (hwif->rw_disk)
@@ -639,7 +639,7 @@ static void ide_disk_setup(ide_drive_t *drive)
639 } 639 }
640 640
641 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, 641 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
642 q->max_sectors / 2); 642 queue_max_sectors(q) / 2);
643 643
644 if (ata_id_is_ssd(id)) 644 if (ata_id_is_ssd(id))
645 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); 645 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index d9123ecae4a9..001f68f0bb28 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -103,7 +103,7 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
103 ide_finish_cmd(drive, cmd, stat); 103 ide_finish_cmd(drive, cmd, stat);
104 else 104 else
105 ide_complete_rq(drive, 0, 105 ide_complete_rq(drive, 0,
106 cmd->rq->nr_sectors << 9); 106 blk_rq_sectors(cmd->rq) << 9);
107 return ide_stopped; 107 return ide_stopped;
108 } 108 }
109 printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n", 109 printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n",
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 537b7c558033..650981758f15 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -194,7 +194,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
194{ 194{
195 struct ide_disk_obj *floppy = drive->driver_data; 195 struct ide_disk_obj *floppy = drive->driver_data;
196 int block = sector / floppy->bs_factor; 196 int block = sector / floppy->bs_factor;
197 int blocks = rq->nr_sectors / floppy->bs_factor; 197 int blocks = blk_rq_sectors(rq) / floppy->bs_factor;
198 int cmd = rq_data_dir(rq); 198 int cmd = rq_data_dir(rq);
199 199
200 ide_debug_log(IDE_DBG_FUNC, "block: %d, blocks: %d", block, blocks); 200 ide_debug_log(IDE_DBG_FUNC, "block: %d, blocks: %d", block, blocks);
@@ -220,14 +220,14 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
220 ide_init_pc(pc); 220 ide_init_pc(pc);
221 memcpy(pc->c, rq->cmd, sizeof(pc->c)); 221 memcpy(pc->c, rq->cmd, sizeof(pc->c));
222 pc->rq = rq; 222 pc->rq = rq;
223 if (rq->data_len) { 223 if (blk_rq_bytes(rq)) {
224 pc->flags |= PC_FLAG_DMA_OK; 224 pc->flags |= PC_FLAG_DMA_OK;
225 if (rq_data_dir(rq) == WRITE) 225 if (rq_data_dir(rq) == WRITE)
226 pc->flags |= PC_FLAG_WRITING; 226 pc->flags |= PC_FLAG_WRITING;
227 } 227 }
228 /* pio will be performed by ide_pio_bytes() which handles sg fine */ 228 /* pio will be performed by ide_pio_bytes() which handles sg fine */
229 pc->buf = NULL; 229 pc->buf = NULL;
230 pc->req_xfer = pc->buf_size = rq->data_len; 230 pc->req_xfer = pc->buf_size = blk_rq_bytes(rq);
231} 231}
232 232
233static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, 233static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
@@ -259,8 +259,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
259 goto out_end; 259 goto out_end;
260 } 260 }
261 if (blk_fs_request(rq)) { 261 if (blk_fs_request(rq)) {
262 if (((long)rq->sector % floppy->bs_factor) || 262 if (((long)blk_rq_pos(rq) % floppy->bs_factor) ||
263 (rq->nr_sectors % floppy->bs_factor)) { 263 (blk_rq_sectors(rq) % floppy->bs_factor)) {
264 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", 264 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
265 drive->name); 265 drive->name);
266 goto out_end; 266 goto out_end;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 41d804065d38..bba4297f2f03 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -116,9 +116,9 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
116unsigned int ide_rq_bytes(struct request *rq) 116unsigned int ide_rq_bytes(struct request *rq)
117{ 117{
118 if (blk_pc_request(rq)) 118 if (blk_pc_request(rq))
119 return rq->data_len; 119 return blk_rq_bytes(rq);
120 else 120 else
121 return rq->hard_cur_sectors << 9; 121 return blk_rq_cur_sectors(rq) << 9;
122} 122}
123EXPORT_SYMBOL_GPL(ide_rq_bytes); 123EXPORT_SYMBOL_GPL(ide_rq_bytes);
124 124
@@ -133,7 +133,7 @@ int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
133 * and complete the whole request right now 133 * and complete the whole request right now
134 */ 134 */
135 if (blk_noretry_request(rq) && error <= 0) 135 if (blk_noretry_request(rq) && error <= 0)
136 nr_bytes = rq->hard_nr_sectors << 9; 136 nr_bytes = blk_rq_sectors(rq) << 9;
137 137
138 rc = ide_end_rq(drive, rq, error, nr_bytes); 138 rc = ide_end_rq(drive, rq, error, nr_bytes);
139 if (rc == 0) 139 if (rc == 0)
@@ -279,7 +279,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
279 279
280 if (cmd) { 280 if (cmd) {
281 if (cmd->protocol == ATA_PROT_PIO) { 281 if (cmd->protocol == ATA_PROT_PIO) {
282 ide_init_sg_cmd(cmd, rq->nr_sectors << 9); 282 ide_init_sg_cmd(cmd, blk_rq_sectors(rq) << 9);
283 ide_map_sg(drive, cmd); 283 ide_map_sg(drive, cmd);
284 } 284 }
285 285
@@ -387,7 +387,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
387 387
388 drv = *(struct ide_driver **)rq->rq_disk->private_data; 388 drv = *(struct ide_driver **)rq->rq_disk->private_data;
389 389
390 return drv->do_request(drive, rq, rq->sector); 390 return drv->do_request(drive, rq, blk_rq_pos(rq));
391 } 391 }
392 return do_special(drive); 392 return do_special(drive);
393kill_rq: 393kill_rq:
@@ -487,10 +487,10 @@ void do_ide_request(struct request_queue *q)
487 487
488 if (!ide_lock_port(hwif)) { 488 if (!ide_lock_port(hwif)) {
489 ide_hwif_t *prev_port; 489 ide_hwif_t *prev_port;
490
491 WARN_ON_ONCE(hwif->rq);
490repeat: 492repeat:
491 prev_port = hwif->host->cur_port; 493 prev_port = hwif->host->cur_port;
492 hwif->rq = NULL;
493
494 if (drive->dev_flags & IDE_DFLAG_SLEEPING && 494 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
495 time_after(drive->sleep, jiffies)) { 495 time_after(drive->sleep, jiffies)) {
496 ide_unlock_port(hwif); 496 ide_unlock_port(hwif);
@@ -519,7 +519,9 @@ repeat:
519 * we know that the queue isn't empty, but this can happen 519 * we know that the queue isn't empty, but this can happen
520 * if the q->prep_rq_fn() decides to kill a request 520 * if the q->prep_rq_fn() decides to kill a request
521 */ 521 */
522 rq = elv_next_request(drive->queue); 522 if (!rq)
523 rq = blk_fetch_request(drive->queue);
524
523 spin_unlock_irq(q->queue_lock); 525 spin_unlock_irq(q->queue_lock);
524 spin_lock_irq(&hwif->lock); 526 spin_lock_irq(&hwif->lock);
525 527
@@ -531,7 +533,7 @@ repeat:
531 /* 533 /*
532 * Sanity: don't accept a request that isn't a PM request 534 * Sanity: don't accept a request that isn't a PM request
533 * if we are currently power managed. This is very important as 535 * if we are currently power managed. This is very important as
534 * blk_stop_queue() doesn't prevent the elv_next_request() 536 * blk_stop_queue() doesn't prevent the blk_fetch_request()
535 * above to return us whatever is in the queue. Since we call 537 * above to return us whatever is in the queue. Since we call
536 * ide_do_request() ourselves, we end up taking requests while 538 * ide_do_request() ourselves, we end up taking requests while
537 * the queue is blocked... 539 * the queue is blocked...
@@ -555,8 +557,11 @@ repeat:
555 startstop = start_request(drive, rq); 557 startstop = start_request(drive, rq);
556 spin_lock_irq(&hwif->lock); 558 spin_lock_irq(&hwif->lock);
557 559
558 if (startstop == ide_stopped) 560 if (startstop == ide_stopped) {
561 rq = hwif->rq;
562 hwif->rq = NULL;
559 goto repeat; 563 goto repeat;
564 }
560 } else 565 } else
561 goto plug_device; 566 goto plug_device;
562out: 567out:
@@ -572,18 +577,24 @@ plug_device:
572plug_device_2: 577plug_device_2:
573 spin_lock_irq(q->queue_lock); 578 spin_lock_irq(q->queue_lock);
574 579
580 if (rq)
581 blk_requeue_request(q, rq);
575 if (!elv_queue_empty(q)) 582 if (!elv_queue_empty(q))
576 blk_plug_device(q); 583 blk_plug_device(q);
577} 584}
578 585
579static void ide_plug_device(ide_drive_t *drive) 586static void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
580{ 587{
581 struct request_queue *q = drive->queue; 588 struct request_queue *q = drive->queue;
582 unsigned long flags; 589 unsigned long flags;
583 590
584 spin_lock_irqsave(q->queue_lock, flags); 591 spin_lock_irqsave(q->queue_lock, flags);
592
593 if (rq)
594 blk_requeue_request(q, rq);
585 if (!elv_queue_empty(q)) 595 if (!elv_queue_empty(q))
586 blk_plug_device(q); 596 blk_plug_device(q);
597
587 spin_unlock_irqrestore(q->queue_lock, flags); 598 spin_unlock_irqrestore(q->queue_lock, flags);
588} 599}
589 600
@@ -632,6 +643,7 @@ void ide_timer_expiry (unsigned long data)
632 unsigned long flags; 643 unsigned long flags;
633 int wait = -1; 644 int wait = -1;
634 int plug_device = 0; 645 int plug_device = 0;
646 struct request *uninitialized_var(rq_in_flight);
635 647
636 spin_lock_irqsave(&hwif->lock, flags); 648 spin_lock_irqsave(&hwif->lock, flags);
637 649
@@ -693,6 +705,8 @@ void ide_timer_expiry (unsigned long data)
693 spin_lock_irq(&hwif->lock); 705 spin_lock_irq(&hwif->lock);
694 enable_irq(hwif->irq); 706 enable_irq(hwif->irq);
695 if (startstop == ide_stopped && hwif->polling == 0) { 707 if (startstop == ide_stopped && hwif->polling == 0) {
708 rq_in_flight = hwif->rq;
709 hwif->rq = NULL;
696 ide_unlock_port(hwif); 710 ide_unlock_port(hwif);
697 plug_device = 1; 711 plug_device = 1;
698 } 712 }
@@ -701,7 +715,7 @@ void ide_timer_expiry (unsigned long data)
701 715
702 if (plug_device) { 716 if (plug_device) {
703 ide_unlock_host(hwif->host); 717 ide_unlock_host(hwif->host);
704 ide_plug_device(drive); 718 ide_requeue_and_plug(drive, rq_in_flight);
705 } 719 }
706} 720}
707 721
@@ -787,6 +801,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)
787 ide_startstop_t startstop; 801 ide_startstop_t startstop;
788 irqreturn_t irq_ret = IRQ_NONE; 802 irqreturn_t irq_ret = IRQ_NONE;
789 int plug_device = 0; 803 int plug_device = 0;
804 struct request *uninitialized_var(rq_in_flight);
790 805
791 if (host->host_flags & IDE_HFLAG_SERIALIZE) { 806 if (host->host_flags & IDE_HFLAG_SERIALIZE) {
792 if (hwif != host->cur_port) 807 if (hwif != host->cur_port)
@@ -866,6 +881,8 @@ irqreturn_t ide_intr (int irq, void *dev_id)
866 */ 881 */
867 if (startstop == ide_stopped && hwif->polling == 0) { 882 if (startstop == ide_stopped && hwif->polling == 0) {
868 BUG_ON(hwif->handler); 883 BUG_ON(hwif->handler);
884 rq_in_flight = hwif->rq;
885 hwif->rq = NULL;
869 ide_unlock_port(hwif); 886 ide_unlock_port(hwif);
870 plug_device = 1; 887 plug_device = 1;
871 } 888 }
@@ -875,7 +892,7 @@ out:
875out_early: 892out_early:
876 if (plug_device) { 893 if (plug_device) {
877 ide_unlock_host(hwif->host); 894 ide_unlock_host(hwif->host);
878 ide_plug_device(drive); 895 ide_requeue_and_plug(drive, rq_in_flight);
879 } 896 }
880 897
881 return irq_ret; 898 return irq_ret;
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 2148df836ce7..e386a32dc9ba 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -96,7 +96,7 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err)
96 96
97 if (rq) 97 if (rq)
98 printk(KERN_CONT ", sector=%llu", 98 printk(KERN_CONT ", sector=%llu",
99 (unsigned long long)rq->sector); 99 (unsigned long long)blk_rq_pos(rq));
100 } 100 }
101 printk(KERN_CONT "\n"); 101 printk(KERN_CONT "\n");
102} 102}
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 203bbeac182f..d9764f0bc82f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -380,7 +380,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
380 } 380 }
381 381
382 tape->first_frame += blocks; 382 tape->first_frame += blocks;
383 rq->data_len -= blocks * tape->blk_size; 383 rq->resid_len -= blocks * tape->blk_size;
384 384
385 if (pc->error) { 385 if (pc->error) {
386 uptodate = 0; 386 uptodate = 0;
@@ -586,7 +586,7 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
586 struct ide_atapi_pc *pc, struct request *rq, 586 struct ide_atapi_pc *pc, struct request *rq,
587 u8 opcode) 587 u8 opcode)
588{ 588{
589 unsigned int length = rq->nr_sectors; 589 unsigned int length = blk_rq_sectors(rq);
590 590
591 ide_init_pc(pc); 591 ide_init_pc(pc);
592 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 592 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
@@ -617,8 +617,8 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
617 struct ide_cmd cmd; 617 struct ide_cmd cmd;
618 u8 stat; 618 u8 stat;
619 619
620 debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu\n", 620 debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n"
621 (unsigned long long)rq->sector, rq->nr_sectors); 621 (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq));
622 622
623 if (!(blk_special_request(rq) || blk_sense_request(rq))) { 623 if (!(blk_special_request(rq) || blk_sense_request(rq))) {
624 /* We do not support buffer cache originated requests. */ 624 /* We do not support buffer cache originated requests. */
@@ -892,7 +892,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
892 rq->cmd_type = REQ_TYPE_SPECIAL; 892 rq->cmd_type = REQ_TYPE_SPECIAL;
893 rq->cmd[13] = cmd; 893 rq->cmd[13] = cmd;
894 rq->rq_disk = tape->disk; 894 rq->rq_disk = tape->disk;
895 rq->sector = tape->first_frame; 895 rq->__sector = tape->first_frame;
896 896
897 if (size) { 897 if (size) {
898 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size, 898 ret = blk_rq_map_kern(drive->queue, rq, tape->buf, size,
@@ -904,7 +904,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
904 blk_execute_rq(drive->queue, tape->disk, rq, 0); 904 blk_execute_rq(drive->queue, tape->disk, rq, 0);
905 905
906 /* calculate the number of transferred bytes and update buffer state */ 906 /* calculate the number of transferred bytes and update buffer state */
907 size -= rq->data_len; 907 size -= rq->resid_len;
908 tape->cur = tape->buf; 908 tape->cur = tape->buf;
909 if (cmd == REQ_IDETAPE_READ) 909 if (cmd == REQ_IDETAPE_READ)
910 tape->valid = size; 910 tape->valid = size;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index f400eb4d4aff..a0c3e1b2f73c 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -385,7 +385,7 @@ out_end:
385 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) 385 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0)
386 ide_finish_cmd(drive, cmd, stat); 386 ide_finish_cmd(drive, cmd, stat);
387 else 387 else
388 ide_complete_rq(drive, 0, cmd->rq->nr_sectors << 9); 388 ide_complete_rq(drive, 0, blk_rq_sectors(cmd->rq) << 9);
389 return ide_stopped; 389 return ide_stopped;
390out_err: 390out_err:
391 ide_error_cmd(drive, cmd); 391 ide_error_cmd(drive, cmd);
diff --git a/drivers/ide/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index b3bc96f930a6..e24ecc87a9b1 100644
--- a/drivers/ide/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
@@ -177,7 +177,7 @@ static void pdc202xx_dma_start(ide_drive_t *drive)
177 u8 clock = inb(high_16 + 0x11); 177 u8 clock = inb(high_16 + 0x11);
178 178
179 outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11); 179 outb(clock | (hwif->channel ? 0x08 : 0x02), high_16 + 0x11);
180 word_count = (rq->nr_sectors << 8); 180 word_count = (blk_rq_sectors(rq) << 8);
181 word_count = (rq_data_dir(rq) == READ) ? 181 word_count = (rq_data_dir(rq) == READ) ?
182 word_count | 0x05000000 : 182 word_count | 0x05000000 :
183 word_count | 0x06000000; 183 word_count | 0x06000000;
diff --git a/drivers/ide/tc86c001.c b/drivers/ide/tc86c001.c
index b4cf42dc8a6f..05a93d6baecc 100644
--- a/drivers/ide/tc86c001.c
+++ b/drivers/ide/tc86c001.c
@@ -112,7 +112,7 @@ static void tc86c001_dma_start(ide_drive_t *drive)
112 ide_hwif_t *hwif = drive->hwif; 112 ide_hwif_t *hwif = drive->hwif;
113 unsigned long sc_base = hwif->config_data; 113 unsigned long sc_base = hwif->config_data;
114 unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04); 114 unsigned long twcr_port = sc_base + (drive->dn ? 0x06 : 0x04);
115 unsigned long nsectors = hwif->rq->nr_sectors; 115 unsigned long nsectors = blk_rq_sectors(hwif->rq);
116 116
117 /* 117 /*
118 * We have to manually load the sector count and size into 118 * We have to manually load the sector count and size into
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
index 564422d23976..5ca76224f6d1 100644
--- a/drivers/ide/tx4939ide.c
+++ b/drivers/ide/tx4939ide.c
@@ -307,7 +307,7 @@ static int tx4939ide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
307 tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ? 307 tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ?
308 TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1); 308 TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1);
309 309
310 tx4939ide_writew(cmd->rq->nr_sectors, base, TX4939IDE_Sec_Cnt); 310 tx4939ide_writew(blk_rq_sectors(cmd->rq), base, TX4939IDE_Sec_Cnt);
311 311
312 return 0; 312 return 0;
313} 313}