1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
William Wilgus 2017-10-13 06:28:50 +02:00 committed by Amaury Pouly
parent 428464774f
commit b2c470719a
2 changed files with 34 additions and 0 deletions

View file

@ -53,6 +53,8 @@
#define WATCHDOG_HW_DELAY (10 * HZ) #define WATCHDOG_HW_DELAY (10 * HZ)
#define WATCHDOG_SW_DELAY (5 * HZ) #define WATCHDOG_SW_DELAY (5 * HZ)
static struct mutex cpufreq_mtx;
void UIE(unsigned int pc, unsigned int num); void UIE(unsigned int pc, unsigned int num);
static void woof_woof(void) static void woof_woof(void)
@ -183,6 +185,7 @@ void system_init(void)
* The main() will naturally set cpu speed to normal after kernel_init() * The main() will naturally set cpu speed to normal after kernel_init()
* so don't bother if the cpu is running at 24MHz here. * so don't bother if the cpu is running at 24MHz here.
* Make sure IO clock is running at expected speed */ * Make sure IO clock is running at expected speed */
mutex_init(&cpufreq_mtx);
imx233_clkctrl_init(); imx233_clkctrl_init();
imx233_clkctrl_enable(CLK_PLL, true); imx233_clkctrl_enable(CLK_PLL, true);
#if IMX233_SUBTARGET >= 3700 #if IMX233_SUBTARGET >= 3700
@ -364,6 +367,20 @@ void imx233_set_cpu_frequency(long frequency)
} }
#ifdef HAVE_ADJUSTABLE_CPU_FREQ #ifdef HAVE_ADJUSTABLE_CPU_FREQ
bool set_cpu_frequency__lock(void)
{
if (get_processor_mode() != CPU_MODE_THREAD_CONTEXT)
return false;
mutex_lock(&cpufreq_mtx);
return true;
}
void set_cpu_frequency__unlock(void)
{
mutex_unlock(&cpufreq_mtx);
}
void set_cpu_frequency(long frequency) void set_cpu_frequency(long frequency)
{ {
return imx233_set_cpu_frequency(frequency); return imx233_set_cpu_frequency(frequency);

View file

@ -54,6 +54,23 @@ bool imx233_us_elapsed(uint32_t ref, unsigned us_delay);
void imx233_reset_block(volatile uint32_t *block_reg); void imx233_reset_block(volatile uint32_t *block_reg);
void imx233_enable_usb_controller(bool enable); void imx233_enable_usb_controller(bool enable);
void imx233_enable_usb_phy(bool enable); void imx233_enable_usb_phy(bool enable);
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
#define CPU_BOOST_LOCK_DEFINED
static inline bool cpu_boost_lock(void)
{
bool set_cpu_frequency__lock(void);
return set_cpu_frequency__lock();
}
static inline void cpu_boost_unlock(void)
{
void set_cpu_frequency__unlock(void);
set_cpu_frequency__unlock();
}
#endif /* HAVE_ADJUSTABLE_CPU_FREQ */
// NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef // NOTE: this is available even if HAVE_ADJUSTABLE_CPU_FREQ is undef
void imx233_set_cpu_frequency(long frequency); void imx233_set_cpu_frequency(long frequency);