Skip to content

Commit 1de1b77

Browse files
ahunter6Ulf Hansson
authored andcommitted
mmc: cqhci: Fix task clearing in CQE error recovery
If a task completion notification (TCN) is received when there is no outstanding task, the cqhci driver issues a "spurious TCN" warning. This was observed to happen right after CQE error recovery. When an error interrupt is received the driver runs recovery logic. It halts the controller, clears all pending tasks, and then re-enables it. On some platforms, like Intel Jasper Lake, a stale task completion event was observed, regardless of the CQHCI_CLEAR_ALL_TASKS bit being set. This results in either: a) Spurious TC completion event for an empty slot. b) Corrupted data being passed up the stack, as a result of premature completion for a newly added task. Rather than add a quirk for affected controllers, ensure tasks are cleared by toggling CQHCI_ENABLE, which would happen anyway if cqhci_clear_all_tasks() timed out. This is simpler and should be safe and effective for all controllers. Fixes: a408022 ("mmc: cqhci: support for command queue enabled host") Cc: stable@vger.kernel.org Reported-by: Kornel Dulęba <korneld@chromium.org> Tested-by: Kornel Dulęba <korneld@chromium.org> Co-developed-by: Kornel Dulęba <korneld@chromium.org> Signed-off-by: Kornel Dulęba <korneld@chromium.org> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Reviewed-by: Avri Altman <avri.altman@wdc.com> Link: https://lore.kernel.org/r/20231103084720.6886-7-adrian.hunter@intel.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 35597bd commit 1de1b77

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

drivers/mmc/host/cqhci-core.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,28 +1075,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc)
10751075

10761076
ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
10771077

1078-
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1079-
ok = false;
1080-
10811078
/*
10821079
* The specification contradicts itself, by saying that tasks cannot be
10831080
* cleared if CQHCI does not halt, but if CQHCI does not halt, it should
10841081
* be disabled/re-enabled, but not to disable before clearing tasks.
10851082
* Have a go anyway.
10861083
*/
1087-
if (!ok) {
1088-
pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc));
1089-
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1090-
cqcfg &= ~CQHCI_ENABLE;
1091-
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1092-
cqcfg |= CQHCI_ENABLE;
1093-
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1094-
/* Be sure that there are no tasks */
1095-
ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1096-
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1097-
ok = false;
1098-
WARN_ON(!ok);
1099-
}
1084+
if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
1085+
ok = false;
1086+
1087+
/* Disable to make sure tasks really are cleared */
1088+
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1089+
cqcfg &= ~CQHCI_ENABLE;
1090+
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1091+
1092+
cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
1093+
cqcfg |= CQHCI_ENABLE;
1094+
cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
1095+
1096+
cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
1097+
1098+
if (!ok)
1099+
cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT);
11001100

11011101
cqhci_recover_mrqs(cq_host);
11021102

0 commit comments

Comments
 (0)