public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] properly stop devices before poweroff
@ 2005-04-21 11:13 Pavel Machek
  2005-04-29 13:18 ` Andrew Morton
  2005-05-01 22:24 ` Adam Belay
  0 siblings, 2 replies; 26+ messages in thread
From: Pavel Machek @ 2005-04-21 11:13 UTC (permalink / raw)
  To: Andrew Morton, kernel list


Without this patch, Linux provokes emergency disk shutdowns and
similar nastiness. It was in SuSE kernels for some time, IIRC.

Signed-off-by: Pavel Machek <pavel@suse.cz>

--- clean/kernel/sys.c	2005-03-19 00:32:32.000000000 +0100
+++ linux/kernel/sys.c	2005-03-22 12:20:53.000000000 +0100
@@ -404,6 +404,7 @@
 	case LINUX_REBOOT_CMD_HALT:
 		notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
 		system_state = SYSTEM_HALT;
+		device_suspend(PMSG_SUSPEND);
 		device_shutdown();
 		printk(KERN_EMERG "System halted.\n");
 		machine_halt();
@@ -414,6 +415,7 @@
 	case LINUX_REBOOT_CMD_POWER_OFF:
 		notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
 		system_state = SYSTEM_POWER_OFF;
+		device_suspend(PMSG_SUSPEND);
 		device_shutdown();
 		printk(KERN_EMERG "Power down.\n");
 		machine_power_off();
@@ -430,6 +432,7 @@
 
 		notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer);
 		system_state = SYSTEM_RESTART;
+		device_suspend(PMSG_FREEZE);
 		device_shutdown();
 		printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer);
 		machine_restart(buffer);

