Skip to content

Commit e99783a

Browse files
minchanhoUlf Hansson
authored andcommitted
mmc: sdhci: handle busy-end interrupt during command
It is fully legal for a controller to start handling busy-end interrupt before it has signaled that the command has completed. So make sure we do things in the proper order, Or it results that command interrupt is ignored so it can cause unexpected operations. This is founded at some toshiba emmc with the bellow warning. "mmc0: Got command interrupt 0x00000001 even though no command operation was in progress." This issue has been also reported by Youssef TRIKI: It is not specific to Toshiba devices, and happens with eMMC devices as well as SD card which support Auto-CMD12 rather than CMD23. Also, similar patch is submitted by: Gwendal Grignou <gwendal@chromium.org> Changes since v1: Fixed conflict with the next of git.linaro.org/people/ulf.hansson/mmc.git and Tested if issue is fixed again. Signed-off-by: Hankyung Yu <hankyung.yu@lge.com> Signed-off-by: Chanho Min <chanho.min@lge.com> Tested-by: Youssef TRIKI <youssef.triki@st.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 0b10f47 commit e99783a

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎drivers/mmc/host/sdhci.c‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
10161016
mod_timer(&host->timer, timeout);
10171017

10181018
host->cmd = cmd;
1019+
host->busy_handle = 0;
10191020

10201021
sdhci_prepare_data(host, cmd);
10211022

@@ -2261,8 +2262,12 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
22612262
if (host->cmd->data)
22622263
DBG("Cannot wait for busy signal when also "
22632264
"doing a data transfer");
2264-
else if (!(host->quirks & SDHCI_QUIRK_NO_BUSY_IRQ))
2265+
else if (!(host->quirks & SDHCI_QUIRK_NO_BUSY_IRQ)
2266+
&& !host->busy_handle) {
2267+
/* Mark that command complete before busy is ended */
2268+
host->busy_handle = 1;
22652269
return;
2270+
}
22662271

22672272
/* The controller does not support the end-of-busy IRQ,
22682273
* fall through and take the SDHCI_INT_RESPONSE */
@@ -2330,7 +2335,15 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
23302335
return;
23312336
}
23322337
if (intmask & SDHCI_INT_DATA_END) {
2333-
sdhci_finish_command(host);
2338+
/*
2339+
* Some cards handle busy-end interrupt
2340+
* before the command completed, so make
2341+
* sure we do things in the proper order.
2342+
*/
2343+
if (host->busy_handle)
2344+
sdhci_finish_command(host);
2345+
else
2346+
host->busy_handle = 1;
23342347
return;
23352348
}
23362349
}

‎include/linux/mmc/sdhci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct sdhci_host {
146146
struct mmc_command *cmd; /* Current command */
147147
struct mmc_data *data; /* Current data request */
148148
unsigned int data_early:1; /* Data finished before cmd */
149+
unsigned int busy_handle:1; /* Handling the order of Busy-end */
149150

150151
struct sg_mapping_iter sg_miter; /* SG state for PIO */
151152
unsigned int blocks; /* remaining PIO blocks */

0 commit comments

Comments
 (0)