Skip to contentSkip to conversation

mmc: core: Wait for Vdd to settle on card power off

PATCH Superseded Erick Shepherd 3 participants 11 messages Feb 11, 2025 – Mar 14, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: core: Wait for Vdd to settle on card power off

The SD spec version 6.0 section 6.4.1.5 requires that Vdd must be lowered to less than 0.5V for a minimum of 1 ms when powering off a card. Increase our wait to 15 ms so that voltage has time to drain down to 0.5V.

---
 drivers/mmc/host/sdhci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci.c +3 -0
index f4a7733a8ad2..b15a1f107549 100644
@@ -2415,6 +2415,9 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	else
 		sdhci_set_power(host, ios->power_mode, ios->vdd);
 
+	if (ios->power_mode == MMC_POWER_OFF)
+		mdelay(15);
+
 	if (host->ops->platform_send_init_74_clocks)
 		host->ops->platform_send_init_74_clocks(host, ios->power_mode);
 
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line

Subject: [PATCH] mmc: core: Wait for Vdd to settle on card power off

                                              ^^^^

Should be a host patch?

Quoted 8 lines

The SD spec version 6.0 section 6.4.1.5 requires that Vdd must be lowered to less than 0.5V for a minimum of 1 ms when powering off a card. Increase our wait to 15 ms so that voltage has time to drain down to 0.5V.

Quoted 23 lines
---
 drivers/mmc/host/sdhci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci.c index renamed from drivers/mmc/host/sdhci.c +0 -0

f4a7733a8ad2..b15a1f107549 100644

drivers/mmc/host/sdhci.c +3 -0
@@ -2415,6 +2415,9 @@ void sdhci_set_ios(struct mmc_host *mmc, struct
 mmc_ios *ios)
 	else
 		sdhci_set_power(host, ios->power_mode, ios->vdd);
 
+	if (ios->power_mode == MMC_POWER_OFF)
+		mdelay(15);
+
 	if (host->ops->platform_send_init_74_clocks)
 		host->ops->platform_send_init_74_clocks(host, ios-
Quoted 1 line

power_mode);

--
2.43.0

maintainer
#2 lore raw
In reply to Erick Shepherd
Quoted 4 lines · Erick Shepherd

The SD spec version 6.0 section 6.4.1.5 requires that Vdd must be lowered to less than 0.5V for a minimum of 1 ms when powering off a card. Increase our wait to 15 ms so that voltage has time to drain down to 0.5V.

mmc_power_off() has a delay. So does mmc_power_cycle()

Why does this need to be in sdhci? Are you experiencing an issue?

Quoted 22 lines
---
 drivers/mmc/host/sdhci.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci.c +3 -0
index f4a7733a8ad2..b15a1f107549 100644
@@ -2415,6 +2415,9 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	else
 		sdhci_set_power(host, ios->power_mode, ios->vdd);
 
+	if (ios->power_mode == MMC_POWER_OFF)
+		mdelay(15);
+
 	if (host->ops->platform_send_init_74_clocks)
 		host->ops->platform_send_init_74_clocks(host, ios->power_mode);
 
#3 lore raw
Quoted 9 lines
Quoted 4 lines

The SD spec version 6.0 section 6.4.1.5 requires that Vdd must be lowered to less than 0.5V for a minimum of 1 ms when powering off a card. Increase our wait to 15 ms so that voltage has time to drain down to 0.5V.

mmc_power_off() has a delay. So does mmc_power_cycle()

Why does this need to be in sdhci? Are you experiencing an issue?

Thank you for taking a look at this. The initial change was made in mmc_power_off() due to an issue we had with some of our devices requiring more time for the Vdd to drain below 0.5V. Ulf gave us this feedback on that change:

Quoted 6 lines

No, this isn't the proper place of adding more "magic" delays.

Instead, make sure the related ->set_ios() callback in the mmc host driver deals with this instead. In case it uses an external regulator, via the regulator API, then this is something that should be controlled with the definition of the regulator.

Should we take a different approach here?

Regards
Erick

