Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+48 -55
-7
arch/sparc/include/asm/bugs.h
··· 7 7 #include <asm/cpudata.h> 8 8 #endif 9 9 10 - #ifdef CONFIG_SPARC64 11 - #include <asm/sstate.h> 12 - #endif 13 - 14 10 extern unsigned long loops_per_jiffy; 15 11 16 12 static void __init check_bugs(void) 17 13 { 18 14 #if defined(CONFIG_SPARC32) && !defined(CONFIG_SMP) 19 15 cpu_data(0).udelay_val = loops_per_jiffy; 20 - #endif 21 - #ifdef CONFIG_SPARC64 22 - sstate_running(); 23 16 #endif 24 17 }
-13
arch/sparc/include/asm/sstate.h
··· 1 - #ifndef _SPARC64_SSTATE_H 2 - #define _SPARC64_SSTATE_H 3 - 4 - extern void sstate_booting(void); 5 - extern void sstate_running(void); 6 - extern void sstate_halt(void); 7 - extern void sstate_poweroff(void); 8 - extern void sstate_panic(void); 9 - extern void sstate_reboot(void); 10 - 11 - extern void sun4v_sstate_init(void); 12 - 13 - #endif /* _SPARC64_SSTATE_H */
-3
arch/sparc64/kernel/hvapi.c
··· 9 9 10 10 #include <asm/hypervisor.h> 11 11 #include <asm/oplib.h> 12 - #include <asm/sstate.h> 13 12 14 13 /* If the hypervisor indicates that the API setting 15 14 * calls are unsupported, by returning HV_EBADTRAP or ··· 182 183 minor = 1; 183 184 if (sun4v_hvapi_register(group, major, &minor)) 184 185 goto bad; 185 - 186 - sun4v_sstate_init(); 187 186 188 187 return; 189 188
-4
arch/sparc64/kernel/reboot.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/pm.h> 9 9 10 - #include <asm/sstate.h> 11 10 #include <asm/oplib.h> 12 11 #include <asm/prom.h> 13 12 ··· 23 24 24 25 void machine_power_off(void) 25 26 { 26 - sstate_poweroff(); 27 27 if (strcmp(of_console_device->type, "serial") || scons_pwroff) 28 28 prom_halt_power_off(); 29 29 ··· 31 33 32 34 void machine_halt(void) 33 35 { 34 - sstate_halt(); 35 36 prom_halt(); 36 37 panic("Halt failed!"); 37 38 } ··· 39 42 { 40 43 char *p; 41 44 42 - sstate_reboot(); 43 45 p = strchr(reboot_command, '\n'); 44 46 if (p) 45 47 *p = 0;
+48 -25
arch/sparc64/kernel/sstate.c
··· 1 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 6 #include <linux/kernel.h> 7 7 #include <linux/notifier.h> 8 + #include <linux/reboot.h> 8 9 #include <linux/init.h> 9 10 10 11 #include <asm/hypervisor.h> 11 - #include <asm/sstate.h> 12 + #include <asm/spitfire.h> 12 13 #include <asm/oplib.h> 13 14 #include <asm/head.h> 14 15 #include <asm/io.h> ··· 51 50 static const char panicing_msg[32] __attribute__((aligned(32))) = 52 51 "Linux panicing"; 53 52 54 - void sstate_booting(void) 53 + static int sstate_reboot_call(struct notifier_block *np, unsigned long type, void *_unused) 55 54 { 56 - do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg); 55 + const char *msg; 56 + 57 + switch (type) { 58 + case SYS_DOWN: 59 + default: 60 + msg = rebooting_msg; 61 + break; 62 + 63 + case SYS_HALT: 64 + msg = halting_msg; 65 + break; 66 + 67 + case SYS_POWER_OFF: 68 + msg = poweroff_msg; 69 + break; 70 + } 71 + 72 + do_set_sstate(HV_SOFT_STATE_TRANSITION, msg); 73 + 74 + return NOTIFY_OK; 57 75 } 58 76 59 - void sstate_running(void) 60 - { 61 - do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg); 62 - } 63 - 64 - void sstate_halt(void) 65 - { 66 - do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg); 67 - } 68 - 69 - void sstate_poweroff(void) 70 - { 71 - do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg); 72 - } 73 - 74 - void sstate_reboot(void) 75 - { 76 - do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg); 77 - } 77 + static struct notifier_block sstate_reboot_notifier = { 78 + .notifier_call = sstate_reboot_call, 79 + }; 78 80 79 81 static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr) 80 82 { ··· 91 87 .priority = INT_MAX, 92 88 }; 93 89 94 - void __init sun4v_sstate_init(void) 90 + static int __init sstate_init(void) 95 91 { 96 92 unsigned long major, minor; 93 + 94 + if (tlb_type != hypervisor) 95 + return 0; 97 96 98 97 major = 1; 99 98 minor = 0; 100 99 if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor)) 101 - return; 100 + return 0; 102 101 103 102 hv_supports_soft_state = 1; 104 103 105 104 prom_sun4v_guest_soft_state(); 105 + 106 + do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg); 107 + 106 108 atomic_notifier_chain_register(&panic_notifier_list, 107 109 &sstate_panic_block); 110 + register_reboot_notifier(&sstate_reboot_notifier); 111 + 112 + return 0; 108 113 } 114 + 115 + core_initcall(sstate_init); 116 + 117 + static int __init sstate_running(void) 118 + { 119 + do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg); 120 + return 0; 121 + } 122 + 123 + late_initcall(sstate_running);
-3
arch/sparc64/mm/init.c
··· 46 46 #include <asm/tsb.h> 47 47 #include <asm/hypervisor.h> 48 48 #include <asm/prom.h> 49 - #include <asm/sstate.h> 50 49 #include <asm/mdesc.h> 51 50 #include <asm/cpudata.h> 52 51 #include <asm/irq.h> ··· 1715 1716 1716 1717 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL; 1717 1718 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; 1718 - 1719 - sstate_booting(); 1720 1719 1721 1720 /* Invalidate both kernel TSBs. */ 1722 1721 memset(swapper_tsb, 0x40, sizeof(swapper_tsb));