diff options
Diffstat (limited to 'drivers/ide/ide-io.c')
-rw-r--r-- | drivers/ide/ide-io.c | 43 |
1 files changed, 30 insertions, 13 deletions
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) | |||
116 | unsigned int ide_rq_bytes(struct request *rq) | 116 | unsigned 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 | } |
123 | EXPORT_SYMBOL_GPL(ide_rq_bytes); | 123 | EXPORT_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); |
393 | kill_rq: | 393 | kill_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); | ||
490 | repeat: | 492 | repeat: |
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; |
562 | out: | 567 | out: |
@@ -572,18 +577,24 @@ plug_device: | |||
572 | plug_device_2: | 577 | plug_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 | ||
579 | static void ide_plug_device(ide_drive_t *drive) | 586 | static 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: | |||
875 | out_early: | 892 | out_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; |