Skip to content

Commit 74d23cc

Browse files
richardcochrandavem330
authored andcommitted
time: move the timecounter/cyclecounter code into its own file.
The timecounter code has almost nothing to do with the clocksource code. Let it live in its own file. This will help isolate the timecounter users from the clocksource users in the source tree. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2c90331 commit 74d23cc

File tree

16 files changed

+231
-187
lines changed

16 files changed

+231
-187
lines changed

drivers/net/ethernet/amd/xgbe/xgbe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
#include <linux/if_vlan.h>
125125
#include <linux/bitops.h>
126126
#include <linux/ptp_clock_kernel.h>
127-
#include <linux/clocksource.h>
127+
#include <linux/timecounter.h>
128128
#include <linux/net_tstamp.h>
129129
#include <net/dcbnl.h>
130130

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include <linux/ptp_clock_kernel.h>
2424
#include <linux/net_tstamp.h>
25-
#include <linux/clocksource.h>
25+
#include <linux/timecounter.h>
2626

2727
/* compilation time flags */
2828

drivers/net/ethernet/freescale/fec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/clocksource.h>
1717
#include <linux/net_tstamp.h>
1818
#include <linux/ptp_clock_kernel.h>
19+
#include <linux/timecounter.h>
1920

2021
#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
2122
defined(CONFIG_M520x) || defined(CONFIG_M532x) || \

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <linux/pci-aspm.h>
3535
#include <linux/crc32.h>
3636
#include <linux/if_vlan.h>
37-
#include <linux/clocksource.h>
37+
#include <linux/timecounter.h>
3838
#include <linux/net_tstamp.h>
3939
#include <linux/ptp_clock_kernel.h>
4040
#include <linux/ptp_classify.h>

drivers/net/ethernet/intel/igb/igb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "e1000_mac.h"
3030
#include "e1000_82575.h"
3131

32-
#include <linux/clocksource.h>
32+
#include <linux/timecounter.h>
3333
#include <linux/net_tstamp.h>
3434
#include <linux/ptp_clock_kernel.h>
3535
#include <linux/bitops.h>

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <linux/if_vlan.h>
3939
#include <linux/jiffies.h>
4040

41-
#include <linux/clocksource.h>
41+
#include <linux/timecounter.h>
4242
#include <linux/net_tstamp.h>
4343
#include <linux/ptp_clock_kernel.h>
4444

drivers/net/ethernet/ti/cpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/list.h>
2828
#include <linux/ptp_clock_kernel.h>
2929
#include <linux/skbuff.h>
30+
#include <linux/timecounter.h>
3031

