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

Commit 386de26a authored by Veerabhadrarao Badiganti's avatar Veerabhadrarao Badiganti Committed by Ram Prakash Gupta
Browse files

mmc: core: Port trivial fixes in mmc from earlier kernels



This is a squash of below minor fixes:

7f5e93a mmc: block: Disable clock scaling during shudown
6c432c8 mmc: core: remove shutdown handler
b93ed34 mmc: core: declare local stack arrays as const
bbefab3 mmc: core: Check for NULL pointer access in ioctl
ecb7097 mmc: core: add checks for pointers before driver shutdown.
2952df2 mmc: mmc_test: Fix possible NULL pointer dereference
aa0a814 mmc: core: Skip frequency retries for SDCC slot
8a5e147 mmc: core: Claim host while freeing card.
7ad1fc3 mmc: core: hpi in TRAN state error handling
cfad32e mmc: core: fix issue with HPI polling timeout
9151c53 mmc: core: Attribute the IO wait time properly in
			mmc_wait_for_req_done().

Change-Id: I93c8a14a5cbd3546b44dba78fb5048b4deafe110
Signed-off-by: default avatarMurali Palnati <palnatim@codeaurora.org>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarSujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: default avatarEugene Yasman <eyasman@codeaurora.org>
Signed-off-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Signed-off-by: default avatarVenkat Gopalakrishnan <venkatg@codeaurora.org>
Signed-off-by: default avatarVijay Viswanath <vviswana@codeaurora.org>
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent 87eaf874
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -653,13 +653,13 @@ static int mmc_blk_ioctl_cmd(struct mmc_blk_data *md,
	struct request *req;

	idata = mmc_blk_ioctl_copy_from_user(ic_ptr);
	if (IS_ERR(idata))
	if (IS_ERR_OR_NULL(idata))
		return PTR_ERR(idata);
	/* This will be NULL on non-RPMB ioctl():s */
	idata->rpmb = rpmb;

	card = md->queue.card;
	if (IS_ERR(card)) {
	if (IS_ERR_OR_NULL(card)) {
		err = PTR_ERR(card);
		goto cmd_done;
	}
+10 −0
Original line number Diff line number Diff line
@@ -134,6 +134,16 @@ static void mmc_bus_shutdown(struct device *dev)
	struct mmc_host *host = card->host;
	int ret;

	if (!drv) {
		pr_debug("%s: %s: drv is NULL\n", dev_name(dev), __func__);
		return;
	}

	if (!card) {
		pr_debug("%s: %s: card is NULL\n", dev_name(dev), __func__);
		return;
	}

	if (dev->driver && drv->shutdown)
		drv->shutdown(card);

+6 −8
Original line number Diff line number Diff line
@@ -1277,7 +1277,7 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
	struct mmc_command *cmd;

	while (1) {
		wait_for_completion(&mrq->completion);
		wait_for_completion_io(&mrq->completion);

		cmd = mrq->cmd;

@@ -1544,6 +1544,10 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
{
	unsigned int mult;

	if (!card) {
		WARN_ON(1);
		return;
	}
	/*
	 * SDIO cards only define an upper 1 s limit on access.
	 */
@@ -3506,7 +3510,6 @@ void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	int i;

	if (host->rescan_disable)
		return;
@@ -3561,12 +3564,7 @@ void mmc_rescan(struct work_struct *work)
		goto out;
	}

	for (i = 0; i < ARRAY_SIZE(freqs); i++) {
		if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min)))
			break;
		if (freqs[i] <= host->f_min)
			break;
	}
	mmc_rescan_try_freq(host, host->f_min);
	host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0;
	mmc_release_host(host);

+30 −4
Original line number Diff line number Diff line
@@ -986,11 +986,11 @@ static void mmc_set_bus_speed(struct mmc_card *card)
 */
static int mmc_select_bus_width(struct mmc_card *card)
{
	static unsigned int ext_csd_bits[] = {
	static const unsigned int ext_csd_bits[] = {
		EXT_CSD_BUS_WIDTH_8,
		EXT_CSD_BUS_WIDTH_4,
	};
	static unsigned int bus_widths[] = {
	static const unsigned int bus_widths[] = {
		MMC_BUS_WIDTH_8,
		MMC_BUS_WIDTH_4,
	};
@@ -2252,6 +2252,27 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type)
	return err;
}

int mmc_send_pon(struct mmc_card *card)
{
	int err = 0;
	struct mmc_host *host = card->host;

	if (!mmc_can_poweroff_notify(card))
		goto out;

	mmc_get_card(card, NULL);
	if (card->pon_type & MMC_LONG_PON)
		err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_LONG);
	else if (card->pon_type & MMC_SHRT_PON)
		err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_SHORT);
	if (err)
		pr_warn("%s: error %d sending PON type %u\n",
			mmc_hostname(host), err, card->pon_type);
	mmc_put_card(card, NULL);
out:
	return err;
}

/*
 * Host is being removed. Free up the current card.
 */
@@ -2259,7 +2280,9 @@ static void mmc_remove(struct mmc_host *host)
{
	mmc_exit_clk_scaling(host);
	mmc_remove_card(host->card);
	mmc_claim_host(host);
	host->card = NULL;
	mmc_release_host(host);
}

/*
@@ -2404,6 +2427,7 @@ static int _mmc_resume(struct mmc_host *host)
static int mmc_shutdown(struct mmc_host *host)
{
	int err = 0;
	struct mmc_card *card = host->card;

	/*
	 * In a specific case for poweroff notify, we need to resume the card
@@ -2420,8 +2444,10 @@ static int mmc_shutdown(struct mmc_host *host)
	if (host->caps2 & MMC_CAP2_CLK_SCALE)
		mmc_exit_clk_scaling(host);

	if (!err)
		err = _mmc_suspend(host, false);
	/* send power off notification */
	if (mmc_card_mmc(card))
		mmc_send_pon(card);

	mmc_log_string(host, "done err %d\n", err);
	return err;
}
+8 −5
Original line number Diff line number Diff line
@@ -819,7 +819,7 @@ static int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)

	err = mmc_wait_for_cmd(card->host, &cmd, 0);
	if (err) {
		pr_warn("%s: error %d interrupting operation. "
		pr_debug("%s: error %d interrupting operation. "
			"HPI command response %#x\n", mmc_hostname(card->host),
			err, cmd.resp[0]);
		return err;
@@ -875,8 +875,6 @@ int mmc_interrupt_hpi(struct mmc_card *card)
	}

	err = mmc_send_hpi_cmd(card, &status);
	if (err)
		goto out;

	prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time);
	do {
@@ -884,8 +882,13 @@ int mmc_interrupt_hpi(struct mmc_card *card)

		if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN)
			break;
		if (time_after(jiffies, prg_wait))
		if (time_after(jiffies, prg_wait)) {
			err = mmc_send_status(card, &status);
			if (!err && R1_CURRENT_STATE(status) != R1_STATE_TRAN)
				err = -ETIMEDOUT;
			else
				break;
		}
	} while (!err);

out:
Loading