diff options
author | Will Deacon <will.deacon@arm.com> | 2012-11-29 17:19:01 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2012-12-05 06:20:03 -0500 |
commit | d91fb5c2677db90460611fce72e6a0af8f6c2a73 (patch) | |
tree | 408562a6274dacea273c2df11f5513d2ad6b8938 | |
parent | f84a935db47d7f261c025ba9eaa7700261257469 (diff) |
arm64: vdso: rework __do_get_tspec register allocation and return shift
In preparation for sub-ns precision in the vdso timespec maths, change
the __do_get_tspec register allocation so that we return the clocksource
shift value instead of the unused xtime tspec.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/kernel/vdso/gettimeofday.S | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index 3a7bdcd55ab6..99b7d405767c 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S | |||
@@ -62,18 +62,18 @@ ENTRY(__kernel_gettimeofday) | |||
62 | /* If tv is NULL, skip to the timezone code. */ | 62 | /* If tv is NULL, skip to the timezone code. */ |
63 | cbz x0, 2f | 63 | cbz x0, 2f |
64 | bl __do_get_tspec | 64 | bl __do_get_tspec |
65 | seqcnt_check w13, 1b | 65 | seqcnt_check w9, 1b |
66 | 66 | ||
67 | /* Convert ns to us. */ | 67 | /* Convert ns to us. */ |
68 | mov x11, #1000 | 68 | mov x13, #1000 |
69 | udiv x10, x10, x11 | 69 | udiv x11, x11, x13 |
70 | stp x9, x10, [x0, #TVAL_TV_SEC] | 70 | stp x10, x11, [x0, #TVAL_TV_SEC] |
71 | 2: | 71 | 2: |
72 | /* If tz is NULL, return 0. */ | 72 | /* If tz is NULL, return 0. */ |
73 | cbz x1, 3f | 73 | cbz x1, 3f |
74 | ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST] | 74 | ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST] |
75 | seqcnt_read w13 | 75 | seqcnt_read w9 |
76 | seqcnt_check w13, 1b | 76 | seqcnt_check w9, 1b |
77 | stp w4, w5, [x1, #TZ_MINWEST] | 77 | stp w4, w5, [x1, #TZ_MINWEST] |
78 | 3: | 78 | 3: |
79 | mov x0, xzr | 79 | mov x0, xzr |
@@ -102,17 +102,17 @@ ENTRY(__kernel_clock_gettime) | |||
102 | cbnz use_syscall, 7f | 102 | cbnz use_syscall, 7f |
103 | 103 | ||
104 | bl __do_get_tspec | 104 | bl __do_get_tspec |
105 | seqcnt_check w13, 1b | 105 | seqcnt_check w9, 1b |
106 | 106 | ||
107 | cmp w0, #CLOCK_MONOTONIC | 107 | cmp w0, #CLOCK_MONOTONIC |
108 | b.ne 6f | 108 | b.ne 6f |
109 | 109 | ||
110 | /* Get wtm timespec. */ | 110 | /* Get wtm timespec. */ |
111 | ldp x14, x15, [vdso_data, #VDSO_WTM_CLK_SEC] | 111 | ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC] |
112 | 112 | ||
113 | /* Check the sequence counter. */ | 113 | /* Check the sequence counter. */ |
114 | seqcnt_read w13 | 114 | seqcnt_read w9 |
115 | seqcnt_check w13, 1b | 115 | seqcnt_check w9, 1b |
116 | b 4f | 116 | b 4f |
117 | 2: | 117 | 2: |
118 | cmp w0, #CLOCK_REALTIME_COARSE | 118 | cmp w0, #CLOCK_REALTIME_COARSE |
@@ -122,37 +122,37 @@ ENTRY(__kernel_clock_gettime) | |||
122 | /* Get coarse timespec. */ | 122 | /* Get coarse timespec. */ |
123 | adr vdso_data, _vdso_data | 123 | adr vdso_data, _vdso_data |
124 | 3: seqcnt_acquire | 124 | 3: seqcnt_acquire |
125 | ldp x9, x10, [vdso_data, #VDSO_XTIME_CRS_SEC] | 125 | ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC] |
126 | 126 | ||
127 | /* Get wtm timespec. */ | 127 | /* Get wtm timespec. */ |
128 | ldp x14, x15, [vdso_data, #VDSO_WTM_CLK_SEC] | 128 | ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC] |
129 | 129 | ||
130 | /* Check the sequence counter. */ | 130 | /* Check the sequence counter. */ |
131 | seqcnt_read w13 | 131 | seqcnt_read w9 |
132 | seqcnt_check w13, 3b | 132 | seqcnt_check w9, 3b |
133 | 133 | ||
134 | cmp w0, #CLOCK_MONOTONIC_COARSE | 134 | cmp w0, #CLOCK_MONOTONIC_COARSE |
135 | b.ne 6f | 135 | b.ne 6f |
136 | 4: | 136 | 4: |
137 | /* Add on wtm timespec. */ | 137 | /* Add on wtm timespec. */ |
138 | add x9, x9, x14 | 138 | add x10, x10, x13 |
139 | add x10, x10, x15 | 139 | add x11, x11, x14 |
140 | 140 | ||
141 | /* Normalise the new timespec. */ | 141 | /* Normalise the new timespec. */ |
142 | mov x14, #NSEC_PER_SEC_LO16 | 142 | mov x15, #NSEC_PER_SEC_LO16 |
143 | movk x14, #NSEC_PER_SEC_HI16, lsl #16 | 143 | movk x15, #NSEC_PER_SEC_HI16, lsl #16 |
144 | cmp x10, x14 | 144 | cmp x11, x15 |
145 | b.lt 5f | 145 | b.lt 5f |
146 | sub x10, x10, x14 | 146 | sub x11, x11, x15 |
147 | add x9, x9, #1 | 147 | add x10, x10, #1 |
148 | 5: | 148 | 5: |
149 | cmp x10, #0 | 149 | cmp x11, #0 |
150 | b.ge 6f | 150 | b.ge 6f |
151 | add x10, x10, x14 | 151 | add x11, x11, x15 |
152 | sub x9, x9, #1 | 152 | sub x10, x10, #1 |
153 | 153 | ||
154 | 6: /* Store to the user timespec. */ | 154 | 6: /* Store to the user timespec. */ |
155 | stp x9, x10, [x1, #TSPEC_TV_SEC] | 155 | stp x10, x11, [x1, #TSPEC_TV_SEC] |
156 | mov x0, xzr | 156 | mov x0, xzr |
157 | ret x2 | 157 | ret x2 |
158 | 7: | 158 | 7: |
@@ -203,39 +203,39 @@ ENDPROC(__kernel_clock_getres) | |||
203 | * Expects vdso_data to be initialised. | 203 | * Expects vdso_data to be initialised. |
204 | * Clobbers the temporary registers (x9 - x15). | 204 | * Clobbers the temporary registers (x9 - x15). |
205 | * Returns: | 205 | * Returns: |
206 | * - (x9, x10) = (ts->tv_sec, ts->tv_nsec) | 206 | * - w9 = vDSO sequence counter |
207 | * - (x11, x12) = (xtime->tv_sec, xtime->tv_nsec) | 207 | * - (x10, x11) = (ts->tv_sec, ts->tv_nsec) |
208 | * - w13 = vDSO sequence counter | 208 | * - w12 = cs_shift |
209 | */ | 209 | */ |
210 | ENTRY(__do_get_tspec) | 210 | ENTRY(__do_get_tspec) |
211 | .cfi_startproc | 211 | .cfi_startproc |
212 | 212 | ||
213 | /* Read from the vDSO data page. */ | 213 | /* Read from the vDSO data page. */ |
214 | ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] | 214 | ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST] |
215 | ldp x11, x12, [vdso_data, #VDSO_XTIME_CLK_SEC] | 215 | ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC] |
216 | ldp w14, w15, [vdso_data, #VDSO_CS_MULT] | 216 | ldp w11, w12, [vdso_data, #VDSO_CS_MULT] |
217 | seqcnt_read w13 | 217 | seqcnt_read w9 |
218 | 218 | ||
219 | /* Read the physical counter. */ | 219 | /* Read the physical counter. */ |
220 | isb | 220 | isb |
221 | mrs x9, cntpct_el0 | 221 | mrs x15, cntpct_el0 |
222 | 222 | ||
223 | /* Calculate cycle delta and convert to ns. */ | 223 | /* Calculate cycle delta and convert to ns. */ |
224 | sub x10, x9, x10 | 224 | sub x10, x15, x10 |
225 | /* We can only guarantee 56 bits of precision. */ | 225 | /* We can only guarantee 56 bits of precision. */ |
226 | movn x9, #0xff00, lsl #48 | 226 | movn x15, #0xff00, lsl #48 |
227 | and x10, x9, x10 | 227 | and x10, x15, x10 |
228 | mul x10, x10, x14 | 228 | mul x10, x10, x11 |
229 | lsr x10, x10, x15 | 229 | lsr x10, x10, x12 |
230 | 230 | ||
231 | /* Use the kernel time to calculate the new timespec. */ | 231 | /* Use the kernel time to calculate the new timespec. */ |
232 | add x10, x12, x10 | 232 | mov x11, #NSEC_PER_SEC_LO16 |
233 | mov x14, #NSEC_PER_SEC_LO16 | 233 | movk x11, #NSEC_PER_SEC_HI16, lsl #16 |
234 | movk x14, #NSEC_PER_SEC_HI16, lsl #16 | 234 | add x15, x10, x14 |
235 | udiv x15, x10, x14 | 235 | udiv x14, x15, x11 |
236 | add x9, x15, x11 | 236 | add x10, x13, x14 |
237 | mul x14, x14, x15 | 237 | mul x13, x14, x11 |
238 | sub x10, x10, x14 | 238 | sub x11, x15, x13 |
239 | 239 | ||
240 | ret | 240 | ret |
241 | .cfi_endproc | 241 | .cfi_endproc |