diff options
author | William Wilgus <me.theuser@yahoo.com> | 2017-10-13 06:28:50 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2017-10-28 14:47:21 +0200 |
commit | b2c470719a79f301ff4e9a6adcc5307ef47cfacf (patch) | |
tree | 0d7c2e631cd8921ab62b22781f7480dcac993061 /firmware/target | |
parent | 428464774fd2918d40235b7a596698c27ee578a3 (diff) | |
download | rockbox-b2c470719a79f301ff4e9a6adcc5307ef47cfacf.tar.gz rockbox-b2c470719a79f301ff4e9a6adcc5307ef47cfacf.zip |
imx233: Implement mutex for cpu_boost_lock/unlock
Playing AAC-HE files resulted in a race condition between
audio/codec/buffering for set_cpu_frequency
Change-Id: I35e1c1fd18db623e2990c305acdca03f57184d0d
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/imx233/system-imx233.c | 17 | ||||
-rw-r--r-- | firmware/target/arm/imx233/system-target.h | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c index 4e1583d568..3ac5d0e557 100644 --- a/firmware/target/arm/imx233/system-imx233.c +++ b/firmware/target/arm/imx233/system-imx233.c | |||
@@ -53,6 +53,8 @@ | |||
53 | #define WATCHDOG_HW_DELAY (10 * HZ) | 53 | #define WATCHDOG_HW_DELAY (10 * HZ) |
54 | #define WATCHDOG_SW_DELAY (5 * HZ) | 54 | #define WATCHDOG_SW_DELAY (5 * HZ) |
55 | 55 | ||
56 | static struct mutex cpufreq_mtx; | ||
57 | |||
56 | void UIE(unsigned int pc, unsigned int num); | 58 | void UIE(unsigned int pc, unsigned int num); |
57 | 59 | ||
58 | static void woof_woof(void) | 60 | static void woof_woof(void) |
@@ -183,6 +185,7 @@ void system_init(void) | |||
183 | * The main() will naturally set cpu speed to normal after kernel_init() | 185 | * The main() will naturally set cpu speed to normal after kernel_init() |
184 | * so don't bother if the cpu is running at 24MHz here. | 186 | * so don't bother if the cpu is running at 24MHz here. |
185 | * Make sure IO clock is running at expected speed */ | 187 | * Make sure IO clock is running at expected speed */ |
188 | mutex_init(&cpufreq_mtx); | ||
186 | imx233_clkctrl_init(); | 189 | imx233_clkctrl_init(); |
187 | imx233_clkctrl_enable(CLK_PLL, true); | 190 | imx233_clkctrl_enable(CLK_PLL, true); |
188 | #if IMX233_SUBTARGET >= 3700 | 191 | #if IMX233_SUBTARGET >= 3700 |
@@ -364,6 +367,20 @@ void imx233_set_cpu_frequency(long frequency) | |||
364 | } | 367 | } |
365 | 368 | ||
366 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 369 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
370 | bool set_cpu_frequency__lock(void) | ||
371 | { | ||
372 | if (get_processor_mode() != CPU_MODE_THREAD_CONTEXT) | ||
373 | return false; | ||
374 | |||
375 | mutex_lock(&cpufreq_mtx); | ||
376 | return true; | ||
377 | } | ||
378 | |||
379 | void set_cpu_frequency__unlock(void) | ||
380 | { | ||
381 | mutex_unlock(&cpufreq_mtx); | ||
382 | } | ||
383 | |||
367 | void set_cpu_frequency(long frequency) | 384 | void set_cpu_frequency(long frequency) |
368 | { | 385 | { |
369 | return imx233_set_cpu_frequency(frequency); | 386 | return imx233_set_cpu_frequency(frequency); |
diff --git a/firmware/target/arm/imx233/system-target.h b/firmware/target/arm/imx233/system-target.h index ee2df9a3e9..45dc58698a 100644 --- a/firmware/target/arm/imx233/system-target.h +++ b/firmware/target/arm/imx233/system-target.h | |||
@@ -54,6 +54,23 @@ bool imx233_us_elapsed(uint32_t ref, unsigned us_delay); | |||
54 | void imx233_reset_block(volatile uint32_t *block_reg); | 54 | void imx233_reset_block(volatile uint32_t *block_reg); |
55 | void imx233_enable_usb_controller(bool enable); | 55 | void imx233_enable_usb_controller(bool enable); |
56 | void imx233_enable_usb_phy(bool enable); | 56 | void imx233_enable_usb_phy(bool enable); |
57 | |||
58 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
59 | #define CPU_BOOST_LOCK_DEFINED | ||
60 | |||
61 | static inline bool cpu_boost_lock(void) | ||
62 | { | ||
63 | bool set_cpu_frequency__lock(void); | ||
64 | return set_cpu_frequency__lock(); | ||
65 | } | ||
66 | |||
67 | static inline void cpu_boost_unlock(void) | ||
68 | { | ||
69 | void set_cpu_frequency__unlock(void); | ||
70 | set_cpu_frequency__unlock(); | ||
71 | } | ||
72 | #endif /* HAVE_ADJUSTABLE_CPU_FREQ */ | ||
73 | |||
57 | // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef | 74 | // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef |
58 | void imx233_set_cpu_frequency(long frequency); | 75 | void imx233_set_cpu_frequency(long frequency); |
59 | 76 | ||