Skip to content

Commit d38dcad

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Let drivers decide whether to use mmc_retune_needed() with pm
Devices might save and restore tuning values so that re-tuning might not be needed after a pm transition. Let drivers decide by pushing the mmc_retune_needed() logic down to them. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent 5a436cc commit d38dcad

15 files changed

+73
-11
lines changed

drivers/mmc/host/sdhci-acpi.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,12 @@ static int sdhci_acpi_remove(struct platform_device *pdev)
524524
static int sdhci_acpi_suspend(struct device *dev)
525525
{
526526
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
527+
struct sdhci_host *host = c->host;
527528

528-
return sdhci_suspend_host(c->host);
529+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
530+
mmc_retune_needed(host->mmc);
531+
532+
return sdhci_suspend_host(host);
529533
}
530534

531535
static int sdhci_acpi_resume(struct device *dev)
@@ -544,8 +548,12 @@ static int sdhci_acpi_resume(struct device *dev)
544548
static int sdhci_acpi_runtime_suspend(struct device *dev)
545549
{
546550
struct sdhci_acpi_host *c = dev_get_drvdata(dev);
551+
struct sdhci_host *host = c->host;
552+
553+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
554+
mmc_retune_needed(host->mmc);
547555

548-
return sdhci_runtime_suspend_host(c->host);
556+
return sdhci_runtime_suspend_host(host);
549557
}
550558

551559
static int sdhci_acpi_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-brcmstb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ static int sdhci_brcmstb_suspend(struct device *dev)
2929
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
3030
int res;
3131

32+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
33+
mmc_retune_needed(host->mmc);
34+
3235
res = sdhci_suspend_host(host);
3336
if (res)
3437
return res;

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,9 @@ static int sdhci_esdhc_suspend(struct device *dev)
13231323
{
13241324
struct sdhci_host *host = dev_get_drvdata(dev);
13251325

1326+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
1327+
mmc_retune_needed(host->mmc);
1328+
13261329
return sdhci_suspend_host(host);
13271330
}
13281331

@@ -1347,6 +1350,9 @@ static int sdhci_esdhc_runtime_suspend(struct device *dev)
13471350

13481351
ret = sdhci_runtime_suspend_host(host);
13491352

1353+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
1354+
mmc_retune_needed(host->mmc);
1355+
13501356
if (!sdhci_sdio_irq_enabled(host)) {
13511357
clk_disable_unprepare(imx_data->clk_per);
13521358
clk_disable_unprepare(imx_data->clk_ipg);

drivers/mmc/host/sdhci-of-arasan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ static int sdhci_arasan_suspend(struct device *dev)
315315
struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host);
316316
int ret;
317317

318+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
319+
mmc_retune_needed(host->mmc);
320+
318321
ret = sdhci_suspend_host(host);
319322
if (ret)
320323
return ret;

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ static int sdhci_at91_runtime_suspend(struct device *dev)
140140

141141
ret = sdhci_runtime_suspend_host(host);
142142

143+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
144+
mmc_retune_needed(host->mmc);
145+
143146
clk_disable_unprepare(priv->gck);
144147
clk_disable_unprepare(priv->hclock);
145148
clk_disable_unprepare(priv->mainck);

drivers/mmc/host/sdhci-of-esdhc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ static int esdhc_of_suspend(struct device *dev)
528528

529529
esdhc_proctl = sdhci_readl(host, SDHCI_HOST_CONTROL);
530530

531+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
532+
mmc_retune_needed(host->mmc);
533+
531534
return sdhci_suspend_host(host);
532535
}
533536

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@ static int sdhci_pci_suspend(struct device *dev)
16531653
struct pci_dev *pdev = to_pci_dev(dev);
16541654
struct sdhci_pci_chip *chip;
16551655
struct sdhci_pci_slot *slot;
1656+
struct sdhci_host *host;
16561657
mmc_pm_flag_t slot_pm_flags;
16571658
mmc_pm_flag_t pm_flags = 0;
16581659
int i, ret;
@@ -1666,14 +1667,19 @@ static int sdhci_pci_suspend(struct device *dev)
16661667
if (!slot)
16671668
continue;
16681669

1669-
ret = sdhci_suspend_host(slot->host);
1670+
host = slot->host;
1671+
1672+
if (chip->pm_retune && host->tuning_mode != SDHCI_TUNING_MODE_3)
1673+
mmc_retune_needed(host->mmc);
1674+
1675+
ret = sdhci_suspend_host(host);
16701676

16711677
if (ret)
16721678
goto err_pci_suspend;
16731679

1674-
slot_pm_flags = slot->host->mmc->pm_flags;
1680+
slot_pm_flags = host->mmc->pm_flags;
16751681
if (slot_pm_flags & MMC_PM_WAKE_SDIO_IRQ)
1676-
sdhci_enable_irq_wakeups(slot->host);
1682+
sdhci_enable_irq_wakeups(host);
16771683

16781684
pm_flags |= slot_pm_flags;
16791685
}
@@ -1737,6 +1743,7 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
17371743
struct pci_dev *pdev = to_pci_dev(dev);
17381744
struct sdhci_pci_chip *chip;
17391745
struct sdhci_pci_slot *slot;
1746+
struct sdhci_host *host;
17401747
int i, ret;
17411748

