ALSA: usb-audio: add support for Akai MPD16
[safe/jmp/linux-2.6] / kernel / kgdb.c
index 6882c04..11f3515 100644 (file)
@@ -1365,6 +1365,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs)
        int sstep_tries = 100;
        int error = 0;
        int i, cpu;
+       int trace_on = 0;
 acquirelock:
        /*
         * Interrupts will be restored by the 'trap return' code, except when
@@ -1379,8 +1380,7 @@ acquirelock:
         * Make sure the above info reaches the primary CPU before
         * our cpu_in_kgdb[] flag setting does:
         */
-       smp_wmb();
-       atomic_set(&cpu_in_kgdb[cpu], 1);
+       atomic_inc(&cpu_in_kgdb[cpu]);
 
        /*
         * CPU will loop if it is a slave or request to become a kgdb
@@ -1400,7 +1400,9 @@ return_normal:
                         */
                        if (arch_kgdb_ops.correct_hw_break)
                                arch_kgdb_ops.correct_hw_break();
-                       atomic_set(&cpu_in_kgdb[cpu], 0);
+                       if (trace_on)
+                               tracing_on();
+                       atomic_dec(&cpu_in_kgdb[cpu]);
                        touch_softlockup_watchdog_sync();
                        clocksource_touch_watchdog();
                        local_irq_restore(flags);
@@ -1449,7 +1451,7 @@ return_normal:
         */
        if (!kgdb_single_step) {
                for (i = 0; i < NR_CPUS; i++)
-                       atomic_set(&passive_cpu_wait[i], 1);
+                       atomic_inc(&passive_cpu_wait[i]);
        }
 
 #ifdef CONFIG_SMP
@@ -1475,6 +1477,9 @@ return_normal:
        kgdb_single_step = 0;
        kgdb_contthread = current;
        exception_level = 0;
+       trace_on = tracing_is_on();
+       if (trace_on)
+               tracing_off();
 
        /* Talk to debugger with gdbserial protocol */
        error = gdb_serial_stub(ks);
@@ -1483,11 +1488,11 @@ return_normal:
        if (kgdb_io_ops->post_exception)
                kgdb_io_ops->post_exception();
 
-       atomic_set(&cpu_in_kgdb[ks->cpu], 0);
+       atomic_dec(&cpu_in_kgdb[ks->cpu]);
 
        if (!kgdb_single_step) {
                for (i = NR_CPUS-1; i >= 0; i--)
-                       atomic_set(&passive_cpu_wait[i], 0);
+                       atomic_dec(&passive_cpu_wait[i]);
                /*
                 * Wait till all the CPUs have quit
                 * from the debugger.
@@ -1506,6 +1511,8 @@ kgdb_restore:
                else
                        kgdb_sstep_pid = 0;
        }
+       if (trace_on)
+               tracing_on();
        /* Free kgdb_active */
        atomic_set(&kgdb_active, -1);
        touch_softlockup_watchdog_sync();
@@ -1736,11 +1743,11 @@ EXPORT_SYMBOL_GPL(kgdb_unregister_io_module);
  */
 void kgdb_breakpoint(void)
 {
-       atomic_set(&kgdb_setting_breakpoint, 1);
+       atomic_inc(&kgdb_setting_breakpoint);
        wmb(); /* Sync point before breakpoint */
        arch_kgdb_breakpoint();
        wmb(); /* Sync point after breakpoint */
-       atomic_set(&kgdb_setting_breakpoint, 0);
+       atomic_dec(&kgdb_setting_breakpoint);
 }
 EXPORT_SYMBOL_GPL(kgdb_breakpoint);