mmc: sdhci: remove mdelay in eMMC tuning
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
@@ -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
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_BLOCKrather thanMMC_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.
Signed-off-by Nick Sanders <[email protected]>Reviewed-by Grant Grundler <[email protected]>Reviewed-by Doug Anderson <[email protected]>
Quoted 23 lines
--- drivers/mmc/host/sdhci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/mmc/host/sdhci.c +4
-2@@ -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
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.
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_BLOCKrather thanMMC_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
Signed-off-by Nick Sanders <[email protected]>Reviewed-by Grant Grundler <[email protected]>Reviewed-by Doug Anderson <[email protected]>Acked-by Ulf Hansson <[email protected]>
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@@ -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
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_BLOCKrather thanMMC_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
Signed-off-by Nick Sanders <[email protected]>Reviewed-by Grant Grundler <[email protected]>Reviewed-by Doug Anderson <[email protected]>Acked-by Ulf Hansson <[email protected]>
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-nextapologies 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/>
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_BLOCKrather thanMMC_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
Signed-off-by Nick Sanders <[email protected]>Reviewed-by Grant Grundler <[email protected]>Reviewed-by Doug Anderson <[email protected]>Acked-by Ulf Hansson <[email protected]>
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-nextapologies 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
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