All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42 ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

This is a series of identical fixes for several SDHCI host
drivers. Patch #2 (for sdhci-of-arasan; plus its dependency in patch #1)
is the only one I've tested, and I wrote it due to a bug described
there.

I then noticed that several other drivers do the same thing, and that
commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for
Intel GLK-based controllers") points out the likely-repeated bug. So the
fix is now factored into a separate sdhci_and_cqhci_reset() helper,
and it's likely that most/all drivers that support a combo SDHCI/CQHCI
controller will want to use it.

Thus, I include additional patches (compile-tested only) that apply this
helper/fix to the other drivers which call cqhci_init() but not
cqhci_deactivate(). They contain appropriate disclaimers and the
relevant parties are CC'd. I would suggest only merging them if you get
some kind of ACK from people familiar with the relevant hardware.

Notably, I do *not* patch drivers/mmc/host/mtk-sd.c although it uses
CQHCI, because it doesn't seem to be an SDHCI-based controller, and so
even if it has a similar bug, it's not clear to me how to patch it.

- Brian

Changes in v4:
 - Improve for-stable cherry-picking notes
 - Add Adrian's Ack
 - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops

Changes in v3:
 - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()

Changes in v2:
 - Rely on cqhci_deactivate() to safely handle (ignore)
   not-yet-initialized CQE support

Brian Norris (7):
  mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
  mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
  mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()

 drivers/mmc/host/sdhci-brcmstb.c   |  3 ++-
 drivers/mmc/host/sdhci-cqhci.h     | 24 ++++++++++++++++++++++++
 drivers/mmc/host/sdhci-esdhc-imx.c |  3 ++-
 drivers/mmc/host/sdhci-msm.c       | 10 ++--------
 drivers/mmc/host/sdhci-of-arasan.c |  3 ++-
 drivers/mmc/host/sdhci-pci-core.c  | 11 ++---------
 drivers/mmc/host/sdhci-pci-gli.c   | 11 ++---------
 drivers/mmc/host/sdhci-tegra.c     |  3 ++-
 drivers/mmc/host/sdhci_am654.c     |  7 ++++---
 9 files changed, 42 insertions(+), 33 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-cqhci.h

-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42 ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

This is a series of identical fixes for several SDHCI host
drivers. Patch #2 (for sdhci-of-arasan; plus its dependency in patch #1)
is the only one I've tested, and I wrote it due to a bug described
there.

I then noticed that several other drivers do the same thing, and that
commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for
Intel GLK-based controllers") points out the likely-repeated bug. So the
fix is now factored into a separate sdhci_and_cqhci_reset() helper,
and it's likely that most/all drivers that support a combo SDHCI/CQHCI
controller will want to use it.

Thus, I include additional patches (compile-tested only) that apply this
helper/fix to the other drivers which call cqhci_init() but not
cqhci_deactivate(). They contain appropriate disclaimers and the
relevant parties are CC'd. I would suggest only merging them if you get
some kind of ACK from people familiar with the relevant hardware.

Notably, I do *not* patch drivers/mmc/host/mtk-sd.c although it uses
CQHCI, because it doesn't seem to be an SDHCI-based controller, and so
even if it has a similar bug, it's not clear to me how to patch it.

- Brian

Changes in v4:
 - Improve for-stable cherry-picking notes
 - Add Adrian's Ack
 - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops

Changes in v3:
 - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()

Changes in v2:
 - Rely on cqhci_deactivate() to safely handle (ignore)
   not-yet-initialized CQE support

Brian Norris (7):
  mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
  mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
  mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
  mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()

 drivers/mmc/host/sdhci-brcmstb.c   |  3 ++-
 drivers/mmc/host/sdhci-cqhci.h     | 24 ++++++++++++++++++++++++
 drivers/mmc/host/sdhci-esdhc-imx.c |  3 ++-
 drivers/mmc/host/sdhci-msm.c       | 10 ++--------
 drivers/mmc/host/sdhci-of-arasan.c |  3 ++-
 drivers/mmc/host/sdhci-pci-core.c  | 11 ++---------
 drivers/mmc/host/sdhci-pci-gli.c   | 11 ++---------
 drivers/mmc/host/sdhci-tegra.c     |  3 ++-
 drivers/mmc/host/sdhci_am654.c     |  7 ++++---
 9 files changed, 42 insertions(+), 33 deletions(-)
 create mode 100644 drivers/mmc/host/sdhci-cqhci.h

-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris, stable

Several SDHCI drivers need to deactivate command queueing in their reset
hook (see sdhci_cqhci_reset() / sdhci-pci-core.c, for example), and
several more are coming.

Those reset implementations have some small subtleties (e.g., ordering
of initialization of SDHCI vs. CQHCI might leave us resetting with a
NULL ->cqe_private), and are often identical across different host
drivers.

We also don't want to force a dependency between SDHCI and CQHCI, or
vice versa; non-SDHCI drivers use CQHCI, and SDHCI drivers might support
command queueing through some other means.

So, implement a small helper, to avoid repeating the same mistakes in
different drivers. Simply stick it in a header, because it's so small it
doesn't deserve its own module right now, and inlining to each driver is
pretty reasonable.

This is marked for -stable, as it is an important prerequisite patch for
several SDHCI controller bugfixes that follow.

Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Whitespace fixup
 - Add Adrian's Ack

Changes in v3:
 - New in v3 (replacing a simple 'cqe_private == NULL' patch in v2)

 drivers/mmc/host/sdhci-cqhci.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 drivers/mmc/host/sdhci-cqhci.h

