From: Dmitry Shmidt Date: Thu, 14 Oct 2010 22:20:21 +0000 (-0700) Subject: mmc: Fix pm_notifier obeying deferred resume X-Git-Tag: firefly_0821_release~9833^2~5^2~103 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a46384364468ab78c8a6fb2857ac935c50c6d500;p=firefly-linux-kernel-4.4.55.git mmc: Fix pm_notifier obeying deferred resume Signed-off-by: Dmitry Shmidt --- diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 708f33f20cb7..265e88e187dc 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -980,11 +980,17 @@ static inline void mmc_bus_put(struct mmc_host *host) int mmc_resume_bus(struct mmc_host *host) { + unsigned long flags; + if (!mmc_bus_needs_resume(host)) return -EINVAL; printk("%s: Starting deferred resume\n", mmc_hostname(host)); + spin_lock_irqsave(&host->lock, flags); host->bus_resume_flags &= ~MMC_BUSRESUME_NEEDS_RESUME; + host->rescan_disable = 0; + spin_unlock_irqrestore(&host->lock, flags); + mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { mmc_power_up(host); @@ -1694,7 +1700,7 @@ int mmc_resume_host(struct mmc_host *host) int err = 0; mmc_bus_get(host); - if (host->bus_resume_flags & MMC_BUSRESUME_MANUAL_RESUME) { + if (mmc_bus_manual_resume(host)) { host->bus_resume_flags |= MMC_BUSRESUME_NEEDS_RESUME; mmc_bus_put(host); return 0; @@ -1737,6 +1743,10 @@ int mmc_pm_notify(struct notifier_block *notify_block, case PM_SUSPEND_PREPARE: spin_lock_irqsave(&host->lock, flags); + if (mmc_bus_needs_resume(host)) { + spin_unlock_irqrestore(&host->lock, flags); + break; + } host->rescan_disable = 1; spin_unlock_irqrestore(&host->lock, flags); cancel_delayed_work_sync(&host->detect); @@ -1758,6 +1768,10 @@ int mmc_pm_notify(struct notifier_block *notify_block, case PM_POST_HIBERNATION: spin_lock_irqsave(&host->lock, flags); + if (mmc_bus_manual_resume(host)) { + spin_unlock_irqrestore(&host->lock, flags); + break; + } host->rescan_disable = 0; spin_unlock_irqrestore(&host->lock, flags); mmc_detect_change(host, 0); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 46489931aea4..077c604b28a5 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -254,6 +254,7 @@ static inline void *mmc_priv(struct mmc_host *host) #define mmc_classdev(x) (&(x)->class_dev) #define mmc_hostname(x) (dev_name(&(x)->class_dev)) #define mmc_bus_needs_resume(host) ((host)->bus_resume_flags & MMC_BUSRESUME_NEEDS_RESUME) +#define mmc_bus_manual_resume(host) ((host)->bus_resume_flags & MMC_BUSRESUME_MANUAL_RESUME) static inline void mmc_set_bus_resume_policy(struct mmc_host *host, int manual) {