diff options
Diffstat (limited to 'drivers/ide/ide-io.c')
-rw-r--r-- | drivers/ide/ide-io.c | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1059f809b809..d5f3c77beadd 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 */ | ||
116 | unsigned 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 | } | ||
123 | EXPORT_SYMBOL_GPL(ide_rq_bytes); | ||
124 | |||
125 | int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) | 115 | int 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 | ||
165 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 155 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
@@ -476,10 +466,14 @@ 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; |
479 | |||
480 | WARN_ON_ONCE(hwif->rq); | ||
481 | repeat: | 469 | repeat: |
482 | prev_port = hwif->host->cur_port; | 470 | prev_port = hwif->host->cur_port; |
471 | |||
472 | if (drive->dev_flags & IDE_DFLAG_BLOCKED) | ||
473 | rq = hwif->rq; | ||
474 | else | ||
475 | WARN_ON_ONCE(hwif->rq); | ||
476 | |||
483 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && | 477 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && |
484 | time_after(drive->sleep, jiffies)) { | 478 | time_after(drive->sleep, jiffies)) { |
485 | ide_unlock_port(hwif); | 479 | ide_unlock_port(hwif); |
@@ -506,43 +500,29 @@ repeat: | |||
506 | hwif->cur_dev = drive; | 500 | hwif->cur_dev = drive; |
507 | drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); | 501 | drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); |
508 | 502 | ||
509 | spin_unlock_irq(&hwif->lock); | 503 | if (rq == NULL) { |
510 | spin_lock_irq(q->queue_lock); | 504 | spin_unlock_irq(&hwif->lock); |
511 | /* | 505 | spin_lock_irq(q->queue_lock); |
512 | * we know that the queue isn't empty, but this can happen | 506 | /* |
513 | * if the q->prep_rq_fn() decides to kill a request | 507 | * we know that the queue isn't empty, but this can |
514 | */ | 508 | * happen if ->prep_rq_fn() decides to kill a request |
515 | if (!rq) | 509 | */ |
516 | rq = blk_fetch_request(drive->queue); | 510 | rq = blk_fetch_request(drive->queue); |
511 | spin_unlock_irq(q->queue_lock); | ||
512 | spin_lock_irq(&hwif->lock); | ||
517 | 513 | ||
518 | spin_unlock_irq(q->queue_lock); | 514 | if (rq == NULL) { |
519 | spin_lock_irq(&hwif->lock); | 515 | ide_unlock_port(hwif); |
520 | 516 | goto out; | |
521 | if (!rq) { | 517 | } |
522 | ide_unlock_port(hwif); | ||
523 | goto out; | ||
524 | } | 518 | } |
525 | 519 | ||
526 | /* | 520 | /* |
527 | * Sanity: don't accept a request that isn't a PM request | 521 | * Sanity: don't accept a request that isn't a PM request |
528 | * if we are currently power managed. This is very important as | 522 | * if we are currently power managed. |
529 | * blk_stop_queue() doesn't prevent the blk_fetch_request() | ||
530 | * above to return us whatever is in the queue. Since we call | ||
531 | * ide_do_request() ourselves, we end up taking requests while | ||
532 | * the queue is blocked... | ||
533 | * | ||
534 | * We let requests forced at head of queue with ide-preempt | ||
535 | * though. I hope that doesn't happen too much, hopefully not | ||
536 | * unless the subdriver triggers such a thing in its own PM | ||
537 | * state machine. | ||
538 | */ | 523 | */ |
539 | if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && | 524 | BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) && |
540 | blk_pm_request(rq) == 0 && | 525 | blk_pm_request(rq) == 0); |
541 | (rq->cmd_flags & REQ_PREEMPT) == 0) { | ||
542 | /* there should be no pending command at this point */ | ||
543 | ide_unlock_port(hwif); | ||
544 | goto plug_device; | ||
545 | } | ||
546 | 526 | ||
547 | hwif->rq = rq; | 527 | hwif->rq = rq; |
548 | 528 | ||