diff --git a/drivers/mmc/host/sdhci-cqhci.h b/drivers/mmc/host/sdhci-cqhci.h
new file mode 100644
index 000000000000..cf8e7ba71bbd
--- /dev/null
+++ b/drivers/mmc/host/sdhci-cqhci.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2022 The Chromium OS Authors
+ *
+ * Support that applies to the combination of SDHCI and CQHCI, while not
+ * expressing a dependency between the two modules.
+ */
+
+#ifndef __MMC_HOST_SDHCI_CQHCI_H__
+#define __MMC_HOST_SDHCI_CQHCI_H__
+
+#include "cqhci.h"
+#include "sdhci.h"
+
+static inline void sdhci_and_cqhci_reset(struct sdhci_host *host, u8 mask)
+{
+	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
+	    host->mmc->cqe_private)
+		cqhci_deactivate(host->mmc);
+
+	sdhci_reset(host, mask);
+}
+
+#endif /* __MMC_HOST_SDHCI_CQHCI_H__ */
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris, stable

Several SDHCI drivers need to deactivate command queueing in their reset
hook (see sdhci_cqhci_reset() / sdhci-pci-core.c, for example), and
several more are coming.

Those reset implementations have some small subtleties (e.g., ordering
of initialization of SDHCI vs. CQHCI might leave us resetting with a
NULL ->cqe_private), and are often identical across different host
drivers.

We also don't want to force a dependency between SDHCI and CQHCI, or
vice versa; non-SDHCI drivers use CQHCI, and SDHCI drivers might support
command queueing through some other means.

So, implement a small helper, to avoid repeating the same mistakes in
different drivers. Simply stick it in a header, because it's so small it
doesn't deserve its own module right now, and inlining to each driver is
pretty reasonable.

This is marked for -stable, as it is an important prerequisite patch for
several SDHCI controller bugfixes that follow.

Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Whitespace fixup
 - Add Adrian's Ack

Changes in v3:
 - New in v3 (replacing a simple 'cqe_private == NULL' patch in v2)

 drivers/mmc/host/sdhci-cqhci.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 drivers/mmc/host/sdhci-cqhci.h

diff --git a/drivers/mmc/host/sdhci-cqhci.h b/drivers/mmc/host/sdhci-cqhci.h
new file mode 100644
index 000000000000..cf8e7ba71bbd
--- /dev/null
+++ b/drivers/mmc/host/sdhci-cqhci.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright 2022 The Chromium OS Authors
+ *
+ * Support that applies to the combination of SDHCI and CQHCI, while not
+ * expressing a dependency between the two modules.
+ */
+
+#ifndef __MMC_HOST_SDHCI_CQHCI_H__
+#define __MMC_HOST_SDHCI_CQHCI_H__
+
+#include "cqhci.h"
+#include "sdhci.h"
+
+static inline void sdhci_and_cqhci_reset(struct sdhci_host *host, u8 mask)
+{
+	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
+	    host->mmc->cqe_private)
+		cqhci_deactivate(host->mmc);
+
+	sdhci_reset(host, mask);
+}
+
+#endif /* __MMC_HOST_SDHCI_CQHCI_H__ */
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 2/7] mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris, stable, Guenter Roeck

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but one
particular case I hit commonly enough: mmc_suspend() -> mmc_power_off().
Typically we will eventually deactivate CQE (cqhci_suspend() ->
cqhci_deactivate()), but that's not guaranteed -- in particular, if
we perform a partial (e.g., interrupted) system suspend.

The same bug was already found and fixed for two other drivers, in v5.7
and v5.9:

  5cf583f1fb9c ("mmc: sdhci-msm: Deactivate CQE during SDHC reset")
  df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel
                 GLK-based controllers")

The latter is especially prescient, saying "other drivers using CQHCI
might benefit from a similar change, if they also have CQHCI reset by
SDHCI_RESET_ALL."

So like these other patches, deactivate CQHCI when resetting the
controller. Do this via the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: 84362d79f436 ("mmc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1")
Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Improve for-stable cherry-picking notes
 - Add Adrian's Ack

Changes in v3:
 - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()

Changes in v2:
 - Rely on cqhci_deactivate() to safely handle (ignore)
   not-yet-initialized CQE support

 drivers/mmc/host/sdhci-of-arasan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 3997cad1f793..cfb891430174 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -25,6 +25,7 @@
 #include <linux/firmware/xlnx-zynqmp.h>
 
 #include "cqhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 
 #define SDHCI_ARASAN_VENDOR_REGISTER	0x78
@@ -366,7 +367,7 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_FORCE_CDTEST) {
 		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 2/7] mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris, stable, Guenter Roeck

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but one
particular case I hit commonly enough: mmc_suspend() -> mmc_power_off().
Typically we will eventually deactivate CQE (cqhci_suspend() ->
cqhci_deactivate()), but that's not guaranteed -- in particular, if
we perform a partial (e.g., interrupted) system suspend.

The same bug was already found and fixed for two other drivers, in v5.7
and v5.9:

  5cf583f1fb9c ("mmc: sdhci-msm: Deactivate CQE during SDHC reset")
  df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel
                 GLK-based controllers")

The latter is especially prescient, saying "other drivers using CQHCI
might benefit from a similar change, if they also have CQHCI reset by
SDHCI_RESET_ALL."

So like these other patches, deactivate CQHCI when resetting the
controller. Do this via the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: 84362d79f436 ("mmc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1")
Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Improve for-stable cherry-picking notes
 - Add Adrian's Ack

Changes in v3:
 - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()

Changes in v2:
 - Rely on cqhci_deactivate() to safely handle (ignore)
   not-yet-initialized CQE support

 drivers/mmc/host/sdhci-of-arasan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index 3997cad1f793..cfb891430174 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -25,6 +25,7 @@
 #include <linux/firmware/xlnx-zynqmp.h>
 
 #include "cqhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 
 #define SDHCI_ARASAN_VENDOR_REGISTER	0x78
