summaryrefslogtreecommitdiffstats
path: root/target/linux/generic-2.4/patches/114-sched_use_tsc.patch
blob: cb51a3f57191a0e83afc653ea58751dc3bb5cf1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Index: linux-2.4.35.4/arch/mips/kernel/time.c
===================================================================
--- linux-2.4.35.4.orig/arch/mips/kernel/time.c
+++ linux-2.4.35.4/arch/mips/kernel/time.c
@@ -151,6 +151,27 @@ void (*mips_timer_ack)(void);
 unsigned int (*mips_hpt_read)(void);
 void (*mips_hpt_init)(unsigned int);
 
+extern __u32 get_htscl(void)
+{
+	return timerhi;
+}
+
+static __u64 tscll_last = 0;
+
+extern __u64 get_tscll(void)
+{
+	__u64 h = (__u64) timerhi;
+	__u32 c = read_c0_count();
+
+	h <<= 32;
+	h += c;
+
+	while (h < tscll_last)
+		h += (((__u64) 1) << 32);
+
+	tscll_last = h;
+	return h;	
+}
 
 /*
  * timeofday services, for syscalls.
@@ -761,3 +782,5 @@ EXPORT_SYMBOL(rtc_lock);
 EXPORT_SYMBOL(to_tm);
 EXPORT_SYMBOL(rtc_set_time);
 EXPORT_SYMBOL(rtc_get_time);
+EXPORT_SYMBOL(get_htscl);
+EXPORT_SYMBOL(get_tscll);
Index: linux-2.4.35.4/include/asm-mips/timex.h
===================================================================
--- linux-2.4.35.4.orig/include/asm-mips/timex.h
+++ linux-2.4.35.4/include/asm-mips/timex.h
@@ -31,6 +31,19 @@ static inline cycles_t get_cycles (void)
 	return read_c0_count();
 }
 
+extern __u32 get_htscl(void);
+extern __u64 get_tscll(void);
+
+#define rdtsc(low, high) \
+		high = get_htscl(); \
+		low = read_c0_count();
+
+#define rdtscl(low) \
+		low = read_c0_count();
+
+#define rdtscll(val) \
+		val = get_tscll();
+
 #define vxtime_lock()		do {} while (0)
 #define vxtime_unlock()		do {} while (0)
 
Index: linux-2.4.35.4/include/net/pkt_sched.h
===================================================================
--- linux-2.4.35.4.orig/include/net/pkt_sched.h
+++ linux-2.4.35.4/include/net/pkt_sched.h
@@ -5,7 +5,11 @@
 #define PSCHED_JIFFIES 		2
 #define PSCHED_CPU 		3
 
+#ifdef __mips__
+#define PSCHED_CLOCK_SOURCE	PSCHED_CPU
+#else
 #define PSCHED_CLOCK_SOURCE	PSCHED_JIFFIES
+#endif
 
 #include <linux/config.h>
 #include <linux/types.h>
@@ -261,7 +265,7 @@ extern int psched_clock_scale;
 #define PSCHED_US2JIFFIE(delay) (((delay)+psched_clock_per_hz-1)/psched_clock_per_hz)
 #define PSCHED_JIFFIE2US(delay) ((delay)*psched_clock_per_hz)
 
-#ifdef CONFIG_X86_TSC
+#if defined(CONFIG_X86_TSC) || defined(__mips__)
 
 #define PSCHED_GET_TIME(stamp) \
 ({ u64 __cur; \