aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-io.c')
-rw-r--r--drivers/ide/ide-io.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 93b7886a2d6e..db96138fefcd 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -112,16 +112,6 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
112 } 112 }
113} 113}
114 114
115/* obsolete, blk_rq_bytes() should be used instead */
116unsigned int ide_rq_bytes(struct request *rq)
117{
118 if (blk_pc_request(rq))
119 return blk_rq_bytes(rq);
120 else
121 return blk_rq_cur_sectors(rq) << 9;
122}
123EXPORT_SYMBOL_GPL(ide_rq_bytes);
124
125int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) 115int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
126{ 116{
127 ide_hwif_t *hwif = drive->hwif; 117 ide_hwif_t *hwif = drive->hwif;
@@ -152,14 +142,14 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
152 142
153 if ((media == ide_floppy || media == ide_tape) && drv_req) { 143 if ((media == ide_floppy || media == ide_tape) && drv_req) {
154 rq->errors = 0; 144 rq->errors = 0;
155 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
156 } else { 145 } else {
157 if (media == ide_tape) 146 if (media == ide_tape)
158 rq->errors = IDE_DRV_ERROR_GENERAL; 147 rq->errors = IDE_DRV_ERROR_GENERAL;
159 else if (blk_fs_request(rq) == 0 && rq->errors == 0) 148 else if (blk_fs_request(rq) == 0 && rq->errors == 0)
160 rq->errors = -EIO; 149 rq->errors = -EIO;
161 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
162 } 150 }
151
152 ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
163} 153}
164 154
165static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) 155static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
@@ -476,14 +466,10 @@ void do_ide_request(struct request_queue *q)
476 466
477 if (!ide_lock_port(hwif)) { 467 if (!ide_lock_port(hwif)) {
478 ide_hwif_t *prev_port; 468 ide_hwif_t *prev_port;
469
470 WARN_ON_ONCE(hwif->rq);
479repeat: 471repeat:
480 prev_port = hwif->host->cur_port; 472 prev_port = hwif->host->cur_port;
481
482 if (drive->dev_flags & IDE_DFLAG_BLOCKED)
483 rq = hwif->rq;
484 else
485 WARN_ON_ONCE(hwif->rq);
486
487 if (drive->dev_flags & IDE_DFLAG_SLEEPING && 473 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
488 time_after(drive->sleep, jiffies)) { 474 time_after(drive->sleep, jiffies)) {
489 ide_unlock_port(hwif); 475 ide_unlock_port(hwif);
@@ -510,29 +496,43 @@ repeat:
510 hwif->cur_dev = drive; 496 hwif->cur_dev = drive;
511 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); 497 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
512 498
513 if (rq == NULL) { 499 spin_unlock_irq(&hwif->lock);
514 spin_unlock_irq(&hwif->lock); 500 spin_lock_irq(q->queue_lock);
515 spin_lock_irq(q->queue_lock); 501 /*
516 /* 502 * we know that the queue isn't empty, but this can happen
517 * we know that the queue isn't empty, but this can 503 * if the q->prep_rq_fn() decides to kill a request
518 * happen if ->prep_rq_fn() decides to kill a request 504 */
519 */ 505 if (!rq)
520 rq = blk_fetch_request(drive->queue); 506 rq = blk_fetch_request(drive->queue);
521 spin_unlock_irq(q->queue_lock);
522 spin_lock_irq(&hwif->lock);
523 507
524 if (rq == NULL) { 508 spin_unlock_irq(q->queue_lock);
525 ide_unlock_port(hwif); 509 spin_lock_irq(&hwif->lock);
526 goto out; 510
527 } 511 if (!rq) {
512 ide_unlock_port(hwif);
513 goto out;
528 } 514 }
529 515
530 /* 516 /*
531 * Sanity: don't accept a request that isn't a PM request 517 * Sanity: don't accept a request that isn't a PM request
532 * if we are currently power managed. 518 * if we are currently power managed. This is very important as
519 * blk_stop_queue() doesn't prevent the blk_fetch_request()
520 * above to return us whatever is in the queue. Since we call
521 * ide_do_request() ourselves, we end up taking requests while
522 * the queue is blocked...
523 *
524 * We let requests forced at head of queue with ide-preempt
525 * though. I hope that doesn't happen too much, hopefully not
526 * unless the subdriver triggers such a thing in its own PM
527 * state machine.
533 */ 528 */
534 BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) && 529 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
535 blk_pm_request(rq) == 0); 530 blk_pm_request(rq) == 0 &&
531 (rq->cmd_flags & REQ_PREEMPT) == 0) {
532 /* there should be no pending command at this point */
533 ide_unlock_port(hwif);
534 goto plug_device;
535 }
536 536
537 hwif->rq = rq; 537 hwif->rq = rq;
538 538