]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 4.19
authorSasha Levin <sashal@kernel.org>
Mon, 4 Dec 2023 10:40:13 +0000 (05:40 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 4 Dec 2023 10:40:13 +0000 (05:40 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-4.19/mmc-block-retry-commands-in-cqe-error-recovery.patch [new file with mode: 0644]
queue-4.19/mmc-core-convert-comma-to-semicolon.patch [new file with mode: 0644]
queue-4.19/mmc-cqhci-fix-task-clearing-in-cqe-error-recovery.patch [new file with mode: 0644]
queue-4.19/mmc-cqhci-increase-recovery-halt-timeout.patch [new file with mode: 0644]
queue-4.19/mmc-cqhci-warn-of-halt-or-task-clear-failure.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/mmc-block-retry-commands-in-cqe-error-recovery.patch b/queue-4.19/mmc-block-retry-commands-in-cqe-error-recovery.patch
new file mode 100644 (file)
index 0000000..7ddbe48
--- /dev/null
@@ -0,0 +1,55 @@
+From 10e473cfdc94ed0e58f2f7b01b4f5f654b7befde Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 10:47:18 +0200
+Subject: mmc: block: Retry commands in CQE error recovery
+
+From: Adrian Hunter <adrian.hunter@intel.com>
+
+[ Upstream commit 8155d1fa3a747baad5caff5f8303321d68ddd48c ]
+
+It is important that MMC_CMDQ_TASK_MGMT command to discard the queue is
+successful because otherwise a subsequent reset might fail to flush the
+cache first.  Retry it and the previous STOP command.
+
+Fixes: 72a5af554df8 ("mmc: core: Add support for handling CQE requests")
+Cc: stable@vger.kernel.org
+Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
+Reviewed-by: Avri Altman <avri.altman@wdc.com>
+Link: https://lore.kernel.org/r/20231103084720.6886-5-adrian.hunter@intel.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/core/core.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
+index d76184e4377ef..3c299417c4abc 100644
+--- a/drivers/mmc/core/core.c
++++ b/drivers/mmc/core/core.c
+@@ -571,7 +571,7 @@ int mmc_cqe_recovery(struct mmc_host *host)
+       cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
+       cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+       cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
+-      mmc_wait_for_cmd(host, &cmd, 0);
++      mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.opcode       = MMC_CMDQ_TASK_MGMT;
+@@ -579,10 +579,13 @@ int mmc_cqe_recovery(struct mmc_host *host)
+       cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
+       cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+       cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
+-      err = mmc_wait_for_cmd(host, &cmd, 0);
++      err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
+       host->cqe_ops->cqe_recovery_finish(host);
++      if (err)
++              err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
++
+       mmc_retune_release(host);
+       return err;
+-- 
+2.42.0
+
diff --git a/queue-4.19/mmc-core-convert-comma-to-semicolon.patch b/queue-4.19/mmc-core-convert-comma-to-semicolon.patch
new file mode 100644 (file)
index 0000000..55e9283
--- /dev/null
@@ -0,0 +1,50 @@
+From aa8de13524971d1f10b294dee14d7b0c46b2fdec Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 16 Dec 2020 21:17:37 +0800
+Subject: mmc: core: convert comma to semicolon
+
+From: Zheng Yongjun <zhengyongjun3@huawei.com>
+
+[ Upstream commit 6b1dc6229aecbcb45e8901576684a8c09e25ad7b ]
+
+Replace a comma between expression statements by a semicolon.
+
+Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
+Link: https://lore.kernel.org/r/20201216131737.14883-1-zhengyongjun3@huawei.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Stable-dep-of: 8155d1fa3a74 ("mmc: block: Retry commands in CQE error recovery")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/core/core.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
+index 6937f39fe6575..d76184e4377ef 100644
+--- a/drivers/mmc/core/core.c
++++ b/drivers/mmc/core/core.c
+@@ -567,10 +567,10 @@ int mmc_cqe_recovery(struct mmc_host *host)
+       host->cqe_ops->cqe_recovery_start(host);
+       memset(&cmd, 0, sizeof(cmd));
+-      cmd.opcode       = MMC_STOP_TRANSMISSION,
+-      cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC,
++      cmd.opcode       = MMC_STOP_TRANSMISSION;
++      cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
+       cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+-      cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT,
++      cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
+       mmc_wait_for_cmd(host, &cmd, 0);
+       memset(&cmd, 0, sizeof(cmd));
+@@ -578,7 +578,7 @@ int mmc_cqe_recovery(struct mmc_host *host)
+       cmd.arg          = 1; /* Discard entire queue */
+       cmd.flags        = MMC_RSP_R1B | MMC_CMD_AC;
+       cmd.flags       &= ~MMC_RSP_CRC; /* Ignore CRC */
+-      cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT,
++      cmd.busy_timeout = MMC_CQE_RECOVERY_TIMEOUT;
+       err = mmc_wait_for_cmd(host, &cmd, 0);
+       host->cqe_ops->cqe_recovery_finish(host);
+-- 
+2.42.0
+
diff --git a/queue-4.19/mmc-cqhci-fix-task-clearing-in-cqe-error-recovery.patch b/queue-4.19/mmc-cqhci-fix-task-clearing-in-cqe-error-recovery.patch
new file mode 100644 (file)
index 0000000..82dbf20
--- /dev/null
@@ -0,0 +1,98 @@
+From c8b7911432e6118f73990a103b737c8919ad3b71 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 10:47:20 +0200
+Subject: mmc: cqhci: Fix task clearing in CQE error recovery
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Adrian Hunter <adrian.hunter@intel.com>
+
+[ 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@vger.kernel.org
+Reported-by: Kornel Dulęba <korneld@chromium.org>
+Tested-by: Kornel Dulęba <korneld@chromium.org>
+Co-developed-by: Kornel Dulęba <korneld@chromium.org>
+Signed-off-by: Kornel Dulęba <korneld@chromium.org>
+Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
+Reviewed-by: Avri Altman <avri.altman@wdc.com>
+Link: https://lore.kernel.org/r/20231103084720.6886-7-adrian.hunter@intel.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/cqhci.c | 32 ++++++++++++++++----------------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+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);
+-- 
+2.42.0
+
diff --git a/queue-4.19/mmc-cqhci-increase-recovery-halt-timeout.patch b/queue-4.19/mmc-cqhci-increase-recovery-halt-timeout.patch
new file mode 100644 (file)
index 0000000..1b9c847
--- /dev/null
@@ -0,0 +1,45 @@
+From fffd593f349725c2b2602c711513ebf2518cd972 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 10:47:16 +0200
+Subject: mmc: cqhci: Increase recovery halt timeout
+
+From: Adrian Hunter <adrian.hunter@intel.com>
+
+[ Upstream commit b578d5d18e929aa7c007a98cce32657145dde219 ]
+
+Failing to halt complicates the recovery. Additionally, unless the card or
+controller are stuck, which is expected to be very rare, then the halt
+should succeed, so it is better to wait. Set a large timeout.
+
+Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
+Cc: stable@vger.kernel.org
+Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
+Reviewed-by: Avri Altman <avri.altman@wdc.com>
+Link: https://lore.kernel.org/r/20231103084720.6886-3-adrian.hunter@intel.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/cqhci.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
+index 495a09b5a8e78..773941a92649d 100644
+--- a/drivers/mmc/host/cqhci.c
++++ b/drivers/mmc/host/cqhci.c
+@@ -926,10 +926,10 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)
+ /*
+  * After halting we expect to be able to use the command line. We interpret the
+  * failure to halt to mean the data lines might still be in use (and the upper
+- * layers will need to send a STOP command), so we set the timeout based on a
+- * generous command timeout.
++ * layers will need to send a STOP command), however failing to halt complicates
++ * the recovery, so set a timeout that would reasonably allow I/O to complete.
+  */
+-#define CQHCI_START_HALT_TIMEOUT      5
++#define CQHCI_START_HALT_TIMEOUT      500
+ static void cqhci_recovery_start(struct mmc_host *mmc)
+ {
+-- 
+2.42.0
+
diff --git a/queue-4.19/mmc-cqhci-warn-of-halt-or-task-clear-failure.patch b/queue-4.19/mmc-cqhci-warn-of-halt-or-task-clear-failure.patch
new file mode 100644 (file)
index 0000000..8161efb
--- /dev/null
@@ -0,0 +1,52 @@
+From b077e95731c94124111a93b3713a26108d517b02 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 10:47:19 +0200
+Subject: mmc: cqhci: Warn of halt or task clear failure
+
+From: Adrian Hunter <adrian.hunter@intel.com>
+
+[ Upstream commit 35597bdb04ec27ef3b1cea007dc69f8ff5df75a5 ]
+
+A correctly operating controller should successfully halt and clear tasks.
+Failure may result in errors elsewhere, so promote messages from debug to
+warnings.
+
+Fixes: a4080225f51d ("mmc: cqhci: support for command queue enabled host")
+Cc: stable@vger.kernel.org
+Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
+Reviewed-by: Avri Altman <avri.altman@wdc.com>
+Reviewed-by: Avri Altman <avri.altman@wdc.com>
+Link: https://lore.kernel.org/r/20231103084720.6886-6-adrian.hunter@intel.com
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/cqhci.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/mmc/host/cqhci.c b/drivers/mmc/host/cqhci.c
+index 773941a92649d..deae330441788 100644
+--- a/drivers/mmc/host/cqhci.c
++++ b/drivers/mmc/host/cqhci.c
+@@ -884,8 +884,8 @@ static bool cqhci_clear_all_tasks(struct mmc_host *mmc, unsigned int timeout)
+       ret = cqhci_tasks_cleared(cq_host);
+       if (!ret)
+-              pr_debug("%s: cqhci: Failed to clear tasks\n",
+-                       mmc_hostname(mmc));
++              pr_warn("%s: cqhci: Failed to clear tasks\n",
++                      mmc_hostname(mmc));
+       return ret;
+ }
+@@ -918,7 +918,7 @@ static bool cqhci_halt(struct mmc_host *mmc, unsigned int timeout)
+       ret = cqhci_halted(cq_host);
+       if (!ret)
+-              pr_debug("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
++              pr_warn("%s: cqhci: Failed to halt\n", mmc_hostname(mmc));
+       return ret;
+ }
+-- 
+2.42.0
+
index e47f8799e66deb5bd9db3e6c93aa86208a84a14a..ead3abd9dcca78dd790f7090b6c8f71a4e19ef52 100644 (file)
@@ -68,3 +68,8 @@ ovl-skip-overlayfs-superblocks-at-global-sync.patch
 ima-detect-changes-to-the-backing-overlay-file.patch
 cpufreq-imx6q-don-t-warn-for-disabling-a-non-existin.patch
 cpufreq-imx6q-don-t-disable-792-mhz-opp-unnecessaril.patch
+mmc-cqhci-increase-recovery-halt-timeout.patch
+mmc-cqhci-warn-of-halt-or-task-clear-failure.patch
+mmc-cqhci-fix-task-clearing-in-cqe-error-recovery.patch
+mmc-core-convert-comma-to-semicolon.patch
+mmc-block-retry-commands-in-cqe-error-recovery.patch