aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@shinybook.infradead.org>2005-07-27 09:14:13 -0400
committerDavid Woodhouse <dwmw2@shinybook.infradead.org>2005-07-27 09:14:13 -0400
commitc5fbc3966f48279dbebfde10248c977014aa9988 (patch)
tree0a52f645d89f91952c26b215f460a4ba195ca42c /kernel
parent39299d9d15c41cbdd7c7009967cd35afaf34d8fa (diff)
parent9e566d8bd61f939b7f5d7d969f5b178571471cf9 (diff)
Merge with master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'kernel')
-rw-r--r--kernel/panic.c9
-rw-r--r--kernel/power/disk.c9
-rw-r--r--kernel/power/poweroff.c4
-rw-r--r--kernel/sched.c8
-rw-r--r--kernel/sys.c113
5 files changed, 85 insertions, 58 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index 74ba5f3e46c7..aabc5f86fa3f 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -111,12 +111,11 @@ NORET_TYPE void panic(const char * fmt, ...)
111 mdelay(1); 111 mdelay(1);
112 i++; 112 i++;
113 } 113 }
114 /* 114 /* This will not be a clean reboot, with everything
115 * Should we run the reboot notifier. For the moment Im 115 * shutting down. But if there is a chance of
116 * choosing not too. It might crash, be corrupt or do 116 * rebooting the system it will be rebooted.
117 * more harm than good for other reasons.
118 */ 117 */
119 machine_restart(NULL); 118 emergency_restart();
120 } 119 }
121#ifdef __sparc__ 120#ifdef __sparc__
122 { 121 {
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 3ec789c6b537..664eb0469b6e 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -59,16 +59,13 @@ static void power_down(suspend_disk_method_t mode)
59 error = pm_ops->enter(PM_SUSPEND_DISK); 59 error = pm_ops->enter(PM_SUSPEND_DISK);
60 break; 60 break;
61 case PM_DISK_SHUTDOWN: 61 case PM_DISK_SHUTDOWN:
62 printk("Powering off system\n"); 62 kernel_power_off();
63 device_shutdown();
64 machine_power_off();
65 break; 63 break;
66 case PM_DISK_REBOOT: 64 case PM_DISK_REBOOT:
67 device_shutdown(); 65 kernel_restart(NULL);
68 machine_restart(NULL);
69 break; 66 break;
70 } 67 }
71 machine_halt(); 68 kernel_halt();
72 /* Valid image is on the disk, if we continue we risk serious data corruption 69 /* Valid image is on the disk, if we continue we risk serious data corruption
73 after resume. */ 70 after resume. */
74 printk(KERN_CRIT "Please power me down manually\n"); 71 printk(KERN_CRIT "Please power me down manually\n");
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
index 715081b2d829..7a4144ba3afd 100644
--- a/kernel/power/poweroff.c
+++ b/kernel/power/poweroff.c
@@ -9,6 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pm.h> 10#include <linux/pm.h>
11#include <linux/workqueue.h> 11#include <linux/workqueue.h>
12#include <linux/reboot.h>
12 13
13/* 14/*
14 * When the user hits Sys-Rq o to power down the machine this is the 15 * When the user hits Sys-Rq o to power down the machine this is the
@@ -17,8 +18,7 @@
17 18
18static void do_poweroff(void *dummy) 19static void do_poweroff(void *dummy)
19{ 20{
20 if (pm_power_off) 21 kernel_power_off();
21 pm_power_off();
22} 22}
23 23
24static DECLARE_WORK(poweroff_work, do_poweroff, NULL); 24static DECLARE_WORK(poweroff_work, do_poweroff, NULL);
diff --git a/kernel/sched.c b/kernel/sched.c
index 4107db0dc091..a646e4f36c41 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3486,7 +3486,7 @@ static void __setscheduler(struct task_struct *p, int policy, int prio)
3486 p->policy = policy; 3486 p->policy = policy;
3487 p->rt_priority = prio; 3487 p->rt_priority = prio;
3488 if (policy != SCHED_NORMAL) 3488 if (policy != SCHED_NORMAL)
3489 p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority; 3489 p->prio = MAX_RT_PRIO-1 - p->rt_priority;
3490 else 3490 else
3491 p->prio = p->static_prio; 3491 p->prio = p->static_prio;
3492} 3492}
@@ -3518,7 +3518,8 @@ recheck:
3518 * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL is 0. 3518 * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL is 0.
3519 */ 3519 */
3520 if (param->sched_priority < 0 || 3520 if (param->sched_priority < 0 ||
3521 param->sched_priority > MAX_USER_RT_PRIO-1) 3521 (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
3522 (!p->mm && param->sched_priority > MAX_RT_PRIO-1))
3522 return -EINVAL; 3523 return -EINVAL;
3523 if ((policy == SCHED_NORMAL) != (param->sched_priority == 0)) 3524 if ((policy == SCHED_NORMAL) != (param->sched_priority == 0))
3524 return -EINVAL; 3525 return -EINVAL;
@@ -3528,7 +3529,8 @@ recheck:
3528 */ 3529 */
3529 if (!capable(CAP_SYS_NICE)) { 3530 if (!capable(CAP_SYS_NICE)) {
3530 /* can't change policy */ 3531 /* can't change policy */
3531 if (policy != p->policy) 3532 if (policy != p->policy &&
3533 !p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
3532 return -EPERM; 3534 return -EPERM;
3533 /* can't increase priority */ 3535 /* can't increase priority */
3534 if (policy != SCHED_NORMAL && 3536 if (policy != SCHED_NORMAL &&
diff --git a/kernel/sys.c b/kernel/sys.c
index 9a24374c23bc..a74039036fb4 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -361,6 +361,68 @@ out_unlock:
361 return retval; 361 return retval;
362} 362}
363 363
364void emergency_restart(void)
365{
366 machine_emergency_restart();
367}
368EXPORT_SYMBOL_GPL(emergency_restart);
369
370void kernel_restart(char *cmd)
371{
372 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
373 system_state = SYSTEM_RESTART;
374 device_suspend(PMSG_FREEZE);
375 device_shutdown();
376 if (!cmd) {
377 printk(KERN_EMERG "Restarting system.\n");
378 } else {
379 printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd);
380 }
381 printk(".\n");
382 machine_restart(cmd);
383}
384EXPORT_SYMBOL_GPL(kernel_restart);
385
386void kernel_kexec(void)
387{
388#ifdef CONFIG_KEXEC
389 struct kimage *image;
390 image = xchg(&kexec_image, 0);
391 if (!image) {
392 return;
393 }
394 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
395 system_state = SYSTEM_RESTART;
396 device_suspend(PMSG_FREEZE);
397 device_shutdown();
398 printk(KERN_EMERG "Starting new kernel\n");
399 machine_shutdown();
400 machine_kexec(image);
401#endif
402}
403EXPORT_SYMBOL_GPL(kernel_kexec);
404
405void kernel_halt(void)
406{
407 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
408 system_state = SYSTEM_HALT;
409 device_suspend(PMSG_SUSPEND);
410 device_shutdown();
411 printk(KERN_EMERG "System halted.\n");
412 machine_halt();
413}
414EXPORT_SYMBOL_GPL(kernel_halt);
415
416void kernel_power_off(void)
417{
418 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
419 system_state = SYSTEM_POWER_OFF;
420 device_suspend(PMSG_SUSPEND);
421 device_shutdown();
422 printk(KERN_EMERG "Power down.\n");
423 machine_power_off();
424}
425EXPORT_SYMBOL_GPL(kernel_power_off);
364 426
365/* 427/*
366 * Reboot system call: for obvious reasons only root may call it, 428 * Reboot system call: for obvious reasons only root may call it,
@@ -389,11 +451,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
389 lock_kernel(); 451 lock_kernel();
390 switch (cmd) { 452 switch (cmd) {
391 case LINUX_REBOOT_CMD_RESTART: 453 case LINUX_REBOOT_CMD_RESTART:
392 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); 454 kernel_restart(NULL);
393 system_state = SYSTEM_RESTART;
394 device_shutdown();
395 printk(KERN_EMERG "Restarting system.\n");
396 machine_restart(NULL);
397 break; 455 break;
398 456
399 case LINUX_REBOOT_CMD_CAD_ON: 457 case LINUX_REBOOT_CMD_CAD_ON:
@@ -405,23 +463,13 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
405 break; 463 break;
406 464
407 case LINUX_REBOOT_CMD_HALT: 465 case LINUX_REBOOT_CMD_HALT:
408 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); 466 kernel_halt();
409 system_state = SYSTEM_HALT;
410 device_suspend(PMSG_SUSPEND);
411 device_shutdown();
412 printk(KERN_EMERG "System halted.\n");
413 machine_halt();
414 unlock_kernel(); 467 unlock_kernel();
415 do_exit(0); 468 do_exit(0);
416 break; 469 break;
417 470
418 case LINUX_REBOOT_CMD_POWER_OFF: 471 case LINUX_REBOOT_CMD_POWER_OFF:
419 notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); 472 kernel_power_off();
420 system_state = SYSTEM_POWER_OFF;
421 device_suspend(PMSG_SUSPEND);
422 device_shutdown();
423 printk(KERN_EMERG "Power down.\n");
424 machine_power_off();
425 unlock_kernel(); 473 unlock_kernel();
426 do_exit(0); 474 do_exit(0);
427 break; 475 break;
@@ -433,32 +481,14 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
433 } 481 }
434 buffer[sizeof(buffer) - 1] = '\0'; 482 buffer[sizeof(buffer) - 1] = '\0';
435 483
436 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); 484 kernel_restart(buffer);
437 system_state = SYSTEM_RESTART;
438 device_suspend(PMSG_FREEZE);
439 device_shutdown();
440 printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer);
441 machine_restart(buffer);
442 break; 485 break;
443 486
444#ifdef CONFIG_KEXEC
445 case LINUX_REBOOT_CMD_KEXEC: 487 case LINUX_REBOOT_CMD_KEXEC:
446 { 488 kernel_kexec();
447 struct kimage *image; 489 unlock_kernel();
448 image = xchg(&kexec_image, 0); 490 return -EINVAL;
449 if (!image) { 491
450 unlock_kernel();
451 return -EINVAL;
452 }
453 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
454 system_state = SYSTEM_RESTART;
455 device_shutdown();
456 printk(KERN_EMERG "Starting new kernel\n");
457 machine_shutdown();
458 machine_kexec(image);
459 break;
460 }
461#endif
462#ifdef CONFIG_SOFTWARE_SUSPEND 492#ifdef CONFIG_SOFTWARE_SUSPEND
463 case LINUX_REBOOT_CMD_SW_SUSPEND: 493 case LINUX_REBOOT_CMD_SW_SUSPEND:
464 { 494 {
@@ -478,8 +508,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
478 508
479static void deferred_cad(void *dummy) 509static void deferred_cad(void *dummy)
480{ 510{
481 notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); 511 kernel_restart(NULL);
482 machine_restart(NULL);
483} 512}
484 513
485/* 514/*