diff options
| author | Subhash Jadavani <subhashj@codeaurora.org> | 2015-12-10 17:38:22 -0800 |
|---|---|---|
| committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:02:02 -0700 |
| commit | 09ed2d9d3c0ab163954d5bd605c84ddfc76f1a99 (patch) | |
| tree | 7239925f90955cc202d2e86531c4fc818678acf6 /block | |
| parent | a627c73479155f8f0328d7bb1d0b8c9e17b7aa88 (diff) | |
block: don't allow nr_pending to go negative
nr_pending can go negative if we attempt to decrement it without matching
increment call earlier. If nr_pending goes negative, LLD's runtime suspend
might race with the ongoing request. This change allows decrementing
nr_pending only if it is non-zero.
Change-Id: I5f1e93ab0e0f950307e2e3c4f95c7cb01e83ffdd
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/blk-core.c | 6 | ||||
| -rw-r--r-- | block/elevator.c | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index d6d2bf0bf08b..979f9759b40e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1446,8 +1446,10 @@ EXPORT_SYMBOL_GPL(part_round_stats); #ifdef CONFIG_PM static void blk_pm_put_request(struct request *rq) { - if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && !--rq->q->nr_pending) - pm_runtime_mark_last_busy(rq->q->dev); + if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && rq->q->nr_pending) { + if (!--rq->q->nr_pending) + pm_runtime_mark_last_busy(rq->q->dev); + } } #else static inline void blk_pm_put_request(struct request *rq) {} diff --git a/block/elevator.c b/block/elevator.c index c3555c9c672f..226a7d84470d 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -538,7 +538,7 @@ void elv_bio_merged(struct request_queue *q, struct request *rq, #ifdef CONFIG_PM static void blk_pm_requeue_request(struct request *rq) { - if (rq->q->dev && !(rq->cmd_flags & REQ_PM)) + if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && rq->q->nr_pending) rq->q->nr_pending--; } |