maintainer
#4 lore raw
Quoted 15 lines · Erick Shepherd
Quoted 9 lines
Quoted 4 lines

The SD spec version 6.0 section 6.4.1.5 requires that Vdd must be lowered to less than 0.5V for a minimum of 1 ms when powering off a card. Increase our wait to 15 ms so that voltage has time to drain down to 0.5V.

mmc_power_off() has a delay. So does mmc_power_cycle()

Why does this need to be in sdhci? Are you experiencing an issue?

Thank you for taking a look at this. The initial change was made in mmc_power_off() due to an issue we had with some of our devices requiring more time for the Vdd to drain below 0.5V. Ulf gave us this feedback on that change:

Quoted 8 lines
Quoted 6 lines

No, this isn't the proper place of adding more "magic" delays.

Instead, make sure the related ->set_ios() callback in the mmc host driver deals with this instead. In case it uses an external regulator, via the regulator API, then this is something that should be controlled with the definition of the regulator.

Should we take a different approach here?

It probably should be dealt with in the ->set_power() callback. Is it one of the PCI devices in sdhci-pci-core.c?

#5 lore raw
Quoted 2 lines

It probably should be dealt with in the ->set_power() callback. Is it one of the PCI devices in sdhci-pci-core.c?

Sure, I can move the delay to sdhci_set_power(). It looks like that gets called right before the if-statement in the change I proposed so the behavior should be the same, unless host->ops->set_power is set.

I believe we saw this failure on devices using the Intel Atom E3930 and E3940, which are Apollo Lake. It looks like there is an entry in sdhci-pci-core.c. Does that change what we should do?

Regards,
Erick

maintainer
#6 lore raw
Quoted 10 lines · Erick Shepherd
Quoted 2 lines

It probably should be dealt with in the ->set_power() callback. Is it one of the PCI devices in sdhci-pci-core.c?

Sure, I can move the delay to sdhci_set_power(). It looks like that gets called right before the if-statement in the change I proposed so the behavior should be the same, unless host->ops->set_power is set.

I believe we saw this failure on devices using the Intel Atom E3930 and E3940, which are Apollo Lake. It looks like there is an entry in sdhci-pci-core.c. Does that change what we should do?

What about something like this?

drivers/mmc/host/sdhci-pci-core.c +4 -1
index 1f0bd723f011..0789df732e93 100644
@@ -610,8 +610,11 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 
 	sdhci_set_power(host, mode, vdd);
 
-	if (mode == MMC_POWER_OFF)
+	if (mode == MMC_POWER_OFF) {
+		if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
+			usleep_range(15000, 17500);
 		return;
+	}
 
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the
#7 lore raw
Quoted 9 lines

What about something like this?

drivers/mmc/host/sdhci-pci-core.c +0 -0
index 1f0bd723f011..0789df732e93 100644
@@ -610,8 +610,11 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 
 	sdhci_set_power(host, mode, vdd);

drivers/mmc/host/sdhci-pci-core.c static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, · line 620

Quoted 10 lines
drivers/mmc/host/sdhci-pci-core.c +4 -1
 
-	if (mode == MMC_POWER_OFF)
+	if (mode == MMC_POWER_OFF) {
+		if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
+			usleep_range(15000, 17500);
 		return;
+	}
 
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the

I talked to one of our digital hardware engineers who worked on this issue. He believes that the issue is likely affecting more than just Apollo Lake devices and recommended keeping the delay for all of our devices. Could something like this work?

