diff options
author | Lin Ming <ming.m.lin@intel.com> | 2013-03-22 23:42:27 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-03-23 00:22:15 -0400 |
commit | c8158819d506a8aedeca53c52dfb709a0aabe011 (patch) | |
tree | acabca463a1898931cd325c415a51a819eabee00 /block/elevator.c | |
parent | 6c9546675864f51506af69eca388e5d922942c56 (diff) |
block: implement runtime pm strategy
When a request is added:
If device is suspended or is suspending and the request is not a
PM request, resume the device.
When the last request finishes:
Call pm_runtime_mark_last_busy().
When pick a request:
If device is resuming/suspending, then only PM request is allowed
to go.
The idea and API is designed by Alan Stern and described here:
http://marc.info/?l=linux-scsi&m=133727953625963&w=2
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/elevator.c')
-rw-r--r-- | block/elevator.c | 26 |
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 | ||
541 | static 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 | |||
547 | static 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 | ||
554 | static inline void blk_pm_requeue_request(struct request *rq) {} | ||
555 | static inline void blk_pm_add_request(struct request_queue *q, | ||
556 | struct request *rq) | ||
557 | { | ||
558 | } | ||
559 | #endif | ||
560 | |||
539 | void elv_requeue_request(struct request_queue *q, struct request *rq) | 561 | void 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) { |