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>
This commit is contained in:
parent
a627c73479
commit
09ed2d9d3c
2 changed files with 5 additions and 3 deletions
|
@ -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) {}
|
||||
|
|
|
@ -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--;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue