diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-17 11:25:23 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-04-17 20:24:21 +0000 |
commit | fceffb7d4aa429a60cd4cf760dd9852bb594b4be (patch) | |
tree | 677b50a39874a2d134b502805638d7b7ae5bba37 | |
parent | 01d1eb425874813864d12d72c93e6e74ab92ac1f (diff) | |
download | rockbox-fceffb7d4aa429a60cd4cf760dd9852bb594b4be.tar.gz rockbox-fceffb7d4aa429a60cd4cf760dd9852bb594b4be.zip |
x1000: disable CPU idle stats by default
There's no point including this in normal builds: the stats are not
used for anything, they are not really of interest to anyone except
developers, and add a small overhead to the kernel tick.
Change-Id: I1b4f67cc62d11d634a8cec279dca513dd10eea96
4 files changed, 19 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/debug-x1000.c b/firmware/target/mips/ingenic_x1000/debug-x1000.c index fed586691c..74bbcd77a6 100644 --- a/firmware/target/mips/ingenic_x1000/debug-x1000.c +++ b/firmware/target/mips/ingenic_x1000/debug-x1000.c | |||
@@ -130,6 +130,7 @@ static bool dbg_audio(void) | |||
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | 132 | ||
133 | #ifdef X1000_CPUIDLE_STATS | ||
133 | static bool dbg_cpuidle(void) | 134 | static bool dbg_cpuidle(void) |
134 | { | 135 | { |
135 | do { | 136 | do { |
@@ -143,6 +144,7 @@ static bool dbg_cpuidle(void) | |||
143 | 144 | ||
144 | return false; | 145 | return false; |
145 | } | 146 | } |
147 | #endif | ||
146 | 148 | ||
147 | #ifdef FIIO_M3K | 149 | #ifdef FIIO_M3K |
148 | extern bool dbg_fiiom3k_touchpad(void); | 150 | extern bool dbg_fiiom3k_touchpad(void); |
@@ -156,7 +158,9 @@ static const struct { | |||
156 | } menuitems[] = { | 158 | } menuitems[] = { |
157 | {"Clocks", &dbg_clocks}, | 159 | {"Clocks", &dbg_clocks}, |
158 | {"GPIOs", &dbg_gpios}, | 160 | {"GPIOs", &dbg_gpios}, |
161 | #ifdef X1000_CPUIDLE_STATS | ||
159 | {"CPU idle", &dbg_cpuidle}, | 162 | {"CPU idle", &dbg_cpuidle}, |
163 | #endif | ||
160 | {"Audio", &dbg_audio}, | 164 | {"Audio", &dbg_audio}, |
161 | #ifdef FIIO_M3K | 165 | #ifdef FIIO_M3K |
162 | {"Touchpad", &dbg_fiiom3k_touchpad}, | 166 | {"Touchpad", &dbg_fiiom3k_touchpad}, |
diff --git a/firmware/target/mips/ingenic_x1000/kernel-x1000.c b/firmware/target/mips/ingenic_x1000/kernel-x1000.c index c8105a3446..eb7c3d6124 100644 --- a/firmware/target/mips/ingenic_x1000/kernel-x1000.c +++ b/firmware/target/mips/ingenic_x1000/kernel-x1000.c | |||
@@ -57,6 +57,7 @@ void tick_start(unsigned interval_in_ms) | |||
57 | 57 | ||
58 | void OST(void) | 58 | void OST(void) |
59 | { | 59 | { |
60 | #ifdef X1000_CPUIDLE_STATS | ||
60 | /* CPU idle time accounting */ | 61 | /* CPU idle time accounting */ |
61 | uint32_t now = __ost_read32(); | 62 | uint32_t now = __ost_read32(); |
62 | uint32_t div = now - __cpu_idle_reftick; | 63 | uint32_t div = now - __cpu_idle_reftick; |
@@ -67,6 +68,7 @@ void OST(void) | |||
67 | __cpu_idle_ticks = 0; | 68 | __cpu_idle_ticks = 0; |
68 | __cpu_idle_reftick = now; | 69 | __cpu_idle_reftick = now; |
69 | } | 70 | } |
71 | #endif | ||
70 | 72 | ||
71 | /* Call regular kernel tick */ | 73 | /* Call regular kernel tick */ |
72 | jz_write(OST_1FLG, 0); | 74 | jz_write(OST_1FLG, 0); |
diff --git a/firmware/target/mips/ingenic_x1000/system-target.h b/firmware/target/mips/ingenic_x1000/system-target.h index 050afcca9e..45a1eab1ff 100644 --- a/firmware/target/mips/ingenic_x1000/system-target.h +++ b/firmware/target/mips/ingenic_x1000/system-target.h | |||
@@ -37,6 +37,11 @@ | |||
37 | # define MIPS_CACHEFUNC_ATTR | 37 | # define MIPS_CACHEFUNC_ATTR |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifdef DEBUG | ||
41 | /* Define this to get CPU idle stats, visible in the debug menu. */ | ||
42 | # define X1000_CPUIDLE_STATS | ||
43 | #endif | ||
44 | |||
40 | #include "mmu-mips.h" | 45 | #include "mmu-mips.h" |
41 | #include "mipsregs.h" | 46 | #include "mipsregs.h" |
42 | #include "mipsr2-endian.h" | 47 | #include "mipsr2-endian.h" |
@@ -66,16 +71,20 @@ static inline int set_irq_level(int lev) | |||
66 | return oldreg; | 71 | return oldreg; |
67 | } | 72 | } |
68 | 73 | ||
74 | #ifdef X1000_CPUIDLE_STATS | ||
69 | /* CPU idle stats, updated each kernel tick in kernel-x1000.c */ | 75 | /* CPU idle stats, updated each kernel tick in kernel-x1000.c */ |
70 | extern int __cpu_idle_avg; | 76 | extern int __cpu_idle_avg; |
71 | extern int __cpu_idle_cur; | 77 | extern int __cpu_idle_cur; |
72 | extern uint32_t __cpu_idle_ticks; | 78 | extern uint32_t __cpu_idle_ticks; |
73 | extern uint32_t __cpu_idle_reftick; | 79 | extern uint32_t __cpu_idle_reftick; |
80 | #endif | ||
74 | 81 | ||
75 | static inline uint32_t __ost_read32(void); | 82 | static inline uint32_t __ost_read32(void); |
76 | static inline void core_sleep(void) | 83 | static inline void core_sleep(void) |
77 | { | 84 | { |
85 | #ifdef X1000_CPUIDLE_STATS | ||
78 | uint32_t t1 = __ost_read32(); | 86 | uint32_t t1 = __ost_read32(); |
87 | #endif | ||
79 | 88 | ||
80 | __asm__ __volatile__( | 89 | __asm__ __volatile__( |
81 | ".set push\n\t" | 90 | ".set push\n\t" |
@@ -90,8 +99,10 @@ static inline void core_sleep(void) | |||
90 | ".set pop\n\t" | 99 | ".set pop\n\t" |
91 | ::: "t0", "t1", "t2"); | 100 | ::: "t0", "t1", "t2"); |
92 | 101 | ||
102 | #ifdef X1000_CPUIDLE_STATS | ||
93 | uint32_t t2 = __ost_read32(); | 103 | uint32_t t2 = __ost_read32(); |
94 | __cpu_idle_ticks += t2 - t1; | 104 | __cpu_idle_ticks += t2 - t1; |
105 | #endif | ||
95 | 106 | ||
96 | enable_irq(); | 107 | enable_irq(); |
97 | } | 108 | } |
diff --git a/firmware/target/mips/ingenic_x1000/system-x1000.c b/firmware/target/mips/ingenic_x1000/system-x1000.c index d841a274ed..33d8db7222 100644 --- a/firmware/target/mips/ingenic_x1000/system-x1000.c +++ b/firmware/target/mips/ingenic_x1000/system-x1000.c | |||
@@ -35,10 +35,12 @@ | |||
35 | #include "x1000/msc.h" | 35 | #include "x1000/msc.h" |
36 | #include "x1000/aic.h" | 36 | #include "x1000/aic.h" |
37 | 37 | ||
38 | #ifdef X1000_CPUIDLE_STATS | ||
38 | int __cpu_idle_avg = 0; | 39 | int __cpu_idle_avg = 0; |
39 | int __cpu_idle_cur = 0; | 40 | int __cpu_idle_cur = 0; |
40 | uint32_t __cpu_idle_ticks = 0; | 41 | uint32_t __cpu_idle_ticks = 0; |
41 | uint32_t __cpu_idle_reftick = 0; | 42 | uint32_t __cpu_idle_reftick = 0; |
43 | #endif | ||
42 | 44 | ||
43 | /* Prepare the CPU to process interrupts, but don't enable them yet */ | 45 | /* Prepare the CPU to process interrupts, but don't enable them yet */ |
44 | static void system_init_irq(void) | 46 | static void system_init_irq(void) |