17421749
chip = pci_get_drvdata(pdev);
@@ -1748,10 +1755,15 @@ static int sdhci_pci_runtime_suspend(struct device *dev)
17481755
if (!slot)
17491756
continue;
17501757

1751-
ret = sdhci_runtime_suspend_host(slot->host);
1758+
host = slot->host;
17521759

1760+
ret = sdhci_runtime_suspend_host(host);
17531761
if (ret)
17541762
goto err_pci_runtime_suspend;
1763+
1764+
if (chip->rpm_retune &&
1765+
host->tuning_mode != SDHCI_TUNING_MODE_3)
1766+
mmc_retune_needed(host->mmc);
17551767
}
17561768

17571769
if (chip->fixes && chip->fixes->suspend) {
@@ -2042,6 +2054,8 @@ static int sdhci_pci_probe(struct pci_dev *pdev,
20422054
chip->allow_runtime_pm = chip->fixes->allow_runtime_pm;
20432055
}
20442056
chip->num_slots = slots;
2057+
chip->pm_retune = true;
2058+
chip->rpm_retune = true;
20452059

20462060
pci_set_drvdata(pdev, chip);
20472061

drivers/mmc/host/sdhci-pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ struct sdhci_pci_chip {
9797
unsigned int quirks;
9898
unsigned int quirks2;
9999
bool allow_runtime_pm;
100+
bool pm_retune;
101+
bool rpm_retune;
100102
const struct sdhci_pci_fixes *fixes;
101103

102104
int num_slots; /* Slots on controller */

drivers/mmc/host/sdhci-pltfm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ static int sdhci_pltfm_suspend(struct device *dev)
213213
{
214214
struct sdhci_host *host = dev_get_drvdata(dev);
215215

216+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
217+
mmc_retune_needed(host->mmc);
218+
216219
return sdhci_suspend_host(host);
217220
}
218221

drivers/mmc/host/sdhci-pxav3.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ static int sdhci_pxav3_suspend(struct device *dev)
527527
struct sdhci_host *host = dev_get_drvdata(dev);
528528

529529
pm_runtime_get_sync(dev);
530+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
531+
mmc_retune_needed(host->mmc);
530532
ret = sdhci_suspend_host(host);
531533
pm_runtime_mark_last_busy(dev);
532534
pm_runtime_put_autosuspend(dev);
@@ -560,6 +562,9 @@ static int sdhci_pxav3_runtime_suspend(struct device *dev)
560562
if (ret)
561563
return ret;
562564

565+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
566+
mmc_retune_needed(host->mmc);
567+
563568
clk_disable_unprepare(pxa->clk_io);
564569
if (!IS_ERR(pxa->clk_core))
565570
clk_disable_unprepare(pxa->clk_core);

drivers/mmc/host/sdhci-s3c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,9 @@ static int sdhci_s3c_suspend(struct device *dev)
743743
{
744744
struct sdhci_host *host = dev_get_drvdata(dev);
745745

746+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
747+
mmc_retune_needed(host->mmc);
748+
746749
return sdhci_suspend_host(host);
747750
}
748751

@@ -764,6 +767,9 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
764767

765768
ret = sdhci_runtime_suspend_host(host);
766769

770+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
771+
mmc_retune_needed(host->mmc);
772+
767773
if (ourhost->cur_clk >= 0)
768774
clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
769775
clk_disable_unprepare(busclk);

drivers/mmc/host/sdhci-sirf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ static int sdhci_sirf_suspend(struct device *dev)
237237
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
238238
int ret;
239239

240+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
241+
mmc_retune_needed(host->mmc);
242+
240243
ret = sdhci_suspend_host(host);
241244
if (ret)
242245
return ret;

drivers/mmc/host/sdhci-spear.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ static int sdhci_suspend(struct device *dev)
165165
struct spear_sdhci *sdhci = sdhci_priv(host);
166166
int ret;
167167

168+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
169+
mmc_retune_needed(host->mmc);
170+
168171
ret = sdhci_suspend_host(host);
169172
if (!ret)
170173
clk_disable(sdhci->clk);

drivers/mmc/host/sdhci-st.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,12 @@ static int sdhci_st_suspend(struct device *dev)
463463
struct sdhci_host *host = dev_get_drvdata(dev);
464464
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
465465
struct st_mmc_platform_data *pdata = sdhci_pltfm_priv(pltfm_host);
466-
int ret = sdhci_suspend_host(host);
466+
int ret;
467+
468+
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
469+
mmc_retune_needed(host->mmc);
467470

471+
ret = sdhci_suspend_host(host);
468472
if (ret)
469473
goto out;
470474

drivers/mmc/host/sdhci.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,8 +2857,6 @@ int sdhci_suspend_host(struct sdhci_host *host)
28572857
sdhci_disable_card_detection(host);
28582858

28592859
mmc_retune_timer_stop(host->mmc);
2860-
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
2861-
mmc_retune_needed(host->mmc);
28622860

28632861
if (!device_may_wakeup(mmc_dev(host->mmc))) {
28642862
host->ier = 0;
@@ -2919,8 +2917,6 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
29192917
unsigned long flags;
29202918

29212919
mmc_retune_timer_stop(host->mmc);
2922-
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
2923-
mmc_retune_needed(host->mmc);
29242920

29252921
spin_lock_irqsave(&host->lock, flags);
29262922
host->ier &= SDHCI_INT_CARD_INT;

0 commit comments

Comments
 (0)