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

Commit 5c3bbdef authored by Talel Shenhar's avatar Talel Shenhar Committed by Matt Wagantall
Browse files

mmc: quirks: add new quirk that allows Cache disable



This change allows us to prevent cache enable for certain
cards that have broken cache functionality.

Change-Id: Iea3f8c8f4e5498a8742fa408a19e3e169d1fa8cb
Signed-off-by: default avatarTalel Shenhar <tatias@codeaurora.org>
parent 19679496
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3107,7 +3107,8 @@ int mmc_flush_cache(struct mmc_card *card)

	if (mmc_card_mmc(card) &&
			(card->ext_csd.cache_size > 0) &&
			(card->ext_csd.cache_ctrl & 1)) {
			(card->ext_csd.cache_ctrl & 1) &&
			(!(card->quirks & MMC_QUIRK_CACHE_DISABLE))) {
		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
				EXT_CSD_FLUSH_CACHE, 1, 0);
		if (err == -ETIMEDOUT) {
+37 −17
Original line number Diff line number Diff line
@@ -1686,12 +1686,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
	 * the existence of cache and it can be turned on.
	 * If HPI is not supported then cache shouldn't be enabled.
	 */
	if (card->ext_csd.cache_size > 0 && card->ext_csd.hpi_en) {
	if (card->ext_csd.cache_size > 0) {
		if (card->ext_csd.hpi_en &&
			(!(card->quirks & MMC_QUIRK_CACHE_DISABLE))) {
			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
					EXT_CSD_CACHE_CTRL, 1,
					card->ext_csd.generic_cmd6_time);
			if (err && err != -EBADMSG) {
			pr_err("%s: %s: mmc_switch() for CACHE_CTRL fails %d\n",
				pr_err("%s: %s: fail on CACHE_CTRL ON %d\n",
					mmc_hostname(host), __func__, err);
				goto free_card;
			}
@@ -1707,6 +1709,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
			} else {
				card->ext_csd.cache_ctrl = 1;
			}
		} else {
			/*
			 * mmc standard doesn't say what is the card default
			 * value for EXT_CSD_CACHE_CTRL.
			 * Hence, cache may be enabled by default by
			 * card vendors.
			 * Thus, it is best to explicitly disable cache in case
			 * we want to avoid cache.
			 */
			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
					EXT_CSD_CACHE_CTRL, 0,
					card->ext_csd.generic_cmd6_time);
			if (err) {
				pr_err("%s: %s: fail on CACHE_CTRL OFF %d\n",
					mmc_hostname(host), __func__, err);
				goto free_card;
			}
		}
	}

	/*
+1 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ struct mmc_card {
#define MMC_QUIRK_INAND_DATA_TIMEOUT  (1<<12)   /* For incorrect data timeout */
#define MMC_QUIRK_BROKEN_HPI (1 << 13)		/* For devices which gets */
						/* broken due to HPI feature */
#define MMC_QUIRK_CACHE_DISABLE (1 << 14)	/* prevent cache enable */

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