]> asedeno.scripts.mit.edu Git - linux.git/commit
ASoC: core: Don't schedule DAPM work if already in target state
authorJon Hunter <jonathanh@nvidia.com>
Fri, 17 Aug 2018 15:35:43 +0000 (16:35 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 3 Sep 2018 14:18:43 +0000 (15:18 +0100)
commite03546ddd3db5352a74dec247dbdaa29889e93f7
tree854a1c79ce94a268127a5e0efbf6a5ba77d77b41
parent85e16fdd2f25ef6b08b4275acd5f60fdccfe0973
ASoC: core: Don't schedule DAPM work if already in target state

When dapm_power_widgets() is called, the dapm_pre_sequence_async() and
dapm_post_sequence_async() functions are scheduled for all DAPM contexts
(apart from the card DAPM context) regardless of whether the DAPM
context is already in the desired state. The overhead of this is not
insignificant and the more DAPM contexts there are the more overhead
there is.

For example, on the Tegra124 Jetson TK1, when profiling the time taken
to execute the dapm_power_widgets() the following times were observed.

  Times for function dapm_power_widgets() are (us):
     Min 23, Ave 190, Max 434, Count 39

Here 'Count' is the number of times that dapm_power_widgets() has been
called. Please note that the above time were measured using ktime_get()
to log the time on entry and exit from dapm_power_widgets(). So it
should be noted that these times may not be purely the time take to
execute this function if it is preempted. However, after applying this
patch and measuring the time taken to execute dapm_power_widgets() again
a significant improvement is seen as shown below.

  Times for function dapm_power_widgets() are (us):
     Min 4, Ave 16, Max 82, Count 39

Therefore, optimise the dapm_power_widgets() function by only scheduling
the dapm_pre/post_sequence_async() work if the DAPM context is not in
the desired state.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-dapm.c