From 688129aafb10755e80a7d94c0c96960693882ff5 Mon Sep 17 00:00:00 2001 From: Vijay Viswanath Date: Fri, 19 May 2017 16:26:33 +0530 Subject: mmc: core: Avoid returning error when clok scaling devfreq is removed When resume clock scaling is not possible because there is no devfreq framework, it is not an error. So avoid printing an error and return success. This is necessary in certain scenarios like during shutdown where we unregister the clock scaling devfreq. Change-Id: Ib37eabdcdbbb58a336ee87220e5758bb559625af Signed-off-by: Vijay Viswanath --- drivers/mmc/core/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index c462eee4a5f7..ef3ffd87d94f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -790,10 +790,15 @@ int mmc_resume_clk_scaling(struct mmc_host *host) if (!mmc_can_scale_clk(host)) return 0; + /* + * If clock scaling is already exited when resume is called, like + * during mmc shutdown, it is not an error and should not fail the + * API calling this. + */ if (!host->clk_scaling.devfreq) { - pr_err("%s: %s: no devfreq is assosiated with this device\n", + pr_warn("%s: %s: no devfreq is assosiated with this device\n", mmc_hostname(host), __func__); - return -EPERM; + return 0; } atomic_set(&host->clk_scaling.devfreq_abort, 0); -- cgit v1.2.3 From 7b46835e9f0ebe022974d4bafc5be32a90dd2e74 Mon Sep 17 00:00:00 2001 From: Vijay Viswanath Date: Tue, 16 May 2017 10:34:21 +0530 Subject: mmc: block: Disable clock scaling during shutdown During shutdown of sdhc drivers, power off notification (PON) is sent to eMMC device. But it doesn't prevent the clock scaling framework from kicking in and sending commands to card after PON is sent. So exit clock scaling framework of sdhc before PON is sent. Change-Id: Ibfe097732042458965db529f235a7fd28cfabaab Signed-off-by: Vijay Viswanath --- drivers/mmc/card/block.c | 4 ---- drivers/mmc/core/mmc.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index e9f1a19dfe3f..a22defee763a 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -4695,10 +4695,6 @@ static int _mmc_blk_suspend(struct mmc_card *card, bool wait) static void mmc_blk_shutdown(struct mmc_card *card) { _mmc_blk_suspend(card, 1); - - /* send power off notification */ - if (mmc_card_mmc(card)) - mmc_send_pon(card); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 5eda4f4fb0fe..df60774b02af 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2933,6 +2933,22 @@ static int mmc_reset(struct mmc_host *host) return ret; } +static int mmc_shutdown(struct mmc_host *host) +{ + struct mmc_card *card = host->card; + + /* + * Exit clock scaling so that it doesn't kick in after + * power off notification is sent + */ + if (host->caps2 & MMC_CAP2_CLK_SCALE) + mmc_exit_clk_scaling(card->host); + /* send power off notification */ + if (mmc_card_mmc(card)) + mmc_send_pon(card); + return 0; +} + static const struct mmc_bus_ops mmc_ops = { .remove = mmc_remove, .detect = mmc_detect, @@ -2943,6 +2959,7 @@ static const struct mmc_bus_ops mmc_ops = { .alive = mmc_alive, .change_bus_speed = mmc_change_bus_speed, .reset = mmc_reset, + .shutdown = mmc_shutdown, }; /* -- cgit v1.2.3