Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312801
b: refs/heads/master
c: 6af9e96
h: refs/heads/master
i:
  312799: 79a3814
v: v3
  • Loading branch information
Venkatraman S authored and Chris Ball committed Jul 11, 2012
1 parent cbf7565 commit b9c20a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fd0ea65d3e675e479e022b6cfc9ebe1864c76afc
refs/heads/master: 6af9e96e052a6d1a760c60cb340c5a6584cb92db
55 changes: 32 additions & 23 deletions trunk/drivers/mmc/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ int mmc_interrupt_hpi(struct mmc_card *card)
{
int err;
u32 status;
unsigned long prg_wait;

BUG_ON(!card);

Expand All @@ -419,30 +420,38 @@ int mmc_interrupt_hpi(struct mmc_card *card)
goto out;
}

/*
* If the card status is in PRG-state, we can send the HPI command.
*/
if (R1_CURRENT_STATE(status) == R1_STATE_PRG) {
do {
/*
* We don't know when the HPI command will finish
* processing, so we need to resend HPI until out
* of prg-state, and keep checking the card status
* with SEND_STATUS. If a timeout error occurs when
* sending the HPI command, we are already out of
* prg-state.
*/
err = mmc_send_hpi_cmd(card, &status);
if (err)
pr_debug("%s: abort HPI (%d error)\n",
mmc_hostname(card->host), err);
switch (R1_CURRENT_STATE(status)) {
case R1_STATE_IDLE:
case R1_STATE_READY:
case R1_STATE_STBY:
/*
* In idle states, HPI is not needed and the caller
* can issue the next intended command immediately
*/
goto out;
case R1_STATE_PRG:
break;
default:
/* In all other states, it's illegal to issue HPI */
pr_debug("%s: HPI cannot be sent. Card state=%d\n",
mmc_hostname(card->host), R1_CURRENT_STATE(status));
err = -EINVAL;
goto out;
}

err = mmc_send_status(card, &status);
if (err)
break;
} while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
} else
pr_debug("%s: Left prg-state\n", mmc_hostname(card->host));
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 {
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:
mmc_release_host(card->host);
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/mmc/core/mmc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)

cmd.opcode = opcode;
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);
if (err) {
Expand Down

0 comments on commit b9c20a0

Please sign in to comment.