提交 da7a45cd 编写于 作者: U Ulf Hansson 提交者: Zheng Zengkai

mmc: core: Disable card detect during shutdown

stable inclusion
from stable-v5.10.89
commit 0d66b395210c5084c2b7324945062c1d1f95487a
bugzilla: 186140 https://gitee.com/openeuler/kernel/issues/I4S8HA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0d66b395210c5084c2b7324945062c1d1f95487a

--------------------------------

commit 66c915d0 upstream.

It's seems prone to problems by allowing card detect and its corresponding
mmc_rescan() work to run, during platform shutdown. For example, we may end
up turning off the power while initializing a card, which potentially could
damage it.

To avoid this scenario, let's add ->shutdown_pre() callback for the mmc host
class device and then turn of the card detect from there.
Reported-by: NAl Cooper <alcooperx@gmail.com>
Suggested-by: NAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20211203141555.105351-1-ulf.hansson@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 31103e37
...@@ -2327,7 +2327,7 @@ void mmc_start_host(struct mmc_host *host) ...@@ -2327,7 +2327,7 @@ void mmc_start_host(struct mmc_host *host)
_mmc_detect_change(host, 0, false); _mmc_detect_change(host, 0, false);
} }
void mmc_stop_host(struct mmc_host *host) void __mmc_stop_host(struct mmc_host *host)
{ {
if (host->slot.cd_irq >= 0) { if (host->slot.cd_irq >= 0) {
mmc_gpio_set_cd_wake(host, false); mmc_gpio_set_cd_wake(host, false);
...@@ -2336,6 +2336,11 @@ void mmc_stop_host(struct mmc_host *host) ...@@ -2336,6 +2336,11 @@ void mmc_stop_host(struct mmc_host *host)
host->rescan_disable = 1; host->rescan_disable = 1;
cancel_delayed_work_sync(&host->detect); cancel_delayed_work_sync(&host->detect);
}
void mmc_stop_host(struct mmc_host *host)
{
__mmc_stop_host(host);
/* clear pm flags now and let card drivers set them as needed */ /* clear pm flags now and let card drivers set them as needed */
host->pm_flags = 0; host->pm_flags = 0;
......
...@@ -69,6 +69,7 @@ static inline void mmc_delay(unsigned int ms) ...@@ -69,6 +69,7 @@ static inline void mmc_delay(unsigned int ms)
void mmc_rescan(struct work_struct *work); void mmc_rescan(struct work_struct *work);
void mmc_start_host(struct mmc_host *host); void mmc_start_host(struct mmc_host *host);
void __mmc_stop_host(struct mmc_host *host);
void mmc_stop_host(struct mmc_host *host); void mmc_stop_host(struct mmc_host *host);
void _mmc_detect_change(struct mmc_host *host, unsigned long delay, void _mmc_detect_change(struct mmc_host *host, unsigned long delay,
......
...@@ -79,9 +79,18 @@ static void mmc_host_classdev_release(struct device *dev) ...@@ -79,9 +79,18 @@ static void mmc_host_classdev_release(struct device *dev)
kfree(host); kfree(host);
} }
static int mmc_host_classdev_shutdown(struct device *dev)
{
struct mmc_host *host = cls_dev_to_mmc_host(dev);
__mmc_stop_host(host);
return 0;
}
static struct class mmc_host_class = { static struct class mmc_host_class = {
.name = "mmc_host", .name = "mmc_host",
.dev_release = mmc_host_classdev_release, .dev_release = mmc_host_classdev_release,
.shutdown_pre = mmc_host_classdev_shutdown,
.pm = MMC_HOST_CLASS_DEV_PM_OPS, .pm = MMC_HOST_CLASS_DEV_PM_OPS,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册