diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2013-10-29 20:00:18 -0400 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-02-13 22:58:15 -0500 |
commit | 2501c9179dff2add6aadd3898cd729e94e777d3a (patch) | |
tree | 5ec2c6fc9d62b21920b7319fbf14e22cad467f6b | |
parent | 710dec95d579bf59c157358cc9cf7b42907d1c0f (diff) |
mmc: core: Use MMC_UNSAFE_RESUME as default behavior
Invoking system suspend or shutdown without using the Kconfig option
MMC_UNSAFE_RESUME, did trigger an ungraceful power cut of the card.
To improve the situation, change the behavior to always make use of the
available bus_ops callbacks that handles system suspend and shutdown
properly.
By changing the behavior MMC_UNSAFE_RESUME becomes redundant, so lets's
remove it.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r-- | drivers/mmc/core/Kconfig | 15 | ||||
-rw-r--r-- | drivers/mmc/core/core.c | 17 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 23 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 23 | ||||
-rw-r--r-- | include/linux/mmc/host.h | 5 |
5 files changed, 3 insertions, 80 deletions
diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig index 269d072ef55e..9ebee72d9c3f 100644 --- a/drivers/mmc/core/Kconfig +++ b/drivers/mmc/core/Kconfig | |||
@@ -2,21 +2,6 @@ | |||
2 | # MMC core configuration | 2 | # MMC core configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | config MMC_UNSAFE_RESUME | ||
6 | bool "Assume MMC/SD cards are non-removable (DANGEROUS)" | ||
7 | help | ||
8 | If you say Y here, the MMC layer will assume that all cards | ||
9 | stayed in their respective slots during the suspend. The | ||
10 | normal behaviour is to remove them at suspend and | ||
11 | redetecting them at resume. Breaking this assumption will | ||
12 | in most cases result in data corruption. | ||
13 | |||
14 | This option is usually just for embedded systems which use | ||
15 | a MMC/SD card for rootfs. Most people should say N here. | ||
16 | |||
17 | This option sets a default which can be overridden by the | ||
18 | module parameter "removable=0" or "removable=1". | ||
19 | |||
20 | config MMC_CLKGATE | 5 | config MMC_CLKGATE |
21 | bool "MMC host clock gating" | 6 | bool "MMC host clock gating" |
22 | help | 7 | help |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 098374b1ab2b..10856ec64412 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -65,23 +65,6 @@ bool use_spi_crc = 1; | |||
65 | module_param(use_spi_crc, bool, 0); | 65 | module_param(use_spi_crc, bool, 0); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * We normally treat cards as removed during suspend if they are not | ||
69 | * known to be on a non-removable bus, to avoid the risk of writing | ||
70 | * back data to a different card after resume. Allow this to be | ||
71 | * overridden if necessary. | ||
72 | */ | ||
73 | #ifdef CONFIG_MMC_UNSAFE_RESUME | ||
74 | bool mmc_assume_removable; | ||
75 | #else | ||
76 | bool mmc_assume_removable = 1; | ||
77 | #endif | ||
78 | EXPORT_SYMBOL(mmc_assume_removable); | ||
79 | module_param_named(removable, mmc_assume_removable, bool, 0644); | ||
80 | MODULE_PARM_DESC( | ||
81 | removable, | ||
82 | "MMC/SD cards are removable and may be removed during suspend"); | ||
83 | |||
84 | /* | ||
85 | * Internal function. Schedule delayed work in the MMC work queue. | 68 | * Internal function. Schedule delayed work in the MMC work queue. |
86 | */ | 69 | */ |
87 | static int mmc_schedule_delayed_work(struct delayed_work *work, | 70 | static int mmc_schedule_delayed_work(struct delayed_work *work, |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 98e9eb0f6643..20f046895228 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -1636,16 +1636,6 @@ static int mmc_power_restore(struct mmc_host *host) | |||
1636 | static const struct mmc_bus_ops mmc_ops = { | 1636 | static const struct mmc_bus_ops mmc_ops = { |
1637 | .remove = mmc_remove, | 1637 | .remove = mmc_remove, |
1638 | .detect = mmc_detect, | 1638 | .detect = mmc_detect, |
1639 | .suspend = NULL, | ||
1640 | .resume = NULL, | ||
1641 | .power_restore = mmc_power_restore, | ||
1642 | .alive = mmc_alive, | ||
1643 | .shutdown = mmc_shutdown, | ||
1644 | }; | ||
1645 | |||
1646 | static const struct mmc_bus_ops mmc_ops_unsafe = { | ||
1647 | .remove = mmc_remove, | ||
1648 | .detect = mmc_detect, | ||
1649 | .suspend = mmc_suspend, | 1639 | .suspend = mmc_suspend, |
1650 | .resume = mmc_resume, | 1640 | .resume = mmc_resume, |
1651 | .runtime_suspend = mmc_runtime_suspend, | 1641 | .runtime_suspend = mmc_runtime_suspend, |
@@ -1655,17 +1645,6 @@ static const struct mmc_bus_ops mmc_ops_unsafe = { | |||
1655 | .shutdown = mmc_shutdown, | 1645 | .shutdown = mmc_shutdown, |
1656 | }; | 1646 | }; |
1657 | 1647 | ||
1658 | static void mmc_attach_bus_ops(struct mmc_host *host) | ||
1659 | { | ||
1660 | const struct mmc_bus_ops *bus_ops; | ||
1661 | |||
1662 | if (!mmc_card_is_removable(host)) | ||
1663 | bus_ops = &mmc_ops_unsafe; | ||
1664 | else | ||
1665 | bus_ops = &mmc_ops; | ||
1666 | mmc_attach_bus(host, bus_ops); | ||
1667 | } | ||
1668 | |||
1669 | /* | 1648 | /* |
1670 | * Starting point for MMC card init. | 1649 | * Starting point for MMC card init. |
1671 | */ | 1650 | */ |
@@ -1685,7 +1664,7 @@ int mmc_attach_mmc(struct mmc_host *host) | |||
1685 | if (err) | 1664 | if (err) |
1686 | return err; | 1665 | return err; |
1687 | 1666 | ||
1688 | mmc_attach_bus_ops(host); | 1667 | mmc_attach_bus(host, &mmc_ops); |
1689 | if (host->ocr_avail_mmc) | 1668 | if (host->ocr_avail_mmc) |
1690 | host->ocr_avail = host->ocr_avail_mmc; | 1669 | host->ocr_avail = host->ocr_avail_mmc; |
1691 | 1670 | ||
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 692fdb177294..2dd359d2242f 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -1209,16 +1209,6 @@ static int mmc_sd_power_restore(struct mmc_host *host) | |||
1209 | static const struct mmc_bus_ops mmc_sd_ops = { | 1209 | static const struct mmc_bus_ops mmc_sd_ops = { |
1210 | .remove = mmc_sd_remove, | 1210 | .remove = mmc_sd_remove, |
1211 | .detect = mmc_sd_detect, | 1211 | .detect = mmc_sd_detect, |
1212 | .suspend = NULL, | ||
1213 | .resume = NULL, | ||
1214 | .power_restore = mmc_sd_power_restore, | ||
1215 | .alive = mmc_sd_alive, | ||
1216 | .shutdown = mmc_sd_suspend, | ||
1217 | }; | ||
1218 | |||
1219 | static const struct mmc_bus_ops mmc_sd_ops_unsafe = { | ||
1220 | .remove = mmc_sd_remove, | ||
1221 | .detect = mmc_sd_detect, | ||
1222 | .runtime_suspend = mmc_sd_runtime_suspend, | 1212 | .runtime_suspend = mmc_sd_runtime_suspend, |
1223 | .runtime_resume = mmc_sd_runtime_resume, | 1213 | .runtime_resume = mmc_sd_runtime_resume, |
1224 | .suspend = mmc_sd_suspend, | 1214 | .suspend = mmc_sd_suspend, |
@@ -1228,17 +1218,6 @@ static const struct mmc_bus_ops mmc_sd_ops_unsafe = { | |||
1228 | .shutdown = mmc_sd_suspend, | 1218 | .shutdown = mmc_sd_suspend, |
1229 | }; | 1219 | }; |
1230 | 1220 | ||
1231 | static void mmc_sd_attach_bus_ops(struct mmc_host *host) | ||
1232 | { | ||
1233 | const struct mmc_bus_ops *bus_ops; | ||
1234 | |||
1235 | if (!mmc_card_is_removable(host)) | ||
1236 | bus_ops = &mmc_sd_ops_unsafe; | ||
1237 | else | ||
1238 | bus_ops = &mmc_sd_ops; | ||
1239 | mmc_attach_bus(host, bus_ops); | ||
1240 | } | ||
1241 | |||
1242 | /* | 1221 | /* |
1243 | * Starting point for SD card init. | 1222 | * Starting point for SD card init. |
1244 | */ | 1223 | */ |
@@ -1254,7 +1233,7 @@ int mmc_attach_sd(struct mmc_host *host) | |||
1254 | if (err) | 1233 | if (err) |
1255 | return err; | 1234 | return err; |
1256 | 1235 | ||
1257 | mmc_sd_attach_bus_ops(host); | 1236 | mmc_attach_bus(host, &mmc_sd_ops); |
1258 | if (host->ocr_avail_sd) | 1237 | if (host->ocr_avail_sd) |
1259 | host->ocr_avail = host->ocr_avail_sd; | 1238 | host->ocr_avail = host->ocr_avail_sd; |
1260 | 1239 | ||
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 99f5709ac343..2a139b2bdb9e 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h | |||
@@ -424,12 +424,9 @@ static inline int mmc_regulator_get_supply(struct mmc_host *mmc) | |||
424 | 424 | ||
425 | int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); | 425 | int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); |
426 | 426 | ||
427 | /* Module parameter */ | ||
428 | extern bool mmc_assume_removable; | ||
429 | |||
430 | static inline int mmc_card_is_removable(struct mmc_host *host) | 427 | static inline int mmc_card_is_removable(struct mmc_host *host) |
431 | { | 428 | { |
432 | return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable; | 429 | return !(host->caps & MMC_CAP_NONREMOVABLE); |
433 | } | 430 | } |
434 | 431 | ||
435 | static inline int mmc_card_keep_power(struct mmc_host *host) | 432 | static inline int mmc_card_keep_power(struct mmc_host *host) |