-- 
Boycott Kodak -- for their patent abuse against Java.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [patch] properly stop devices before poweroff
@ 2005-04-21 11:30 tvrtko.ursulin
  2005-04-21 11:38 ` Pavel Machek
  0 siblings, 1 reply; 26+ messages in thread
From: tvrtko.ursulin @ 2005-04-21 11:30 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, kernel list

On 21/04/2005 12:13:46 linux-kernel-owner wrote:

>Without this patch, Linux provokes emergency disk shutdowns and
>similar nastiness. It was in SuSE kernels for some time, IIRC.

OMG! And I did try to raise that issue 10 months ago, see below:

http://www.ussg.iu.edu/hypermail/linux/kernel/0406.0/0242.html



^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: [patch] properly stop devices before poweroff
@ 2005-04-21 15:02 tvrtko.ursulin
  0 siblings, 0 replies; 26+ messages in thread
From: tvrtko.ursulin @ 2005-04-21 15:02 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, kernel list

On 21/04/2005 12:38:29 linux-kernel-owner wrote:

>> >Without this patch, Linux provokes emergency disk shutdowns and
>> >similar nastiness. It was in SuSE kernels for some time, IIRC.
>> OMG! And I did try to raise that issue 10 months ago, see below:
>> http://www.ussg.iu.edu/hypermail/linux/kernel/0406.0/0242.html
>
>Heh, verify that this patch works for you and it might finally get
>fixed...

I can't "hear" the difference between normal and emergency shutdown, and 
information I found does not suggest they are recorded amongst s.m.a.r.t 
attributes. Power_Cycle_Count, Load_Cycle_Count and 
Power-Off_Retract_Count seem to be in sync, although common sense would 
suggests that the last one should possibly not increment on a clean 
shutdown. I will experiment a bit when I find some spare time.


^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: [patch] properly stop devices before poweroff
@ 2005-07-26 19:02 Luck, Tony
  2005-07-26 19:10 ` Andrew Morton
  2005-07-28  1:37 ` Kenji Kaneshige
  0 siblings, 2 replies; 26+ messages in thread
From: Luck, Tony @ 2005-07-26 19:02 UTC (permalink / raw)
  To: Kenji Kaneshige, Andrew Morton
  Cc: Adam Belay, greg, pavel, linux-kernel, linux-ia64

I started on my OLS homework from Andrew ... and began looking
into what is going on here.

The story so far: Pavel added calls to device_suspend() to three of
the cases in the sys_reboot() path.  This stopped ia64 from being
able to shutdown.  There is a oops with a stacktrace pointing back
at the sys_reboot call.

Initial analysis from Kenji Kaneshige said that we might fix this
by adding a patch to the ia64 version of pcibios_disable_device()
to make it check whether the device was enabled before calling
acpi_pci_irq_disable().  This might fix things if the issue was
simply problems with this being called twice.  Pavel sent a
"Looks good", Adam said "Is it the right fix?"

I just tried it ... it doesn't work, we still see an oops from
the sys_reboot() ... so shutdown hangs, and we can sidestep the
issue of whether this is ideologically correct.

Then I wondered whether it was just an e1000 problem (since Pavel
had also commented that we should perhaps removed the reboot notifier
from the e1000 driver).  So I rebuilt my kernel with e1000 as a module
and ran "rmmod e1000" before running shutdown.  Which promptly failed
with a stack trace that ran through mptscsih driver instead of e1000.
[N.B. Kaneshige-san has also noted that his i386 system which has the
mptfusion also hangs executing a SYNCHRONIZE_CACHE command]. 

Code examination in the e1000 case shows that we are a bit confused
and call first:

notifier_call_chain(reboot_notifier, ...)
  e1000_notify_reboot(...)
    e1000_suspend(...)
      pci_disable_device(...)
      pci_set_power_state(...)

and then:

device_suspend(...)
   suspend_device() == dev->bus->suspend == pci_device_suspend
     e1000_suspend()
       pci_disable_device()
       pciset_power_state()

So it looks like Pavel is right ... registering the reboot notifier is
bogus in e1000.  Commenting out the register/unregister also allows
me to get past the e1000 so that I can fail in mptscsih_suspend() path.
But the fusion driver doesn't register a reboot notifier, so I can't
try the same trick there :-)

Andrew: How did you get the squitty font on ia64?  The stack trace
from the oops flies off the top of the screen.  I've tried a few
"vga=0x0f07" type options, but I keep getting a big font.

-Tony

^ permalink raw reply	[flat|nested] 26+ messages in thread
* RE: [patch] properly stop devices before poweroff
@ 2005-07-27 21:14 Luck, Tony
  0 siblings, 0 replies; 26+ messages in thread
From: Luck, Tony @ 2005-07-27 21:14 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Andrew Morton, kaneshige.kenji, ambx1, greg, linux-kernel,
	linux-ia64, Brown, Len

>> The remaining problem is cause by the order of the calls in sys_reboot:
>> 
>>                 device_suspend(PMSG_SUSPEND);
>>                 device_shutdown();
>> 
>> The call to device_suspend() shuts down the mpt/fusion 
>driver.  But then
>> device_shutdown() calls sd_shutdown() which prints:
>> 
>>   Synchronizing SCSI cache for disk sdb
>
>Okay, looks to me like sd_shutdown should be done from
>device_suspend(), not device_shutdown [because it needs scsi subsystem
>to be functional]. Also for reboot we probably want PMSG_FREEZE (not
>PMSG_SUSPEND), to keep it slightly faster.

Are you going to work on making those changes?

-Tony

^ permalink raw reply	[flat|nested] 26+ messages in thread
[parent not found: <200506260105.j5Q15eBj021334@hera.kernel.org>]

end of thread, other threads:[~2005-08-01 15:22 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-21 11:13 [patch] properly stop devices before poweroff Pavel Machek
2005-04-29 13:18 ` Andrew Morton
2005-04-29 13:36   ` Zwane Mwaikambo
2005-04-30  9:47     ` Andrew Morton
2005-04-30 13:40       ` Pavel Machek
2005-05-01 19:09   ` Kenji Kaneshige
2005-05-01 19:57     ` Pavel Machek
2005-05-01 22:16     ` Adam Belay
2005-05-16  7:56       ` Andrew Morton
2005-05-19 12:43         ` Kenji Kaneshige
2005-05-01 22:24 ` Adam Belay
2005-05-01 23:16   ` Pavel Machek
2005-05-02  0:01     ` Adam Belay
2005-05-02  9:55       ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2005-04-21 11:30 tvrtko.ursulin
2005-04-21 11:38 ` Pavel Machek
2005-04-21 15:02 tvrtko.ursulin
2005-07-26 19:02 Luck, Tony
2005-07-26 19:10 ` Andrew Morton
2005-07-27  0:14   ` tony.luck
2005-07-27  0:23     ` Andrew Morton
2005-07-27  7:40     ` Pavel Machek
2005-07-28  1:37 ` Kenji Kaneshige
2005-07-28  1:41   ` Andrew Morton
2005-07-27 21:14 Luck, Tony
     [not found] <200506260105.j5Q15eBj021334@hera.kernel.org>
2005-08-01 15:19 ` [PATCH] " Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox