mmc: Fix pm_notifier obeying deferred resume
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 14 Oct 2010 22:20:21 +0000 (15:20 -0700)
committerArve Hjønnevåg <arve@android.com>
Mon, 1 Jul 2013 20:40:24 +0000 (13:40 -0700)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/mmc/core/core.c
include/linux/mmc/host.h

index 00abe448f0713de5ce54b622566ea11233b0bbe6..297367ab5486c129ed9e219f5365d9d2fd53183e 100644 (file)
@@ -1596,11 +1596,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);
@@ -2722,7 +2728,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;
@@ -2788,6 +2794,10 @@ int mmc_pm_notify(struct notifier_block *notify_block,
                }
 
                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);
@@ -2811,6 +2821,10 @@ int mmc_pm_notify(struct notifier_block *notify_block,
        case PM_POST_RESTORE:
 
                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);
index b81b8485eefe8e574455fb40bfd3488875405f3a..d286d7ecaee41dbbe68698d1d8a564657d0271a9 100644 (file)
@@ -403,6 +403,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)
 {