From: "Mark M. Hoffman" Date: Tue, 20 Nov 2007 13:15:21 +0000 Subject: Re: [lm-sensors] broken suspend [Was: 2.6.24-rc2-mm1] Message-Id: <20071120131520.GC12077@jupiter.solarsys.private> List-Id: References: <4741EB91.9080000@assembler.cz> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: Alan Stern Cc: Rudolf Marek , Jiri Slaby , Greg KH , Kernel development list , lm-sensors@lm-sensors.org, "Rafael J. Wysocki" , Andrew Morton , Linux-pm mailing list Hi all: * Alan Stern [2007-11-19 15:27:14 -0500]: > On Mon, 19 Nov 2007, Rudolf Marek wrote: >=20 > > Hello all, > > >>> gives coretemp_cpu_callback -> coretemp_device_remove -> > > >>> platform_device_unregister, so coretemp seems to be what I have and= you don't. > > >=20 > > > Yes. > > >=20 > > > For the coretemp developers: coretemp_cpu_callback() needs to be more= =20 > > > careful about what it does. During a system sleep transition (suspen= d,=20 > > > hibernate, resume) it isn't possible to register or unregister a=20 > > > device. Attempts to register will fail and attempts to unregister wi= ll=20 > > > block until the system sleep is over -- and for this callback that=20 > > > means hanging. > >=20 > > Well I wrote the driver. Thanks for the clarification. If I recall corr= ectly I=20 > > looked how this part should be done from others drivers. Now while chec= king > > what happened to the file, seems Rafael added something related. > >=20 > > http://git.kernel.org/?p=3Dlinux/kernel/git/torvalds/linux-2.6.git;a=3D= commit;h=8Bb7844286fb8c9fce6f65d8288aeb09d03a5e0d >=20 > That does look like it was meant for exactly this sort of situation. >=20 > > > It's not clear what the best way is to fix this. Perhaps the CPU=20 > > > notification should be sent along with a special flag indicating that= =20 > > > the CPU transition is part of a system sleep (although this seems=20 > > > racy). Perhaps the driver should notice when a system sleep begins, = > > > and defer all CPU-change handling until after the sleep is over. > >=20 > > maybe it does exist? CPU_DOWN_PREPARE ? > >=20 > > http://git.kernel.org/?p=3Dlinux/kernel/git/torvalds/linux-2.6.git;a=3D= blob;f=3DDocumentation/cpu-hotplug.txt;hb=3DHEAD > >=20 > > Unfortunately I'm not very familiar with this, calling the=20 > > coretemp_device_remove from CPU_DOWN_PREPARE would help? Looking at mic= rocode=20 > > driver, seems it just hide sysfs interface from user. AFAICT from that documentation, it would have been better to unregister the device on CPU_DOWN_PREPARE anyway. CPU_DEAD seems to be too late - it's already gone by then. > I'm not sure exactly what you want to do here. But it seems like a=20 > waste to unregister the coretemp devices at the start of a system sleep=20 > and then register them back at the end. >=20 > Could you simply leave the devices registered throughout the entire > sleep? Of course, at the end you would have to check that all the CPUs > really did come back up, and unregister the devices for the CPUs that > are still offline. Is it possible to unregister a driver on CPU_DOWN_PREPARE_FROZEN? If so, then the simplest fix would be the patch below (Jiri: feel free to try it). Otherwise it would take a bit of refactoring to bring the sysfs interface down/up for suspend/resume. commit ce9c7b78c839a6304696d90083eac08baad524ce Author: Mark M. Hoffman Date: Tue Nov 20 07:51:50 2007 -0500 hwmon: (coretemp) fix suspend/resume hang =20 Signed-off-by: Mark M. Hoffman diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 5c82ec7..afe2d31 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -338,10 +338,12 @@ static int coretemp_cpu_callback(struct notifier_bloc= k *nfb, switch (action) { case CPU_ONLINE: case CPU_ONLINE_FROZEN: + case CPU_DOWN_FAILED: + case CPU_DOWN_FAILED_FROZEN: coretemp_device_add(cpu); break; - case CPU_DEAD: - case CPU_DEAD_FROZEN: + case CPU_DOWN_PREPARE: + case CPU_DOWN_PREPARE_FROZEN: coretemp_device_remove(cpu); break; } --=20 Mark M. Hoffman mhoffman@lightlink.com _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors