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

Commit b3994408 authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Xiaonian Wang
Browse files

mmc: block: ensure CMDQ is empty before queuing cache flush



Some devices might stop responding to new commands if device cache flush
is queued to host controller while host controller is still processing
outstanding requests.

To workaround this issue, we are making the cmdq thread to wait for all
the oustanding requests to be finished before queuing cache flush command
on host controller.

Change-Id: I15387734f51ca4cadfc9e11270f14d8a0806a00f
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
[xiaonian@codeaurora.org: fixed trivial merge conflicts,
changed MMC_QUIRK_CMDQ_EMPTY_BEFORE_FLUSH definition to
bit 18]
Signed-off-by: default avatarXiaonian Wang <xiaonian@codeaurora.org>
parent 5794e943
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -3790,6 +3790,19 @@ static int mmc_blk_cmdq_issue_rq(struct mmc_queue *mq, struct request *req)
			else
				ret = mmc_blk_cmdq_issue_discard_rq(mq, req);
		} else if (req_op(req) == REQ_OP_FLUSH) {
			if (card->quirks &
			    MMC_QUIRK_CMDQ_EMPTY_BEFORE_FLUSH) {
				ret = wait_event_interruptible(
					card->host->cmdq_ctx.queue_empty_wq,
					(!card->host->cmdq_ctx.active_reqs));
				if (ret) {
					pr_err("%s: failed while waiting for the CMDQ to be empty %s err (%d)\n",
						mmc_hostname(card->host),
						__func__, ret);
					BUG_ON(1);
				}
			}

			ret = mmc_blk_cmdq_issue_flush_rq(mq, req);
		} else {
			ret = mmc_blk_cmdq_issue_rw_rq(mq, req);
@@ -4285,6 +4298,8 @@ static const struct mmc_fixup blk_fixups[] =
		  MMC_QUIRK_BLK_NO_CMD23),
	MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
		  MMC_QUIRK_BLK_NO_CMD23),
	MMC_FIXUP(CID_NAME_ANY, CID_MANFID_TOSHIBA, CID_OEMID_ANY,
		  add_quirk_mmc, MMC_QUIRK_CMDQ_EMPTY_BEFORE_FLUSH),

	/*
	 * Some MMC cards need longer data read timeout than indicated in CSD.
+2 −1
Original line number Diff line number Diff line
@@ -390,7 +390,8 @@ struct mmc_card {
#define MMC_QUIRK_QCA9377_SETTINGS (1 << 17)	/* QCA9377 card settings*/



/* Make sure CMDQ is empty before queuing cache flush */
#define MMC_QUIRK_CMDQ_EMPTY_BEFORE_FLUSH (1 << 18)

	unsigned int		erase_size;	/* erase size in sectors */
 	unsigned int		erase_shift;	/* if erase unit is power 2 */