diff options
author | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-03 19:04:51 +0300 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:33:06 +0800 |
commit | b5c66568664ba7e3639d4d6ad4764af44c29011c (patch) | |
tree | e7754040804799c450b766168bd096ecdc07e8e4 /arch/arm/mach-imx | |
parent | a5cfbd3c18b2ca4ec6ce9e8abc463a498256011c (diff) |
MLK-19047-2 ARM: imx: busfreq: Prevent double reduce_bus_freq
The low_bus_freq_handler can be scheduled again between when it starts
executing and when it takes the bus_freq_mutex. This can result in
calling reduce_bus_freq twice as shown in the following trace:
[ 762.101949] set_low_bus_freq(743): begin
[ 762.101971] set_low_bus_freq(768): schedule low_bus_freq
[ 762.114111] set_low_bus_freq(771): scheduled low_bus_freq
[ 765.125161] reduce_bus_freq_handler(722): lock...
[ 765.125174] bus_freq_daemon_handler(1043): lock...
[ 765.125191] bus_freq_daemon_handler(1048): call set_low_bus_freq
[ 765.125200] set_low_bus_freq(743): begin
[ 765.125210] set_low_bus_freq(768): schedule low_bus_freq
[ 765.125228] set_low_bus_freq(771): scheduled low_bus_freq
[ 765.125239] bus_freq_daemon_handler(1052): unlock...
[ 765.160624] reduce_bus_freq_handler(726): call reduce
[ 765.166952] reduce_bus_freq(685): begin
[ 765.170865] busfreq_notify(159): notify low enter
[ 765.176095] Bus freq set to 24000000 start...
[ 765.182731] Bus freq set to 24000000 done! cpu=0
[ 765.192646] imx_busfreq soc:busfreq: Bus freq set to low mode. Count: high 0, med 0, audio 0
[ 765.203912] reduce_bus_freq(717): end
[ 765.208903] reduce_bus_freq_handler(733): unlock...
[ 768.166631] reduce_bus_freq_handler(722): lock...
[ 768.172386] reduce_bus_freq_handler(726): call reduce
[ 768.186330] reduce_bus_freq(685): begin
[ 768.191310] busfreq_notify(159): notify low enter
Prevent this scenario by explicitly calling cancel_low_bus_freq_handler
from inside reduce_bus_freq_handler.
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Acked-by: Anson Huang <Anson.Huang@nxp.com>
Diffstat (limited to 'arch/arm/mach-imx')
-rw-r--r-- | arch/arm/mach-imx/busfreq-imx.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/arch/arm/mach-imx/busfreq-imx.c b/arch/arm/mach-imx/busfreq-imx.c index d26571682eb5..2cbc033ad07a 100644 --- a/arch/arm/mach-imx/busfreq-imx.c +++ b/arch/arm/mach-imx/busfreq-imx.c @@ -695,12 +695,20 @@ static void reduce_bus_freq(void) high_bus_count, med_bus_count, audio_bus_count); } +static inline void cancel_low_bus_freq_handler(void) +{ + cancel_delayed_work(&low_bus_freq_handler); + cancel_reduce_bus_freq = true; +} + static void reduce_bus_freq_handler(struct work_struct *work) { mutex_lock(&bus_freq_mutex); - if (!cancel_reduce_bus_freq) + if (!cancel_reduce_bus_freq) { reduce_bus_freq(); + cancel_low_bus_freq_handler(); + } mutex_unlock(&bus_freq_mutex); } @@ -738,12 +746,6 @@ static int set_low_bus_freq(void) return 0; } -static inline void cancel_low_bus_freq_handler(void) -{ - cancel_delayed_work(&low_bus_freq_handler); - cancel_reduce_bus_freq = true; -} - /* * Set the DDR to either 528MHz or 400MHz for iMX6qd * or 400MHz for iMX6dl. |