All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Jaehoon Chung <jh80.chung@samsung.com>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Ulf Hansson <ulfh@kernel.org>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request
Date: Mon, 23 Nov 2026 19:15:55 +0000	[thread overview]
Message-ID: <20261123191703.179283-12-lee@kernel.org> (raw)
In-Reply-To: <20261123191703.179283-1-lee@kernel.org>

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.

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@kernel.org>
---
 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);
-- 
2.56.1.750.gf70dc682cf-goog


  parent reply	other threads:[~2026-11-23 19:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 19:15 [PATCH 00/13] mmc: Assorted bug fixes across MMC host drivers Lee Jones
2026-11-23 19:15 ` Lee Jones
2026-11-23 19:15 ` [PATCH 01/13] mmc: cavium: Remove MMC slots before destroying slot platform devices Lee Jones
2026-11-23 19:15 ` [PATCH 02/13] mmc: cavium: Prevent slot_pdev[] out-of-bounds write during probe Lee Jones
2026-11-23 19:15 ` [PATCH 03/13] mmc: sdhci-msm: Resume runtime PM before accessing registers on remove Lee Jones
2026-11-23 19:15 ` [PATCH 04/13] mmc: meson-gx: Fail request when descriptor chain DMA mapping fails Lee Jones
2026-11-23 19:15   ` Lee Jones
2026-11-27 23:18   ` Valerio Setti
2026-11-27 23:18     ` Valerio Setti
2026-11-23 19:15 ` [PATCH 05/13] mmc: jz4740: Skip DMA cleanup in PIO mode during post_req Lee Jones
2026-11-23 19:15 ` [PATCH 06/13] mmc: renesas_sdhi: Guard host->cmd access in internal DMAC issue work Lee Jones
2026-11-23 19:15 ` [PATCH 07/13] mmc: tifm_sd: Synchronise timeout handler with request completion Lee Jones
2026-11-23 19:15 ` [PATCH 08/13] mmc: omap: Shut down cover timer before disabling cover BH work Lee Jones
2026-11-23 19:15 ` [PATCH 09/13] mmc: renesas_sdhi: Disable internal DMAC BH work items on release Lee Jones
2026-11-23 19:15 ` [PATCH 10/13] mmc: jz4740: Apply DMA max_seg_size limit to unified tx-rx channel Lee Jones
2026-11-23 19:15 ` Lee Jones [this message]
2026-11-24  1:45   ` [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request Shawn Lin
2026-11-23 19:15 ` [PATCH 12/13] mmc: renesas_sdhi: Fix SDIO manual tap correction in SDR104 mode Lee Jones
2026-11-23 19:15 ` [PATCH 13/13] mmc: sdhci-brcmstb: Handle absent optional sdio_freq clock in probe Lee Jones
2026-11-23 19:31   ` Florian Fainelli
2026-11-25 13:37 ` [PATCH 00/13] mmc: Assorted bug fixes across MMC host drivers Biju Das
2026-11-25 13:37   ` Biju Das
2026-11-25 15:08   ` wsa+renesas
2026-11-25 15:08     ` wsa+renesas
2026-11-25 18:02     ` Biju Das
2026-11-25 18:02       ` Biju Das
2026-11-25 17:50 ` Markus Elfring
2026-11-25 17:50   ` Markus Elfring
2026-11-26  8:53   ` Lee Jones
2026-11-26  8:53     ` Lee Jones
2026-11-26  9:23     ` [00/13] " Markus Elfring
2026-11-26  9:23       ` Markus Elfring
2026-11-26 11:29       ` Lee Jones
2026-11-26 11:29         ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123191703.179283-12-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=jh80.chung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=ulfh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.