@@ -366,7 +367,7 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_FORCE_CDTEST) {
 		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 3/7] mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

I only patch the bcm7216 variant even though others potentially *could*
provide the 'supports-cqe' property (and thus enable CQHCI), because
d46ba2d17f90 ("mmc: sdhci-brcmstb: Add support for Command Queuing
(CQE)") and some Broadcom folks confirm that only the 7216 variant
actually supports it.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: d46ba2d17f90 ("mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Improve commit notes
 - Add Adrian's Ack
 - Add Florian's Reviewed-by

Changes in v3:
 - Use new SDHCI+CQHCI helper

Changes in v2:
 - Rely on cqhci_deactivate() to handle NULL cqe_private, instead of
   moving around CQE capability flags

 drivers/mmc/host/sdhci-brcmstb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c
index aff36a933ebe..55d8bd232695 100644
--- a/drivers/mmc/host/sdhci-brcmstb.c
+++ b/drivers/mmc/host/sdhci-brcmstb.c
@@ -12,6 +12,7 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -55,7 +56,7 @@ static void brcmstb_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	/* Reset will clear this, so re-enable it */
 	if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK)
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 3/7] mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

I only patch the bcm7216 variant even though others potentially *could*
provide the 'supports-cqe' property (and thus enable CQHCI), because
d46ba2d17f90 ("mmc: sdhci-brcmstb: Add support for Command Queuing
(CQE)") and some Broadcom folks confirm that only the 7216 variant
actually supports it.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: d46ba2d17f90 ("mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Improve commit notes
 - Add Adrian's Ack
 - Add Florian's Reviewed-by

Changes in v3:
 - Use new SDHCI+CQHCI helper

Changes in v2:
 - Rely on cqhci_deactivate() to handle NULL cqe_private, instead of
   moving around CQE capability flags

 drivers/mmc/host/sdhci-brcmstb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c
index aff36a933ebe..55d8bd232695 100644
--- a/drivers/mmc/host/sdhci-brcmstb.c
+++ b/drivers/mmc/host/sdhci-brcmstb.c
@@ -12,6 +12,7 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -55,7 +56,7 @@ static void brcmstb_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	/* Reset will clear this, so re-enable it */
 	if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK)
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 4/7] mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: bb6e358169bf ("mmc: sdhci-esdhc-imx: add CMDQ support")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add dependency notes
 - Add Adrian's Ack

Changes in v3:
 - Use new SDHCI+CQHCI helper
 - Add Reviewed-by

Changes in v2:
 - Drop unnecessary ESDHC_FLAG_CQHCI check

 drivers/mmc/host/sdhci-esdhc-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 55981b0f0b10..b297c3c360eb 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -25,6 +25,7 @@
 #include <linux/of_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
 #include "cqhci.h"
@@ -1288,7 +1289,7 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
 
 static void esdhc_reset(struct sdhci_host *host, u8 mask)
 {
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 4/7] mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: bb6e358169bf ("mmc: sdhci-esdhc-imx: add CMDQ support")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add dependency notes
 - Add Adrian's Ack

Changes in v3:
 - Use new SDHCI+CQHCI helper
 - Add Reviewed-by

Changes in v2:
 - Drop unnecessary ESDHC_FLAG_CQHCI check

 drivers/mmc/host/sdhci-esdhc-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 55981b0f0b10..b297c3c360eb 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -25,6 +25,7 @@
 #include <linux/of_device.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "sdhci-esdhc.h"
 #include "cqhci.h"
@@ -1288,7 +1289,7 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
 
 static void esdhc_reset(struct sdhci_host *host, u8 mask)
 {
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
 	sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 5/7] mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: 3c4019f97978 ("mmc: tegra: HW Command Queue Support for Tegra SDMMC")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add dependency notes
 - Add Adrian's Ack

Changes in v3:
 - Use new SDHCI+CQHCI helper

Changes in v2:
 - Drop unnecessary 'enable_hwcq' check

 drivers/mmc/host/sdhci-tegra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 413925bce0ca..c71000a07656 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -28,6 +28,7 @@
 
 #include <soc/tegra/common.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -367,7 +368,7 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
 	const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
 	u32 misc_ctrl, clk_ctrl, pad_ctrl;
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (!(mask & SDHCI_RESET_ALL))
 		return;
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 5/7] mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: 3c4019f97978 ("mmc: tegra: HW Command Queue Support for Tegra SDMMC")
Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add dependency notes
 - Add Adrian's Ack

Changes in v3:
 - Use new SDHCI+CQHCI helper

