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