Commit 3503e0acbfab0dbcd24ccadd5fe841f3f8290e81
1 parent
e18ed145c7
Exists in
master
and in
7 other branches
Revert "ide: improve handling of Power Management requests"
This reverts commit a1317f714af7aed60ddc182d0122477cbe36ee9b.
Showing 1 changed file with 32 additions and 22 deletions Side-by-side Diff
drivers/ide/ide-io.c
... | ... | @@ -466,14 +466,10 @@ |
466 | 466 | |
467 | 467 | if (!ide_lock_port(hwif)) { |
468 | 468 | ide_hwif_t *prev_port; |
469 | + | |
470 | + WARN_ON_ONCE(hwif->rq); | |
469 | 471 | repeat: |
470 | 472 | 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 | - | |
477 | 473 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && |
478 | 474 | time_after(drive->sleep, jiffies)) { |
479 | 475 | ide_unlock_port(hwif); |
480 | 476 | |
481 | 477 | |
482 | 478 | |
483 | 479 | |
... | ... | @@ -500,29 +496,43 @@ |
500 | 496 | hwif->cur_dev = drive; |
501 | 497 | drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); |
502 | 498 | |
503 | - if (rq == NULL) { | |
504 | - spin_unlock_irq(&hwif->lock); | |
505 | - spin_lock_irq(q->queue_lock); | |
506 | - /* | |
507 | - * we know that the queue isn't empty, but this can | |
508 | - * happen if ->prep_rq_fn() decides to kill a request | |
509 | - */ | |
499 | + spin_unlock_irq(&hwif->lock); | |
500 | + spin_lock_irq(q->queue_lock); | |
501 | + /* | |
502 | + * we know that the queue isn't empty, but this can happen | |
503 | + * if the q->prep_rq_fn() decides to kill a request | |
504 | + */ | |
505 | + if (!rq) | |
510 | 506 | rq = blk_fetch_request(drive->queue); |
511 | - spin_unlock_irq(q->queue_lock); | |
512 | - spin_lock_irq(&hwif->lock); | |
513 | 507 | |
514 | - if (rq == NULL) { | |
515 | - ide_unlock_port(hwif); | |
516 | - goto out; | |
517 | - } | |
508 | + spin_unlock_irq(q->queue_lock); | |
509 | + spin_lock_irq(&hwif->lock); | |
510 | + | |
511 | + if (!rq) { | |
512 | + ide_unlock_port(hwif); | |
513 | + goto out; | |
518 | 514 | } |
519 | 515 | |
520 | 516 | /* |
521 | 517 | * Sanity: don't accept a request that isn't a PM request |
522 | - * 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. | |
523 | 528 | */ |
524 | - BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) && | |
525 | - blk_pm_request(rq) == 0); | |
529 | + if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && | |
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 | + } | |
526 | 536 | |
527 | 537 | hwif->rq = rq; |
528 | 538 |