ia64/xen-unstable
changeset 4926:8e3f809f3616
bitkeeper revision 1.1413 (42886cbcgOQRttqbKGwhoGUdvq0jbg)
Fix the watchdog disable/enable interface. This cleans up common code
somewhat.
Signed-off-by: Keir Fraser <keir@xensource.com>
Fix the watchdog disable/enable interface. This cleans up common code
somewhat.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Mon May 16 09:49:48 2005 +0000 (2005-05-16) |
parents | a789d0f55020 |
children | 2c0bcfd2a1fc |
files | xen/arch/ia64/xenmisc.c xen/arch/x86/cdb.c xen/arch/x86/domain.c xen/arch/x86/nmi.c xen/arch/x86/setup.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/traps.c xen/common/page_alloc.c xen/drivers/char/console.c xen/include/asm-ia64/config.h xen/include/asm-x86/apic.h |
line diff
1.1 --- a/xen/arch/ia64/xenmisc.c Mon May 16 08:41:49 2005 +0000 1.2 +++ b/xen/arch/ia64/xenmisc.c Mon May 16 09:49:48 2005 +0000 1.3 @@ -23,8 +23,6 @@ unsigned long wait_init_idle; 1.4 int phys_proc_id[NR_CPUS]; 1.5 unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c 1.6 1.7 -unsigned int watchdog_on = 0; // from arch/x86/nmi.c ?!? 1.8 - 1.9 void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n"); } 1.10 void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check abort handling)\n"); } 1.11 void ia64_mca_cpu_init(void *x) { }
2.1 --- a/xen/arch/x86/cdb.c Mon May 16 08:41:49 2005 +0000 2.2 +++ b/xen/arch/x86/cdb.c Mon May 16 09:49:48 2005 +0000 2.3 @@ -327,7 +327,6 @@ int 2.4 static atomic_t xendbg_running = ATOMIC_INIT(1); 2.5 static char recv_buf[4096]; 2.6 unsigned flags; 2.7 - unsigned old_watchdog; 2.8 2.9 if (xdb_ctx.serhnd < 0) { 2.10 dbg_printk("Debugger not ready yet.\n"); 2.11 @@ -358,8 +357,7 @@ int 2.12 interrupts while we're here. */ 2.13 local_irq_save(flags); 2.14 2.15 - old_watchdog = watchdog_on; 2.16 - watchdog_on = 0; 2.17 + watchdog_disable(); 2.18 2.19 /* Shouldn't really do this, but otherwise we stop for no 2.20 obvious reason, which is Bad */ 2.21 @@ -385,7 +383,7 @@ int 2.22 ASSERT(!local_irq_is_enabled()); 2.23 } 2.24 } 2.25 - watchdog_on = old_watchdog; 2.26 + watchdog_enable(); 2.27 atomic_inc(&xendbg_running); 2.28 local_irq_restore(flags); 2.29 return 0;
3.1 --- a/xen/arch/x86/domain.c Mon May 16 08:41:49 2005 +0000 3.2 +++ b/xen/arch/x86/domain.c Mon May 16 09:49:48 2005 +0000 3.3 @@ -186,7 +186,7 @@ void __attribute__((noreturn)) __machine 3.4 3.5 void machine_halt(void) 3.6 { 3.7 - watchdog_on = 0; 3.8 + watchdog_disable(); 3.9 smp_call_function(__machine_halt, NULL, 1, 0); 3.10 __machine_halt(NULL); 3.11 }
4.1 --- a/xen/arch/x86/nmi.c Mon May 16 08:41:49 2005 +0000 4.2 +++ b/xen/arch/x86/nmi.c Mon May 16 09:49:48 2005 +0000 4.3 @@ -28,7 +28,6 @@ 4.4 #include <asm/debugger.h> 4.5 4.6 unsigned int nmi_watchdog = NMI_NONE; 4.7 -unsigned int watchdog_on = 0; 4.8 static unsigned int nmi_hz = HZ; 4.9 unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */ 4.10 4.11 @@ -256,6 +255,28 @@ static unsigned int 4.12 last_irq_sums [NR_CPUS], 4.13 alert_counter [NR_CPUS]; 4.14 4.15 +static spinlock_t watchdog_lock = SPIN_LOCK_UNLOCKED; 4.16 +static unsigned int watchdog_disable_count = 1; 4.17 +static unsigned int watchdog_on; 4.18 + 4.19 +void watchdog_disable(void) 4.20 +{ 4.21 + unsigned long flags; 4.22 + spin_lock_irqsave(&watchdog_lock, flags); 4.23 + if ( watchdog_disable_count++ == 0 ) 4.24 + watchdog_on = 0; 4.25 + spin_unlock_irqrestore(&watchdog_lock, flags); 4.26 +} 4.27 + 4.28 +void watchdog_enable(void) 4.29 +{ 4.30 + unsigned long flags; 4.31 + spin_lock_irqsave(&watchdog_lock, flags); 4.32 + if ( --watchdog_disable_count == 0 ) 4.33 + watchdog_on = 1; 4.34 + spin_unlock_irqrestore(&watchdog_lock, flags); 4.35 +} 4.36 + 4.37 void touch_nmi_watchdog (void) 4.38 { 4.39 int i;
5.1 --- a/xen/arch/x86/setup.c Mon May 16 08:41:49 2005 +0000 5.2 +++ b/xen/arch/x86/setup.c Mon May 16 09:49:48 2005 +0000 5.3 @@ -450,7 +450,8 @@ static void __init start_of_day(void) 5.4 while ( wait_init_idle != 0 ) 5.5 cpu_relax(); 5.6 5.7 - watchdog_on = 1; 5.8 + watchdog_enable(); 5.9 + 5.10 #ifdef __x86_64__ /* x86_32 uses low mappings when building DOM0. */ 5.11 zap_low_mappings(); 5.12 #endif
6.1 --- a/xen/arch/x86/traps.c Mon May 16 08:41:49 2005 +0000 6.2 +++ b/xen/arch/x86/traps.c Mon May 16 09:49:48 2005 +0000 6.3 @@ -199,7 +199,7 @@ asmlinkage void fatal_trap(int trapnr, s 6.4 "machine check", "simd error" 6.5 }; 6.6 6.7 - watchdog_on = 0; 6.8 + watchdog_disable(); 6.9 6.10 show_registers(regs); 6.11
7.1 --- a/xen/arch/x86/x86_32/traps.c Mon May 16 08:41:49 2005 +0000 7.2 +++ b/xen/arch/x86/x86_32/traps.c Mon May 16 09:49:48 2005 +0000 7.3 @@ -111,8 +111,7 @@ asmlinkage void do_double_fault(void) 7.4 struct tss_struct *tss = &doublefault_tss; 7.5 unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1; 7.6 7.7 - /* Disable the NMI watchdog. It's useless now. */ 7.8 - watchdog_on = 0; 7.9 + watchdog_disable(); 7.10 7.11 console_force_unlock(); 7.12
8.1 --- a/xen/arch/x86/x86_64/traps.c Mon May 16 08:41:49 2005 +0000 8.2 +++ b/xen/arch/x86/x86_64/traps.c Mon May 16 09:49:48 2005 +0000 8.3 @@ -60,8 +60,7 @@ void show_page_walk(unsigned long addr) 8.4 asmlinkage void double_fault(void); 8.5 asmlinkage void do_double_fault(struct cpu_user_regs *regs) 8.6 { 8.7 - /* Disable the NMI watchdog. It's useless now. */ 8.8 - watchdog_on = 0; 8.9 + watchdog_disable(); 8.10 8.11 console_force_unlock(); 8.12
9.1 --- a/xen/common/page_alloc.c Mon May 16 08:41:49 2005 +0000 9.2 +++ b/xen/common/page_alloc.c Mon May 16 09:49:48 2005 +0000 9.3 @@ -356,15 +356,13 @@ void scrub_heap_pages(void) 9.4 unsigned long pfn, flags; 9.5 9.6 printk("Scrubbing Free RAM: "); 9.7 + watchdog_disable(); 9.8 9.9 for ( pfn = 0; pfn < (bitmap_size * 8); pfn++ ) 9.10 { 9.11 - /* Every 100MB, print a progress dot and appease the watchdog. */ 9.12 + /* Every 100MB, print a progress dot. */ 9.13 if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 ) 9.14 - { 9.15 printk("."); 9.16 - touch_nmi_watchdog(); 9.17 - } 9.18 9.19 /* Quick lock-free check. */ 9.20 if ( allocated_in_map(pfn) ) 9.21 @@ -383,6 +381,7 @@ void scrub_heap_pages(void) 9.22 spin_unlock_irqrestore(&heap_lock, flags); 9.23 } 9.24 9.25 + watchdog_enable(); 9.26 printk("done.\n"); 9.27 } 9.28
10.1 --- a/xen/drivers/char/console.c Mon May 16 08:41:49 2005 +0000 10.2 +++ b/xen/drivers/char/console.c Mon May 16 09:49:48 2005 +0000 10.3 @@ -502,14 +502,12 @@ integer_param("debugtrace", debugtrace_k 10.4 10.5 void debugtrace_dump(void) 10.6 { 10.7 - int _watchdog_on = watchdog_on; 10.8 unsigned long flags; 10.9 10.10 if ( (debugtrace_bytes == 0) || !debugtrace_used ) 10.11 return; 10.12 10.13 - /* Watchdog can trigger if we print a really large buffer. */ 10.14 - watchdog_on = 0; 10.15 + watchdog_disable(); 10.16 10.17 spin_lock_irqsave(&debugtrace_lock, flags); 10.18 10.19 @@ -529,7 +527,7 @@ void debugtrace_dump(void) 10.20 10.21 spin_unlock_irqrestore(&debugtrace_lock, flags); 10.22 10.23 - watchdog_on = _watchdog_on; 10.24 + watchdog_enable(); 10.25 } 10.26 10.27 void debugtrace_printk(const char *fmt, ...) 10.28 @@ -635,7 +633,7 @@ void panic(const char *fmt, ...) 10.29 __putstr("Reboot in five seconds...\n"); 10.30 spin_unlock_irqrestore(&console_lock, flags); 10.31 10.32 - watchdog_on = 0; 10.33 + watchdog_disable(); 10.34 mdelay(5000); 10.35 machine_restart(0); 10.36 }
11.1 --- a/xen/include/asm-ia64/config.h Mon May 16 08:41:49 2005 +0000 11.2 +++ b/xen/include/asm-ia64/config.h Mon May 16 09:49:48 2005 +0000 11.3 @@ -29,7 +29,8 @@ typedef int pid_t; 11.4 #define FASTCALL(x) x // see linux/include/linux/linkage.h 11.5 #define fastcall // " " 11.6 11.7 -#define touch_nmi_watchdog() 11.8 +#define watchdog_disable() ((void)0) 11.9 +#define watchdog_enable() ((void)0) 11.10 // from linux/include/linux/types.h 11.11 #define CLEAR_BITMAP(name,bits) \ 11.12 memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long)) 11.13 @@ -261,7 +262,6 @@ struct screen_info { }; 11.14 // these declarations got moved at some point, find a better place for them 11.15 extern int opt_noht; 11.16 extern int ht_per_core; 11.17 -extern unsigned int watchdog_on; 11.18 11.19 // xen/include/asm/config.h 11.20 /******************************************************************************
12.1 --- a/xen/include/asm-x86/apic.h Mon May 16 08:41:49 2005 +0000 12.2 +++ b/xen/include/asm-x86/apic.h Mon May 16 09:49:48 2005 +0000 12.3 @@ -104,15 +104,16 @@ extern void release_lapic_nmi(void); 12.4 extern void disable_timer_nmi_watchdog(void); 12.5 extern void enable_timer_nmi_watchdog(void); 12.6 extern void nmi_watchdog_tick (struct cpu_user_regs *regs); 12.7 -extern void touch_nmi_watchdog(void); 12.8 extern int APIC_init_uniprocessor (void); 12.9 extern void disable_APIC_timer(void); 12.10 extern void enable_APIC_timer(void); 12.11 12.12 -extern unsigned int watchdog_on; 12.13 extern int check_nmi_watchdog (void); 12.14 extern void enable_NMI_through_LVT0 (void * dummy); 12.15 12.16 +extern void watchdog_disable(void); 12.17 +extern void watchdog_enable(void); 12.18 + 12.19 extern unsigned int nmi_watchdog; 12.20 #define NMI_NONE 0 12.21 #define NMI_IO_APIC 1