mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-02-15 04:42:02 +00:00
60 lines
2.1 KiB
Diff
60 lines
2.1 KiB
Diff
From fe98179e184bdb0ff7061d1a026f82b749854720 Mon Sep 17 00:00:00 2001
|
|
From: Jonathan Bell <jonathan@raspberrypi.com>
|
|
Date: Tue, 26 Mar 2024 13:17:10 +0000
|
|
Subject: [PATCH 0993/1002] drivers: mmc: cqhci: clear CQHCI_CTL if halt fails
|
|
|
|
The eMMC spec says that in certain circumstances the controller can't
|
|
respond to a halt request - in practice, this occurs if a CMD
|
|
timeout happens (card went away/crashed).
|
|
|
|
Clear the halt request by writing 0 to CQHCI_CTL. Also fix a logic error
|
|
testing for halt in cqhci_request.
|
|
|
|
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
|
|
---
|
|
drivers/mmc/host/cqhci-core.c | 13 +++++++++----
|
|
1 file changed, 9 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
|
|
index 41e94cd14109..5da5bf8ad038 100644
|
|
--- a/drivers/mmc/host/cqhci-core.c
|
|
+++ b/drivers/mmc/host/cqhci-core.c
|
|
@@ -383,9 +383,11 @@ static void cqhci_off(struct mmc_host *mmc)
|
|
|
|
err = readx_poll_timeout(cqhci_read_ctl, cq_host, reg,
|
|
reg & CQHCI_HALT, 0, CQHCI_OFF_TIMEOUT);
|
|
- if (err < 0)
|
|
+ if (err < 0) {
|
|
pr_err("%s: cqhci: CQE stuck on\n", mmc_hostname(mmc));
|
|
- else
|
|
+ /* eMMC v5.1 B.2.8 recommends writing 0 to CQHCI_CTL if stuck */
|
|
+ cqhci_writel(cq_host, 0, CQHCI_CTL);
|
|
+ } else
|
|
pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc));
|
|
|
|
if (cq_host->ops->post_disable)
|
|
@@ -612,7 +614,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
|
cqhci_writel(cq_host, 0, CQHCI_CTL);
|
|
mmc->cqe_on = true;
|
|
pr_debug("%s: cqhci: CQE on\n", mmc_hostname(mmc));
|
|
- if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) {
|
|
+ if (cqhci_readl(cq_host, CQHCI_CTL) & CQHCI_HALT) {
|
|
pr_err("%s: cqhci: CQE failed to exit halt state\n",
|
|
mmc_hostname(mmc));
|
|
}
|
|
@@ -975,8 +977,11 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)
|
|
|
|
ret = cqhci_halted(cq_host);
|
|
|
|
- if (!ret)
|
|
+ if (!ret) {
|
|
pr_warn("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
|
|
+ /* eMMC v5.1 B.2.8 recommends writing 0 to CQHCI_CTL if stuck */
|
|
+ cqhci_writel(cq_host, 0, CQHCI_CTL);
|
|
+ }
|
|
|
|
return ret;
|
|
}
|
|
--
|
|
2.44.0
|
|
|