This source file includes following definitions.
- synchronise_count_master
- synchronise_count_slave
1
2
3
4
5
6
7
8
9
10
11
12 #include <linux/kernel.h>
13 #include <linux/irqflags.h>
14 #include <linux/cpumask.h>
15
16 #include <asm/r4k-timer.h>
17 #include <linux/atomic.h>
18 #include <asm/barrier.h>
19 #include <asm/mipsregs.h>
20
21 static unsigned int initcount = 0;
22 static atomic_t count_count_start = ATOMIC_INIT(0);
23 static atomic_t count_count_stop = ATOMIC_INIT(0);
24
25 #define COUNTON 100
26 #define NR_LOOPS 3
27
28 void synchronise_count_master(int cpu)
29 {
30 int i;
31 unsigned long flags;
32
33 pr_info("Synchronize counters for CPU %u: ", cpu);
34
35 local_irq_save(flags);
36
37
38
39
40
41
42
43
44
45
46
47
48 for (i = 0; i < NR_LOOPS; i++) {
49
50 while (atomic_read(&count_count_start) != 1)
51 mb();
52 atomic_set(&count_count_stop, 0);
53 smp_wmb();
54
55
56 atomic_inc(&count_count_start);
57
58
59 if (i == 1)
60 initcount = read_c0_count();
61
62
63
64
65 if (i == NR_LOOPS-1)
66 write_c0_count(initcount);
67
68
69
70
71 while (atomic_read(&count_count_stop) != 1)
72 mb();
73 atomic_set(&count_count_start, 0);
74 smp_wmb();
75 atomic_inc(&count_count_stop);
76 }
77
78 write_c0_compare(read_c0_count() + COUNTON);
79
80 local_irq_restore(flags);
81
82
83
84
85
86
87 pr_cont("done.\n");
88 }
89
90 void synchronise_count_slave(int cpu)
91 {
92 int i;
93
94
95
96
97
98
99 for (i = 0; i < NR_LOOPS; i++) {
100 atomic_inc(&count_count_start);
101 while (atomic_read(&count_count_start) != 2)
102 mb();
103
104
105
106
107 if (i == NR_LOOPS-1)
108 write_c0_count(initcount);
109
110 atomic_inc(&count_count_stop);
111 while (atomic_read(&count_count_stop) != 2)
112 mb();
113 }
114
115 write_c0_compare(read_c0_count() + COUNTON);
116 }
117 #undef NR_LOOPS