Patch "mmc: cqhci: Fix task clearing in CQE error recovery" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mmc: cqhci: Fix task clearing in CQE error recovery

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mmc-cqhci-fix-task-clearing-in-cqe-error-recovery.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c8b7911432e6118f73990a103b737c8919ad3b71
Author: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Date:   Fri Nov 3 10:47:20 2023 +0200

    mmc: cqhci: Fix task clearing in CQE error recovery
    
    [ Upstream commit 1de1b77982e1a1df9707cb11f9b1789e6b8919d4 ]
    
    If a task completion notification (TCN) is received when there is no
    outstanding task, the cqhci driver issues a "spurious TCN" warning. This
    was observed to happen right after CQE error recovery.
    
    When an error interrupt is received the driver runs recovery logic.
    It halts the controller, clears all pending tasks, and then re-enables
    it. On some platforms, like Intel Jasper Lake, a stale task completion
    event was observed, regardless of the CQHCI_CLEAR_ALL_TASKS bit being set.
    
    This results in either:
    a) Spurious TC completion event for an empty slot.
    b) Corrupted data being passed up the stack, as a result of premature
       completion for a newly added task.
    
    Rather than add a quirk for affected controllers, ensure tasks are cleared
    by toggling CQHCI_ENABLE, which would happen anyway if
    cqhci_clear_all_tasks() timed out. This is simpler and should be safe and
    effective for all controllers.
    
    Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
    Cc: stable@xxxxxxxxxxxxxxx
    Reported-by: Kornel Dulęba <korneld@xxxxxxxxxxxx>
    Tested-by: Kornel Dulęba <korneld@xxxxxxxxxxxx>
    Co-developed-by: Kornel Dulęba <korneld@xxxxxxxxxxxx>
    Signed-off-by: Kornel Dulęba <korneld@xxxxxxxxxxxx>
    Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Reviewed-by: Avri Altman <avri.altman@xxxxxxx>
    Link: https://lore.kernel.org/r/20231103084720.6886-7-adrian.hunter@xxxxxxxxx
    Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
index deae330441788..a17b87fa26351 100644
--- a/drivers/mmc/host/cqhci.c
+++ b/drivers/mmc/host/cqhci.c
@@ -1017,28 +1017,28 @@ static void cqhci_recovery_finish(struct mmc_host *mmc)
 
 	ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
 
-	if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
-		ok = false;
-
 	/*
 	 * The specification contradicts itself, by saying that tasks cannot be
 	 * cleared if CQHCI does not halt, but if CQHCI does not halt, it should
 	 * be disabled/re-enabled, but not to disable before clearing tasks.
 	 * Have a go anyway.
 	 */
-	if (!ok) {
-		pr_debug("%s: cqhci: disable / re-enable\n", mmc_hostname(mmc));
-		cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
-		cqcfg &= ~CQHCI_ENABLE;
-		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
-		cqcfg |= CQHCI_ENABLE;
-		cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
-		/* Be sure that there are no tasks */
-		ok = cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
-		if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
-			ok = false;
-		WARN_ON(!ok);
-	}
+	if (!cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT))
+		ok = false;
+
+	/* Disable to make sure tasks really are cleared */
+	cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
+	cqcfg &= ~CQHCI_ENABLE;
+	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
+
+	cqcfg = cqhci_readl(cq_host, CQHCI_CFG);
+	cqcfg |= CQHCI_ENABLE;
+	cqhci_writel(cq_host, cqcfg, CQHCI_CFG);
+
+	cqhci_halt(mmc, CQHCI_FINISH_HALT_TIMEOUT);
+
+	if (!ok)
+		cqhci_clear_all_tasks(mmc, CQHCI_CLEAR_TIMEOUT);
 
 	cqhci_recover_mrqs(cq_host);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux