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

Commit 5a2695b2 authored by Bao D. Nguyen's avatar Bao D. Nguyen
Browse files

mmc: core: Removed workaround for SD card SDR104 CRC handling



Remove the workaround for SD card's SDR104 mode CRC error handling.
The SD card's SDR104 mode CRC errors issue was seen on some
SDCC controllers and the software reduced the SD card clock speed
as a workaround to avoid CRC errors. The latest SDCC controller
does not have this issue, so removing the workaround.

Change-Id: I3638500c83f7a6a2f9e4eae28a3179eea1d1fc89
Signed-off-by: default avatarBao D. Nguyen <nguyenb@codeaurora.org>
parent 01697ba5
Loading
Loading
Loading
Loading
+0 −47
Original line number Diff line number Diff line
@@ -1601,8 +1601,6 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req,

	/* We couldn't get a response from the card.  Give up. */
	if (err) {
		if (card->err_in_sdr104)
			return ERR_RETRY;
		/* Check if the card is removed */
		if (mmc_detect_card_removed(card->host))
			return ERR_NOMEDIUM;
@@ -3184,7 +3182,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
	struct mmc_async_req *new_areq;
	struct mmc_async_req *old_areq;
	bool req_pending = true;
	bool reset = false;
#ifdef CONFIG_MMC_SIMULATE_MAX_SPEED
	unsigned long waitfor = jiffies;
#endif
@@ -3235,26 +3232,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
		old_req = mmc_queue_req_to_req(mq_rq);
		type = rq_data_dir(old_req) == READ ? MMC_BLK_READ : MMC_BLK_WRITE;

		if (card->err_in_sdr104) {
			/*
			 * Data CRC/timeout errors will manifest as CMD/DATA
			 * ERR. But we'd like to retry these too.
			 * Moreover, no harm done if this fails too for multiple
			 * times, we anyway reduce the bus-speed and retry the
			 * same request.
			 * If that fails too, we don't override this status.
			 */
			if (status == MMC_BLK_ABORT ||
			    status == MMC_BLK_CMD_ERR ||
			    status == MMC_BLK_DATA_ERR ||
			    status == MMC_BLK_RETRY)
				/* reset on all of these errors and retry */
				reset = true;

			status = MMC_BLK_RETRY;
			card->err_in_sdr104 = false;
		}

		switch (status) {
		case MMC_BLK_SUCCESS:
		case MMC_BLK_PARTIAL:
@@ -3300,30 +3277,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)
			retune_retry_done = brq->retune_retry_done;
			if (retry++ < MMC_BLK_MAX_RETRIES)
				break;
			else if (reset) {
				reset = false;
				/*
				 * If we exhaust all the retries due to
				 * CRC/timeout errors in SDR140 mode with UHS SD
				 * cards, re-configure the card in SDR50
				 * bus-speed mode.
				 * All subsequent re-init of this card will be
				 * in SDR50 mode, unless it is removed and
				 * re-inserted. When new UHS SD cards are
				 * inserted, it may start at SDR104 mode if
				 * supported by the card.
				 */
				pr_err("%s: blocked SDR104, lower the bus-speed (SDR50 / DDR50)\n",
					old_req->rq_disk->disk_name);
				mmc_host_clear_sdr104(card->host);
				mmc_suspend_clk_scaling(card->host);
				mmc_blk_reset(md, card->host, type);
				/* SDR104 mode is blocked from now on */
				card->sdr104_blocked = true;
				/* retry 5 times again */
				retry = 0;
				break;
			}
			/* Fall through */
		case MMC_BLK_ABORT:
			if (!mmc_blk_reset(md, card->host, type) &&
+8 −60
Original line number Diff line number Diff line
@@ -453,32 +453,6 @@ int mmc_clk_update_freq(struct mmc_host *host,
}
EXPORT_SYMBOL(mmc_clk_update_freq);

int mmc_recovery_fallback_lower_speed(struct mmc_host *host)
{
	int err = 0;

	if (!host->card)
		return -EINVAL;

	if (host->sdr104_wa && mmc_card_sd(host->card) &&
	    (host->ios.timing == MMC_TIMING_UHS_SDR104) &&
	    !host->card->sdr104_blocked) {
		pr_err("%s: %s: blocked SDR104, lower the bus-speed (SDR50 / DDR50)\n",
			mmc_hostname(host), __func__);
		mmc_host_clear_sdr104(host);
		err = mmc_hw_reset(host);
		host->card->sdr104_blocked = true;
	} else if (mmc_card_sd(host->card)) {
		/* If sdr104_wa is not present, just return status */
		err = host->bus_ops->alive(host);
	}
	if (err)
		pr_err("%s: %s: Fallback to lower speed mode failed with err=%d\n",
			mmc_hostname(host), __func__, err);

	return err;
}

static int mmc_devfreq_set_target(struct device *dev,
				unsigned long *freq, u32 devfreq_flags)
{
@@ -526,9 +500,6 @@ static int mmc_devfreq_set_target(struct device *dev,
	if (abort)
		goto out;

	if (mmc_card_sd(host->card) && host->card->sdr104_blocked)
		goto rel_host;

	/*
	 * In case we were able to claim host there is no need to
	 * defer the frequency change. It will be done now
@@ -537,18 +508,14 @@ static int mmc_devfreq_set_target(struct device *dev,

	mmc_host_clk_hold(host);
	err = mmc_clk_update_freq(host, *freq, clk_scaling->state);
	if (err && err != -EAGAIN) {
	if (err && err != -EAGAIN)
		pr_err("%s: clock scale to %lu failed with error %d\n",
			mmc_hostname(host), *freq, err);
		err = mmc_recovery_fallback_lower_speed(host);
	} else {
	else
		pr_debug("%s: clock change to %lu finished successfully (%s)\n",
			mmc_hostname(host), *freq, current->comm);
	}


	mmc_host_clk_release(host);
rel_host:
	mmc_release_host(host);
out:
	current->flags &= ~PF_MEMALLOC;
@@ -572,9 +539,6 @@ void mmc_deferred_scaling(struct mmc_host *host)
	if (!host->clk_scaling.enable)
		return;

	if (mmc_card_sd(host->card) && host->card->sdr104_blocked)
		return;

	spin_lock_bh(&host->clk_scaling.lock);

	if (!host->clk_scaling.need_freq_change) {
@@ -599,15 +563,14 @@ void mmc_deferred_scaling(struct mmc_host *host)

	err = mmc_clk_update_freq(host, target_freq,
		clk_scaling.state);
	if (err && err != -EAGAIN) {
	if (err && err != -EAGAIN)
		pr_err("%s: failed on deferred scale clocks (%d)\n",
			mmc_hostname(host), err);
		mmc_recovery_fallback_lower_speed(host);
	} else {
	else
		pr_debug("%s: clocks were successfully scaled to %lu (%s)\n",
			mmc_hostname(host),
			target_freq, current->comm);
	}

	atomic_dec(&host->clk_scaling.devfreq_abort);
}
EXPORT_SYMBOL(mmc_deferred_scaling);
@@ -1620,14 +1583,8 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
			}
		}
		if (!cmd->error || !cmd->retries ||
		    mmc_card_removed(host->card)) {
			if (cmd->error && !cmd->retries &&
			     cmd->opcode != MMC_SEND_STATUS &&
			     cmd->opcode != MMC_SEND_TUNING_BLOCK &&
			     cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200)
				mmc_recovery_fallback_lower_speed(host);
		    mmc_card_removed(host->card))
			break;
		}

		mmc_retune_recheck(host);

@@ -4259,17 +4216,8 @@ int _mmc_detect_card_removed(struct mmc_host *host)
	}

	if (ret) {
		if (host->ops->get_cd && host->ops->get_cd(host)) {
			ret = mmc_recovery_fallback_lower_speed(host);
		} else {
		mmc_card_set_removed(host->card);
			if (host->card->sdr104_blocked) {
				mmc_host_set_sdr104(host);
				host->card->sdr104_blocked = false;
			}
			pr_debug("%s: card remove detected\n",
					mmc_hostname(host));
		}
		pr_debug("%s: card remove detected\n", mmc_hostname(host));
	}

	return ret;
+1 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ void mmc_init_context_info(struct mmc_host *host);

extern bool mmc_can_scale_clk(struct mmc_host *host);
extern int mmc_init_clk_scaling(struct mmc_host *host);
extern int mmc_suspend_clk_scaling(struct mmc_host *host);
extern int mmc_resume_clk_scaling(struct mmc_host *host);
extern int mmc_exit_clk_scaling(struct mmc_host *host);
extern unsigned long mmc_get_max_frequency(struct mmc_host *host);
+0 −2
Original line number Diff line number Diff line
@@ -1308,8 +1308,6 @@ static int _mmc_sd_resume(struct mmc_host *host)
	}
	mmc_card_clr_suspended(host->card);

	if (host->card->sdr104_blocked)
		goto out;
	err = mmc_resume_clk_scaling(host);
	if (err) {
		pr_err("%s: %s: fail to resume clock scaling (%d)\n",
+0 −2
Original line number Diff line number Diff line
@@ -397,8 +397,6 @@ struct mmc_card {
	enum mmc_pon_type	pon_type;
	bool cmdq_init;
	struct mmc_bkops_info bkops;
	bool			err_in_sdr104;
	bool			sdr104_blocked;
};

static inline bool mmc_large_sector(struct mmc_card *card)
Loading