···466466467467 if (!ide_lock_port(hwif)) {468468 ide_hwif_t *prev_port;469469+470470+ WARN_ON_ONCE(hwif->rq);469471repeat:470472 prev_port = hwif->host->cur_port;471471-472472- if (drive->dev_flags & IDE_DFLAG_BLOCKED)473473- rq = hwif->rq;474474- else475475- WARN_ON_ONCE(hwif->rq);476476-477473 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&478474 time_after(drive->sleep, jiffies)) {479475 ide_unlock_port(hwif);···496500 hwif->cur_dev = drive;497501 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);498502499499- if (rq == NULL) {500500- spin_unlock_irq(&hwif->lock);501501- spin_lock_irq(q->queue_lock);502502- /*503503- * we know that the queue isn't empty, but this can504504- * happen if ->prep_rq_fn() decides to kill a request505505- */503503+ spin_unlock_irq(&hwif->lock);504504+ spin_lock_irq(q->queue_lock);505505+ /*506506+ * we know that the queue isn't empty, but this can happen507507+ * if the q->prep_rq_fn() decides to kill a request508508+ */509509+ if (!rq)506510 rq = blk_fetch_request(drive->queue);507507- spin_unlock_irq(q->queue_lock);508508- spin_lock_irq(&hwif->lock);509511510510- if (rq == NULL) {511511- ide_unlock_port(hwif);512512- goto out;513513- }512512+ spin_unlock_irq(q->queue_lock);513513+ spin_lock_irq(&hwif->lock);514514+515515+ if (!rq) {516516+ ide_unlock_port(hwif);517517+ goto out;514518 }515519516520 /*517521 * Sanity: don't accept a request that isn't a PM request518518- * if we are currently power managed.522522+ * if we are currently power managed. This is very important as523523+ * blk_stop_queue() doesn't prevent the blk_fetch_request()524524+ * above to return us whatever is in the queue. Since we call525525+ * ide_do_request() ourselves, we end up taking requests while526526+ * the queue is blocked...527527+ * 528528+ * We let requests forced at head of queue with ide-preempt529529+ * though. I hope that doesn't happen too much, hopefully not530530+ * unless the subdriver triggers such a thing in its own PM531531+ * state machine.519532 */520520- BUG_ON((drive->dev_flags & IDE_DFLAG_BLOCKED) &&521521- blk_pm_request(rq) == 0);533533+ if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&534534+ blk_pm_request(rq) == 0 &&535535+ (rq->cmd_flags & REQ_PREEMPT) == 0) {536536+ /* there should be no pending command at this point */537537+ ide_unlock_port(hwif);538538+ goto plug_device;539539+ }522540523541 hwif->rq = rq;524542