From: Adrian Hunter <adrian.hunter@intel.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org,
linux-mmc@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Mark Brown" <broonie@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Søren Andersen" <san@skov.dk>,
"Christian Loehle" <christian.loehle@arm.com>
Subject: Re: [PATCH v3 6/6] mmc: sdhci: prevent command execution after undervoltage shutdown
Date: Fri, 7 Mar 2025 14:36:09 +0200 [thread overview]
Message-ID: <c7e98e11-38d2-40b4-a7d0-3a884cf8d8b8@intel.com> (raw)
In-Reply-To: <20250221093918.3942378-7-o.rempel@pengutronix.de>
On 21/02/25 11:39, Oleksij Rempel wrote:
> Introduce an emergency_stop flag in struct mmc_host to block further
> MMC/SD commands after an undervoltage shutdown. If emergency_stop is
> set, sdhci_send_command() will reject new requests with -EBUSY and log a
> warning. This helps diagnose and identify code paths that may still
> attempt writes after the undervoltage shutdown sequence has completed.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> changes v3:
> - add comments
> ---
> drivers/mmc/core/mmc.c | 7 +++++++
> drivers/mmc/host/sdhci.c | 9 +++++++++
> include/linux/mmc/host.h | 1 +
> 3 files changed, 17 insertions(+)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index a50cdd550a22..0cd6b81d0678 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -2370,6 +2370,13 @@ static int _mmc_handle_undervoltage(struct mmc_host *host)
> */
> mmc_card_set_removed(card);
>
> + /*
> + * Signal the host controller driver that we are in emergency stop mode.
> + * This prevents any new storage requests from being issued, ensuring
> + * that no further operations take place while in this state.
> + */
> + host->emergency_stop = true;
> +
> return err;
> }
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index f4a7733a8ad2..8d67f27e7d9e 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1658,6 +1658,15 @@ static bool sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
>
> WARN_ON(host->cmd);
>
> + if (host->mmc->emergency_stop) {
This is unnecessary.
The host controller driver should not have to block requests
because the mmc core layer should not be requesting them.
We definitely wouldn't want to be duplicating this code in
every host controller driver, so let's not start.
> + pr_warn("%s: Ignoring normal request, emergency stop is active\n",
> + mmc_hostname(host->mmc));
> + WARN_ON_ONCE(1);
> +
> + cmd->error = -EBUSY;
> + return true;
> + }
> +
> /* Initially, a command has no error */
> cmd->error = 0;
>
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 4e147ad82804..5dfe2cdde59f 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -501,6 +501,7 @@ struct mmc_host {
> unsigned int can_dma_map_merge:1; /* merging can be used */
> unsigned int vqmmc_enabled:1; /* vqmmc regulator is enabled */
> unsigned int undervoltage:1; /* Undervoltage state */
> + unsigned int emergency_stop:1; /* Emergency stop. No transfers are allowed. */
>
> int rescan_disable; /* disable card detection */
> int rescan_entered; /* used with nonremovable devices */
prev parent reply other threads:[~2025-03-07 12:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 9:39 [PATCH v3 0/6] mmc: handle undervoltage events and prevent eMMC corruption Oleksij Rempel
2025-02-21 9:39 ` [PATCH v3 1/6] mmc: core: Handle undervoltage events and register regulator notifiers Oleksij Rempel
2025-02-21 9:39 ` [PATCH v3 2/6] mmc: core: make mmc_interrupt_hpi() global Oleksij Rempel
2025-02-21 9:39 ` [PATCH v3 3/6] mmc: core: refactor _mmc_suspend() for undervoltage handling Oleksij Rempel
2025-02-21 9:39 ` [PATCH v3 4/6] mmc: core: add undervoltage handler for MMC/eMMC devices Oleksij Rempel
2025-02-21 10:39 ` Christian Loehle
2025-02-27 8:47 ` Avri Altman
2025-03-07 13:02 ` Adrian Hunter
2025-02-21 9:39 ` [PATCH v3 5/6] mmc: block: abort requests and suppress errors after undervoltage shutdown Oleksij Rempel
2025-02-21 9:39 ` [PATCH v3 6/6] mmc: sdhci: prevent command execution " Oleksij Rempel
2025-03-07 12:36 ` Adrian Hunter [this message]
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=c7e98e11-38d2-40b4-a7d0-3a884cf8d8b8@intel.com \
--to=adrian.hunter@intel.com \
--cc=broonie@kernel.org \
--cc=christian.loehle@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=rafael@kernel.org \
--cc=san@skov.dk \
--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
all inboxes | Powered by JetHome®