]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/linux/processor.h
mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized
[karo-tx-linux.git] / include / linux / processor.h
1 /* Misc low level processor primitives */
2 #ifndef _LINUX_PROCESSOR_H
3 #define _LINUX_PROCESSOR_H
4
5 #include <asm/processor.h>
6
7 /*
8  * spin_begin is used before beginning a busy-wait loop, and must be paired
9  * with spin_end when the loop is exited. spin_cpu_relax must be called
10  * within the loop.
11  *
12  * The loop body should be as small and fast as possible, on the order of
13  * tens of instructions/cycles as a guide. It should and avoid calling
14  * cpu_relax, or any "spin" or sleep type of primitive including nested uses
15  * of these primitives. It should not lock or take any other resource.
16  * Violations of these guidelies will not cause a bug, but may cause sub
17  * optimal performance.
18  *
19  * These loops are optimized to be used where wait times are expected to be
20  * less than the cost of a context switch (and associated overhead).
21  *
22  * Detection of resource owner and decision to spin or sleep or guest-yield
23  * (e.g., spin lock holder vcpu preempted, or mutex owner not on CPU) can be
24  * tested within the loop body.
25  */
26 #ifndef spin_begin
27 #define spin_begin()
28 #endif
29
30 #ifndef spin_cpu_relax
31 #define spin_cpu_relax() cpu_relax()
32 #endif
33
34 /*
35  * spin_cpu_yield may be called to yield (undirected) to the hypervisor if
36  * necessary. This should be used if the wait is expected to take longer
37  * than context switch overhead, but we can't sleep or do a directed yield.
38  */
39 #ifndef spin_cpu_yield
40 #define spin_cpu_yield() cpu_relax_yield()
41 #endif
42
43 #ifndef spin_end
44 #define spin_end()
45 #endif
46
47 /*
48  * spin_until_cond can be used to wait for a condition to become true. It
49  * may be expected that the first iteration will true in the common case
50  * (no spinning), so that callers should not require a first "likely" test
51  * for the uncontended case before using this primitive.
52  *
53  * Usage and implementation guidelines are the same as for the spin_begin
54  * primitives, above.
55  */
56 #ifndef spin_until_cond
57 #define spin_until_cond(cond)                                   \
58 do {                                                            \
59         if (unlikely(!(cond))) {                                \
60                 spin_begin();                                   \
61                 do {                                            \
62                         spin_cpu_relax();                       \
63                 } while (!(cond));                              \
64                 spin_end();                                     \
65         }                                                       \
66 } while (0)
67
68 #endif
69
70 #endif /* _LINUX_PROCESSOR_H */