Merge tag 'fscache-fixes-20140917' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / arch / s390 / kernel / vdso32 / clock_gettime.S
CommitLineData
b020632e
MS
1/*
2 * Userland implementation of clock_gettime() for 32 bits processes in a
3 * s390 kernel for use in the vDSO
4 *
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#include <asm/vdso.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15
16 .text
17 .align 4
18 .globl __kernel_clock_gettime
19 .type __kernel_clock_gettime,@function
20__kernel_clock_gettime:
21 .cfi_startproc
22 basr %r5,0
230: al %r5,21f-0b(%r5) /* get &_vdso_data */
b3423982 24 chi %r2,__CLOCK_REALTIME
5da76157 25 je 11f
b3423982 26 chi %r2,__CLOCK_MONOTONIC
b020632e
MS
27 jne 19f
28
29 /* CLOCK_MONOTONIC */
b020632e
MS
301: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
31 tml %r4,0x0001 /* pending update ? loop */
32 jnz 1b
33 stck 24(%r15) /* Store TOD clock */
34 lm %r0,%r1,24(%r15)
35 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
36 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
37 brc 3,2f
38 ahi %r0,-1
79c74ecb 392: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
b020632e 40 lr %r2,%r0
79c74ecb 41 l %r0,__VDSO_TK_MULT(%r5)
b020632e
MS
42 ltr %r1,%r1
43 mr %r0,%r0
44 jnm 3f
79c74ecb 45 a %r0,__VDSO_TK_MULT(%r5)
b020632e 463: alr %r0,%r2
ca5de58b 47 al %r0,__VDSO_WTOM_NSEC(%r5)
b020632e
MS
48 al %r1,__VDSO_WTOM_NSEC+4(%r5)
49 brc 12,5f
50 ahi %r0,1
79c74ecb
MS
515: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
52 srdl %r0,0(%r2) /* >> tk->shift */
ca5de58b 53 l %r2,__VDSO_WTOM_SEC+4(%r5)
b020632e
MS
54 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
55 jne 1b
56 basr %r5,0
576: ltr %r0,%r0
58 jnz 7f
59 cl %r1,20f-6b(%r5)
60 jl 8f
617: ahi %r2,1
62 sl %r1,20f-6b(%r5)
63 brc 3,6b
64 ahi %r0,-1
65 j 6b
668: st %r2,0(%r3) /* store tp->tv_sec */
67 st %r1,4(%r3) /* store tp->tv_nsec */
5da76157 68 lhi %r2,0
b020632e
MS
69 br %r14
70
71 /* CLOCK_REALTIME */
b020632e
MS
7211: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
73 tml %r4,0x0001 /* pending update ? loop */
74 jnz 11b
75 stck 24(%r15) /* Store TOD clock */
76 lm %r0,%r1,24(%r15)
77 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
78 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
79 brc 3,12f
80 ahi %r0,-1
79c74ecb 8112: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
b020632e 82 lr %r2,%r0
79c74ecb 83 l %r0,__VDSO_TK_MULT(%r5)
b020632e
MS
84 ltr %r1,%r1
85 mr %r0,%r0
86 jnm 13f
79c74ecb 87 a %r0,__VDSO_TK_MULT(%r5)
b020632e 8813: alr %r0,%r2
79c74ecb 89 al %r0,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
b020632e
MS
90 al %r1,__VDSO_XTIME_NSEC+4(%r5)
91 brc 12,14f
92 ahi %r0,1
79c74ecb
MS
9314: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
94 srdl %r0,0(%r2) /* >> tk->shift */
95 l %r2,__VDSO_XTIME_SEC+4(%r5)
b020632e
MS
96 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
97 jne 11b
98 basr %r5,0
9915: ltr %r0,%r0
100 jnz 16f
101 cl %r1,20f-15b(%r5)
102 jl 17f
10316: ahi %r2,1
104 sl %r1,20f-15b(%r5)
105 brc 3,15b
106 ahi %r0,-1
107 j 15b
10817: st %r2,0(%r3) /* store tp->tv_sec */
109 st %r1,4(%r3) /* store tp->tv_nsec */
5da76157 110 lhi %r2,0
b020632e
MS
111 br %r14
112
113 /* Fallback to system call */
11419: lhi %r1,__NR_clock_gettime
115 svc 0
116 br %r14
117
11820: .long 1000000000
11921: .long _vdso_data - 0b
120 .cfi_endproc
121 .size __kernel_clock_gettime,.-__kernel_clock_gettime