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

Commit 55fe6b0e authored by Veerabhadrarao Badiganti's avatar Veerabhadrarao Badiganti Committed by Gerrit - the friendly Code Review server
Browse files

mmc: card: Call blk_requeue_request() with queue-lock held



blk_requeue_request() must be called with queue lock held.

If it is called without this lock then there is a chance that block-
queue would be accessed simultaneously by more than one entity (say,
request completion & re-queue) and both can mess-up the queue
pointers which can result in unexpected results.

Change-Id: If81711ecf65a185f4c8dc19b8568621460c93db8
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent 9486b04b
Loading
Loading
Loading
Loading
+12 −5
Original line number Original line Diff line number Diff line
@@ -3196,11 +3196,11 @@ static struct mmc_cmdq_req *mmc_blk_cmdq_rw_prep(
static void mmc_blk_cmdq_requeue_rw_rq(struct mmc_queue *mq,
static void mmc_blk_cmdq_requeue_rw_rq(struct mmc_queue *mq,
				struct request *req)
				struct request *req)
{
{
	struct mmc_card *card = mq->card;
	struct request_queue *q = req->q;
	struct mmc_host *host = card->host;


	blk_requeue_request(req->q, req);
	spin_lock_irq(q->queue_lock);
	mmc_put_card(host->card);
	blk_requeue_request(q, req);
	spin_unlock_irq(q->queue_lock);
}
}


static int mmc_blk_cmdq_issue_rw_rq(struct mmc_queue *mq, struct request *req)
static int mmc_blk_cmdq_issue_rw_rq(struct mmc_queue *mq, struct request *req)
@@ -4090,9 +4090,16 @@ static int mmc_blk_cmdq_issue_rq(struct mmc_queue *mq, struct request *req)
			 * If issuing of the request fails with eitehr EBUSY or
			 * If issuing of the request fails with eitehr EBUSY or
			 * EAGAIN error, re-queue the request.
			 * EAGAIN error, re-queue the request.
			 * This case would occur with ICE calls.
			 * This case would occur with ICE calls.
			 * For request which gets completed successfully or
			 * errored out, we release host lock in completion or
			 * error handling softirq context. But here the request
			 * is neither completed nor erred-out, so release the
			 * host lock explicitly.
			 */
			 */
			if (ret == -EBUSY || ret == -EAGAIN)
			if (ret == -EBUSY || ret == -EAGAIN) {
				mmc_blk_cmdq_requeue_rw_rq(mq, req);
				mmc_blk_cmdq_requeue_rw_rq(mq, req);
				mmc_put_card(host->card);
			}
		}
		}
	}
	}