Skip to contentSkip to conversation

mmc: core: Attempt to flush cache before reset

PATCH Superseded Adrian Hunter 2 participants 4 messages Apr 28, 2016 – May 4, 2016 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: core: Attempt to flush cache before reset

CMD0 or hardware reset may invalidate the cache, so it needs to be flushed before reset.

In the case of recovery, we can't expect flushing the cache to work always, but have a go and ignore errors.

---
 drivers/mmc/core/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mmc/core/core.c +6 -0
index 99275e40bf2f..1b4e0ccb0885 100644
@@ -2453,6 +2453,12 @@ int mmc_hw_reset(struct mmc_host *host)
 		return -EOPNOTSUPP;
 	}
 
+	/*
+	 * 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->card);
+
 	ret = host->bus_ops->reset(host);
 	mmc_bus_put(host);
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Adrian Hunter

CMD0 or hardware reset may invalidate the cache, so it needs to be flushed before reset.

In the case of recovery, we can't expect flushing the cache to work always, but have a go and ignore errors.

Makes sense!

Quoted 11 lines
---
 drivers/mmc/core/core.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mmc/core/core.c +0 -0
index 99275e40bf2f..1b4e0ccb0885 100644

drivers/mmc/core/core.c int mmc_hw_reset(struct mmc_host *host) · line 2461

Quoted 9 lines
drivers/mmc/core/core.c +6 -0
@@ -2453,6 +2453,12 @@ int mmc_hw_reset(struct mmc_host *host)
                return -EOPNOTSUPP;
        }
 
+       /*
+        * 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->card);
+

I prefer if you move this into mmc_reset() in drivers/mmc/core/mmc.c instead, as it's an mmc specific operation.

Quoted 6 lines
drivers/mmc/core/core.c +0 -1
        ret = host->bus_ops->reset(host);
        mmc_bus_put(host);
 
--

1.9.1

Kind regards
Uffe

#2 lore raw

PATCH v2 1/1 mmc: mmc: Attempt to flush cache before reset

CMD0 or hardware reset may invalidate the cache, so it needs to be flushed before reset.

In the case of recovery, we can't expect flushing the cache to work always, but have a go and ignore errors.

---

Changes in V2:

Do flush in mmc_reset() instead of mmc_hw_reset()

 drivers/mmc/core/mmc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mmc/core/mmc.c +6 -0
index 0cf42af33d0f..d4d1b77c1c1e 100644
@@ -1965,6 +1965,12 @@ static int mmc_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->card);
+
 	if ((host->caps & MMC_CAP_HW_RESET) && host->ops->hw_reset &&
 	     mmc_can_reset(card)) {
 		/* If the card accept RST_n signal, send it. */
Signature · 1 line
1.9.1
Applied
#3 lore raw

Re: [PATCH V2] mmc: mmc: Attempt to flush cache before reset

Quoted 7 lines · Adrian Hunter

CMD0 or hardware reset may invalidate the cache, so it needs to be flushed before reset.

In the case of recovery, we can't expect flushing the cache to work always, but have a go and ignore errors.

Thanks, applied for next!

Kind regards
Uffe

Quoted 32 lines

---

Changes in V2:

Do flush in mmc_reset() instead of mmc_hw_reset()

 drivers/mmc/core/mmc.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/mmc/core/mmc.c +6 -1
index 0cf42af33d0f..d4d1b77c1c1e 100644
@@ -1965,6 +1965,12 @@ static int mmc_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->card);
+
        if ((host->caps & MMC_CAP_HW_RESET) && host->ops->hw_reset &&
             mmc_can_reset(card)) {
                /* If the card accept RST_n signal, send it. */
--

1.9.1