Changes in v2:
 - Drop unnecessary 'enable_hwcq' check

 drivers/mmc/host/sdhci-tegra.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 413925bce0ca..c71000a07656 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -28,6 +28,7 @@
 
 #include <soc/tegra/common.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -367,7 +368,7 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask)
 	const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
 	u32 misc_ctrl, clk_ctrl, pad_ctrl;
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (!(mask & SDHCI_RESET_ALL))
 		return;
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 6/7] mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: f545702b74f9 ("mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v4:
 - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
 - Add dependency notes
 - Drop bouncing Faiz Abbas <faiz_abbas@ti.com> address

Changes in v3:
 - Use new SDHCI+CQHCI helper

 drivers/mmc/host/sdhci_am654.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c
index 8f1023480e12..c2333c7acac9 100644
--- a/drivers/mmc/host/sdhci_am654.c
+++ b/drivers/mmc/host/sdhci_am654.c
@@ -15,6 +15,7 @@
 #include <linux/sys_soc.h>
 
 #include "cqhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 
 /* CTL_CFG Registers */
@@ -378,7 +379,7 @@ static void sdhci_am654_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) {
 		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
@@ -464,7 +465,7 @@ static struct sdhci_ops sdhci_am654_ops = {
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
 	.irq = sdhci_am654_cqhci_irq,
-	.reset = sdhci_reset,
+	.reset = sdhci_and_cqhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_am654_pdata = {
@@ -494,7 +495,7 @@ static struct sdhci_ops sdhci_j721e_8bit_ops = {
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
 	.irq = sdhci_am654_cqhci_irq,
-	.reset = sdhci_reset,
+	.reset = sdhci_and_cqhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_j721e_8bit_pdata = {
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 6/7] mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

 [[ NOTE: this is completely untested by the author, but included solely
    because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
    SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
    drivers using CQHCI might benefit from a similar change, if they
    also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
    bug on at least MSM, Arasan, and Intel hardware. ]]

SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
tracking that properly in software. When out of sync, we may trigger
various timeouts.

It's not typical to perform resets while CQE is enabled, but this may
occur in some suspend or error recovery scenarios.

Include this fix by way of the new sdhci_and_cqhci_reset() helper.

This patch depends on (and should not compile without) the patch
entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
CQHCI".

Fixes: f545702b74f9 ("mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v4:
 - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
 - Add dependency notes
 - Drop bouncing Faiz Abbas <faiz_abbas@ti.com> address

Changes in v3:
 - Use new SDHCI+CQHCI helper

 drivers/mmc/host/sdhci_am654.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c
index 8f1023480e12..c2333c7acac9 100644
--- a/drivers/mmc/host/sdhci_am654.c
+++ b/drivers/mmc/host/sdhci_am654.c
@@ -15,6 +15,7 @@
 #include <linux/sys_soc.h>
 
 #include "cqhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 
 /* CTL_CFG Registers */
@@ -378,7 +379,7 @@ static void sdhci_am654_reset(struct sdhci_host *host, u8 mask)
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
 	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
 
-	sdhci_reset(host, mask);
+	sdhci_and_cqhci_reset(host, mask);
 
 	if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) {
 		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
@@ -464,7 +465,7 @@ static struct sdhci_ops sdhci_am654_ops = {
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
 	.irq = sdhci_am654_cqhci_irq,
-	.reset = sdhci_reset,
+	.reset = sdhci_and_cqhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_am654_pdata = {
@@ -494,7 +495,7 @@ static struct sdhci_ops sdhci_j721e_8bit_ops = {
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
 	.irq = sdhci_am654_cqhci_irq,
-	.reset = sdhci_reset,
+	.reset = sdhci_and_cqhci_reset,
 };
 
 static const struct sdhci_pltfm_data sdhci_j721e_8bit_pdata = {
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 7/7] mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()
  2022-10-26 19:42 ` Brian Norris
@ 2022-10-26 19:42   ` Brian Norris
  -1 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

An earlier patch ("mmc: cqhci: Provide helper for resetting both SDHCI
and CQHCI") does these operations for us.

I keep these as a separate patch, since the earlier patch is a
prerequisite to some important bugfixes that need to be backported via
linux-stable.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add Adrian's Ack

Changes in v3:
 - Rewrite to new helper, patch sdhci-msm too

Changes in v2:
 - Factor out ->cqe_private helpers

 drivers/mmc/host/sdhci-msm.c      | 10 ++--------
 drivers/mmc/host/sdhci-pci-core.c | 11 ++---------
 drivers/mmc/host/sdhci-pci-gli.c  | 11 ++---------
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 3a091a387ecb..03f76384ab3f 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -19,6 +19,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/reset.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -2304,13 +2305,6 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
 	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
 }
 
-static void sdhci_msm_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL))
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 static int sdhci_msm_register_vreg(struct sdhci_msm_host *msm_host)
 {
 	int ret;
@@ -2450,7 +2444,7 @@ static const struct of_device_id sdhci_msm_dt_match[] = {
 MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match);
 
 static const struct sdhci_ops sdhci_msm_ops = {
-	.reset = sdhci_msm_reset,
+	.reset = sdhci_and_cqhci_reset,
 	.set_clock = sdhci_msm_set_clock,
 	.get_min_clock = sdhci_msm_get_min_clock,
 	.get_max_clock = sdhci_msm_get_max_clock,
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 169b84761041..cc039155b5c7 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -38,6 +38,7 @@
 #include "cqhci.h"
 
 #include "sdhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pci.h"
 
 static void sdhci_pci_hw_reset(struct sdhci_host *host);
@@ -234,14 +235,6 @@ static void sdhci_pci_dumpregs(struct mmc_host *mmc)
 	sdhci_dumpregs(mmc_priv(mmc));
 }
 
-static void sdhci_cqhci_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
-	    host->mmc->cqe_private)
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 /*****************************************************************************\
  *                                                                           *
  * Hardware specific quirk handling                                          *
@@ -703,7 +696,7 @@ static const struct sdhci_ops sdhci_intel_glk_ops = {
 	.set_power		= sdhci_intel_set_power,
 	.enable_dma		= sdhci_pci_enable_dma,
 	.set_bus_width		= sdhci_set_bus_width,
-	.reset			= sdhci_cqhci_reset,
+	.reset			= sdhci_and_cqhci_reset,
 	.set_uhs_signaling	= sdhci_intel_set_uhs_signaling,
 	.hw_reset		= sdhci_pci_hw_reset,
 	.irq			= sdhci_cqhci_irq,
diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
index 4d509f656188..633a8ee8f8c5 100644
--- a/drivers/mmc/host/sdhci-pci-gli.c
+++ b/drivers/mmc/host/sdhci-pci-gli.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/iopoll.h>
 #include "sdhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pci.h"
 #include "cqhci.h"
 
@@ -922,14 +923,6 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot)
 	return ret;
 }
 
-static void sdhci_gl9763e_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
-	    host->mmc->cqe_private)
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
 {
 	struct pci_dev *pdev = slot->chip->pdev;
@@ -1136,7 +1129,7 @@ static const struct sdhci_ops sdhci_gl9763e_ops = {
 	.set_clock		= sdhci_set_clock,
 	.enable_dma		= sdhci_pci_enable_dma,
 	.set_bus_width		= sdhci_set_bus_width,
-	.reset			= sdhci_gl9763e_reset,
+	.reset			= sdhci_and_cqhci_reset,
 	.set_uhs_signaling	= sdhci_set_gl9763e_signaling,
 	.voltage_switch		= sdhci_gli_voltage_switch,
 	.irq                    = sdhci_gl9763e_cqhci_irq,
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 7/7] mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()
@ 2022-10-26 19:42   ` Brian Norris
  0 siblings, 0 replies; 22+ messages in thread
From: Brian Norris @ 2022-10-26 19:42 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni, Brian Norris

An earlier patch ("mmc: cqhci: Provide helper for resetting both SDHCI
and CQHCI") does these operations for us.

I keep these as a separate patch, since the earlier patch is a
prerequisite to some important bugfixes that need to be backported via
linux-stable.

Signed-off-by: Brian Norris <briannorris@chromium.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
---

Changes in v4:
 - Add Adrian's Ack

Changes in v3:
 - Rewrite to new helper, patch sdhci-msm too

Changes in v2:
 - Factor out ->cqe_private helpers

 drivers/mmc/host/sdhci-msm.c      | 10 ++--------
 drivers/mmc/host/sdhci-pci-core.c | 11 ++---------
 drivers/mmc/host/sdhci-pci-gli.c  | 11 ++---------
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 3a091a387ecb..03f76384ab3f 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -19,6 +19,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/reset.h>
 
+#include "sdhci-cqhci.h"
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
 
@@ -2304,13 +2305,6 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host)
 	pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps);
 }
 
-static void sdhci_msm_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL))
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 static int sdhci_msm_register_vreg(struct sdhci_msm_host *msm_host)
 {
 	int ret;
@@ -2450,7 +2444,7 @@ static const struct of_device_id sdhci_msm_dt_match[] = {
 MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match);
 
 static const struct sdhci_ops sdhci_msm_ops = {
-	.reset = sdhci_msm_reset,
+	.reset = sdhci_and_cqhci_reset,
 	.set_clock = sdhci_msm_set_clock,
 	.get_min_clock = sdhci_msm_get_min_clock,
 	.get_max_clock = sdhci_msm_get_max_clock,
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index 169b84761041..cc039155b5c7 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -38,6 +38,7 @@
 #include "cqhci.h"
 
 #include "sdhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pci.h"
 
 static void sdhci_pci_hw_reset(struct sdhci_host *host);
@@ -234,14 +235,6 @@ static void sdhci_pci_dumpregs(struct mmc_host *mmc)
 	sdhci_dumpregs(mmc_priv(mmc));
 }
 
-static void sdhci_cqhci_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
-	    host->mmc->cqe_private)
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 /*****************************************************************************\
  *                                                                           *
  * Hardware specific quirk handling                                          *
@@ -703,7 +696,7 @@ static const struct sdhci_ops sdhci_intel_glk_ops = {
 	.set_power		= sdhci_intel_set_power,
 	.enable_dma		= sdhci_pci_enable_dma,
 	.set_bus_width		= sdhci_set_bus_width,
-	.reset			= sdhci_cqhci_reset,
+	.reset			= sdhci_and_cqhci_reset,
 	.set_uhs_signaling	= sdhci_intel_set_uhs_signaling,
 	.hw_reset		= sdhci_pci_hw_reset,
 	.irq			= sdhci_cqhci_irq,
diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
index 4d509f656188..633a8ee8f8c5 100644
--- a/drivers/mmc/host/sdhci-pci-gli.c
+++ b/drivers/mmc/host/sdhci-pci-gli.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/iopoll.h>
 #include "sdhci.h"
+#include "sdhci-cqhci.h"
 #include "sdhci-pci.h"
 #include "cqhci.h"
 
@@ -922,14 +923,6 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot)
 	return ret;
 }
 
-static void sdhci_gl9763e_reset(struct sdhci_host *host, u8 mask)
-{
-	if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
-	    host->mmc->cqe_private)
-		cqhci_deactivate(host->mmc);
-	sdhci_reset(host, mask);
-}
-
 static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
 {
 	struct pci_dev *pdev = slot->chip->pdev;
@@ -1136,7 +1129,7 @@ static const struct sdhci_ops sdhci_gl9763e_ops = {
 	.set_clock		= sdhci_set_clock,
 	.enable_dma		= sdhci_pci_enable_dma,
 	.set_bus_width		= sdhci_set_bus_width,
-	.reset			= sdhci_gl9763e_reset,
+	.reset			= sdhci_and_cqhci_reset,
 	.set_uhs_signaling	= sdhci_set_gl9763e_signaling,
 	.voltage_switch		= sdhci_gli_voltage_switch,
 	.irq                    = sdhci_gl9763e_cqhci_irq,
-- 
2.38.0.135.g90850a2211-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
  2022-10-26 19:42   ` Brian Norris
@ 2022-10-26 19:44     ` Florian Fainelli
  -1 siblings, 0 replies; 22+ messages in thread
From: Florian Fainelli @ 2022-10-26 19:44 UTC (permalink / raw)
  To: Brian Norris, Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	NXP Linux Team, Haibo Chen, Sowjanya Komatineni, stable

On 10/26/22 12:42, Brian Norris wrote:
> Several SDHCI drivers need to deactivate command queueing in their reset
> hook (see sdhci_cqhci_reset() / sdhci-pci-core.c, for example), and
> several more are coming.
> 
> Those reset implementations have some small subtleties (e.g., ordering
> of initialization of SDHCI vs. CQHCI might leave us resetting with a
> NULL ->cqe_private), and are often identical across different host
> drivers.
> 
> We also don't want to force a dependency between SDHCI and CQHCI, or
> vice versa; non-SDHCI drivers use CQHCI, and SDHCI drivers might support
> command queueing through some other means.
> 
> So, implement a small helper, to avoid repeating the same mistakes in
> different drivers. Simply stick it in a header, because it's so small it
> doesn't deserve its own module right now, and inlining to each driver is
> pretty reasonable.
> 
> This is marked for -stable, as it is an important prerequisite patch for
> several SDHCI controller bugfixes that follow.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
@ 2022-10-26 19:44     ` Florian Fainelli
  0 siblings, 0 replies; 22+ messages in thread
From: Florian Fainelli @ 2022-10-26 19:44 UTC (permalink / raw)
  To: Brian Norris, Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	NXP Linux Team, Haibo Chen, Sowjanya Komatineni, stable

On 10/26/22 12:42, Brian Norris wrote:
> Several SDHCI drivers need to deactivate command queueing in their reset
> hook (see sdhci_cqhci_reset() / sdhci-pci-core.c, for example), and
> several more are coming.
> 
> Those reset implementations have some small subtleties (e.g., ordering
> of initialization of SDHCI vs. CQHCI might leave us resetting with a
> NULL ->cqe_private), and are often identical across different host
> drivers.
> 
> We also don't want to force a dependency between SDHCI and CQHCI, or
> vice versa; non-SDHCI drivers use CQHCI, and SDHCI drivers might support
> command queueing through some other means.
> 
> So, implement a small helper, to avoid repeating the same mistakes in
> different drivers. Simply stick it in a header, because it's so small it
> doesn't deserve its own module right now, and inlining to each driver is
> pretty reasonable.
> 
> This is marked for -stable, as it is an important prerequisite patch for
> several SDHCI controller bugfixes that follow.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 6/7] mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42   ` Brian Norris
@ 2022-10-27  7:58     ` Adrian Hunter
  -1 siblings, 0 replies; 22+ messages in thread
From: Adrian Hunter @ 2022-10-27  7:58 UTC (permalink / raw)
  To: Brian Norris, Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Shawn Lin, Michal Simek, Sascha Hauer,
	Bjorn Andersson, Thierry Reding, linux-arm-msm, linux-arm-kernel,
	Broadcom internal kernel review list, Jonathan Hunter,
	Andy Gross, Pengutronix Kernel Team, linux-kernel, Konrad Dybcio,
	Al Cooper, Fabio Estevam, Florian Fainelli, NXP Linux Team,
	Haibo Chen, Sowjanya Komatineni

On 26/10/22 22:42, Brian Norris wrote:
>  [[ NOTE: this is completely untested by the author, but included solely
>     because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
>     SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
>     drivers using CQHCI might benefit from a similar change, if they
>     also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
>     bug on at least MSM, Arasan, and Intel hardware. ]]
> 
> SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
> tracking that properly in software. When out of sync, we may trigger
> various timeouts.
> 
> It's not typical to perform resets while CQE is enabled, but this may
> occur in some suspend or error recovery scenarios.
> 
> Include this fix by way of the new sdhci_and_cqhci_reset() helper.
> 
> This patch depends on (and should not compile without) the patch
> entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
> CQHCI".
> 
> Fixes: f545702b74f9 ("mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E")
> Signed-off-by: Brian Norris <briannorris@chromium.org>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> 
> Changes in v4:
>  - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
>  - Add dependency notes
>  - Drop bouncing Faiz Abbas <faiz_abbas@ti.com> address
> 
> Changes in v3:
>  - Use new SDHCI+CQHCI helper
> 
>  drivers/mmc/host/sdhci_am654.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c
> index 8f1023480e12..c2333c7acac9 100644
> --- a/drivers/mmc/host/sdhci_am654.c
> +++ b/drivers/mmc/host/sdhci_am654.c
> @@ -15,6 +15,7 @@
>  #include <linux/sys_soc.h>
>  
>  #include "cqhci.h"
> +#include "sdhci-cqhci.h"
>  #include "sdhci-pltfm.h"
>  
>  /* CTL_CFG Registers */
> @@ -378,7 +379,7 @@ static void sdhci_am654_reset(struct sdhci_host *host, u8 mask)
>  	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>  	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
>  
> -	sdhci_reset(host, mask);
> +	sdhci_and_cqhci_reset(host, mask);
>  
>  	if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) {
>  		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> @@ -464,7 +465,7 @@ static struct sdhci_ops sdhci_am654_ops = {
>  	.set_clock = sdhci_am654_set_clock,
>  	.write_b = sdhci_am654_write_b,
>  	.irq = sdhci_am654_cqhci_irq,
> -	.reset = sdhci_reset,
> +	.reset = sdhci_and_cqhci_reset,
>  };
>  
>  static const struct sdhci_pltfm_data sdhci_am654_pdata = {
> @@ -494,7 +495,7 @@ static struct sdhci_ops sdhci_j721e_8bit_ops = {
>  	.set_clock = sdhci_am654_set_clock,
>  	.write_b = sdhci_am654_write_b,
>  	.irq = sdhci_am654_cqhci_irq,
> -	.reset = sdhci_reset,
> +	.reset = sdhci_and_cqhci_reset,
>  };
>  
>  static const struct sdhci_pltfm_data sdhci_j721e_8bit_pdata = {


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 6/7] mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-10-27  7:58     ` Adrian Hunter
  0 siblings, 0 replies; 22+ messages in thread
From: Adrian Hunter @ 2022-10-27  7:58 UTC (permalink / raw)
  To: Brian Norris, Ulf Hansson
  Cc: Shawn Guo, linux-mmc, Shawn Lin, Michal Simek, Sascha Hauer,
	Bjorn Andersson, Thierry Reding, linux-arm-msm, linux-arm-kernel,
	Broadcom internal kernel review list, Jonathan Hunter,
	Andy Gross, Pengutronix Kernel Team, linux-kernel, Konrad Dybcio,
	Al Cooper, Fabio Estevam, Florian Fainelli, NXP Linux Team,
	Haibo Chen, Sowjanya Komatineni

On 26/10/22 22:42, Brian Norris wrote:
>  [[ NOTE: this is completely untested by the author, but included solely
>     because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix
>     SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other
>     drivers using CQHCI might benefit from a similar change, if they
>     also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same
>     bug on at least MSM, Arasan, and Intel hardware. ]]
> 
> SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't
> tracking that properly in software. When out of sync, we may trigger
> various timeouts.
> 
> It's not typical to perform resets while CQE is enabled, but this may
> occur in some suspend or error recovery scenarios.
> 
> Include this fix by way of the new sdhci_and_cqhci_reset() helper.
> 
> This patch depends on (and should not compile without) the patch
> entitled "mmc: cqhci: Provide helper for resetting both SDHCI and
> CQHCI".
> 
> Fixes: f545702b74f9 ("mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E")
> Signed-off-by: Brian Norris <briannorris@chromium.org>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> 
> Changes in v4:
>  - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
>  - Add dependency notes
>  - Drop bouncing Faiz Abbas <faiz_abbas@ti.com> address
> 
> Changes in v3:
>  - Use new SDHCI+CQHCI helper
> 
>  drivers/mmc/host/sdhci_am654.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c
> index 8f1023480e12..c2333c7acac9 100644
> --- a/drivers/mmc/host/sdhci_am654.c
> +++ b/drivers/mmc/host/sdhci_am654.c
> @@ -15,6 +15,7 @@
>  #include <linux/sys_soc.h>
>  
>  #include "cqhci.h"
> +#include "sdhci-cqhci.h"
>  #include "sdhci-pltfm.h"
>  
>  /* CTL_CFG Registers */
> @@ -378,7 +379,7 @@ static void sdhci_am654_reset(struct sdhci_host *host, u8 mask)
>  	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
>  	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
>  
> -	sdhci_reset(host, mask);
> +	sdhci_and_cqhci_reset(host, mask);
>  
>  	if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) {
>  		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> @@ -464,7 +465,7 @@ static struct sdhci_ops sdhci_am654_ops = {
>  	.set_clock = sdhci_am654_set_clock,
>  	.write_b = sdhci_am654_write_b,
>  	.irq = sdhci_am654_cqhci_irq,
> -	.reset = sdhci_reset,
> +	.reset = sdhci_and_cqhci_reset,
>  };
>  
>  static const struct sdhci_pltfm_data sdhci_am654_pdata = {
> @@ -494,7 +495,7 @@ static struct sdhci_ops sdhci_j721e_8bit_ops = {
>  	.set_clock = sdhci_am654_set_clock,
>  	.write_b = sdhci_am654_write_b,
>  	.irq = sdhci_am654_cqhci_irq,
> -	.reset = sdhci_reset,
> +	.reset = sdhci_and_cqhci_reset,
>  };
>  
>  static const struct sdhci_pltfm_data sdhci_j721e_8bit_pdata = {


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI
  2022-10-26 19:42 ` Brian Norris
@ 2022-11-07 20:12   ` Ulf Hansson
  -1 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2022-11-07 20:12 UTC (permalink / raw)
  To: Brian Norris
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni

On Wed, 26 Oct 2022 at 21:42, Brian Norris <briannorris@chromium.org> wrote:
>
> This is a series of identical fixes for several SDHCI host
> drivers. Patch #2 (for sdhci-of-arasan; plus its dependency in patch #1)
> is the only one I've tested, and I wrote it due to a bug described
> there.
>
> I then noticed that several other drivers do the same thing, and that
> commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for
> Intel GLK-based controllers") points out the likely-repeated bug. So the
> fix is now factored into a separate sdhci_and_cqhci_reset() helper,
> and it's likely that most/all drivers that support a combo SDHCI/CQHCI
> controller will want to use it.
>
> Thus, I include additional patches (compile-tested only) that apply this
> helper/fix to the other drivers which call cqhci_init() but not
> cqhci_deactivate(). They contain appropriate disclaimers and the
> relevant parties are CC'd. I would suggest only merging them if you get
> some kind of ACK from people familiar with the relevant hardware.
>
> Notably, I do *not* patch drivers/mmc/host/mtk-sd.c although it uses
> CQHCI, because it doesn't seem to be an SDHCI-based controller, and so
> even if it has a similar bug, it's not clear to me how to patch it.
>
> - Brian
>
> Changes in v4:
>  - Improve for-stable cherry-picking notes
>  - Add Adrian's Ack
>  - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
>
> Changes in v3:
>  - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()
>
> Changes in v2:
>  - Rely on cqhci_deactivate() to safely handle (ignore)
>    not-yet-initialized CQE support
>
> Brian Norris (7):
>   mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
>   mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
>   mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()
>
>  drivers/mmc/host/sdhci-brcmstb.c   |  3 ++-
>  drivers/mmc/host/sdhci-cqhci.h     | 24 ++++++++++++++++++++++++
>  drivers/mmc/host/sdhci-esdhc-imx.c |  3 ++-
>  drivers/mmc/host/sdhci-msm.c       | 10 ++--------
>  drivers/mmc/host/sdhci-of-arasan.c |  3 ++-
>  drivers/mmc/host/sdhci-pci-core.c  | 11 ++---------
>  drivers/mmc/host/sdhci-pci-gli.c   | 11 ++---------
>  drivers/mmc/host/sdhci-tegra.c     |  3 ++-
>  drivers/mmc/host/sdhci_am654.c     |  7 ++++---
>  9 files changed, 42 insertions(+), 33 deletions(-)
>  create mode 100644 drivers/mmc/host/sdhci-cqhci.h
>

Patch1 -> patch6, applied for fixes and by adding stable tags. Patch7
applied for next.

Thanks and kind regards
Uffe

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI
@ 2022-11-07 20:12   ` Ulf Hansson
  0 siblings, 0 replies; 22+ messages in thread
From: Ulf Hansson @ 2022-11-07 20:12 UTC (permalink / raw)
  To: Brian Norris
  Cc: Shawn Guo, linux-mmc, Adrian Hunter, Shawn Lin, Michal Simek,
	Sascha Hauer, Bjorn Andersson, Thierry Reding, linux-arm-msm,
	linux-arm-kernel, Broadcom internal kernel review list,
	Jonathan Hunter, Andy Gross, Pengutronix Kernel Team,
	linux-kernel, Konrad Dybcio, Al Cooper, Fabio Estevam,
	Florian Fainelli, NXP Linux Team, Haibo Chen,
	Sowjanya Komatineni

On Wed, 26 Oct 2022 at 21:42, Brian Norris <briannorris@chromium.org> wrote:
>
> This is a series of identical fixes for several SDHCI host
> drivers. Patch #2 (for sdhci-of-arasan; plus its dependency in patch #1)
> is the only one I've tested, and I wrote it due to a bug described
> there.
>
> I then noticed that several other drivers do the same thing, and that
> commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for
> Intel GLK-based controllers") points out the likely-repeated bug. So the
> fix is now factored into a separate sdhci_and_cqhci_reset() helper,
> and it's likely that most/all drivers that support a combo SDHCI/CQHCI
> controller will want to use it.
>
> Thus, I include additional patches (compile-tested only) that apply this
> helper/fix to the other drivers which call cqhci_init() but not
> cqhci_deactivate(). They contain appropriate disclaimers and the
> relevant parties are CC'd. I would suggest only merging them if you get
> some kind of ACK from people familiar with the relevant hardware.
>
> Notably, I do *not* patch drivers/mmc/host/mtk-sd.c although it uses
> CQHCI, because it doesn't seem to be an SDHCI-based controller, and so
> even if it has a similar bug, it's not clear to me how to patch it.
>
> - Brian
>
> Changes in v4:
>  - Improve for-stable cherry-picking notes
>  - Add Adrian's Ack
>  - Also fix sdhci_am654_ops, sdhci_j721e_8bit_ops
>
> Changes in v3:
>  - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset()
>
> Changes in v2:
>  - Rely on cqhci_deactivate() to safely handle (ignore)
>    not-yet-initialized CQE support
>
> Brian Norris (7):
>   mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI
>   mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI
>   mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI
>   mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset()
>
>  drivers/mmc/host/sdhci-brcmstb.c   |  3 ++-
>  drivers/mmc/host/sdhci-cqhci.h     | 24 ++++++++++++++++++++++++
>  drivers/mmc/host/sdhci-esdhc-imx.c |  3 ++-
>  drivers/mmc/host/sdhci-msm.c       | 10 ++--------
>  drivers/mmc/host/sdhci-of-arasan.c |  3 ++-
>  drivers/mmc/host/sdhci-pci-core.c  | 11 ++---------
>  drivers/mmc/host/sdhci-pci-gli.c   | 11 ++---------
>  drivers/mmc/host/sdhci-tegra.c     |  3 ++-
>  drivers/mmc/host/sdhci_am654.c     |  7 ++++---
>  9 files changed, 42 insertions(+), 33 deletions(-)
>  create mode 100644 drivers/mmc/host/sdhci-cqhci.h
>

Patch1 -> patch6, applied for fixes and by adding stable tags. Patch7
applied for next.

Thanks and kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-11-07 20:15 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 19:42 [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI Brian Norris
2022-10-26 19:42 ` Brian Norris
2022-10-26 19:42 ` [PATCH v4 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-26 19:44   ` Florian Fainelli
2022-10-26 19:44     ` Florian Fainelli
2022-10-26 19:42 ` [PATCH v4 2/7] mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-26 19:42 ` [PATCH v4 3/7] mmc: sdhci-brcmstb: " Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-26 19:42 ` [PATCH v4 4/7] mms: sdhci-esdhc-imx: " Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-26 19:42 ` [PATCH v4 5/7] mmc: sdhci-tegra: " Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-26 19:42 ` [PATCH v4 6/7] mmc: sdhci_am654: " Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-10-27  7:58   ` Adrian Hunter
2022-10-27  7:58     ` Adrian Hunter
2022-10-26 19:42 ` [PATCH v4 7/7] mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset() Brian Norris
2022-10-26 19:42   ` Brian Norris
2022-11-07 20:12 ` [PATCH v4 0/7] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI Ulf Hansson
2022-11-07 20:12   ` Ulf Hansson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.