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

Commit 281249eb authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Gerrit - the friendly Code Review server
Browse files

mmc: core: Fix debugfs and IOCTL calls in cmdq mode



Currently getting status/ext_csd using debugfs or IOCTL
calls in cmdq mode is not working.
Fix it by halting the cmdq engine and making sure that
card queue is empty before issuing these cmds.

Change-Id: Idb89def9ff5c2fee6866759b9a8c652049552933
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
parent f779b1c4
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -672,6 +672,16 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,

	mmc_get_card(card);

	if (mmc_card_cmdq(card)) {
		err = mmc_cmdq_halt_on_empty_queue(card->host);
		if (err) {
			pr_err("%s: halt failed while doing %s err (%d)\n",
					mmc_hostname(card->host),
					__func__, err);
			goto cmd_rel_host_halt;
		}
	}

	err = mmc_blk_part_switch(card, md);
	if (err)
		goto cmd_rel_host;
@@ -729,6 +739,12 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
	}

cmd_rel_host:
	if (mmc_card_cmdq(card)) {
		if (mmc_cmdq_halt(card->host, false))
			pr_err("%s: %s: cmdq unhalt failed\n",
			       mmc_hostname(card->host), __func__);
	}
cmd_rel_host_halt:
	mmc_release_host(card->host);

cmd_done:
+2 −1
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ static bool mmc_is_vaild_state_for_clk_scaling(struct mmc_host *host)
	return R1_CURRENT_STATE(status) == R1_STATE_TRAN;
}

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

@@ -391,6 +391,7 @@ static int mmc_cmdq_halt_on_empty_queue(struct mmc_host *host)
out:
	return err;
}
EXPORT_SYMBOL(mmc_cmdq_halt_on_empty_queue);

int mmc_clk_update_freq(struct mmc_host *host,
		unsigned long freq, enum mmc_load state)
+39 −1
Original line number Diff line number Diff line
@@ -358,11 +358,26 @@ static int mmc_dbg_card_status_get(void *data, u64 *val)
	int		ret;

	mmc_get_card(card);
	if (mmc_card_cmdq(card)) {
		ret = mmc_cmdq_halt_on_empty_queue(card->host);
		if (ret) {
			pr_err("%s: halt failed while doing %s err (%d)\n",
					mmc_hostname(card->host), __func__,
					ret);
			goto out;
		}
	}

	ret = mmc_send_status(data, &status);
	if (!ret)
		*val = status;

	if (mmc_card_cmdq(card)) {
		if (mmc_cmdq_halt(card->host, false))
			pr_err("%s: %s: cmdq unhalt failed\n",
			       mmc_hostname(card->host), __func__);
	}
out:
	mmc_put_card(card);

	return ret;
@@ -387,10 +402,20 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
	ext_csd = kmalloc(512, GFP_KERNEL);
	if (!ext_csd) {
		err = -ENOMEM;
		goto out_free;
		goto out_free_halt;
	}

	mmc_get_card(card);
	if (mmc_card_cmdq(card)) {
		err = mmc_cmdq_halt_on_empty_queue(card->host);
		if (err) {
			pr_err("%s: halt failed while doing %s err (%d)\n",
					mmc_hostname(card->host), __func__,
					err);
			mmc_put_card(card);
			goto out_free_halt;
		}
	}
	err = mmc_send_ext_csd(card, ext_csd);
	mmc_put_card(card);
	if (err)
@@ -402,10 +427,23 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
	BUG_ON(n != EXT_CSD_STR_LEN);

	filp->private_data = buf;

	if (mmc_card_cmdq(card)) {
		if (mmc_cmdq_halt(card->host, false))
			pr_err("%s: %s: cmdq unhalt failed\n",
			       mmc_hostname(card->host), __func__);
	}

	kfree(ext_csd);
	return 0;

out_free:
	if (mmc_card_cmdq(card)) {
		if (mmc_cmdq_halt(card->host, false))
			pr_err("%s: %s: cmdq unhalt failed\n",
			       mmc_hostname(card->host), __func__);
	}
out_free_halt:
	kfree(buf);
	kfree(ext_csd);
	return err;
+1 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ struct mmc_cmdq_req;

extern int mmc_cmdq_discard_queue(struct mmc_host *host, u32 tasks);
extern int mmc_cmdq_halt(struct mmc_host *host, bool enable);
extern int mmc_cmdq_halt_on_empty_queue(struct mmc_host *host);
extern void mmc_cmdq_post_req(struct mmc_host *host, struct mmc_request *mrq,
			      int err);
extern int mmc_cmdq_start_req(struct mmc_host *host,