From: Lin Ming <ming.m.lin@intel.com>
To: Jens Axboe <axboe@kernel.dk>,
Alan Stern <stern@rowland.harvard.edu>,
Jeff Moyer <jmoyer@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
linux-scsi@vger.kernel.org, Lin Ming <ming.m.lin@intel.com>
Subject: [RFC v2 PATCH 2/4] block: add queue runtime pm callbacks
Date: Thu, 17 May 2012 23:48:04 +0800 [thread overview]
Message-ID: <1337269686-3781-3-git-send-email-ming.m.lin@intel.com> (raw)
In-Reply-To: <1337269686-3781-1-git-send-email-ming.m.lin@intel.com>
Add runtime pm suspend/resume callbacks to request queue.
As an example, implement these callbacks in sd driver.
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
---
block/blk-settings.c | 8 ++++++++
drivers/scsi/sd.c | 21 +++++++++++++++++++++
include/linux/blkdev.h | 6 ++++++
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index d3234fc..120d9fc 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -99,6 +99,14 @@ void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn)
}
EXPORT_SYMBOL_GPL(blk_queue_lld_busy);
+void blk_queue_runtime_pm(struct request_queue *q,
+ runtime_pm_fn *suspend_fn, runtime_pm_fn *resume_fn)
+{
+ q->runtime_suspend = suspend_fn;
+ q->runtime_resume = resume_fn;
+}
+EXPORT_SYMBOL_GPL(blk_queue_runtime_pm);
+
/**
* blk_set_default_limits - reset limits to default values
* @lim: the queue_limits structure to reset
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 1205a8b..0335cde 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -938,6 +938,25 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
return scsi_prep_return(q, rq, ret);
}
+static int sd_block_runtime_suspend(struct request_queue *q)
+{
+ struct scsi_device *sdp = q->queuedata;
+
+ pm_runtime_mark_last_busy(&sdp->sdev_gendev);
+ pm_runtime_put_autosuspend(&sdp->sdev_gendev);
+
+ return 0;
+}
+
+static int sd_block_runtime_resume(struct request_queue *q)
+{
+ struct scsi_device *sdp = q->queuedata;
+
+ pm_runtime_get(&sdp->sdev_gendev);
+
+ return 0;
+}
+
/**
* sd_open - open a scsi disk device
* @inode: only i_rdev member may be used
@@ -2616,6 +2635,8 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
blk_queue_unprep_rq(sdp->request_queue, sd_unprep_fn);
+ blk_queue_runtime_pm(sdp->request_queue,
+ sd_block_runtime_suspend, sd_block_runtime_resume);
gd->driverfs_dev = &sdp->sdev_gendev;
gd->flags = GENHD_FL_EXT_DEVT;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2aa2466..f52f518 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -216,6 +216,7 @@ typedef void (softirq_done_fn)(struct request *);
typedef int (dma_drain_needed_fn)(struct request *);
typedef int (lld_busy_fn) (struct request_queue *q);
typedef int (bsg_job_fn) (struct bsg_job *);
+typedef int (runtime_pm_fn) (struct request_queue *q);
enum blk_eh_timer_return {
BLK_EH_NOT_HANDLED,
@@ -289,6 +290,9 @@ struct request_queue {
rq_timed_out_fn *rq_timed_out_fn;
dma_drain_needed_fn *dma_drain_needed;
lld_busy_fn *lld_busy_fn;
+ runtime_pm_fn *runtime_suspend;
+ runtime_pm_fn *runtime_resume;
+ int rpm_status;
/*
* Dispatch queue sorting
@@ -855,6 +859,8 @@ extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
extern void blk_queue_unprep_rq(struct request_queue *, unprep_rq_fn *ufn);
extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *);
+extern void blk_queue_runtime_pm(struct request_queue *q,
+ runtime_pm_fn *, runtime_pm_fn *);
extern void blk_queue_dma_alignment(struct request_queue *, int);
extern void blk_queue_update_dma_alignment(struct request_queue *, int);
extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
--
1.7.2.5
next prev parent reply other threads:[~2012-05-17 15:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 15:48 [RFC v2 PATCH 0/4]: block layer runtime pm Lin Ming
2012-05-17 15:48 ` [RFC v2 PATCH 1/4] block: add a flag to identify PM request Lin Ming
2012-05-17 17:46 ` Alan Stern
2012-05-17 15:48 ` Lin Ming [this message]
2012-05-17 18:29 ` [RFC v2 PATCH 2/4] block: add queue runtime pm callbacks Alan Stern
2012-05-17 18:56 ` Alan Stern
2012-05-18 14:53 ` Lin Ming
2012-05-21 14:41 ` Lin Ming
2012-05-21 15:00 ` Alan Stern
2012-05-21 15:14 ` Lin Ming
2012-05-21 18:32 ` Alan Stern
2012-05-24 10:19 ` Lin Ming
2012-05-24 14:52 ` Alan Stern
2012-05-22 6:12 ` Lin Ming
2012-05-22 15:56 ` Alan Stern
2012-05-23 8:41 ` Lin Ming
2012-05-23 14:58 ` Alan Stern
2012-05-23 15:59 ` Lin Ming
2012-06-05 17:27 ` Alan Stern
2012-06-06 14:26 ` Lin Ming
2012-05-17 15:48 ` [RFC v2 PATCH 3/4] block: implement block layer runtime pm Lin Ming
2012-05-17 15:48 ` [RFC v2 PATCH 4/4] [SCSI] sd: change to auto suspend mode Lin Ming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1337269686-3781-3-git-send-email-ming.m.lin@intel.com \
--to=ming.m.lin@intel.com \
--cc=axboe@kernel.dk \
--cc=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox