blob: 1ffc8ef203ecab83e75f2a75f1a82ce820b828bf [file] [log] [blame]
Bart Van Asschebca6b062018-09-26 14:01:03 -07001/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _BLOCK_BLK_PM_H_
4#define _BLOCK_BLK_PM_H_
5
6#include <linux/pm_runtime.h>
7
8#ifdef CONFIG_PM
9static inline void blk_pm_requeue_request(struct request *rq)
10{
11 if (rq->q->dev && !(rq->rq_flags & RQF_PM))
12 rq->q->nr_pending--;
13}
14
15static inline void blk_pm_add_request(struct request_queue *q,
16 struct request *rq)
17{
18 if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 &&
19 (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING))
20 pm_request_resume(q->dev);
21}
22
23static inline void blk_pm_put_request(struct request *rq)
24{
25 if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending)
26 pm_runtime_mark_last_busy(rq->q->dev);
27}
28#else
29static inline void blk_pm_requeue_request(struct request *rq)
30{
31}
32
33static inline void blk_pm_add_request(struct request_queue *q,
34 struct request *rq)
35{
36}
37
38static inline void blk_pm_put_request(struct request *rq)
39{
40}
41#endif
42
43#endif /* _BLOCK_BLK_PM_H_ */