mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: Lee Jones <lee@kernel.org>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Ulf Hansson <ulfh@kernel.org>,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: shawn.lin@rock-chips.com
Subject: Re: [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request
Date: Tue, 24 Nov 2026 09:45:08 +0800	[thread overview]
Message-ID: <55ccec4a-0f33-4332-a70f-000b2cde351f@rock-chips.com> (raw)
In-Reply-To: <20261123191703.179283-12-lee@kernel.org>

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@rock-chips.com>

> 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);


  reply	other threads:[~2026-11-24  1:45 UTC|newest]

Thread overview: 16+ 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 ` [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 ` [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 ` [PATCH 11/13] mmc: dw_mmc: Disarm central watchdog when ending a request Lee Jones
2026-11-24  1:45   ` Shawn Lin [this message]
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

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=55ccec4a-0f33-4332-a70f-000b2cde351f@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=jh80.chung@samsung.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®