Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [RFC PATCH] mmc: cqhci: keep CQE enabled if halt times out
@ 2026-06-23 14:04 Pengpeng Hou
  2026-07-03 15:41 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-23 14:04 UTC (permalink / raw)
  To: Adrian Hunter, Asutosh Das, Ritesh Harjani, Ulf Hansson
  Cc: Pengpeng Hou, linux-mmc, linux-kernel

cqhci_off() asks the controller to halt before post_disable(), clearing
mmc->cqe_on and freeing CQE resources. If the halt wait times out, the
function still continues through that success path even though the
hardware may still be using the command queue.

Make cqhci_off() report whether the halt completed and leave the CQE
state/resources intact when the controller remains stuck on. This keeps
the existing host-specific ->disable() ordering and is intended as an
RFC patch because the cqe_disable callback itself has no error return.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/mmc/host/cqhci-core.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
index 178277d90..84846207c 100644
--- a/drivers/mmc/host/cqhci-core.c
+++ b/drivers/mmc/host/cqhci-core.c
@@ -372,14 +372,14 @@ static u32 cqhci_read_ctl(struct cqhci_host *cq_host)
 	return cqhci_readl(cq_host, CQHCI_CTL);
 }
 
-static void cqhci_off(struct mmc_host *mmc)
+static bool cqhci_off(struct mmc_host *mmc)
 {
 	struct cqhci_host *cq_host = mmc->cqe_private;
 	u32 reg;
 	int err;
 
 	if (!cq_host->enabled || !mmc->cqe_on || cq_host->recovery_halt)
-		return;
+		return true;
 
 	if (cq_host->ops->disable)
 		cq_host->ops->disable(mmc, false);
@@ -388,15 +388,19 @@ 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
-		pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc));
+		return false;
+	}
+
+	pr_debug("%s: cqhci: CQE off\n", mmc_hostname(mmc));
 
 	if (cq_host->ops->post_disable)
 		cq_host->ops->post_disable(mmc);
 
 	mmc->cqe_on = false;
+
+	return true;
 }
 
 static void cqhci_disable(struct mmc_host *mmc)
@@ -406,7 +410,8 @@ static void cqhci_disable(struct mmc_host *mmc)
 	if (!cq_host->enabled)
 		return;
 
-	cqhci_off(mmc);
+	if (!cqhci_off(mmc))
+		return;
 
 	__cqhci_disable(cq_host);
 
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-03 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 14:04 [RFC PATCH] mmc: cqhci: keep CQE enabled if halt times out Pengpeng Hou
2026-07-03 15:41 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox