From: Kamal Dasu <kamal.dasu@broadcom.com>
To: linux-mmc@vger.kernel.org, Ulf Hansson <ulfh@kernel.org>
Cc: Ulf Hansson <ulf.hansson@oss.qualcomm.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Oleksij Rempel <o.rempel@pengutronix.de>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
Shawn Lin <shawn.lin@linux.dev>
Subject: [PATCH v11 5/6] mmc: core: Move and split reset functions for eMMC
Date: Fri, 30 Oct 2026 14:10:32 -0400 [thread overview]
Message-ID: <20261030181034.3811225-6-kamal.dasu@broadcom.com> (raw)
In-Reply-To: <20261030181034.3811225-1-kamal.dasu@broadcom.com>
From: Ulf Hansson <ulf.hansson@oss.qualcomm.com>
To prepare for a subsequent change and to simplify review, let's move the
function for resetting the eMMC card a few lines up in the file.
While at it, split the cache flush out of _mmc_hw_reset() into a new
mmc_hw_reset_recovery() function and use that for the ->hw_reset() bus
operation. This keeps the flush for recovery, where it was intended, but
allows the card to be reset without it, by calling _mmc_hw_reset()
directly. That is needed when resetting the card at system resume, as the
cache has already been flushed at suspend and the flush would only fail
with a timeout, after the card has been accessed by firmware.
There are no functional changes.
Signed-off-by: Ulf Hansson <ulf.hansson@oss.qualcomm.com>
Co-developed-by: Kamal Dasu <kamal.dasu@broadcom.com>
Signed-off-by: Kamal Dasu <kamal.dasu@broadcom.com>
---
drivers/mmc/core/mmc.c | 73 ++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 34 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index c936272bcd81..026003ba507d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -2271,6 +2271,44 @@ static int mmc_shutdown(struct mmc_host *host)
return err;
}
+static bool mmc_card_can_reset(struct mmc_card *card)
+{
+ u8 rst_n_function;
+
+ rst_n_function = card->ext_csd.rst_n_function;
+ return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED);
+}
+
+static int _mmc_hw_reset(struct mmc_host *host)
+{
+ struct mmc_card *card = host->card;
+
+ if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset &&
+ mmc_card_can_reset(card)) {
+ /* If the card accept RST_n signal, send it. */
+ mmc_set_clock(host, host->f_init);
+ host->ops->card_hw_reset(host);
+ /* Set initial state and call mmc_set_ios */
+ mmc_set_initial_state(host);
+ } else {
+ /* Do a brute force power cycle */
+ mmc_power_cycle(host, card->ocr);
+ mmc_pwrseq_reset(host);
+ }
+ return mmc_init_card(host, card->ocr, card);
+}
+
+static int mmc_hw_reset_recovery(struct mmc_host *host)
+{
+ /*
+ * In the case of recovery, we can't expect flushing the cache to work
+ * always, but we have a go and ignore errors.
+ */
+ _mmc_flush_cache(host);
+
+ return _mmc_hw_reset(host);
+}
+
/*
* Callback for resume.
*/
@@ -2319,39 +2357,6 @@ static int mmc_runtime_resume(struct mmc_host *host)
return 0;
}
-static bool mmc_card_can_reset(struct mmc_card *card)
-{
- u8 rst_n_function;
-
- rst_n_function = card->ext_csd.rst_n_function;
- return ((rst_n_function & EXT_CSD_RST_N_EN_MASK) == EXT_CSD_RST_N_ENABLED);
-}
-
-static int _mmc_hw_reset(struct mmc_host *host)
-{
- struct mmc_card *card = host->card;
-
- /*
- * In the case of recovery, we can't expect flushing the cache to work
- * always, but we have a go and ignore errors.
- */
- _mmc_flush_cache(host);
-
- if ((host->caps & MMC_CAP_HW_RESET) && host->ops->card_hw_reset &&
- mmc_card_can_reset(card)) {
- /* If the card accept RST_n signal, send it. */
- mmc_set_clock(host, host->f_init);
- host->ops->card_hw_reset(host);
- /* Set initial state and call mmc_set_ios */
- mmc_set_initial_state(host);
- } else {
- /* Do a brute force power cycle */
- mmc_power_cycle(host, card->ocr);
- mmc_pwrseq_reset(host);
- }
- return mmc_init_card(host, card->ocr, card);
-}
-
/**
* _mmc_handle_undervoltage - Handle an undervoltage event for MMC/eMMC devices
* @host: MMC host structure
@@ -2410,7 +2415,7 @@ static const struct mmc_bus_ops mmc_ops = {
.runtime_resume = mmc_runtime_resume,
.alive = mmc_alive,
.shutdown = mmc_shutdown,
- .hw_reset = _mmc_hw_reset,
+ .hw_reset = mmc_hw_reset_recovery,
.cache_enabled = _mmc_cache_enabled,
.flush_cache = _mmc_flush_cache,
.handle_undervoltage = _mmc_handle_undervoltage,
--
2.34.1
next prev parent reply other threads:[~2026-10-30 18:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 18:10 [PATCH v11 0/6] mmc: core: Keep the card powered across suspend when firmware needs it live Kamal Dasu
2026-10-30 18:10 ` [PATCH v11 1/6] dt-bindings: mmc: Extend keep-power-in-suspend beyond SDIO Kamal Dasu
2026-10-30 18:10 ` [PATCH v11 2/6] dt-bindings: mmc: Add reset-card-at-resume property Kamal Dasu
2026-10-30 18:10 ` [PATCH v11 3/6] mmc: core: Add option to keep an eMMC powered on at system suspend Kamal Dasu
2026-10-30 18:10 ` [PATCH v11 4/6] mmc: core: Split sdio_set_host_pm_flags() Kamal Dasu
2026-10-30 18:10 ` Kamal Dasu [this message]
2026-10-30 18:10 ` [PATCH v11 6/6] mmc: core: Add support for resetting an eMMC at system resume Kamal Dasu
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=20261030181034.3811225-6-kamal.dasu@broadcom.com \
--to=kamal.dasu@broadcom.com \
--cc=adrian.hunter@intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=robh@kernel.org \
--cc=shawn.lin@linux.dev \
--cc=ulf.hansson@oss.qualcomm.com \
--cc=ulfh@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/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®