1 From 9c9b415c50bc298ac61412dff856eae2f54889ee Mon Sep 17 00:00:00 2001
2 From: Ralf Baechle <ralf@linux-mips.org>
3 Date: Thu, 12 Sep 2013 13:47:32 +0200
4 Subject: [PATCH] MIPS: Reimplement get_cycles().
6 This essentially reverts commit efb9ca08b5a2374b29938cdcab417ce4feb14b54
7 (kernel.org) / 58020a106879a8b372068741c81f0015c9b0b96dbv [[MIPS] Change
8 get_cycles to always return 0.]
10 Most users of get_cycles() invoke it as a timing interface. That's why
11 in modern kernels it was never very much missed for. /dev/random however
12 uses get_cycles() in the how the jitter in the interrupt timing contains
15 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
17 arch/mips/include/asm/timex.h | 33 ++++++++++++++++++++++++++++++++-
18 1 file changed, 32 insertions(+), 1 deletion(-)
20 --- a/arch/mips/include/asm/timex.h
21 +++ b/arch/mips/include/asm/timex.h
26 +#include <asm/cpu-features.h>
27 #include <asm/mipsregs.h>
32 typedef unsigned int cycles_t;
35 + * On R4000/R4400 before version 5.0 an erratum exists such that if the
36 + * cycle counter is read in the exact moment that it is matching the
37 + * compare register, no interrupt will be generated.
39 + * There is a suggested workaround and also the erratum can't strike if
40 + * the compare interrupt isn't being used as the clock source device.
41 + * However for now the implementaton of this function doesn't get these
42 + * fine details right.
44 static inline cycles_t get_cycles(void)
47 + switch (cpu_data[0].cputype) {
51 + if ((read_c0_prid() & 0xff) >= 0x0050)
52 + return read_c0_count();
61 + if (cpu_has_counter)
62 + return read_c0_count();
66 + return 0; /* no usable counter */
69 #endif /* __KERNEL__ */