Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754115Ab0LJHkh (ORCPT ); Fri, 10 Dec 2010 02:40:37 -0500 Received: from cantor2.suse.de ([195.135.220.15]:35114 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753274Ab0LJHkf (ORCPT ); Fri, 10 Dec 2010 02:40:35 -0500 Date: Fri, 10 Dec 2010 08:40:31 +0100 Message-ID: From: Takashi Iwai To: "Rafael J. Wysocki" Cc: Chris Ball , Maxim Levitsky , Oliver Neukum , Andrew Morton , Pavel Machek , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mmc: Fix re-probing after hibernation In-Reply-To: <201012092137.24603.rjw@sisk.pl> References: <1291821839-15088-1-git-send-email-tiwai@suse.de> <20101209015303.GB19741@void.printf.net> <201012092137.24603.rjw@sisk.pl> User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4640 Lines: 127 At Thu, 9 Dec 2010 21:37:24 +0100, Rafael J. Wysocki wrote: > > On Thursday, December 09, 2010, Takashi Iwai wrote: > > At Thu, 9 Dec 2010 01:53:03 +0000, > > Chris Ball wrote: > > > > > > Hi Takashi, > > > > > > On Wed, Dec 08, 2010 at 04:23:59PM +0100, Takashi Iwai wrote: > > > > 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. > > > > > > > > Cc: > > > > Signed-off-by: Takashi Iwai > > > > --- > > > > drivers/mmc/core/core.c | 2 +- > > > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > > > > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > > > > index 31ae07a..30094f6 100644 > > > > --- a/drivers/mmc/core/core.c > > > > +++ b/drivers/mmc/core/core.c > > > > @@ -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? > > > > Right, I took a look at Documentation/pm/notifiers.txt, and it's > > clearly written that PM_POST_RESTORE is 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.c seems returning PM_POST_HIBERNATION > > while user.c returns PM_POST_RESTORE after image restoration, and I > > guess it's a bug of user.c. > > > > The untested patch is below (sorry I have no corresponding machine > > at my home.) Rafael, Pavel, could you check this? > > > > > > thanks, > > > > Takashi > > > > === > > From 915fda609e02b02e4fc6b944e4432ea1d964adc5 Mon Sep 17 00:00:00 2001 > > From: Takashi Iwai > > Date: Thu, 9 Dec 2010 08:09:21 +0100 > > Subject: [PATCH] PM: Fix PM_POST_* notification with user-space suspend > > > > 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 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. Cc: Signed-off-by: Takashi Iwai --- drivers/mmc/core/core.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 31ae07a..57dcf8f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -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; -- 1.7.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/