diff options
Diffstat (limited to 'drivers/char/ipmi')
-rw-r--r-- | drivers/char/ipmi/ipmi_devintf.c | 6 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 27 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 62 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 268 |
4 files changed, 215 insertions, 148 deletions
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index c2aa44ee6eb..0246a2b8ce4 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -865,7 +865,7 @@ static void ipmi_new_smi(int if_num, struct device *device) entry->dev = dev; mutex_lock(®_list_mutex); - class_device_create(ipmi_class, NULL, dev, device, "ipmi%d", if_num); + device_create(ipmi_class, device, dev, "ipmi%d", if_num); list_add(&entry->link, ®_list); mutex_unlock(®_list_mutex); } @@ -883,7 +883,7 @@ static void ipmi_smi_gone(int if_num) break; } } - class_device_destroy(ipmi_class, dev); + device_destroy(ipmi_class, dev); mutex_unlock(®_list_mutex); } @@ -938,7 +938,7 @@ static __exit void cleanup_ipmi(void) mutex_lock(®_list_mutex); list_for_each_entry_safe(entry, entry2, ®_list, link) { list_del(&entry->link); - class_device_destroy(ipmi_class, entry->dev); + device_destroy(ipmi_class, entry->dev); kfree(entry); } mutex_unlock(®_list_mutex); diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 6a01dd9e43f..5dc1265ce1d 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -221,10 +221,8 @@ struct ipmi_smi void *send_info; #ifdef CONFIG_PROC_FS - /* A list of proc entries for this interface. This does not - need a lock, only one thread creates it and only one thread - destroys it. */ - spinlock_t proc_entry_lock; + /* A list of proc entries for this interface. */ + struct mutex proc_entry_lock; struct ipmi_proc_entry *proc_entries; #endif @@ -1891,11 +1889,11 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, file->write_proc = write_proc; file->owner = owner; - spin_lock(&smi->proc_entry_lock); + mutex_lock(&smi->proc_entry_lock); /* Stick it on the list. */ entry->next = smi->proc_entries; smi->proc_entries = entry; - spin_unlock(&smi->proc_entry_lock); + mutex_unlock(&smi->proc_entry_lock); } #endif /* CONFIG_PROC_FS */ @@ -1939,7 +1937,7 @@ static void remove_proc_entries(ipmi_smi_t smi) #ifdef CONFIG_PROC_FS struct ipmi_proc_entry *entry; - spin_lock(&smi->proc_entry_lock); + mutex_lock(&smi->proc_entry_lock); while (smi->proc_entries) { entry = smi->proc_entries; smi->proc_entries = entry->next; @@ -1948,7 +1946,7 @@ static void remove_proc_entries(ipmi_smi_t smi) kfree(entry->name); kfree(entry); } - spin_unlock(&smi->proc_entry_lock); + mutex_unlock(&smi->proc_entry_lock); remove_proc_entry(smi->proc_dir_name, proc_ipmi_root); #endif /* CONFIG_PROC_FS */ } @@ -2614,6 +2612,14 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) return; } +void ipmi_poll_interface(ipmi_user_t user) +{ + ipmi_smi_t intf = user->intf; + + if (intf->handlers->poll) + intf->handlers->poll(intf->send_info); +} + int ipmi_register_smi(struct ipmi_smi_handlers *handlers, void *send_info, struct ipmi_device_id *device_id, @@ -2671,7 +2677,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, } intf->curr_seq = 0; #ifdef CONFIG_PROC_FS - spin_lock_init(&intf->proc_entry_lock); + mutex_init(&intf->proc_entry_lock); #endif spin_lock_init(&intf->waiting_msgs_lock); INIT_LIST_HEAD(&intf->waiting_msgs); @@ -4136,7 +4142,7 @@ static __exit void cleanup_ipmi(void) del_timer_sync(&ipmi_timer); #ifdef CONFIG_PROC_FS - remove_proc_entry(proc_ipmi_root->name, &proc_root); + remove_proc_entry(proc_ipmi_root->name, NULL); #endif /* CONFIG_PROC_FS */ driver_unregister(&ipmidriver); @@ -4166,6 +4172,7 @@ EXPORT_SYMBOL(ipmi_destroy_user); EXPORT_SYMBOL(ipmi_get_version); EXPORT_SYMBOL(ipmi_request_settime); EXPORT_SYMBOL(ipmi_request_supply_msgs); +EXPORT_SYMBOL(ipmi_poll_interface); EXPORT_SYMBOL(ipmi_register_smi); EXPORT_SYMBOL(ipmi_unregister_smi); EXPORT_SYMBOL(ipmi_register_for_cmd); diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index dd441ff4af5..4f560d0bb80 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -675,7 +675,8 @@ static void handle_transaction_done(struct smi_info *smi_info) } /* Called on timeouts and events. Timeouts should pass the elapsed - time, interrupts should pass in zero. */ + time, interrupts should pass in zero. Must be called with + si_lock held and interrupts disabled. */ static enum si_sm_result smi_event_handler(struct smi_info *smi_info, int time) { @@ -892,13 +893,16 @@ static int ipmi_thread(void *data) static void poll(void *send_info) { struct smi_info *smi_info = send_info; + unsigned long flags; /* * Make sure there is some delay in the poll loop so we can * drive time forward and timeout things. */ udelay(10); + spin_lock_irqsave(&smi_info->si_lock, flags); smi_event_handler(smi_info, 10); + spin_unlock_irqrestore(&smi_info->si_lock, flags); } static void request_events(void *send_info) @@ -1006,6 +1010,10 @@ static int smi_start_processing(void *send_info, new_smi->intf = intf; + /* Try to claim any interrupts. */ + if (new_smi->irq_setup) + new_smi->irq_setup(new_smi); + /* Set up the timer that drives the interface. */ setup_timer(&new_smi->si_timer, smi_timeout, (long)new_smi); new_smi->last_timeout_jiffies = jiffies; @@ -1072,19 +1080,19 @@ static char *si_type[SI_MAX_PARMS]; #define MAX_SI_TYPE_STR 30 static char si_type_str[MAX_SI_TYPE_STR]; static unsigned long addrs[SI_MAX_PARMS]; -static int num_addrs; +static unsigned int num_addrs; static unsigned int ports[SI_MAX_PARMS]; -static int num_ports; +static unsigned int num_ports; static int irqs[SI_MAX_PARMS]; -static int num_irqs; +static unsigned int num_irqs; static int regspacings[SI_MAX_PARMS]; -static int num_regspacings; +static unsigned int num_regspacings; static int regsizes[SI_MAX_PARMS]; -static int num_regsizes; +static unsigned int num_regsizes; static int regshifts[SI_MAX_PARMS]; -static int num_regshifts; +static unsigned int num_regshifts; static int slave_addrs[SI_MAX_PARMS]; -static int num_slave_addrs; +static unsigned int num_slave_addrs; #define IPMI_IO_ADDR_SPACE 0 #define IPMI_MEM_ADDR_SPACE 1 @@ -1106,12 +1114,12 @@ MODULE_PARM_DESC(type, "Defines the type of each interface, each" " interface separated by commas. The types are 'kcs'," " 'smic', and 'bt'. For example si_type=kcs,bt will set" " the first interface to kcs and the second to bt"); -module_param_array(addrs, long, &num_addrs, 0); +module_param_array(addrs, ulong, &num_addrs, 0); MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the" " addresses separated by commas. Only use if an interface" " is in memory. Otherwise, set it to zero or leave" " it blank."); -module_param_array(ports, int, &num_ports, 0); +module_param_array(ports, uint, &num_ports, 0); MODULE_PARM_DESC(ports, "Sets the port address of each interface, the" " addresses separated by commas. Only use if an interface" " is a port. Otherwise, set it to zero or leave" @@ -1965,10 +1973,10 @@ struct dmi_ipmi_data u8 slave_addr; }; -static int __devinit decode_dmi(struct dmi_header *dm, +static int __devinit decode_dmi(const struct dmi_header *dm, struct dmi_ipmi_data *dmi) { - u8 *data = (u8 *)dm; + const u8 *data = (const u8 *)dm; unsigned long base_addr; u8 reg_spacing; u8 len = dm->length; @@ -2091,13 +2099,14 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data) static void __devinit dmi_find_bmc(void) { - struct dmi_device *dev = NULL; + const struct dmi_device *dev = NULL; struct dmi_ipmi_data data; int rv; while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) { memset(&data, 0, sizeof(data)); - rv = decode_dmi((struct dmi_header *) dev->device_data, &data); + rv = decode_dmi((const struct dmi_header *) dev->device_data, + &data); if (!rv) try_init_dmi(&data); } @@ -2252,19 +2261,19 @@ static int __devinit ipmi_of_probe(struct of_device *dev, return ret; } - regsize = get_property(np, "reg-size", &proplen); + regsize = of_get_property(np, "reg-size", &proplen); if (regsize && proplen != 4) { dev_warn(&dev->dev, PFX "invalid regsize from OF\n"); return -EINVAL; } - regspacing = get_property(np, "reg-spacing", &proplen); + regspacing = of_get_property(np, "reg-spacing", &proplen); if (regspacing && proplen != 4) { dev_warn(&dev->dev, PFX "invalid regspacing from OF\n"); return -EINVAL; } - regshift = get_property(np, "reg-shift", &proplen); + regshift = of_get_property(np, "reg-shift", &proplen); if (regshift && proplen != 4) { dev_warn(&dev->dev, PFX "invalid regshift from OF\n"); return -EINVAL; @@ -2371,20 +2380,9 @@ static int try_get_dev_id(struct smi_info *smi_info) /* Otherwise, we got some data. */ resp_len = smi_info->handlers->get_result(smi_info->si_sm, resp, IPMI_MAX_MSG_LENGTH); - if (resp_len < 14) { - /* That's odd, it should be longer. */ - rv = -EINVAL; - goto out; - } - if ((resp[1] != IPMI_GET_DEVICE_ID_CMD) || (resp[2] != 0)) { - /* That's odd, it shouldn't be able to fail. */ - rv = -EINVAL; - goto out; - } - - /* Record info from the get device id, in case we need it. */ - ipmi_demangle_device_id(resp+3, resp_len-3, &smi_info->device_id); + /* Check and record info from the get device id, in case we need it. */ + rv = ipmi_demangle_device_id(resp, resp_len, &smi_info->device_id); out: kfree(resp); @@ -2764,10 +2762,6 @@ static int try_smi_init(struct smi_info *new_smi) setup_oem_data_handler(new_smi); setup_xaction_handlers(new_smi); - /* Try to claim any interrupts. */ - if (new_smi->irq_setup) - new_smi->irq_setup(new_smi); - INIT_LIST_HEAD(&(new_smi->xmit_msgs)); INIT_LIST_HEAD(&(new_smi->hp_xmit_msgs)); new_smi->curr_msg = NULL; diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 41f78e2c158..e686fc92516 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -50,10 +50,19 @@ #include <linux/poll.h> #include <linux/string.h> #include <linux/ctype.h> +#include <linux/delay.h> #include <asm/atomic.h> -#ifdef CONFIG_X86_LOCAL_APIC -#include <asm/apic.h> +#ifdef CONFIG_X86 +/* This is ugly, but I've determined that x86 is the only architecture + that can reasonably support the IPMI NMI watchdog timeout at this + time. If another architecture adds this capability somehow, it + will have to be a somewhat different mechanism and I have no idea + how it will work. So in the unlikely event that another + architecture supports this, we can figure out a good generic + mechanism for it at that time. */ +#include <asm/kdebug.h> +#define HAVE_DIE_NMI #endif #define PFX "IPMI Watchdog: " @@ -166,8 +175,6 @@ static char expect_close; static int ifnum_to_use = -1; -static DECLARE_RWSEM(register_sem); - /* Parameters to ipmi_set_timeout */ #define IPMI_SET_TIMEOUT_NO_HB 0 #define IPMI_SET_TIMEOUT_HB_IF_NECESSARY 1 @@ -193,11 +200,9 @@ static int set_param_int(const char *val, struct kernel_param *kp) if (endp == val) return -EINVAL; - down_read(®ister_sem); *((int *)kp->arg) = l; if (watchdog_user) rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); - up_read(®ister_sem); return rv; } @@ -226,17 +231,15 @@ static int set_param_str(const char *val, struct kernel_param *kp) s = strstrip(valcp); - down_read(®ister_sem); rv = fn(s, NULL); if (rv) - goto out_unlock; + goto out; check_parms(); if (watchdog_user) rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); - out_unlock: - up_read(®ister_sem); + out: return rv; } @@ -319,9 +322,12 @@ static unsigned char ipmi_version_minor; /* If a pretimeout occurs, this is used to allow only one panic to happen. */ static atomic_t preop_panic_excl = ATOMIC_INIT(-1); -static int ipmi_heartbeat(void); -static void panic_halt_ipmi_heartbeat(void); +#ifdef HAVE_DIE_NMI +static int testing_nmi; +static int nmi_handler_registered; +#endif +static int ipmi_heartbeat(void); /* We use a mutex to make sure that only one thing can send a set timeout at one time, because we only have one copy of the data. @@ -360,6 +366,9 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, int hbnow = 0; + /* These can be cleared as we are setting the timeout. */ + pretimeout_since_last_heartbeat = 0; + data[0] = 0; WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); @@ -434,31 +443,75 @@ static int ipmi_set_timeout(int do_heartbeat) wait_for_completion(&set_timeout_wait); + mutex_unlock(&set_timeout_lock); + if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) || ((send_heartbeat_now) && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) - { rv = ipmi_heartbeat(); - } - mutex_unlock(&set_timeout_lock); out: return rv; } -static void dummy_smi_free(struct ipmi_smi_msg *msg) +static atomic_t panic_done_count = ATOMIC_INIT(0); + +static void panic_smi_free(struct ipmi_smi_msg *msg) { + atomic_dec(&panic_done_count); } -static void dummy_recv_free(struct ipmi_recv_msg *msg) +static void panic_recv_free(struct ipmi_recv_msg *msg) { + atomic_dec(&panic_done_count); +} + +static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = +{ + .done = panic_smi_free +}; +static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = +{ + .done = panic_recv_free +}; + +static void panic_halt_ipmi_heartbeat(void) +{ + struct kernel_ipmi_msg msg; + struct ipmi_system_interface_addr addr; + int rv; + + /* Don't reset the timer if we have the timer turned off, that + re-enables the watchdog. */ + if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) + return; + + addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + addr.channel = IPMI_BMC_CHANNEL; + addr.lun = 0; + + msg.netfn = 0x06; + msg.cmd = IPMI_WDOG_RESET_TIMER; + msg.data = NULL; + msg.data_len = 0; + rv = ipmi_request_supply_msgs(watchdog_user, + (struct ipmi_addr *) &addr, + 0, + &msg, + NULL, + &panic_halt_heartbeat_smi_msg, + &panic_halt_heartbeat_recv_msg, + 1); + if (!rv) + atomic_add(2, &panic_done_count); } + static struct ipmi_smi_msg panic_halt_smi_msg = { - .done = dummy_smi_free + .done = panic_smi_free }; static struct ipmi_recv_msg panic_halt_recv_msg = { - .done = dummy_recv_free + .done = panic_recv_free }; /* Special call, doesn't claim any locks. This is only to be called @@ -470,13 +523,21 @@ static void panic_halt_ipmi_set_timeout(void) int send_heartbeat_now; int rv; + /* Wait for the messages to be free. */ + while (atomic_read(&panic_done_count) != 0) + ipmi_poll_interface(watchdog_user); rv = i_ipmi_set_timeout(&panic_halt_smi_msg, &panic_halt_recv_msg, &send_heartbeat_now); if (!rv) { + atomic_add(2, &panic_done_count); if (send_heartbeat_now) panic_halt_ipmi_heartbeat(); - } + } else + printk(KERN_WARNING PFX + "Unable to extend the watchdog timeout."); + while (atomic_read(&panic_done_count) != 0) + ipmi_poll_interface(watchdog_user); } /* We use a semaphore to make sure that only one thing can send a @@ -505,24 +566,14 @@ static struct ipmi_recv_msg heartbeat_recv_msg = .done = heartbeat_free_recv }; -static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = -{ - .done = dummy_smi_free -}; -static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = -{ - .done = dummy_recv_free -}; - static int ipmi_heartbeat(void) { struct kernel_ipmi_msg msg; int rv; struct ipmi_system_interface_addr addr; - if (ipmi_ignore_heartbeat) { + if (ipmi_ignore_heartbeat) return 0; - } if (ipmi_start_timer_on_heartbeat) { ipmi_start_timer_on_heartbeat = 0; @@ -533,7 +584,6 @@ static int ipmi_heartbeat(void) We don't want to set the action, though, we want to leave that alone (thus it can't be combined with the above operation. */ - pretimeout_since_last_heartbeat = 0; return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); } @@ -586,35 +636,6 @@ static int ipmi_heartbeat(void) return rv; } -static void panic_halt_ipmi_heartbeat(void) -{ - struct kernel_ipmi_msg msg; - struct ipmi_system_interface_addr addr; - - - /* Don't reset the timer if we have the timer turned off, that - re-enables the watchdog. */ - if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) - return; - - addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - addr.channel = IPMI_BMC_CHANNEL; - addr.lun = 0; - - msg.netfn = 0x06; - msg.cmd = IPMI_WDOG_RESET_TIMER; - msg.data = NULL; - msg.data_len = 0; - ipmi_request_supply_msgs(watchdog_user, - (struct ipmi_addr *) &addr, - 0, - &msg, - NULL, - &panic_halt_heartbeat_smi_msg, - &panic_halt_heartbeat_recv_msg, - 1); -} - static struct watchdog_info ident = { .options = 0, /* WDIOF_SETTIMEOUT, */ @@ -895,7 +916,6 @@ static void ipmi_register_watchdog(int ipmi_intf) { int rv = -EBUSY; - down_write(®ister_sem); if (watchdog_user) goto out; @@ -921,15 +941,56 @@ static void ipmi_register_watchdog(int ipmi_intf) printk(KERN_CRIT PFX "Unable to register misc device\n"); } - out: - up_write(®ister_sem); +#ifdef HAVE_DIE_NMI + if (nmi_handler_registered) { + int old_pretimeout = pretimeout; + int old_timeout = timeout; + int old_preop_val = preop_val; + + /* Set the pretimeout to go off in a second and give + ourselves plenty of time to stop the timer. */ + ipmi_watchdog_state = WDOG_TIMEOUT_RESET; + preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ + pretimeout = 99; + timeout = 100; + + testing_nmi = 1; + + rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); + if (rv) { + printk(KERN_WARNING PFX "Error starting timer to" + " test NMI: 0x%x. The NMI pretimeout will" + " likely not work\n", rv); + rv = 0; + goto out_restore; + } + + msleep(1500); + if (testing_nmi != 2) { + printk(KERN_WARNING PFX "IPMI NMI didn't seem to" + " occur. The NMI pretimeout will" + " likely not work\n"); + } + out_restore: + testing_nmi = 0; + preop_val = old_preop_val; + pretimeout = old_pretimeout; + timeout = old_timeout; + } +#endif + + out: if ((start_now) && (rv == 0)) { /* Run from startup, so start the timer now. */ start_now = 0; /* Disable this function after first startup. */ ipmi_watchdog_state = action_val; ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); printk(KERN_INFO PFX "Starting now!\n"); + } else { + /* Stop the timer now. */ + ipmi_watchdog_state = WDOG_TIMEOUT_NONE; + ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); } } @@ -937,8 +998,6 @@ static void ipmi_unregister_watchdog(int ipmi_intf) { int rv; - down_write(®ister_sem); - if (!watchdog_user) goto out; @@ -963,20 +1022,44 @@ static void ipmi_unregister_watchdog(int ipmi_intf) watchdog_user = NULL; out: - up_write(®ister_sem); + return; } -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI static int -ipmi_nmi(void *dev_id, int cpu, int handled) +ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) { + struct die_args *args = data; + + if (val != DIE_NMI) + return NOTIFY_OK; + + /* Hack, if it's a memory or I/O error, ignore it. */ + if (args->err & 0xc0) + return NOTIFY_OK; + + /* + * If we get here, it's an NMI that's not a memory or I/O + * error. We can't truly tell if it's from IPMI or not + * without sending a message, and sending a message is almost + * impossible because of locking. + */ + + if (testing_nmi) { + testing_nmi = 2; + return NOTIFY_STOP; + } + /* If we are not expecting a timeout, ignore it. */ if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) - return NOTIFY_DONE; + return NOTIFY_OK; + + if (preaction_val != WDOG_PRETIMEOUT_NMI) + return NOTIFY_OK; /* If no one else handled the NMI, we assume it was the IPMI watchdog. */ - if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) { + if (preop_val == WDOG_PREOP_PANIC) { /* On some machines, the heartbeat will give an error and not work unless we re-enable the timer. So do so. */ @@ -985,18 +1068,12 @@ ipmi_nmi(void *dev_id, int cpu, int handled) panic(PFX "pre-timeout"); } - return NOTIFY_DONE; + return NOTIFY_STOP; } -static struct nmi_handler ipmi_nmi_handler = -{ - .link = LIST_HEAD_INIT(ipmi_nmi_handler.link), - .dev_name = "ipmi_watchdog", - .dev_id = NULL, - .handler = ipmi_nmi, - .priority = 0, /* Call us last. */ +static struct notifier_block ipmi_nmi_handler = { + .notifier_call = ipmi_nmi }; -int nmi_handler_registered; #endif static int wdog_reboot_handler(struct notifier_block *this, @@ -1009,7 +1086,7 @@ static int wdog_reboot_handler(struct notifier_block *this, /* Make sure we only do this once. */ reboot_event_handled = 1; - if (code == SYS_DOWN || code == SYS_HALT) { + if (code == SYS_POWER_OFF || code == SYS_HALT) { /* Disable the WDT if we are shutting down. */ ipmi_watchdog_state = WDOG_TIMEOUT_NONE; panic_halt_ipmi_set_timeout(); @@ -1113,7 +1190,7 @@ static int preaction_op(const char *inval, char *outval) preaction_val = WDOG_PRETIMEOUT_NONE; else if (strcmp(inval, "pre_smi") == 0) preaction_val = WDOG_PRETIMEOUT_SMI; -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI else if (strcmp(inval, "pre_nmi") == 0) preaction_val = WDOG_PRETIMEOUT_NMI; #endif @@ -1147,7 +1224,7 @@ static int preop_op(const char *inval, char *outval) static void check_parms(void) { -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI int do_nmi = 0; int rv; @@ -1160,20 +1237,9 @@ static void check_parms(void) preop_op("preop_none", NULL); do_nmi = 0; } -#ifdef CONFIG_X86_LOCAL_APIC - if (nmi_watchdog == NMI_IO_APIC) { - printk(KERN_WARNING PFX "nmi_watchdog is set to IO APIC" - " mode (value is %d), that is incompatible" - " with using NMI in the IPMI watchdog." - " Disabling IPMI nmi pretimeout.\n", - nmi_watchdog); - preaction_val = WDOG_PRETIMEOUT_NONE; - do_nmi = 0; - } -#endif } if (do_nmi && !nmi_handler_registered) { - rv = request_nmi(&ipmi_nmi_handler); + rv = register_die_notifier(&ipmi_nmi_handler); if (rv) { printk(KERN_WARNING PFX "Can't register nmi handler\n"); @@ -1181,7 +1247,7 @@ static void check_parms(void) } else nmi_handler_registered = 1; } else if (!do_nmi && nmi_handler_registered) { - release_nmi(&ipmi_nmi_handler); + unregister_die_notifier(&ipmi_nmi_handler); nmi_handler_registered = 0; } #endif @@ -1217,9 +1283,9 @@ static int __init ipmi_wdog_init(void) rv = ipmi_smi_watcher_register(&smi_watcher); if (rv) { -#ifdef HAVE_NMI_HANDLER - if (preaction_val == WDOG_PRETIMEOUT_NMI) - release_nmi(&ipmi_nmi_handler); +#ifdef HAVE_DIE_NMI + if (nmi_handler_registered) + unregister_die_notifier(&ipmi_nmi_handler); #endif atomic_notifier_chain_unregister(&panic_notifier_list, &wdog_panic_notifier); @@ -1238,9 +1304,9 @@ static void __exit ipmi_wdog_exit(void) ipmi_smi_watcher_unregister(&smi_watcher); ipmi_unregister_watchdog(watchdog_ifnum); -#ifdef HAVE_NMI_HANDLER +#ifdef HAVE_DIE_NMI if (nmi_handler_registered) - release_nmi(&ipmi_nmi_handler); + unregister_die_notifier(&ipmi_nmi_handler); #endif atomic_notifier_chain_unregister(&panic_notifier_list, |