Re: [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request
From: Shawn Lin
Date: Mon Nov 23 2026 - 20:45:28 EST
Hi
在 2026/11/24 星期二 3:15, Lee Jones 写道:
When EVENT_DATA_ERROR (such as SDMMC_INT_DCRC or SDMMC_INT_SBE) is
handled in STATE_SENDING_DATA, send_stop_abort() starts a stop command
and arms host->wd_timer for DW_MCI_WD_CMD_EVENTS. In STATE_DATA_BUSY,
dw_mci_data_complete() resets the controller on data error, aborting the
in-flight stop command, and dw_mci_work_func() ends the request via
dw_mci_request_end() if EVENT_CMD_COMPLETE is not already pending.
Sure, it's a bug for send_stop_abort() case. The dw_mmc state machine
is so complicated and prone to error... This fix looks clean and
minimal,
Reviewed-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
Because dw_mci_request_end() does not disarm host->wd_timer, the stale
command watch remains armed after mmc_request_done() and later injects a
spurious SDMMC_INT_RTO and EVENT_CMD_COMPLETE while idle or during a
subsequent recovery command (for example MMC_GO_IDLE_STATE, which does
not re-arm the command watchdog).
Disarm the central watchdog under host->irq_lock when transitioning to
STATE_IDLE in dw_mci_request_end(), and clear wd_states and
wd_deadline_ns alongside wd_events when disarming in
dw_mci_wd_deliver().
Fixes: ce0043b9a302 ("mmc: dw_mmc: add central watchdog and convert CTO onto it")
Closes: https://sashiko.dev/#/bug/linux-d7e53c20-ef39-494b-bb97-b00b62186c2f
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/mmc/host/dw_mmc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index ff0b25d287a9..6865cffad51a 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -79,8 +79,11 @@
static void dw_mci_wd_deliver(struct dw_mci *host, unsigned long events)
{
host->wd_events &= ~events;
- if (!host->wd_events)
+ if (!host->wd_events) {
+ host->wd_states = 0;
+ host->wd_deadline_ns = 0;
hrtimer_try_to_cancel(&host->wd_timer);
+ }
}
/*
@@ -1887,15 +1890,20 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq)
__acquires(&host->lock)
{
struct mmc_host *prev_mmc = host->mmc;
+ unsigned long irqflags;
WARN_ON(host->cmd || host->data);
host->mrq = NULL;
- if (host->state == STATE_SENDING_CMD11)
+ if (host->state == STATE_SENDING_CMD11) {
host->state = STATE_WAITING_CMD11_DONE;
- else
+ } else {
+ spin_lock_irqsave(&host->irq_lock, irqflags);
+ dw_mci_wd_deliver(host, ~0UL);
+ spin_unlock_irqrestore(&host->irq_lock, irqflags);
host->state = STATE_IDLE;
+ }
spin_unlock(&host->lock);
mmc_request_done(prev_mmc, mrq);