Index: linux-2.6.30/arch/x86/kernel/apic/nmi.c =================================================================== --- linux-2.6.30.orig/arch/x86/kernel/apic/nmi.c +++ linux-2.6.30/arch/x86/kernel/apic/nmi.c @@ -400,13 +400,21 @@ nmi_watchdog_tick(struct pt_regs *regs, int cpu = smp_processor_id(); int rc = 0; - /* check for other users first */ + /* see if the local APIC nmi watchdog went off. */ + if (__get_cpu_var(wd_enabled) && nmi_watchdog == NMI_LOCAL_APIC) { + rc = lapic_wd_event(nmi_hz); + if (rc) + goto skip_notify; + } + + /* check for other users after the local APIC */ if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP) { rc = 1; touched = 1; } + skip_notify: sum = get_timer_irqs(cpu); if (__get_cpu_var(nmi_touch)) { @@ -447,22 +455,15 @@ nmi_watchdog_tick(struct pt_regs *regs, local_set(&__get_cpu_var(alert_counter), 0); } - /* see if the nmi watchdog went off */ - if (!__get_cpu_var(wd_enabled)) - return rc; - switch (nmi_watchdog) { - case NMI_LOCAL_APIC: - rc |= lapic_wd_event(nmi_hz); - break; - case NMI_IO_APIC: + /* see if the IO APIC nmi watchdog went off */ + if (__get_cpu_var(wd_enabled) && (nmi_watchdog == NMI_IO_APIC)) /* * don't know how to accurately check for this. * just assume it was a watchdog timer interrupt * This matches the old behaviour. */ rc = 1; - break; - } + return rc; } Index: linux-2.6.30/drivers/char/ipmi/ipmi_si_intf.c =================================================================== --- linux-2.6.30.orig/drivers/char/ipmi/ipmi_si_intf.c +++ linux-2.6.30/drivers/char/ipmi/ipmi_si_intf.c @@ -294,6 +294,9 @@ struct smi_info { static int force_kipmid[SI_MAX_PARMS]; static int num_force_kipmid; +static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; +static int num_max_busy_us; + static int unload_when_empty = 1; static int try_smi_init(struct smi_info *smi); @@ -924,23 +927,56 @@ static void set_run_to_completion(void * } } +#define ipmi_si_set_not_busy(timespec) \ + do { (timespec)->tv_nsec = -1; } while (0) +#define ipmi_si_is_busy(timespec) ((timespec)->tv_nsec != -1) + +static int ipmi_thread_busy_wait(enum si_sm_result smi_result, + const struct smi_info *smi_info, + struct timespec *busy_until) +{ + unsigned int max_busy_us = 0; + + if (smi_info->intf_num < num_max_busy_us) + max_busy_us = kipmid_max_busy_us[smi_info->intf_num]; + if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) + ipmi_si_set_not_busy(busy_until); + else if (!ipmi_si_is_busy(busy_until)) { + getnstimeofday(busy_until); + timespec_add_ns(busy_until, max_busy_us*NSEC_PER_USEC); + } else { + struct timespec now; + getnstimeofday(&now); + if (unlikely(timespec_compare(&now, busy_until) > 0)) { + ipmi_si_set_not_busy(busy_until); + return 0; + } + } + return 1; +} + static int ipmi_thread(void *data) { struct smi_info *smi_info = data; unsigned long flags; enum si_sm_result smi_result; + struct timespec busy_until; + ipmi_si_set_not_busy(&busy_until); set_user_nice(current, 19); while (!kthread_should_stop()) { + int busy_wait; spin_lock_irqsave(&(smi_info->si_lock), flags); smi_result = smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags); + busy_wait = ipmi_thread_busy_wait(smi_result, smi_info, + &busy_until); if (smi_result == SI_SM_CALL_WITHOUT_DELAY) ; /* do nothing */ - else if (smi_result == SI_SM_CALL_WITH_DELAY) + else if (smi_result == SI_SM_CALL_WITH_DELAY && busy_wait) schedule(); else - schedule_timeout_interruptible(1); + schedule_timeout_interruptible(0); } return 0; } @@ -1143,7 +1179,7 @@ static int regsizes[SI_MAX_PAR static unsigned int num_regsizes; static int regshifts[SI_MAX_PARMS]; static unsigned int num_regshifts; -static int slave_addrs[SI_MAX_PARMS]; +static int slave_addrs[SI_MAX_PARMS]; /* Leaving 0 chooses the default value */ static unsigned int num_slave_addrs; #define IPMI_IO_ADDR_SPACE 0 @@ -1211,6 +1247,11 @@ module_param(unload_when_empty, int, 0); MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are" " specified or found, default is 1. Setting to 0" " is useful for hot add of devices using hotmod."); +module_param_array(kipmid_max_busy_us, uint, &num_max_busy_us, 0644); +MODULE_PARM_DESC(kipmid_max_busy_us, + "Max time (in microseconds) to busy-wait for IPMI data before" + " sleeping. 0 (default) means to wait forever. Set to 100-500" + " if kipmid is using up a lot of CPU time."); static void std_irq_cleanup(struct smi_info *info) @@ -1606,7 +1647,7 @@ static int hotmod_handler(const char *va regsize = 1; regshift = 0; irq = 0; - ipmb = 0x20; + ipmb = 0; /* Choose the default if not specified */ next = strchr(curr, ':'); if (next) { @@ -1798,6 +1839,7 @@ static __devinit void hardcode_find_bmc( info->irq = irqs[i]; if (info->irq) info->irq_setup = std_irq_setup; + info->slave_addr = slave_addrs[i]; try_smi_init(info); } Index: linux-2.6.30/include/linux/ipmi_smi.h =================================================================== --- linux-2.6.30.orig/include/linux/ipmi_smi.h +++ linux-2.6.30/include/linux/ipmi_smi.h @@ -39,7 +39,6 @@ #include #include #include -#include /* This files describes the interface for IPMI system management interface drivers to bind into the IPMI message handler. */