drivers/mmc/host/sdhci.c +3 -0
@@ -2176,6 +2176,9 @@ EXPORT_SYMBOL_GPL(sdhci_set_power_noreg);
 void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
 		     unsigned short vdd)
 {
+	if (mode == MMC_POWER_OFF)
+		usleep_range(15000, 17500);
+
 	if (IS_ERR(host->mmc->supply.vmmc))
 		sdhci_set_power_noreg(host, mode, vdd);
 	else

Regards,
Erick

maintainer
#8 lore raw
Quoted 28 lines · Erick Shepherd
Quoted 9 lines

What about something like this?

drivers/mmc/host/sdhci-pci-core.c +0 -0
index 1f0bd723f011..0789df732e93 100644
@@ -610,8 +610,11 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 
 	sdhci_set_power(host, mode, vdd);

drivers/mmc/host/sdhci-pci-core.c static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, · line 620

Quoted 10 lines
drivers/mmc/host/sdhci-pci-core.c +4 -1
 
-	if (mode == MMC_POWER_OFF)
+	if (mode == MMC_POWER_OFF) {
+		if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
+			usleep_range(15000, 17500);
 		return;
+	}
 
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the

I talked to one of our digital hardware engineers who worked on this issue. He believes that the issue is likely affecting more than just Apollo Lake devices and recommended keeping the delay for all of our devices. Could something like this work?

drivers/mmc/host/sdhci.c EXPORT_SYMBOL_GPL(sdhci_set_power_noreg); · line 2184

Quoted 9 lines
drivers/mmc/host/sdhci.c +3 -0
@@ -2176,6 +2176,9 @@ EXPORT_SYMBOL_GPL(sdhci_set_power_noreg);
 void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
 		     unsigned short vdd)
 {
+	if (mode == MMC_POWER_OFF)
+		usleep_range(15000, 17500);
+
 	if (IS_ERR(host->mmc->supply.vmmc))
 		sdhci_set_power_noreg(host, mode, vdd);
 	else

sdhci is used by a number of drivers (drivers/mmc/host/sdhci*) that typically use the regulator framework to meet voltage requirements. So that is not the right place to make changes.

It would be best to put the affected PCI device IDs into sdhci_intel_set_power() as I showed.

#9 lore raw
Quoted 6 lines

sdhci is used by a number of drivers (drivers/mmc/host/sdhci*) that typically use the regulator framework to meet voltage requirements. So that is not the right place to make changes.

It would be best to put the affected PCI device IDs into sdhci_intel_set_power() as I showed.

I see, that makes sense. The majority of our devices are using either Apollo Lake or Bay Trail host controllers. Would it be ok to expand your solution to include both? I tested the following change on a few of our devices and confirmed the delay is called. If this looks good I can submit a V2 of this patch.

drivers/mmc/host/sdhci-pci-core.c +5 -2
@@ -610,9 +610,12 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 
 	sdhci_set_power(host, mode, vdd);
 
-	if (mode == MMC_POWER_OFF)
+	if (mode == MMC_POWER_OFF) {
+		if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD ||
+		    slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BYT_SD)
+			usleep_range(15000, 17500);
 		return;
-
+	}
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the
 	 * present state not yet having propagated. Retry for up to 2ms.
Signature · 2 lines
Regards,
Erick
maintainer
#10 lore raw
Quoted 20 lines · Erick Shepherd
Quoted 6 lines

sdhci is used by a number of drivers (drivers/mmc/host/sdhci*) that typically use the regulator framework to meet voltage requirements. So that is not the right place to make changes.

It would be best to put the affected PCI device IDs into sdhci_intel_set_power() as I showed.

I see, that makes sense. The majority of our devices are using either Apollo Lake or Bay Trail host controllers. Would it be ok to expand your solution to include both? I tested the following change on a few of our devices and confirmed the delay is called. If this looks good I can submit a V2 of this patch.

drivers/mmc/host/sdhci-pci-core.c +0 -1
@@ -610,9 +610,12 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode,
 
 	sdhci_set_power(host, mode, vdd);
 
-	if (mode == MMC_POWER_OFF)

drivers/mmc/host/sdhci-pci-core.c static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, · line 621

Quoted 10 lines
drivers/mmc/host/sdhci-pci-core.c +5 -1
+	if (mode == MMC_POWER_OFF) {
+		if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD ||
+		    slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BYT_SD)
+			usleep_range(15000, 17500);
 		return;
-
+	}
 	/*
 	 * Bus power might not enable after D3 -> D0 transition due to the
 	 * present state not yet having propagated. Retry for up to 2ms.

That would be fine