mmc: msm_sdcc: Set CPU_DMA latency for acceptable QOS
To prevent speed degradation in high throughput
scenarios, specify CPU_DMA latency which gives
acceptable QOS. This should be derived without
knowledge of specific low power mode latencies.
For MMC/SD cards, reads tend to be the fastest
transactions, and suffer most from latency. To
ensure acceptable QOS, the average chunk size read
is used with typical best-in-class read speeds
seen across targets and cards.
With an average chunk size of 128KiB transferred
at 30MB/s, a 5% degradation in speed allows for
an additional 200us latency. This default can
be overridden by newer targets with more stringent
latency requirements.
Change-Id: I77d320d2b5e34e3b72ba41ed25454ece042eeddb
Signed-off-by: Oluwafemi Adeyemi <aadeyemi@codeaurora.org>
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 318c319..0e096eb 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -168,16 +168,12 @@
/* Prevent idle power collapse(pc) while operating in peripheral mode */
static void msmsdcc_pm_qos_update_latency(struct msmsdcc_host *host, int vote)
{
- u32 swfi_latency = 0;
-
- if (!host->plat->swfi_latency)
+ if (!host->cpu_dma_latency)
return;
- swfi_latency = host->plat->swfi_latency + 1;
-
if (vote)
pm_qos_update_request(&host->pm_qos_req_dma,
- swfi_latency);
+ host->cpu_dma_latency);
else
pm_qos_update_request(&host->pm_qos_req_dma,
PM_QOS_DEFAULT_VALUE);
@@ -4543,9 +4539,13 @@
/* Apply Hard reset to SDCC to put it in power on default state */
msmsdcc_hard_reset(host);
+#define MSM_MMC_DEFAULT_CPUDMA_LATENCY 200 /* usecs */
/* pm qos request to prevent apps idle power collapse */
- if (host->plat->swfi_latency)
- pm_qos_add_request(&host->pm_qos_req_dma,
+ if (host->plat->cpu_dma_latency)
+ host->cpu_dma_latency = host->plat->cpu_dma_latency;
+ else
+ host->cpu_dma_latency = MSM_MMC_DEFAULT_CPUDMA_LATENCY;
+ pm_qos_add_request(&host->pm_qos_req_dma,
PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE);
ret = msmsdcc_vreg_init(host, true);
@@ -4831,7 +4831,7 @@
msmsdcc_vreg_init(host, false);
clk_disable:
clk_disable(host->clk);
- if (host->plat->swfi_latency)
+ if (host->cpu_dma_latency)
pm_qos_remove_request(&host->pm_qos_req_dma);
clk_put:
clk_put(host->clk);
@@ -4905,7 +4905,7 @@
if (!IS_ERR_OR_NULL(host->dfab_pclk))
clk_put(host->dfab_pclk);
- if (host->plat->swfi_latency)
+ if (host->cpu_dma_latency)
pm_qos_remove_request(&host->pm_qos_req_dma);
msmsdcc_vreg_init(host, false);
diff --git a/drivers/mmc/host/msm_sdcc.h b/drivers/mmc/host/msm_sdcc.h
index 406af4f..50477da 100644
--- a/drivers/mmc/host/msm_sdcc.h
+++ b/drivers/mmc/host/msm_sdcc.h
@@ -395,6 +395,7 @@
bool sdio_gpio_lpm;
bool irq_wake_enabled;
struct pm_qos_request_list pm_qos_req_dma;
+ u32 cpu_dma_latency;
bool sdcc_suspending;
bool sdcc_irq_disabled;
bool sdcc_suspended;