Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>,
	Asutosh Das <quic_asutoshd@quicinc.com>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	"Ulf Hansson" <ulfh@kernel.org>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] mmc: cqhci: keep CQE enabled if halt times out
Date: Fri, 3 Jul 2026 18:41:43 +0300	[thread overview]
Message-ID: <87ef634f-de1e-4a79-a9fd-977d62d85ead@intel.com> (raw)
In-Reply-To: <20260623140401.80963-1-pengpeng@iscas.ac.cn>

On 23/06/2026 17:04, Pengpeng Hou wrote:
> 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.

CQHCI should be idle when cqhci_off() is used, so it should halt
immediately.  If not, it is a hardware error, but carrying on is
a reasonable option because I/O errors will trigger recovery
later.

> 
> 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.

Is there a real problem that you are trying to fix?

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


      reply	other threads:[~2026-07-03 15:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=87ef634f-de1e-4a79-a9fd-977d62d85ead@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=pengpeng@iscas.ac.cn \
    --cc=quic_asutoshd@quicinc.com \
    --cc=ritesh.list@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox