Skip to content

Commit a1317f7

Browse files
bzolnierdavem330
authored andcommitted
ide: improve handling of Power Management requests
Make hwif->rq point to PM request during PM sequence and do not allow any other types of requests to slip in (the old comment was never correct as there should be no such requests generated during PM sequence). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ba9413b commit a1317f7

1 file changed

Lines changed: 22 additions & 32 deletions

File tree

‎drivers/ide/ide-io.c‎

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,14 @@ void do_ide_request(struct request_queue *q)
476476

477477
if (!ide_lock_port(hwif)) {
478478
ide_hwif_t *prev_port;
479-
480-
WARN_ON_ONCE(hwif->rq);
481479
repeat:
482480
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+
483487
if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
484488
time_after(drive->sleep, jiffies)) {
485489
ide_unlock_port(hwif);
@@ -506,43 +510,29 @@ void do_ide_request(struct request_queue *q)
506510
hwif->cur_dev = drive;
507511
drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
508512

509-
spin_unlock_irq(&hwif->lock);
510-
spin_lock_irq(q->queue_lock);
511-
/*
512-
* we know that the queue isn't empty, but this can happen
513-
* if the q->prep_rq_fn() decides to kill a request
514-
*/
515-
if (!rq)
513+
if (rq == NULL) {
514+
spin_unlock_irq(&hwif->lock);
515+
spin_lock_irq(q->queue_lock);
516+
/*
517+
* we know that the queue isn't empty, but this can
518+
* happen if ->prep_rq_fn() decides to kill a request
519+
*/
516520
rq = blk_fetch_request(drive->queue);
521+
spin_unlock_irq(q->queue_lock);
522+
spin_lock_irq(&hwif->lock);
517523

518-
spin_unlock_irq(q->queue_lock);
519-
spin_lock_irq(&hwif->lock);
520-
521-
if (!rq) {
522-
ide_unlock_port(hwif);
523-
goto out;
524+
if (rq == NULL) {
525+
ide_unlock_port(hwif);
526+
goto out;
527+
}
524528
}
525529

526530
/*
527531
* Sanity: don't accept a request that isn't a PM request
528-
* if we are currently power managed. This is very important as
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.
532+
* if we are currently power managed.
538533
*/
539-
if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
540-
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-
}
534+
BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
535+
blk_pm_request(rq) == 0);
546536

547537
hwif->rq = rq;
548538

0 commit comments

Comments
 (0)