From bf86cf1cb6efc1e35cdbfe16de60de962f3bf3bc Mon Sep 17 00:00:00 2001 From: Veerabhadrarao Badiganti Date: Mon, 20 Feb 2017 13:51:13 +0530 Subject: [PATCH] mmc: cmdq_hci: Increase HAC interrupt wait time in halt path When system is heavily loaded, in some cases interrupt servicing is getting effected and cmdq halt interrupt handler is getting invoked after 1 sec delay. Since wait time of HAC interrupt in cmdq driver is 1 sec, the delayed interrupt is being treated as unexpected interrupt. For fixing this case, increasing the timeout to 10 seconds. Change-Id: I55879095aa2b81a10f40963aee02b2068a3305b4 Signed-off-by: Veerabhadrarao Badiganti Signed-off-by: Sayali Lokhande --- drivers/mmc/host/cmdq_hci.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/cmdq_hci.c b/drivers/mmc/host/cmdq_hci.c index b90e4da7236a..9b696118418c 100644 --- a/drivers/mmc/host/cmdq_hci.c +++ b/drivers/mmc/host/cmdq_hci.c @@ -29,8 +29,8 @@ #define DCMD_SLOT 31 #define NUM_SLOTS 32 -/* 1 sec */ -#define HALT_TIMEOUT_MS 1000 +/* 10 sec */ +#define HALT_TIMEOUT_MS 10000 static int cmdq_halt_poll(struct mmc_host *mmc); static int cmdq_halt(struct mmc_host *mmc, bool halt); @@ -875,6 +875,7 @@ static int cmdq_halt(struct mmc_host *mmc, bool halt) { struct cmdq_host *cq_host = (struct cmdq_host *)mmc_cmdq_private(mmc); u32 val; + u32 config = 0; int retries = 3; if (halt) { @@ -883,9 +884,28 @@ static int cmdq_halt(struct mmc_host *mmc, bool halt) CQCTL); val = wait_for_completion_timeout(&cq_host->halt_comp, msecs_to_jiffies(HALT_TIMEOUT_MS)); - if (!val && !(cmdq_readl(cq_host, CQCTL) & HALT)) { - retries--; - continue; + if (!val) { + pr_warn("%s: %s: HAC int timeout\n", + mmc_hostname(mmc), __func__); + if ((cmdq_readl(cq_host, CQCTL) & HALT)) { + /* + * Don't retry if CQE is halted but irq + * is not triggered in timeout period. + * And since we are returning error, + * un-halt CQE. Since irq was not fired + * yet, no need to set other params + */ + retries = 0; + config = cmdq_readl(cq_host, CQCTL); + config &= ~HALT; + cmdq_writel(cq_host, config, CQCTL); + } else { + pr_warn("%s: %s: retryng halt (%d)\n", + mmc_hostname(mmc), __func__, + retries); + retries--; + continue; + } } else { /* halt done: re-enable legacy interrupts */ if (cq_host->ops->clear_set_irqs)