diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-02 03:49:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-02 03:49:38 -0400 |
commit | 446139a8f7078d96159a936fd6059660db425405 (patch) | |
tree | 01b122d257de51c365c1bef32285efa0fbe1c189 /arch/sparc64/kernel | |
parent | cdb3592a20b41377a28a0737dc9af95e53024470 (diff) |
sparc64: Implement SSTATE purely using notifiers and initcalls.
Don't clutter up the tree with sstate_blah() scattered all over the
place.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel')
-rw-r--r-- | arch/sparc64/kernel/hvapi.c | 3 | ||||
-rw-r--r-- | arch/sparc64/kernel/reboot.c | 4 | ||||
-rw-r--r-- | arch/sparc64/kernel/sstate.c | 67 |
3 files changed, 45 insertions, 29 deletions
diff --git a/arch/sparc64/kernel/hvapi.c b/arch/sparc64/kernel/hvapi.c index 691760b5b012..1d272c3b5740 100644 --- a/arch/sparc64/kernel/hvapi.c +++ b/arch/sparc64/kernel/hvapi.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <asm/hypervisor.h> | 10 | #include <asm/hypervisor.h> |
11 | #include <asm/oplib.h> | 11 | #include <asm/oplib.h> |
12 | #include <asm/sstate.h> | ||
13 | 12 | ||
14 | /* If the hypervisor indicates that the API setting | 13 | /* If the hypervisor indicates that the API setting |
15 | * calls are unsupported, by returning HV_EBADTRAP or | 14 | * calls are unsupported, by returning HV_EBADTRAP or |
@@ -184,8 +183,6 @@ void __init sun4v_hvapi_init(void) | |||
184 | if (sun4v_hvapi_register(group, major, &minor)) | 183 | if (sun4v_hvapi_register(group, major, &minor)) |
185 | goto bad; | 184 | goto bad; |
186 | 185 | ||
187 | sun4v_sstate_init(); | ||
188 | |||
189 | return; | 186 | return; |
190 | 187 | ||
191 | bad: | 188 | bad: |
diff --git a/arch/sparc64/kernel/reboot.c b/arch/sparc64/kernel/reboot.c index 04dd34cbb872..11f249660630 100644 --- a/arch/sparc64/kernel/reboot.c +++ b/arch/sparc64/kernel/reboot.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | #include <linux/pm.h> | 8 | #include <linux/pm.h> |
9 | 9 | ||
10 | #include <asm/sstate.h> | ||
11 | #include <asm/oplib.h> | 10 | #include <asm/oplib.h> |
12 | #include <asm/prom.h> | 11 | #include <asm/prom.h> |
13 | 12 | ||
@@ -24,7 +23,6 @@ EXPORT_SYMBOL(pm_power_off); | |||
24 | 23 | ||
25 | void machine_power_off(void) | 24 | void machine_power_off(void) |
26 | { | 25 | { |
27 | sstate_poweroff(); | ||
28 | if (strcmp(of_console_device->type, "serial") || scons_pwroff) | 26 | if (strcmp(of_console_device->type, "serial") || scons_pwroff) |
29 | prom_halt_power_off(); | 27 | prom_halt_power_off(); |
30 | 28 | ||
@@ -33,7 +31,6 @@ void machine_power_off(void) | |||
33 | 31 | ||
34 | void machine_halt(void) | 32 | void machine_halt(void) |
35 | { | 33 | { |
36 | sstate_halt(); | ||
37 | prom_halt(); | 34 | prom_halt(); |
38 | panic("Halt failed!"); | 35 | panic("Halt failed!"); |
39 | } | 36 | } |
@@ -42,7 +39,6 @@ void machine_restart(char *cmd) | |||
42 | { | 39 | { |
43 | char *p; | 40 | char *p; |
44 | 41 | ||
45 | sstate_reboot(); | ||
46 | p = strchr(reboot_command, '\n'); | 42 | p = strchr(reboot_command, '\n'); |
47 | if (p) | 43 | if (p) |
48 | *p = 0; | 44 | *p = 0; |
diff --git a/arch/sparc64/kernel/sstate.c b/arch/sparc64/kernel/sstate.c index 5b6e75b7f052..8cdbe5946b43 100644 --- a/arch/sparc64/kernel/sstate.c +++ b/arch/sparc64/kernel/sstate.c | |||
@@ -1,14 +1,15 @@ | |||
1 | /* sstate.c: System soft state support. | 1 | /* sstate.c: System soft state support. |
2 | * | 2 | * |
3 | * Copyright (C) 2007 David S. Miller <davem@davemloft.net> | 3 | * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net> |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/notifier.h> | 7 | #include <linux/notifier.h> |
8 | #include <linux/reboot.h> | ||
8 | #include <linux/init.h> | 9 | #include <linux/init.h> |
9 | 10 | ||
10 | #include <asm/hypervisor.h> | 11 | #include <asm/hypervisor.h> |
11 | #include <asm/sstate.h> | 12 | #include <asm/spitfire.h> |
12 | #include <asm/oplib.h> | 13 | #include <asm/oplib.h> |
13 | #include <asm/head.h> | 14 | #include <asm/head.h> |
14 | #include <asm/io.h> | 15 | #include <asm/io.h> |
@@ -50,31 +51,34 @@ static const char rebooting_msg[32] __attribute__((aligned(32))) = | |||
50 | static const char panicing_msg[32] __attribute__((aligned(32))) = | 51 | static const char panicing_msg[32] __attribute__((aligned(32))) = |
51 | "Linux panicing"; | 52 | "Linux panicing"; |
52 | 53 | ||
53 | void sstate_booting(void) | 54 | static int sstate_reboot_call(struct notifier_block *np, unsigned long type, void *_unused) |
54 | { | 55 | { |
55 | do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg); | 56 | const char *msg; |
56 | } | ||
57 | 57 | ||
58 | void sstate_running(void) | 58 | switch (type) { |
59 | { | 59 | case SYS_DOWN: |
60 | do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg); | 60 | default: |
61 | } | 61 | msg = rebooting_msg; |
62 | break; | ||
62 | 63 | ||
63 | void sstate_halt(void) | 64 | case SYS_HALT: |
64 | { | 65 | msg = halting_msg; |
65 | do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg); | 66 | break; |
66 | } | ||
67 | 67 | ||
68 | void sstate_poweroff(void) | 68 | case SYS_POWER_OFF: |
69 | { | 69 | msg = poweroff_msg; |
70 | do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg); | 70 | break; |
71 | } | 71 | } |
72 | 72 | ||
73 | void sstate_reboot(void) | 73 | do_set_sstate(HV_SOFT_STATE_TRANSITION, msg); |
74 | { | 74 | |
75 | do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg); | 75 | return NOTIFY_OK; |
76 | } | 76 | } |
77 | 77 | ||
78 | static struct notifier_block sstate_reboot_notifier = { | ||
79 | .notifier_call = sstate_reboot_call, | ||
80 | }; | ||
81 | |||
78 | static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr) | 82 | static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr) |
79 | { | 83 | { |
80 | do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg); | 84 | do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg); |
@@ -87,18 +91,37 @@ static struct notifier_block sstate_panic_block = { | |||
87 | .priority = INT_MAX, | 91 | .priority = INT_MAX, |
88 | }; | 92 | }; |
89 | 93 | ||
90 | void __init sun4v_sstate_init(void) | 94 | static int __init sstate_init(void) |
91 | { | 95 | { |
92 | unsigned long major, minor; | 96 | unsigned long major, minor; |
93 | 97 | ||
98 | if (tlb_type != hypervisor) | ||
99 | return 0; | ||
100 | |||
94 | major = 1; | 101 | major = 1; |
95 | minor = 0; | 102 | minor = 0; |
96 | if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor)) | 103 | if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor)) |
97 | return; | 104 | return 0; |
98 | 105 | ||
99 | hv_supports_soft_state = 1; | 106 | hv_supports_soft_state = 1; |
100 | 107 | ||
101 | prom_sun4v_guest_soft_state(); | 108 | prom_sun4v_guest_soft_state(); |
109 | |||
110 | do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg); | ||
111 | |||
102 | atomic_notifier_chain_register(&panic_notifier_list, | 112 | atomic_notifier_chain_register(&panic_notifier_list, |
103 | &sstate_panic_block); | 113 | &sstate_panic_block); |
114 | register_reboot_notifier(&sstate_reboot_notifier); | ||
115 | |||
116 | return 0; | ||
104 | } | 117 | } |
118 | |||
119 | core_initcall(sstate_init); | ||
120 | |||
121 | static int __init sstate_running(void) | ||
122 | { | ||
123 | do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | late_initcall(sstate_running); | ||