Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp910213imm; Fri, 17 Aug 2018 08:37:27 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxrbNF9JjsgJL8MkFwvyuUunXWlINPUZG16A1o2o13MJkXCszg3pcFdwaqwM7keWZGvgu1x X-Received: by 2002:a17:902:d213:: with SMTP id t19-v6mr468830ply.63.1534520247834; Fri, 17 Aug 2018 08:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534520247; cv=none; d=google.com; s=arc-20160816; b=F7DYmozenl4ItYMMDf4dhWIQeVTVHJ32hYLRtWKl0NGsvRxbEI+xHNJFbDH+IX3qFR 7bGf1acFt6l0c2zF761UBhsguMe83wNASo/BQYduq6W2M1WqlwO9N5/niNCZtiZD1XQb yxQpxKVcOIayfEOdGzKBNOfrFK2mHEd8RnThuDv/49v44nyLu5MdoY2axaC9gFTuTvzQ mwmkgUbn2jRvb6XzMaPmCTRhmVqwXAjmFy8WuS9GfU2oRfzS200tFXVJ3xs/RKbGz3W8 i46Eum+xoE54bc9XSfaS9ITi54xhklbXzH4P6p8S4kwrkDT3Zz/0U4tlzVHE/dzBRkOa XpmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=lDcgJ3waTs8mc0/I5BKAMuCcTlpl9Ena666lYgO2BdU=; b=D9EqINTCLTO64zUjhIQOp1xirNR5WZe2swAmXPdtlvo+7w7yT/bjcbeAunQOgNtwnt /QDZv8gLMBdxKhA4lHy61mxy3JkRZl07DrfnA2lBTLaY9ZAfjMXEid8Y6BVDw9tQR5EQ swUrJdWYpi7ivFpvlPFISCB0lrcciUBUiYdEKSvUTk3J1MxRTOAAmprtlgHTUgMRgVtH 3ZdtRX3/aE7eql0CwUzQtiSVz3gAzz1RP3BwUmG3X/86RJCoo5hkHX3PUWDIJn4bY9NW swB+7VNw5iaCE6PAhe0cuz0+aT1KLBGztBwxh+qoipRnGdyqyFjaKEaaXJ6zEB8TdyF9 h33g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7-v6si2554554pll.142.2018.08.17.08.37.12; Fri, 17 Aug 2018 08:37:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbeHQSj4 (ORCPT + 99 others); Fri, 17 Aug 2018 14:39:56 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:19105 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726815AbeHQSjz (ORCPT ); Fri, 17 Aug 2018 14:39:55 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Fri, 17 Aug 2018 08:35:44 -0700 Received: from HQMAIL106.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 17 Aug 2018 08:36:06 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 17 Aug 2018 08:36:06 -0700 Received: from HQMAIL104.nvidia.com (172.18.146.11) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 17 Aug 2018 15:36:05 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1347.2 via Frontend Transport; Fri, 17 Aug 2018 15:36:05 +0000 Received: from moonraker.nvidia.com (Not Verified[10.2.171.150]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Fri, 17 Aug 2018 08:36:05 -0700 From: Jon Hunter To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai CC: , , , Jon Hunter Subject: [PATCH] ASoC: core: Don't schedule DAPM work if already in target state Date: Fri, 17 Aug 2018 16:35:43 +0100 Message-ID: <1534520143-29266-1-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.7.4 X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 461d951917c0..2e9231aeabb9 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1953,7 +1953,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) dapm_pre_sequence_async(&card->dapm, 0); /* Run other bias changes in parallel */ list_for_each_entry(d, &card->dapm_list, list) { - if (d != &card->dapm) + if (d != &card->dapm && d->bias_level != d->target_bias_level) async_schedule_domain(dapm_pre_sequence_async, d, &async_domain); } @@ -1977,7 +1977,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) /* Run all the bias changes in parallel */ list_for_each_entry(d, &card->dapm_list, list) { - if (d != &card->dapm) + if (d != &card->dapm && d->bias_level != d->target_bias_level) async_schedule_domain(dapm_post_sequence_async, d, &async_domain); } -- 2.7.4