Re: [PATCH 1/2] mmc: cqhci: Log error IRQ details and card R1 status on recovery
From: Adrian Hunter
Date: Fri Dec 04 2026 - 05:53:42 EST
On 01/12/2026 19:20, Athira Palliprath via B4 Relay wrote:
> From: Athira Palliprath <palliprath@xxxxxxxxxxxx>
>
> Currently cqhci_error_irq() only logs the error IRQ status, cmd_error,
> data_error, and TERRI at pr_debug() level and never reads CQHCI_CRI or
> CQHCI_CRA (the eMMC R1 card response status on Response Error Detected).
> As a result, production kernel logs on CQE-enabled devices only record
> "running CQE recovery" without indicating whether recovery was triggered
> by an uncorrectable NAND ECC error (R1_CARD_ECC_FAILED), a bus CRC error
> (-EILSEQ), or a host timeout (-ETIMEDOUT).
What about making more use of mmc_debugfs_err_stats_inc() instead?
>
> Log these error details via pr_err_ratelimited() once per recovery
> trigger (after the recovery_halt guard and idle check so normal I/O and
> in-progress recoveries emit zero extra messages), including CRI and CRA
> when CQHCI_IS_RED is set.
>
> Signed-off-by: Athira Palliprath <palliprath@xxxxxxxxxxxx>
> ---
> drivers/mmc/host/cqhci-core.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/mmc/host/cqhci-core.c b/drivers/mmc/host/cqhci-core.c
> index a466cd88b..69b125c1e 100644
> --- a/drivers/mmc/host/cqhci-core.c
> +++ b/drivers/mmc/host/cqhci-core.c
> @@ -724,6 +724,19 @@ static void cqhci_error_irq(struct mmc_host *mmc, u32 status, int cmd_error,
> goto out_unlock;
> }
>
> + if (status & CQHCI_IS_RED) {
> + u32 cri = cqhci_readl(cq_host, CQHCI_CRI);
> + u32 cra = cqhci_readl(cq_host, CQHCI_CRA);
> +
> + pr_err_ratelimited("%s: cqhci: error IRQ status: 0x%08x cmd error %d data error %d TERRI: 0x%08x CRI: 0x%08x CRA: 0x%08x\n",
> + mmc_hostname(mmc), status, cmd_error,
> + data_error, terri, cri, cra);
Might just as well put cqhci_readl(cq_host, CQHCI_CRI) and
cqhci_readl(cq_host, CQHCI_CRA) into the arguments list.
Also, we probably don't need to optimize the error path,
so could have only this version of the print, and drop
the 'if'
And it feels a bit redundant to keep the pr_debug() as well.
> + } else {
> + pr_err_ratelimited("%s: cqhci: error IRQ status: 0x%08x cmd error %d data error %d TERRI: 0x%08x\n",
> + mmc_hostname(mmc), status, cmd_error,
> + data_error, terri);
> + }
> +
> if (CQHCI_TERRI_C_VALID(terri)) {
> tag = CQHCI_TERRI_C_TASK(terri);
> slot = &cq_host->slot[tag];
>