Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cf0ebea authored by Subhash Jadavani's avatar Subhash Jadavani
Browse files

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: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent cbac2b43
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1329,9 +1329,11 @@ EXPORT_SYMBOL_GPL(part_round_stats);
#ifdef CONFIG_PM_RUNTIME
static void blk_pm_put_request(struct request *rq)
{
	if (rq->q->dev && !(rq->cmd_flags & REQ_PM) && !--rq->q->nr_pending)
	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) {}
#endif
+1 −1
Original line number Diff line number Diff line
@@ -542,7 +542,7 @@ void elv_bio_merged(struct request_queue *q, struct request *rq,
#ifdef CONFIG_PM_RUNTIME
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--;
}