diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/clocksource.h | 22 | ||||
-rw-r--r-- | include/linux/dw_apb_timer.h | 2 | ||||
-rw-r--r-- | include/linux/futex.h | 4 | ||||
-rw-r--r-- | include/linux/hrtimer.h | 12 | ||||
-rw-r--r-- | include/linux/irqchip/mips-gic.h | 8 | ||||
-rw-r--r-- | include/linux/ktime.h | 81 | ||||
-rw-r--r-- | include/linux/mlx4/device.h | 2 | ||||
-rw-r--r-- | include/linux/skbuff.h | 2 | ||||
-rw-r--r-- | include/linux/tick.h | 4 | ||||
-rw-r--r-- | include/linux/timecounter.h | 12 | ||||
-rw-r--r-- | include/linux/timekeeper_internal.h | 10 | ||||
-rw-r--r-- | include/linux/timekeeping.h | 4 | ||||
-rw-r--r-- | include/linux/types.h | 3 | ||||
-rw-r--r-- | include/linux/wait.h | 2 |
14 files changed, 63 insertions, 105 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 65602d395a52..e315d04a2fd9 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -75,8 +75,8 @@ struct module; * structure. */ struct clocksource { - cycle_t (*read)(struct clocksource *cs); - cycle_t mask; + u64 (*read)(struct clocksource *cs); + u64 mask; u32 mult; u32 shift; u64 max_idle_ns; @@ -98,8 +98,8 @@ struct clocksource { #ifdef CONFIG_CLOCKSOURCE_WATCHDOG /* Watchdog related data, used by the framework */ struct list_head wd_list; - cycle_t cs_last; - cycle_t wd_last; + u64 cs_last; + u64 wd_last; #endif struct module *owner; }; @@ -117,7 +117,7 @@ struct clocksource { #define CLOCK_SOURCE_RESELECT 0x100 /* simplify initialization of mask field */ -#define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +#define CLOCKSOURCE_MASK(bits) (u64)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) static inline u32 clocksource_freq2mult(u32 freq, u32 shift_constant, u64 from) { @@ -176,7 +176,7 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant) * * XXX - This could use some mult_lxl_ll() asm optimization */ -static inline s64 clocksource_cyc2ns(cycle_t cycles, u32 mult, u32 shift) +static inline s64 clocksource_cyc2ns(u64 cycles, u32 mult, u32 shift) { return ((u64) cycles * mult) >> shift; } @@ -236,13 +236,13 @@ static inline void __clocksource_update_freq_khz(struct clocksource *cs, u32 khz extern int timekeeping_notify(struct clocksource *clock); -extern cycle_t clocksource_mmio_readl_up(struct clocksource *); -extern cycle_t clocksource_mmio_readl_down(struct clocksource *); -extern cycle_t clocksource_mmio_readw_up(struct clocksource *); -extern cycle_t clocksource_mmio_readw_down(struct clocksource *); +extern u64 clocksource_mmio_readl_up(struct clocksource *); +extern u64 clocksource_mmio_readl_down(struct clocksource *); +extern u64 clocksource_mmio_readw_up(struct clocksource *); +extern u64 clocksource_mmio_readw_down(struct clocksource *); extern int clocksource_mmio_init(void __iomem *, const char *, - unsigned long, int, unsigned, cycle_t (*)(struct clocksource *)); + unsigned long, int, unsigned, u64 (*)(struct clocksource *)); extern int clocksource_i8253_init(void); diff --git a/include/linux/dw_apb_timer.h b/include/linux/dw_apb_timer.h index 1f79b20918b1..4334106f44c3 100644 --- a/include/linux/dw_apb_timer.h +++ b/include/linux/dw_apb_timer.h @@ -50,6 +50,6 @@ dw_apb_clocksource_init(unsigned rating, const char *name, void __iomem *base, unsigned long freq); void dw_apb_clocksource_register(struct dw_apb_clocksource *dw_cs); void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs); -cycle_t dw_apb_clocksource_read(struct dw_apb_clocksource *dw_cs); +u64 dw_apb_clocksource_read(struct dw_apb_clocksource *dw_cs); #endif /* __DW_APB_TIMER_H__ */ diff --git a/include/linux/futex.h b/include/linux/futex.h index 6435f46d6e13..7c5b694864cd 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -1,14 +1,14 @@ #ifndef _LINUX_FUTEX_H #define _LINUX_FUTEX_H +#include <linux/ktime.h> #include <uapi/linux/futex.h> struct inode; struct mm_struct; struct task_struct; -union ktime; -long do_futex(u32 __user *uaddr, int op, u32 val, union ktime *timeout, +long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, u32 __user *uaddr2, u32 val2, u32 val3); extern int diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 5e00f80b1535..cdab81ba29f8 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -228,8 +228,8 @@ static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t t static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) { - timer->node.expires.tv64 = tv64; - timer->_softexpires.tv64 = tv64; + timer->node.expires = tv64; + timer->_softexpires = tv64; } static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) @@ -256,11 +256,11 @@ static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) { - return timer->node.expires.tv64; + return timer->node.expires; } static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) { - return timer->_softexpires.tv64; + return timer->_softexpires; } static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) @@ -297,7 +297,7 @@ extern void hrtimer_peek_ahead_timers(void); * this resolution values. */ # define HIGH_RES_NSEC 1 -# define KTIME_HIGH_RES (ktime_t) { .tv64 = HIGH_RES_NSEC } +# define KTIME_HIGH_RES (HIGH_RES_NSEC) # define MONOTONIC_RES_NSEC HIGH_RES_NSEC # define KTIME_MONOTONIC_RES KTIME_HIGH_RES @@ -333,7 +333,7 @@ __hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now) * hrtimer_start_range_ns() to prevent short timeouts. */ if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel) - rem.tv64 -= hrtimer_resolution; + rem -= hrtimer_resolution; return rem; } diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h index 81f930b0bca9..7b49c71c968b 100644 --- a/include/linux/irqchip/mips-gic.h +++ b/include/linux/irqchip/mips-gic.h @@ -259,11 +259,11 @@ extern void gic_init(unsigned long gic_base_addr, unsigned long gic_addrspace_size, unsigned int cpu_vec, unsigned int irqbase); extern void gic_clocksource_init(unsigned int); -extern cycle_t gic_read_count(void); +extern u64 gic_read_count(void); extern unsigned int gic_get_count_width(void); -extern cycle_t gic_read_compare(void); -extern void gic_write_compare(cycle_t cnt); -extern void gic_write_cpu_compare(cycle_t cnt, int cpu); +extern u64 gic_read_compare(void); +extern void gic_write_compare(u64 cnt); +extern void gic_write_cpu_compare(u64 cnt, int cpu); extern void gic_start_count(void); extern void gic_stop_count(void); extern int gic_get_c0_compare_int(void); diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 0fb7ffb1775f..0c8bd45c8206 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -24,21 +24,8 @@ #include <linux/time.h> #include <linux/jiffies.h> -/* - * ktime_t: - * - * A single 64-bit variable is used to store the hrtimers - * internal representation of time values in scalar nanoseconds. The - * design plays out best on 64-bit CPUs, where most conversions are - * NOPs and most arithmetic ktime_t operations are plain arithmetic - * operations. - * - */ -union ktime { - s64 tv64; -}; - -typedef union ktime ktime_t; /* Kill this */ +/* Nanosecond scalar representation for kernel time values */ +typedef s64 ktime_t; /** * ktime_set - Set a ktime_t variable from a seconds/nanoseconds value @@ -50,39 +37,34 @@ typedef union ktime ktime_t; /* Kill this */ static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs) { if (unlikely(secs >= KTIME_SEC_MAX)) - return (ktime_t){ .tv64 = KTIME_MAX }; + return KTIME_MAX; - return (ktime_t) { .tv64 = secs * NSEC_PER_SEC + (s64)nsecs }; + return secs * NSEC_PER_SEC + (s64)nsecs; } /* Subtract two ktime_t variables. rem = lhs -rhs: */ -#define ktime_sub(lhs, rhs) \ - ({ (ktime_t){ .tv64 = (lhs).tv64 - (rhs).tv64 }; }) +#define ktime_sub(lhs, rhs) ((lhs) - (rhs)) /* Add two ktime_t variables. res = lhs + rhs: */ -#define ktime_add(lhs, rhs) \ - ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; }) +#define ktime_add(lhs, rhs) ((lhs) + (rhs)) /* * Same as ktime_add(), but avoids undefined behaviour on overflow; however, * this means that you must check the result for overflow yourself. */ -#define ktime_add_unsafe(lhs, rhs) \ - ({ (ktime_t){ .tv64 = (u64) (lhs).tv64 + (rhs).tv64 }; }) +#define ktime_add_unsafe(lhs, rhs) ((u64) (lhs) + (rhs)) /* * Add a ktime_t variable and a scalar nanosecond value. * res = kt + nsval: */ -#define ktime_add_ns(kt, nsval) \ - ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) +#define ktime_add_ns(kt, nsval) ((kt) + (nsval)) /* * Subtract a scalar nanosecod from a ktime_t variable * res = kt - nsval: */ -#define ktime_sub_ns(kt, nsval) \ - ({ (ktime_t){ .tv64 = (kt).tv64 - (nsval) }; }) +#define ktime_sub_ns(kt, nsval) ((kt) - (nsval)) /* convert a timespec to ktime_t format: */ static inline ktime_t timespec_to_ktime(struct timespec ts) @@ -103,31 +85,16 @@ static inline ktime_t timeval_to_ktime(struct timeval tv) } /* Map the ktime_t to timespec conversion to ns_to_timespec function */ -#define ktime_to_timespec(kt) ns_to_timespec((kt).tv64) +#define ktime_to_timespec(kt) ns_to_timespec((kt)) /* Map the ktime_t to timespec conversion to ns_to_timespec function */ -#define ktime_to_timespec64(kt) ns_to_timespec64((kt).tv64) +#define ktime_to_timespec64(kt) ns_to_timespec64((kt)) /* Map the ktime_t to timeval conversion to ns_to_timeval function */ -#define ktime_to_timeval(kt) ns_to_timeval((kt).tv64) +#define ktime_to_timeval(kt) ns_to_timeval((kt)) /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */ -#define ktime_to_ns(kt) ((kt).tv64) - - -/** - * ktime_equal - Compares two ktime_t variables to see if they are equal - * @cmp1: comparable1 - * @cmp2: comparable2 - * - * Compare two ktime_t variables. - * - * Return: 1 if equal. - */ -static inline int ktime_equal(const ktime_t cmp1, const ktime_t cmp2) -{ - return cmp1.tv64 == cmp2.tv64; -} +#define ktime_to_ns(kt) (kt) /** * ktime_compare - Compares two ktime_t variables for less, greater or equal @@ -141,9 +108,9 @@ static inline int ktime_equal(const ktime_t cmp1, const ktime_t cmp2) */ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2) { - if (cmp1.tv64 < cmp2.tv64) + if (cmp1 < cmp2) return -1; - if (cmp1.tv64 > cmp2.tv64) + if (cmp1 > cmp2) return 1; return 0; } @@ -182,7 +149,7 @@ static inline s64 ktime_divns(const ktime_t kt, s64 div) */ BUG_ON(div < 0); if (__builtin_constant_p(div) && !(div >> 32)) { - s64 ns = kt.tv64; + s64 ns = kt; u64 tmp = ns < 0 ? -ns : ns; do_div(tmp, div); @@ -199,7 +166,7 @@ static inline s64 ktime_divns(const ktime_t kt, s64 div) * so catch them on 64bit as well. */ WARN_ON(div < 0); - return kt.tv64 / div; + return kt / div; } #endif @@ -256,7 +223,7 @@ extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs); static inline __must_check bool ktime_to_timespec_cond(const ktime_t kt, struct timespec *ts) { - if (kt.tv64) { + if (kt) { *ts = ktime_to_timespec(kt); return true; } else { @@ -275,7 +242,7 @@ static inline __must_check bool ktime_to_timespec_cond(const ktime_t kt, static inline __must_check bool ktime_to_timespec64_cond(const ktime_t kt, struct timespec64 *ts) { - if (kt.tv64) { + if (kt) { *ts = ktime_to_timespec64(kt); return true; } else { @@ -290,20 +257,16 @@ static inline __must_check bool ktime_to_timespec64_cond(const ktime_t kt, * this resolution values. */ #define LOW_RES_NSEC TICK_NSEC -#define KTIME_LOW_RES (ktime_t){ .tv64 = LOW_RES_NSEC } +#define KTIME_LOW_RES (LOW_RES_NSEC) static inline ktime_t ns_to_ktime(u64 ns) { - static const ktime_t ktime_zero = { .tv64 = 0 }; - - return ktime_add_ns(ktime_zero, ns); + return ns; } static inline ktime_t ms_to_ktime(u64 ms) { - static const ktime_t ktime_zero = { .tv64 = 0 }; - - return ktime_add_ms(ktime_zero, ms); + return ms * NSEC_PER_MSEC; } # include <linux/timekeeping.h> diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index c9f379689dd0..93bdb3485192 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h @@ -1460,7 +1460,7 @@ int mlx4_get_roce_gid_from_slave(struct mlx4_dev *dev, int port, int slave_id, int mlx4_FLOW_STEERING_IB_UC_QP_RANGE(struct mlx4_dev *dev, u32 min_range_qpn, u32 max_range_qpn); -cycle_t mlx4_read_clock(struct mlx4_dev *dev); +u64 mlx4_read_clock(struct mlx4_dev *dev); struct mlx4_active_ports { DECLARE_BITMAP(ports, MLX4_MAX_PORTS); diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index ac7fa34db8a7..b53c0cfd417e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3227,7 +3227,7 @@ static inline ktime_t net_timedelta(ktime_t t) static inline ktime_t net_invalid_timestamp(void) { - return ktime_set(0, 0); + return 0; } struct sk_buff *skb_clone_sk(struct sk_buff *skb); diff --git a/include/linux/tick.h b/include/linux/tick.h index 62be0786d6d0..a04fea19676f 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -127,9 +127,7 @@ static inline void tick_nohz_idle_exit(void) { } static inline ktime_t tick_nohz_get_sleep_length(void) { - ktime_t len = { .tv64 = NSEC_PER_SEC/HZ }; - - return len; + return NSEC_PER_SEC / HZ; } static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } diff --git a/include/linux/timecounter.h b/include/linux/timecounter.h index 4382035a75bb..2496ad4cfc99 100644 --- a/include/linux/timecounter.h +++ b/include/linux/timecounter.h @@ -20,7 +20,7 @@ #include <linux/types.h> /* simplify initialization of mask field */ -#define CYCLECOUNTER_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) +#define CYCLECOUNTER_MASK(bits) (u64)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) /** * struct cyclecounter - hardware abstraction for a free running counter @@ -37,8 +37,8 @@ * @shift: cycle to nanosecond divisor (power of two) */ struct cyclecounter { - cycle_t (*read)(const struct cyclecounter *cc); - cycle_t mask; + u64 (*read)(const struct cyclecounter *cc); + u64 mask; u32 mult; u32 shift; }; @@ -63,7 +63,7 @@ struct cyclecounter { */ struct timecounter { const struct cyclecounter *cc; - cycle_t cycle_last; + u64 cycle_last; u64 nsec; u64 mask; u64 frac; @@ -77,7 +77,7 @@ struct timecounter { * @frac: pointer to storage for the fractional nanoseconds. */ static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc, - cycle_t cycles, u64 mask, u64 *frac) + u64 cycles, u64 mask, u64 *frac) { u64 ns = (u64) cycles; @@ -134,6 +134,6 @@ extern u64 timecounter_read(struct timecounter *tc); * in the past. */ extern u64 timecounter_cyc2time(struct timecounter *tc, - cycle_t cycle_tstamp); + u64 cycle_tstamp); #endif diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h index e88005459035..110f4532188c 100644 --- a/include/linux/timekeeper_internal.h +++ b/include/linux/timekeeper_internal.h @@ -29,9 +29,9 @@ */ struct tk_read_base { struct clocksource *clock; - cycle_t (*read)(struct clocksource *cs); - cycle_t mask; - cycle_t cycle_last; + u64 (*read)(struct clocksource *cs); + u64 mask; + u64 cycle_last; u32 mult; u32 shift; u64 xtime_nsec; @@ -97,7 +97,7 @@ struct timekeeper { struct timespec64 raw_time; /* The following members are for timekeeping internal use */ - cycle_t cycle_interval; + u64 cycle_interval; u64 xtime_interval; s64 xtime_remainder; u32 raw_interval; @@ -136,7 +136,7 @@ extern void update_vsyscall_tz(void); extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm, struct clocksource *c, u32 mult, - cycle_t cycle_last); + u64 cycle_last); extern void update_vsyscall_tz(void); #else diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 361f8bf1429d..d2e804e15c3e 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -293,7 +293,7 @@ extern void ktime_get_raw_and_real_ts64(struct timespec64 *ts_raw, * @cs_was_changed_seq: The sequence number of clocksource change events */ struct system_time_snapshot { - cycle_t cycles; + u64 cycles; ktime_t real; ktime_t raw; unsigned int clock_was_set_seq; @@ -321,7 +321,7 @@ struct system_device_crosststamp { * timekeeping code to verify comparibility of two cycle values */ struct system_counterval_t { - cycle_t cycles; + u64 cycles; struct clocksource *cs; }; diff --git a/include/linux/types.h b/include/linux/types.h index d501ad3ba247..1e7bd24848fc 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -228,8 +228,5 @@ struct callback_head { typedef void (*rcu_callback_t)(struct rcu_head *head); typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func); -/* clocksource cycle base type */ -typedef u64 cycle_t; - #endif /* __ASSEMBLY__ */ #endif /* _LINUX_TYPES_H */ diff --git a/include/linux/wait.h b/include/linux/wait.h index 2408e8d5c05c..1421132e9086 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -510,7 +510,7 @@ do { \ hrtimer_init_on_stack(&__t.timer, CLOCK_MONOTONIC, \ HRTIMER_MODE_REL); \ hrtimer_init_sleeper(&__t, current); \ - if ((timeout).tv64 != KTIME_MAX) \ + if ((timeout) != KTIME_MAX) \ hrtimer_start_range_ns(&__t.timer, timeout, \ current->timer_slack_ns, \ HRTIMER_MODE_REL); \ |