mmc: Fix re-probing after hibernation
PATCH 1/1 mmc: Fix re-probing after hibernation
The commit 4c2ef25fe0b847d2ae818f74758ddb0be1c27d8e
mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume
introduced a bug where the device probing no longer works after hibernation. This was because the pm notifier expects PM_POST_HIBERNATION call while the system sends PM_POST_RESTORE instead, thus disable_rescan is kept as 1.
--- drivers/mmc/core/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/core/core.c +1 -1
@@ -1772,7 +1772,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,break ;case PM_POST_SUSPEND : -case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;
Signature · 1 line
1.7.3.1
Quoted 19 lines · Takashi Iwai
The commit
4c2ef25fe0b847d2ae818f74758ddb0be1c27d8e
mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume
introduced a bug where the device probing no longer works after hibernation. This was because the pm notifier expectsPM_POST_HIBERNATIONcall while the system sendsPM_POST_RESTOREinstead, thusdisable_rescanis kept as 1.Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- drivers/mmc/core/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/mmc/core/core.c +0
-0
drivers/mmc/core/core.c int mmc_pm_notify(struct notifier_block *notify_block, · line 1778
Quoted 8 lines
drivers/mmc/core/core.c +1
-1@@ -1772,7 +1772,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,break ;case PM_POST_SUSPEND : -case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;
So that was the case....
Takasi, thank you very much.
I always use the 'unsafe resume' thing so I wasn't affected.
Best regards,
Maxim Levitsky
Hi Takashi,
Quoted 19 lines · Takashi Iwai
The commit
4c2ef25fe0b847d2ae818f74758ddb0be1c27d8e
mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume
introduced a bug where the device probing no longer works after hibernation. This was because the pm notifier expectsPM_POST_HIBERNATIONcall while the system sendsPM_POST_RESTOREinstead, thusdisable_rescanis kept as 1.Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- drivers/mmc/core/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/mmc/core/core.c +0
-0
drivers/mmc/core/core.c int mmc_pm_notify(struct notifier_block *notify_block, · line 1778
Quoted 8 lines
drivers/mmc/core/core.c +1
-1@@ -1772,7 +1772,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,break ;case PM_POST_SUSPEND : -case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;
Thanks very much for tracking this down! The code suggests that POST_RESTORE is only emitted on a *failed* hibernation restore -- from include/linux/notifier.h:
/* Hibernation and suspend events */
#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ #define PM_POST_RESTORE 0x0006 /* Restore failed */
So, this all suggests that we want to add the POST_RESTORE case but also want to keep the POST_HIBERNATION case. Do you agree? Was the case you saw of failed probe after hibernation a failed restore from hibernation image?
By the way, it looks like there are some other drivers which also test for POST_HIBERNATION but not POST_RESTORE:
drivers/media/video/tlg2300/pd-main.c
drivers/s390/char/vmwatchdog.c
drivers/s390/cio/css.c
drivers/staging/brcm80211/brcmfmac/dhd_linux.c
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
A message that is not in the archive (sent off-list or not yet received): s5hlj3z1ksb.wl%[email protected]
Quoted 72 lines · Takashi Iwai
At Thu, 9 Dec 2010 01:53:03 +0000,
Quoted 37 lines · Chris Ball
Hi Takashi,
Quoted 19 lines · Takashi Iwai
The commit
4c2ef25fe0b847d2ae818f74758ddb0be1c27d8e
mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume
introduced a bug where the device probing no longer works after hibernation. This was because the pm notifier expectsPM_POST_HIBERNATIONcall while the system sendsPM_POST_RESTOREinstead, thusdisable_rescanis kept as 1.Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- drivers/mmc/core/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/mmc/core/core.c +0
-0drivers/mmc/core/core.c int mmc_pm_notify(struct notifier_block *notify_block, · line 1778
Quoted 8 lines
drivers/mmc/core/core.c +1
-1@@ -1772,7 +1772,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,break ;case PM_POST_SUSPEND : -case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;Thanks very much for tracking this down! The code suggests that
POST_RESTOREis only emitted on a *failed* hibernation restore -- frominclude/linux/notifier.h:/* Hibernation and suspend events */
Quoted 8 lines
#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ #define PM_POST_RESTORE 0x0006 /* Restore failed */So, this all suggests that we want to add the
POST_RESTOREcase but also want to keep thePOST_HIBERNATIONcase. Do you agree? Was the case you saw of failed probe after hibernation a failed restore from hibernation image?Right, I took a look at
Documentation/pm/notifiers.txt, and it's clearly written thatPM_POST_RESTOREis only for the error case. But S4 resume succeeded actually on my machine, so it took time to spot out the culprit.Looking at the code in
kernel/power/, this might be the case of user-space suspend.hibernate.cseems returningPM_POST_HIBERNATIONwhileuser.creturnsPM_POST_RESTOREafter image restoration, and I guess it's a bug ofuser.c.The untested patch is below (sorry I have no corresponding machine at my home.) Rafael, Pavel, could you check this?
thanks,
Takashi
===
From915fda609e02b02e4fc6b944e4432ea1d964adc5Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Thu, 9 Dec 2010 08:09:21 +0100
Subject: [PATCH] PM: Fix PM_POST_* notification with user-space suspend
Quoted 3 lines
The user-space hibernation sends a wrong notification after the image restoration because of thinko for the file flag check. RDONLY corresponds to hibernation and WRONLY to restoration, confusingly.
The patch is correct. I'm taking it to my tree.
Thanks,
Rafael
Quoted 19 lines
Signed-off-by Takashi Iwai <[email protected]>--- kernel/power/user.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)kernel/power/user.c +1
-1@@ -137,7 +137,7 @@ static int snapshot_release(struct inode *inode, struct file *filp)free_all_swap_pages (data->swap);if (data->frozen)thaw_processes (); -pm_notifier_call_chain (data->mode ==O_WRONLY ? +pm_notifier_call_chain (data->mode ==O_RDONLY ?PM_POST_HIBERNATION :PM_POST_RESTORE );atomic_inc (&snapshot_device_available);
At Thu, 9 Dec 2010 21:37:24 +0100,
Quoted 74 lines · Rafael J. Wysocki
Quoted 72 lines · Takashi Iwai
At Thu, 9 Dec 2010 01:53:03 +0000,
Quoted 37 lines · Chris Ball
Hi Takashi,
Quoted 19 lines · Takashi Iwai
The commit
4c2ef25fe0b847d2ae818f74758ddb0be1c27d8e
mmc: fix all hangs related to mmc/sd card insert/removal during suspend/resume
introduced a bug where the device probing no longer works after hibernation. This was because the pm notifier expectsPM_POST_HIBERNATIONcall while the system sendsPM_POST_RESTOREinstead, thusdisable_rescanis kept as 1.Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- drivers/mmc/core/core.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/mmc/core/core.c +0
-0drivers/mmc/core/core.c int mmc_pm_notify(struct notifier_block *notify_block, · line 1778
Quoted 8 lines
drivers/mmc/core/core.c +1
-1@@ -1772,7 +1772,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,break ;case PM_POST_SUSPEND : -case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;Thanks very much for tracking this down! The code suggests that
POST_RESTOREis only emitted on a *failed* hibernation restore -- frominclude/linux/notifier.h:/* Hibernation and suspend events */
Quoted 8 lines
#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ #define PM_POST_RESTORE 0x0006 /* Restore failed */So, this all suggests that we want to add the
POST_RESTOREcase but also want to keep thePOST_HIBERNATIONcase. Do you agree? Was the case you saw of failed probe after hibernation a failed restore from hibernation image?Right, I took a look at
Documentation/pm/notifiers.txt, and it's clearly written thatPM_POST_RESTOREis only for the error case. But S4 resume succeeded actually on my machine, so it took time to spot out the culprit.Looking at the code in
kernel/power/, this might be the case of user-space suspend.hibernate.cseems returningPM_POST_HIBERNATIONwhileuser.creturnsPM_POST_RESTOREafter image restoration, and I guess it's a bug ofuser.c.The untested patch is below (sorry I have no corresponding machine at my home.) Rafael, Pavel, could you check this?
thanks,
Takashi
===
From915fda609e02b02e4fc6b944e4432ea1d964adc5Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Thu, 9 Dec 2010 08:09:21 +0100
Subject: [PATCH] PM: Fix PM_POST_* notification with user-space suspend
Quoted 5 lines
Quoted 3 lines
The user-space hibernation sends a wrong notification after the image restoration because of thinko for the file flag check. RDONLY corresponds to hibernation and WRONLY to restoration, confusingly.
The patch is correct. I'm taking it to my tree.
Thanks! So it's an over-3-years-old old bug ;)
Meanwhile, the fix below should be still added to mmc-core. It's still needed for the error case.
Takashi
===
From: Takashi Iwai <[email protected]>
Subject: [PATCH] mmc: Fix re-probing with PM_POST_RESTORE notification
In the error-path where PM notifies PM_POST_RESTORE, the rescan-blockage should be cleared as well. Otherwise it'll be never re-probed.
Also, as a bonus, this fixes a bug in S4 with user-mode suspend in the current code, as it sends PM_POST_RESTORE instead of PM_POST_HIBERNATION wrongly.
--- drivers/mmc/core/core.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/mmc/core/core.c +1 -0
@@ -1773,6 +1773,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,case PM_POST_SUSPEND :case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;
Signature · 1 line
1.7.3.1
Hi Takashi,
Quoted 20 lines · Takashi Iwai
Subject: [PATCH] mmc: Fix re-probing with
PM_POST_RESTOREnotificationIn the error-path where PM notifies
PM_POST_RESTORE, the rescan-blockage should be cleared as well. Otherwise it'll be never re-probed.Also, as a bonus, this fixes a bug in S4 with user-mode suspend in the current code, as it sends
PM_POST_RESTOREinstead ofPM_POST_HIBERNATIONwrongly.Cc <[email protected]>Signed-off-by Takashi Iwai <[email protected]>--- drivers/mmc/core/core.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)drivers/mmc/core/core.c +0
-0
drivers/mmc/core/core.c int mmc_pm_notify(struct notifier_block *notify_block, · line 1779
Quoted 7 lines
drivers/mmc/core/core.c +1
-0@@ -1773,6 +1773,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,case PM_POST_SUSPEND :case PM_POST_HIBERNATION : +case PM_POST_RESTORE :spin_lock_irqsave (&host->lock, flags); host->rescan_disable =0 ;
Thanks, have pushed this to mmc-next and queued it for .37/stable.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child