1 #ifndef __CRIS_SMPLOCK_H
2 #define __CRIS_SMPLOCK_H
4 #include <linux/config.h>
8 #error "SMP is not supported for CRIS"
14 extern __inline void lock_kernel(void)
17 int proc = smp_processor_id();
21 /* set_bit works atomic in SMP machines */
22 while(set_bit(0, (void *)&kernel_flag))
25 * We just start another level if we have the lock
27 if (proc == active_kernel_processor)
32 smp_spins[smp_processor_id()]++;
35 * Doing test_bit here doesn't lock the bus
37 if (test_bit(proc, (void *)&smp_invalidate_needed))
38 if (clear_bit(proc, (void *)&smp_invalidate_needed))
41 while(test_bit(0, (void *)&kernel_flag));
44 * We got the lock, so tell the world we are here and increment
47 active_kernel_processor = proc;
52 extern __inline void unlock_kernel(void)
58 * If it's the last level we have in the kernel, then
61 if (kernel_counter == 0)
62 panic("Kernel counter wrong.\n"); /* FIXME: Why is kernel_counter sometimes 0 here? */
64 if(! --kernel_counter)
66 active_kernel_processor = NO_PROC_ID;
67 clear_bit(0, (void *)&kernel_flag);