3132
struct cpsw_cpts {
3233
u32 idver; /* Identification and version */

include/clocksource/arm_arch_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef __CLKSOURCE_ARM_ARCH_TIMER_H
1717
#define __CLKSOURCE_ARM_ARCH_TIMER_H
1818

19-
#include <linux/clocksource.h>
19+
#include <linux/timecounter.h>
2020
#include <linux/types.h>
2121

2222
#define ARCH_TIMER_CTRL_ENABLE (1 << 0)

include/linux/clocksource.h

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -18,115 +18,13 @@
1818
#include <asm/div64.h>
1919
#include <asm/io.h>
2020

21-
/* clocksource cycle base type */
22-
typedef u64 cycle_t;
2321
struct clocksource;
2422
struct module;
2523

2624
#ifdef CONFIG_ARCH_CLOCKSOURCE_DATA
2725
#include <asm/clocksource.h>
2826
#endif
2927

30-
/**
31-
* struct cyclecounter - hardware abstraction for a free running counter
32-
* Provides completely state-free accessors to the underlying hardware.
33-
* Depending on which hardware it reads, the cycle counter may wrap
34-
* around quickly. Locking rules (if necessary) have to be defined
35-
* by the implementor and user of specific instances of this API.
36-
*
37-
* @read: returns the current cycle value
38-
* @mask: bitmask for two's complement
39-
* subtraction of non 64 bit counters,
40-
* see CLOCKSOURCE_MASK() helper macro
41-
* @mult: cycle to nanosecond multiplier
42-
* @shift: cycle to nanosecond divisor (power of two)
43-
*/
44-
struct cyclecounter {
45-
cycle_t (*read)(const struct cyclecounter *cc);
46-
cycle_t mask;
47-
u32 mult;
48-
u32 shift;
49-
};
50-
51-
/**
52-
* struct timecounter - layer above a %struct cyclecounter which counts nanoseconds
53-
* Contains the state needed by timecounter_read() to detect
54-
* cycle counter wrap around. Initialize with
55-
* timecounter_init(). Also used to convert cycle counts into the
56-
* corresponding nanosecond counts with timecounter_cyc2time(). Users
57-
* of this code are responsible for initializing the underlying
58-
* cycle counter hardware, locking issues and reading the time
59-
* more often than the cycle counter wraps around. The nanosecond
60-
* counter will only wrap around after ~585 years.
61-
*
62-
* @cc: the cycle counter used by this instance
63-
* @cycle_last: most recent cycle counter value seen by
64-
* timecounter_read()
65-
* @nsec: continuously increasing count
66-
*/
67-
struct timecounter {
68-
const struct cyclecounter *cc;
69-
cycle_t cycle_last;
70-
u64 nsec;
71-
};
72-
73-
/**
74-
* cyclecounter_cyc2ns - converts cycle counter cycles to nanoseconds
75-
* @cc: Pointer to cycle counter.
76-
* @cycles: Cycles
77-
*
78-
* XXX - This could use some mult_lxl_ll() asm optimization. Same code
79-
* as in cyc2ns, but with unsigned result.
80-
*/
81-
static inline u64 cyclecounter_cyc2ns(const struct cyclecounter *cc,
82-
cycle_t cycles)
83-
{
84-
u64 ret = (u64)cycles;
85-
ret = (ret * cc->mult) >> cc->shift;
86-
return ret;
87-
}
88-
89-
/**
90-
* timecounter_init - initialize a time counter
91-
* @tc: Pointer to time counter which is to be initialized/reset
92-
* @cc: A cycle counter, ready to be used.
93-
* @start_tstamp: Arbitrary initial time stamp.
94-
*
95-
* After this call the current cycle register (roughly) corresponds to
96-
* the initial time stamp. Every call to timecounter_read() increments
97-
* the time stamp counter by the number of elapsed nanoseconds.
98-
*/
99-
extern void timecounter_init(struct timecounter *tc,
100-
const struct cyclecounter *cc,
101-
u64 start_tstamp);
102-
103-
/**
104-
* timecounter_read - return nanoseconds elapsed since timecounter_init()
105-
* plus the initial time stamp
106-
* @tc: Pointer to time counter.
107-
*
108-
* In other words, keeps track of time since the same epoch as
109-
* the function which generated the initial time stamp.
110-
*/
111-
extern u64 timecounter_read(struct timecounter *tc);
112-
113-
/**
114-
* timecounter_cyc2time - convert a cycle counter to same
115-
* time base as values returned by
116-
* timecounter_read()
117-
* @tc: Pointer to time counter.
118-
* @cycle_tstamp: a value returned by tc->cc->read()
119-
*
120-
* Cycle counts that are converted correctly as long as they
121-
* fall into the interval [-1/2 max cycle count, +1/2 max cycle count],
122-
* with "max cycle count" == cs->mask+1.
123-
*
124-
* This allows conversion of cycle counter values which were generated
125-
* in the past.
126-
*/
127-
extern u64 timecounter_cyc2time(struct timecounter *tc,
128-
cycle_t cycle_tstamp);
129-
13028
/**
13129
* struct clocksource - hardware abstraction for a free running counter
13230
* Provides mostly state-free accessors to the underlying hardware.

include/linux/mlx4/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
#include <linux/atomic.h>
4444

45-
#include <linux/clocksource.h>
45+
#include <linux/timecounter.h>
4646

4747
#define MAX_MSIX_P_PORT 17
4848
#define MAX_MSIX 64

0 commit comments

Comments
 (0)