aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/block/elevator.c b/block/elevator.c
index a0ffdd943c98..eba5b04c29b1 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -34,6 +34,7 @@
34#include <linux/blktrace_api.h> 34#include <linux/blktrace_api.h>
35#include <linux/hash.h> 35#include <linux/hash.h>
36#include <linux/uaccess.h> 36#include <linux/uaccess.h>
37#include <linux/pm_runtime.h>
37 38
38#include <trace/events/block.h> 39#include <trace/events/block.h>
39 40
@@ -536,6 +537,27 @@ void elv_bio_merged(struct request_queue *q, struct request *rq,
536 e->type->ops.elevator_bio_merged_fn(q, rq, bio); 537 e->type->ops.elevator_bio_merged_fn(q, rq, bio);
537} 538}
538 539
540#ifdef CONFIG_PM_RUNTIME
541static void blk_pm_requeue_request(struct request *rq)
542{
543 if (rq->q->dev && !(rq->cmd_flags & REQ_PM))
544 rq->q->nr_pending--;
545}
546
547static void blk_pm_add_request(struct request_queue *q, struct request *rq)
548{
549 if (q->dev && !(rq->cmd_flags & REQ_PM) && q->nr_pending++ == 0 &&
550 (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING))
551 pm_request_resume(q->dev);
552}
553#else
554static inline void blk_pm_requeue_request(struct request *rq) {}
555static inline void blk_pm_add_request(struct request_queue *q,
556 struct request *rq)
557{
558}
559#endif
560
539void elv_requeue_request(struct request_queue *q, struct request *rq) 561void elv_requeue_request(struct request_queue *q, struct request *rq)
540{ 562{
541 /* 563 /*
@@ -550,6 +572,8 @@ void elv_requeue_request(struct request_queue *q, struct request *rq)
550 572
551 rq->cmd_flags &= ~REQ_STARTED; 573 rq->cmd_flags &= ~REQ_STARTED;
552 574
575 blk_pm_requeue_request(rq);
576
553 __elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE); 577 __elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE);
554} 578}
555 579
@@ -572,6 +596,8 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)
572{ 596{
573 trace_block_rq_insert(q, rq); 597 trace_block_rq_insert(q, rq);
574 598
599 blk_pm_add_request(q, rq);
600
575 rq->q = q; 601 rq->q = q;
576 602
577 if (rq->cmd_flags & REQ_SOFTBARRIER) { 603 if (rq->cmd_flags & REQ_SOFTBARRIER) {