Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
0003  */
0004 
0005 #ifndef _ASM_SPARC_VVAR_DATA_H
0006 #define _ASM_SPARC_VVAR_DATA_H
0007 
0008 #include <asm/clocksource.h>
0009 #include <asm/processor.h>
0010 #include <asm/barrier.h>
0011 #include <linux/time.h>
0012 #include <linux/types.h>
0013 
0014 struct vvar_data {
0015     unsigned int seq;
0016 
0017     int vclock_mode;
0018     struct { /* extract of a clocksource struct */
0019         u64 cycle_last;
0020         u64 mask;
0021         int mult;
0022         int shift;
0023     } clock;
0024     /* open coded 'struct timespec' */
0025     u64     wall_time_sec;
0026     u64     wall_time_snsec;
0027     u64     monotonic_time_snsec;
0028     u64     monotonic_time_sec;
0029     u64     monotonic_time_coarse_sec;
0030     u64     monotonic_time_coarse_nsec;
0031     u64     wall_time_coarse_sec;
0032     u64     wall_time_coarse_nsec;
0033 
0034     int     tz_minuteswest;
0035     int     tz_dsttime;
0036 };
0037 
0038 extern struct vvar_data *vvar_data;
0039 extern int vdso_fix_stick;
0040 
0041 static inline unsigned int vvar_read_begin(const struct vvar_data *s)
0042 {
0043     unsigned int ret;
0044 
0045 repeat:
0046     ret = READ_ONCE(s->seq);
0047     if (unlikely(ret & 1)) {
0048         cpu_relax();
0049         goto repeat;
0050     }
0051     smp_rmb(); /* Finish all reads before we return seq */
0052     return ret;
0053 }
0054 
0055 static inline int vvar_read_retry(const struct vvar_data *s,
0056                     unsigned int start)
0057 {
0058     smp_rmb(); /* Finish all reads before checking the value of seq */
0059     return unlikely(s->seq != start);
0060 }
0061 
0062 static inline void vvar_write_begin(struct vvar_data *s)
0063 {
0064     ++s->seq;
0065     smp_wmb(); /* Makes sure that increment of seq is reflected */
0066 }
0067 
0068 static inline void vvar_write_end(struct vvar_data *s)
0069 {
0070     smp_wmb(); /* Makes the value of seq current before we increment */
0071     ++s->seq;
0072 }
0073 
0074 
0075 #endif /* _ASM_SPARC_VVAR_DATA_H */