mmc: msm_sdcc: skip the start request if SDCC is in bad state
If SDCC power/clock is off or SDCC interrupt is disabled and if we
configure the SDCC to start new request, it's definitely going to fail
so it's better not to start the request if SDCC is not in proper
state to handle it.
Change-Id: Ib49ab456ad61a0333205b3f3399250fcd097d218
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 254f710..c194f9c 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -1862,10 +1862,6 @@
}
spin_lock_irqsave(&host->lock, flags);
- WARN(host->curr.mrq, "Request in progress\n");
- WARN(!host->pwr, "SDCC power is turned off\n");
- WARN(!host->clks_on, "SDCC clocks are turned off\n");
- WARN(host->sdcc_irq_disabled, "SDCC IRQ is disabled\n");
if (host->eject) {
if (mrq->data && !(mrq->data->flags & MMC_DATA_READ)) {
@@ -1881,6 +1877,29 @@
}
/*
+ * Don't start the request if SDCC is not in proper state to handle it
+ */
+ if (!host->pwr || !host->clks_on || host->sdcc_irq_disabled) {
+ WARN(1, "%s: %s: SDCC is in bad state. don't process"
+ " new request (CMD%d)\n", mmc_hostname(host->mmc),
+ __func__, mrq->cmd->opcode);
+ msmsdcc_dump_sdcc_state(host);
+ mrq->cmd->error = -EIO;
+ if (mrq->data) {
+ mrq->data->error = -EIO;
+ mrq->data->bytes_xfered = 0;
+ }
+ spin_unlock_irqrestore(&host->lock, flags);
+ mmc_request_done(mmc, mrq);
+ return;
+ }
+
+ WARN(host->curr.mrq, "%s: %s: New request (CMD%d) received while"
+ " other request (CMD%d) is in progress\n",
+ mmc_hostname(host->mmc), __func__,
+ mrq->cmd->opcode, host->curr.mrq->cmd->opcode);
+
+ /*
* Kick the software command timeout timer here.
* Timer expires in 10 secs.
*/