aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-io.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 1059f809b809..93b7886a2d6e 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -476,10 +476,14 @@ void do_ide_request(struct request_queue *q)
476 476
477 if (!ide_lock_port(hwif)) { 477 if (!ide_lock_port(hwif)) {
478 ide_hwif_t *prev_port; 478 ide_hwif_t *prev_port;
479
480 WARN_ON_ONCE(hwif->rq);
481repeat: 479repeat:
482 prev_port = hwif->host->cur_port; 480 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
483 if (drive->dev_flags & IDE_DFLAG_SLEEPING && 487 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
484 time_after(drive->sleep, jiffies)) { 488 time_after(drive->sleep, jiffies)) {
485 ide_unlock_port(hwif); 489 ide_unlock_port(hwif);
@@ -506,43 +510,29 @@ repeat:
506 hwif->cur_dev = drive; 510 hwif->cur_dev = drive;
507 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); 511 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
508 512
509 spin_unlock_irq(&hwif->lock); 513 if (rq == NULL) {
510 spin_lock_irq(q->queue_lock); 514 spin_unlock_irq(&hwif->lock);
511 /* 515 spin_lock_irq(q->queue_lock);
512 * we know that the queue isn't empty, but this can happen 516 /*
513 * if the q->prep_rq_fn() decides to kill a request 517 * we know that the queue isn't empty, but this can
514 */ 518 * happen if ->prep_rq_fn() decides to kill a request
515 if (!rq) 519 */
516 rq = blk_fetch_request(drive->queue); 520 rq = blk_fetch_request(drive->queue);
521 spin_unlock_irq(q->queue_lock);
522 spin_lock_irq(&hwif->lock);
517 523
518 spin_unlock_irq(q->queue_lock); 524 if (rq == NULL) {
519 spin_lock_irq(&hwif->lock); 525 ide_unlock_port(hwif);
520 526 goto out;
521 if (!rq) { 527 }
522 ide_unlock_port(hwif);
523 goto out;
524 } 528 }
525 529
526 /* 530 /*
527 * Sanity: don't accept a request that isn't a PM request 531 * Sanity: don't accept a request that isn't a PM request
528 * if we are currently power managed. This is very important as 532 * 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 */ 533 */
539 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && 534 BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
540 blk_pm_request(rq) == 0 && 535 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 536
547 hwif->rq = rq; 537 hwif->rq = rq;
548 538