Skip to contentSkip to conversation

mmc: sdhci: remove mdelay in eMMC tuning

PATCH In review Nick Sanders 6 participants 7 messages May 7, 2014 – May 14, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: remove mdelay in eMMC tuning

This patch removes an unneccesary 1ms mdelay in the HS200 tuning loop, called 40 times per retuning. Currently this causes a latency of >40ms on any emmc accesses triggering wake from runtime PM, which can occur for a significant portion of reads on a mostly idle system.

The delay is left in place for SD Cards, which use MMC_SEND_TUNING_BLOCK rather than MMC_SEND_TUNING_BLOCK_HS200. I'm not able to find evidence that this is required for SD in the specs I have access to, however this delay has been present from initial checkin for SD so I have preserved the original behavior for compatibility.

This has been verified to fix observed glitching on local audio playback and recording on apps with inbuilt assumptions on storage latency.

---
 drivers/mmc/host/sdhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +4 -1
index df6d85a..05ffac2 100644
@@ -1987,7 +1987,10 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 		ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
 		tuning_loop_counter--;
 		timeout--;
-		mdelay(1);
+
+		/* eMMC spec does not require a delay between tuning cycles */
+		if (opcode == MMC_SEND_TUNING_BLOCK)
+			mdelay(1);
 	} while (ctrl & SDHCI_CTRL_EXEC_TUNING);
 
 	/*
Signature · 1 line
1.9.1.423.g4596e3a
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Nick Sanders

This patch removes an unneccesary 1ms mdelay in the HS200 tuning loop, called 40 times per retuning. Currently this causes a latency of >40ms on any emmc accesses triggering wake from runtime PM, which can occur for a significant portion of reads on a mostly idle system.

Aha, so you are actually using "MMC_CAP_RUNTIME_RESUME" here - cool :-).

I suppose those patches that enables the "cap" has not reached mainline yet. Any plans on sending them?

Quoted 8 lines

The delay is left in place for SD Cards, which use MMC_SEND_TUNING_BLOCK rather than MMC_SEND_TUNING_BLOCK_HS200. I'm not able to find evidence that this is required for SD in the specs I have access to, however this delay has been present from initial checkin for SD so I have preserved the original behavior for compatibility.

Quoted 7 lines

This has been verified to fix observed glitching on local audio playback and recording on apps with inbuilt assumptions on storage latency.

Quoted 23 lines
---
 drivers/mmc/host/sdhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +4 -2
index df6d85a..05ffac2 100644
@@ -1987,7 +1987,10 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
                ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
                tuning_loop_counter--;
                timeout--;
-               mdelay(1);
+
+               /* eMMC spec does not require a delay between tuning cycles */
+               if (opcode == MMC_SEND_TUNING_BLOCK)
+                       mdelay(1);
        } while (ctrl & SDHCI_CTRL_EXEC_TUNING);
 
        /*
--

1.9.1.423.g4596e3a

#2 lore raw
Quoted 4 lines · Ulf Hansson

Aha, so you are actually using "MMC_CAP_RUNTIME_RESUME" here - cool :-).

I suppose those patches that enables the "cap" has not reached mainline yet. Any plans on sending them?

I am actually running 3.10, so MMC_CAP_RUNTIME_RESUME isn't used yet. sdhci-acpi.c is enabling runtime pm for my device, and there are no caps checks otherwise.

#3 lore raw
In reply to Ulf Hansson
Quoted 23 lines · Ulf Hansson
Quoted 4 lines · Nick Sanders

This patch removes an unneccesary 1ms mdelay in the HS200 tuning loop, called 40 times per retuning. Currently this causes a latency of >40ms on any emmc accesses triggering wake from runtime PM, which can occur for a significant portion of reads on a mostly idle system.

Aha, so you are actually using "MMC_CAP_RUNTIME_RESUME" here - cool :-).

I suppose those patches that enables the "cap" has not reached mainline yet. Any plans on sending them?

Quoted 12 lines

The delay is left in place for SD Cards, which use MMC_SEND_TUNING_BLOCK rather than MMC_SEND_TUNING_BLOCK_HS200. I'm not able to find evidence that this is required for SD in the specs I have access to, however this delay has been present from initial checkin for SD so I have preserved the original behavior for compatibility.

This has been verified to fix observed glitching on local audio playback and recording on apps with inbuilt assumptions on storage latency.

Quoted 5 lines
Quoted 3 lines

Ulf,
Is your ACK enough to get this to land upstream or does cjb need to respond it's been accepted?

It doesn't appear to have landed in mmc-next branch yet:
http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc.git/log/?h=mmc-next

apologies if it appears I am being impatient...but it's been almost a week now.

thanks,
grant

Quoted 24 lines
Quoted 24 lines
---
 drivers/mmc/host/sdhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +4 -2
index df6d85a..05ffac2 100644
@@ -1987,7 +1987,10 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
                ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
                tuning_loop_counter--;
                timeout--;
-               mdelay(1);
+
+               /* eMMC spec does not require a delay between tuning cycles */
+               if (opcode == MMC_SEND_TUNING_BLOCK)
+                       mdelay(1);
        } while (ctrl & SDHCI_CTRL_EXEC_TUNING);
 
        /*
--

1.9.1.423.g4596e3a

#4 lore raw

Hi,

Quoted 17 lines · Grant Grundler
Quoted 11 lines
Quoted 11 lines

The delay is left in place for SD Cards, which use MMC_SEND_TUNING_BLOCK rather than MMC_SEND_TUNING_BLOCK_HS200. I'm not able to find evidence that this is required for SD in the specs I have access to, however this delay has been present from initial checkin for SD so I have preserved the original behavior for compatibility.

This has been verified to fix observed glitching on local audio playback and recording on apps with inbuilt assumptions on storage latency.

Quoted 5 lines
Quoted 3 lines
Quoted 8 lines

Ulf,
Is your ACK enough to get this to land upstream or does cjb need to respond it's been accepted?

It doesn't appear to have landed in mmc-next branch yet:
http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc.git/log/?h=mmc-next

apologies if it appears I am being impatient...but it's been almost a week now.

Sorry about that. Looks fine, pushed to mmc-next with Ulf's ACK now.

- Chris.

Signature · 1 line
Chris Ball   <http://printf.net/>
#5 lore raw
In reply to Grant Grundler
Quoted 30 lines · On Tuesday 13 May 2014 18:13:30 Grant Grundler wrote:
Quoted 23 lines · Ulf Hansson
Quoted 4 lines · Nick Sanders

This patch removes an unneccesary 1ms mdelay in the HS200 tuning loop, called 40 times per retuning. Currently this causes a latency of >40ms on any emmc accesses triggering wake from runtime PM, which can occur for a significant portion of reads on a mostly idle system.

Aha, so you are actually using "MMC_CAP_RUNTIME_RESUME" here - cool :-).

I suppose those patches that enables the "cap" has not reached mainline yet. Any plans on sending them?

Quoted 12 lines

The delay is left in place for SD Cards, which use MMC_SEND_TUNING_BLOCK rather than MMC_SEND_TUNING_BLOCK_HS200. I'm not able to find evidence that this is required for SD in the specs I have access to, however this delay has been present from initial checkin for SD so I have preserved the original behavior for compatibility.

This has been verified to fix observed glitching on local audio playback and recording on apps with inbuilt assumptions on storage latency.

Quoted 5 lines
Quoted 3 lines
Quoted 9 lines

Ulf,
Is your ACK enough to get this to land upstream or does cjb need to respond it's been accepted?

It doesn't appear to have landed in mmc-next branch yet:
http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc.git/log/?h=mmc-next

apologies if it appears I am being impatient...but it's been almost a week now.

I just stumbled over this thread. Looking at the callers of the execute_tuning() function, I see that all three come from non-atomic context. How about an add-on patch to turn the mdelay(1) into an msleep(1)? That would be much friendlier to other tasks running concurrently.

Arnd

#6 lore raw

Arnd,

Quoted 5 lines · Arnd Bergmann

I just stumbled over this thread. Looking at the callers of the execute_tuning() function, I see that all three come from non-atomic context. How about an add-on patch to turn the mdelay(1) into an msleep(1)? That would be much friendlier to other tasks running concurrently.

Even better if someone could tell us why the mdelay() was there to begin with. As I understand it Nick was confident that it wasn't needed for eMMC. He didn't _think_ it was needed for SD cards either but it was safer to leave it there for SD cards since the delay wasn't causing any known problems on them.

-Doug