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

Commit 66a7393a authored by Subhash Jadavani's avatar Subhash Jadavani
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>
parent 3b74bf1e
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -3403,6 +3403,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 (cmd_flags & REQ_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);
@@ -3860,6 +3873,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 Micron MMC cards needs longer data read timeout than
+3 −0
Original line number Diff line number Diff line
@@ -383,6 +383,9 @@ struct mmc_card {
#define MMC_QUIRK_QCA6574_SETTINGS (1 << 15)	/* QCA6574 card settings*/
#define MMC_QUIRK_QCA9377_SETTINGS (1 << 16)	/* QCA9377 card settings*/

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

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