提交 6af9e96e 编写于 作者: V Venkatraman S 提交者: Chris Ball

mmc: core: Fix the HPI execution sequence

mmc_execute_hpi should send the HPI command only once, and only
if the card is in PRG state.

According to eMMC spec, the command's completion time is
not dependent on OUT_OF_INTERRUPT_TIME. Only the transition
out of PRG STATE is guarded by OUT_OF_INTERRUPT_TIME - which
is defined to begin at the end of sending the command itself.

Specify the default timeout for the actual sending of HPI
command, and then use OUT_OF_INTERRUPT_TIME to wait for
the transition out of PRG state.
Reported-by: NAlex Lemberg <Alex.Lemberg@sandisk.com>
Signed-off-by: NVenkatraman S <svenkatr@ti.com>
Reviewed-by: NNamjae Jeon <linkinjeon@gmail.com>
Reviewed-by: NSubhash Jadavani <subhashj@codeaurora.org>
Acked-by: NJaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: NChris Ball <cjb@laptop.org>
上级 fd0ea65d
...@@ -404,6 +404,7 @@ int mmc_interrupt_hpi(struct mmc_card *card) ...@@ -404,6 +404,7 @@ int mmc_interrupt_hpi(struct mmc_card *card)
{ {
int err; int err;
u32 status; u32 status;
unsigned long prg_wait;
BUG_ON(!card); BUG_ON(!card);
...@@ -419,30 +420,38 @@ int mmc_interrupt_hpi(struct mmc_card *card) ...@@ -419,30 +420,38 @@ int mmc_interrupt_hpi(struct mmc_card *card)
goto out; goto out;
} }
/* switch (R1_CURRENT_STATE(status)) {
* If the card status is in PRG-state, we can send the HPI command. case R1_STATE_IDLE:
*/ case R1_STATE_READY:
if (R1_CURRENT_STATE(status) == R1_STATE_PRG) { case R1_STATE_STBY:
do { /*
/* * In idle states, HPI is not needed and the caller
* We don't know when the HPI command will finish * can issue the next intended command immediately
* processing, so we need to resend HPI until out */
* of prg-state, and keep checking the card status goto out;
* with SEND_STATUS. If a timeout error occurs when case R1_STATE_PRG:
* sending the HPI command, we are already out of break;
* prg-state. default:
*/ /* In all other states, it's illegal to issue HPI */
err = mmc_send_hpi_cmd(card, &status); pr_debug("%s: HPI cannot be sent. Card state=%d\n",
if (err) mmc_hostname(card->host), R1_CURRENT_STATE(status));
pr_debug("%s: abort HPI (%d error)\n", err = -EINVAL;
mmc_hostname(card->host), err); goto out;
}
err = mmc_send_status(card, &status); err = mmc_send_hpi_cmd(card, &status);
if (err) if (err)
break; goto out;
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
} else prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time);
pr_debug("%s: Left prg-state\n", mmc_hostname(card->host)); do {
err = mmc_send_status(card, &status);
if (!err && R1_CURRENT_STATE(status) == R1_STATE_TRAN)
break;
if (time_after(jiffies, prg_wait))
err = -ETIMEDOUT;
} while (!err);
out: out:
mmc_release_host(card->host); mmc_release_host(card->host);
......
...@@ -569,7 +569,6 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) ...@@ -569,7 +569,6 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
cmd.opcode = opcode; cmd.opcode = opcode;
cmd.arg = card->rca << 16 | 1; cmd.arg = card->rca << 16 | 1;
cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time;
err = mmc_wait_for_cmd(card->host, &cmd, 0); err = mmc_wait_for_cmd(card->host, &cmd, 0);
if (err) { if (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册