From: Guenter Roeck <linux@roeck-us.net>
To: Brian Norris <briannorris@chromium.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Shawn Lin <shawn.lin@rock-chips.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Shawn Guo <shawnguo@kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Faiz Abbas <faiz_abbas@ti.com>,
NXP Linux Team <linux-imx@nxp.com>,
Haibo Chen <haibo.chen@nxp.com>, Al Cooper <alcooperx@gmail.com>,
linux-mmc@vger.kernel.org,
Pengutronix Kernel Team <kernel@pengutronix.de>,
linux-kernel@vger.kernel.org,
Florian Fainelli <f.fainelli@gmail.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Thierry Reding <thierry.reding@gmail.com>,
Michal Simek <michal.simek@xilinx.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Sowjanya Komatineni <skomatineni@nvidia.com>,
linux-arm-kernel@lists.infradead.org,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/5] mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI
Date: Tue, 18 Oct 2022 07:26:26 -0700 [thread overview]
Message-ID: <20221018142626.GA2096645@roeck-us.net> (raw)
In-Reply-To: <20221017205610.1.I29f6a2189e84e35ad89c1833793dca9e36c64297@changeid>
On Mon, Oct 17, 2022 at 08:57:20PM -0700, Brian Norris wrote:
> 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. Also, move around the DT/caps handling, because
> sdhci_setup_host() performs resets before we've initialized CQHCI. This
> is the pattern followed in other SDHCI/CQHCI drivers.
>
> 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>
> ---
>
> drivers/mmc/host/sdhci-of-arasan.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 3997cad1f793..1988a703781a 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -366,6 +366,10 @@ 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);
>
> + if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
> + sdhci_arasan->has_cqe)
> + cqhci_deactivate(host->mmc);
> +
> sdhci_reset(host, mask);
>
> if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_FORCE_CDTEST) {
> @@ -1521,7 +1525,8 @@ static int sdhci_arasan_register_sdclk(struct sdhci_arasan_data *sdhci_arasan,
> return 0;
> }
>
> -static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan)
> +static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan,
> + struct device_node *np)
> {
> struct sdhci_host *host = sdhci_arasan->host;
> struct cqhci_host *cq_host;
> @@ -1549,6 +1554,10 @@ static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan)
> if (dma64)
> cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
>
> + host->mmc->caps2 |= MMC_CAP2_CQE;
> + if (!of_property_read_bool(np, "disable-cqe-dcmd"))
> + host->mmc->caps2 |= MMC_CAP2_CQE_DCMD;
> +
> ret = cqhci_init(cq_host, host->mmc, dma64);
> if (ret)
> goto cleanup;
> @@ -1705,13 +1714,9 @@ static int sdhci_arasan_probe(struct platform_device *pdev)
> host->mmc_host_ops.start_signal_voltage_switch =
> sdhci_arasan_voltage_switch;
> sdhci_arasan->has_cqe = true;
> - host->mmc->caps2 |= MMC_CAP2_CQE;
> -
> - if (!of_property_read_bool(np, "disable-cqe-dcmd"))
> - host->mmc->caps2 |= MMC_CAP2_CQE_DCMD;
> }
>
> - ret = sdhci_arasan_add_host(sdhci_arasan);
> + ret = sdhci_arasan_add_host(sdhci_arasan, np);
> if (ret)
> goto err_add_host;
>
> --
> 2.38.0.413.g74048e4d9e-goog
>
next prev parent reply other threads:[~2022-10-18 14:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 3:57 [PATCH 0/5] mmc: sdhci controllers: Fix SDHCI_RESET_ALL for CQHCI Brian Norris
2022-10-18 3:57 ` [PATCH 1/5] mmc: sdhci-of-arasan: " Brian Norris
2022-10-18 14:26 ` Guenter Roeck [this message]
2022-10-18 16:13 ` Adrian Hunter
2022-10-18 16:59 ` Brian Norris
2022-10-18 17:58 ` Adrian Hunter
2022-10-18 3:57 ` [PATCH 2/5] mmc: sdhci-brcmstb: " Brian Norris
2022-10-18 3:57 ` [PATCH 3/5] mms: sdhci-esdhc-imx: " Brian Norris
2022-10-18 7:22 ` Bough Chen
2022-10-19 21:56 ` Brian Norris
2022-10-18 3:57 ` [PATCH 4/5] mmc: sdhci-tegra: " Brian Norris
2022-10-18 3:57 ` [PATCH 5/5] mmc: sdhci_am654: " Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018142626.GA2096645@roeck-us.net \
--to=linux@roeck-us.net \
--cc=adrian.hunter@intel.com \
--cc=alcooperx@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=briannorris@chromium.org \
--cc=f.fainelli@gmail.com \
--cc=faiz_abbas@ti.com \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=jonathanh@nvidia.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=s.hauer@pengutronix.de \
--cc=shawn.lin@rock-chips.com \
--cc=shawnguo@kernel.org \
--cc=skomatineni@nvidia.com \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).