From patchwork Wed Jun 19 11:35:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167223 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp500487ock; Wed, 19 Jun 2019 04:35:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxtg2TPRSrEiNYavL+XsHKekvdmE9w7jfgM+7+731GFdiOSS2X3g+Xe+QRzcmb4PMbcPEvk X-Received: by 2002:a65:5302:: with SMTP id m2mr7334557pgq.369.1560944155390; Wed, 19 Jun 2019 04:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944155; cv=none; d=google.com; s=arc-20160816; b=GFUwYmwQ2+jTiXhwUQw81h/mZmGgNENTPzpPeg+1IXhxqdh9sYj9cC4UcSbeEHlOmI i0tH2g1K0cdIEGjKyY4bru6UR9kkvdHSFV0aojUwDq987NNVFq4SRmq7zdxIe+Mun2m4 7D2pWD3i0l2CkOvoPXJAY95YCd+wrmSustARmthDV6veqM0IqJZEj2/XUjLugsZYgw3N /CPbJo7pieP0Vihb8oQ3QCNjNcDXDamlE1fLSM9qn2Flw5dimiPUvLx3hN0g5dr1wo/Q p8viePFROVfQHzKT+qLIzsZauakFSNPKqfH3G1xIbcapbNKhaUhgRYclVMeTq1bRL0Nr jXfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FbHOn34+83W+J2f3XHDBG84b3Et0zmkMSETpfTN9TuM=; b=ryWiI/pcnnNRC5X4mS4C89wQduacz5qjzVx4L/lltqdH/JrXtiqE37UgvALEV0OBRD 52KP1gAUnRcGC1HQ6NkBKuubRLen9nwLcXcmglhTecSJCjvqsNgZb0zf1oSXcDxwrwVg m34SzBX3Ybis9dmg2V/GaFXTMIkBw7hKJyeyqEdaQsEVLl16XmlQ23DG44NbJKW7i638 K3mp/hH0Fd2C3g8y85HfKqfFMLBmzjQ/EZ2r/9DiWWACz8O5D6bfep4fIomImKApU9U1 7U7X+9fCqj/4BU9KiKHLnOugC39F+0QICSYP3clxSs4n3xLKj57VyEpP4U8n2RUi1y60 diSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kxQEEkAR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p5si14892887pls.163.2019.06.19.04.35.55; Wed, 19 Jun 2019 04:35:55 -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; dkim=pass header.i=@linaro.org header.s=google header.b=kxQEEkAR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731689AbfFSLfx (ORCPT + 30 others); Wed, 19 Jun 2019 07:35:53 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33276 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731678AbfFSLfw (ORCPT ); Wed, 19 Jun 2019 07:35:52 -0400 Received: by mail-pf1-f196.google.com with SMTP id x15so9598014pfq.0 for ; Wed, 19 Jun 2019 04:35:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FbHOn34+83W+J2f3XHDBG84b3Et0zmkMSETpfTN9TuM=; b=kxQEEkARyeojCDFzYuUzvewk7k5NUoW6fOXRw1fAAx6pBEVaVHsSoG8181u8HnoUQR HCjSIYu4FDMdSwO9QBQ93ghJTvXQDRKOrxOtSZOl5PhFiiFU6XwXd5O8bak1li6slYht j7bdEzNIX25FMM2uw48OrNOWIXoFOwV4QbyMGJ2c5X6VGC1byZeaSeNgniZzuomvyMeP wg/5VA9N7vddpB/zl4Gn4MzYwj8Opeas3K04pBMwCaHvvk44VigdHc70Ckg6SH1QfY2F LI2WDPgEQokwMwp8Kj9Uzpoz+jkMOtbJ1IjU9IwjcE33zLlMikRaHo66K67Qmri+abuV 2dYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FbHOn34+83W+J2f3XHDBG84b3Et0zmkMSETpfTN9TuM=; b=jLTpwhytZTkeKX39dCqVC8UvIojESPVTT0DfoXqf1f3ORK7SfiV0E9yHnCHuuWMbJu doI8pJSFJfxFNSpN9k830S8C4Qly8HrYdmhFPCiYMJIaDJw700x+dHzeBAnoy2PSdKp/ JM3ty4YPC7tDtcSkF2ZuL+TcRuVyrhM20e0/297y2CkMfTFOgMemUYKuGz6G1asyahvV Csmn4ocBZeJ1KrGXP5dF5aSszV2jESTRre1S3yPIbGTq+cnDnVbj2dK5MlekcNzmZ2Aj y4U9X0w4hNA2G7jynH/wkmCt0TvYbtY4P3mPTX+Jprui4Yzpni43L4GcduMNo1pzOzr7 +PgQ== X-Gm-Message-State: APjAAAUl36Vk40l2rVf6LmZTKzeXOL5zbb7YIgckiB4GsY0KvIYIdRyQ VT9vYFE08pGeTyoDgSiksHdjXQ== X-Received: by 2002:a62:2b81:: with SMTP id r123mr82588812pfr.108.1560944151327; Wed, 19 Jun 2019 04:35:51 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id y22sm38252952pgj.38.2019.06.19.04.35.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 04:35:50 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 1/6] cpufreq: Remove the redundant !setpolicy check Date: Wed, 19 Jun 2019 17:05:37 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpufreq_start_governor() is only called for !setpolicy case, checking it again is not required. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 85ff958e01f1..54befd775bd6 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2153,7 +2153,7 @@ static int cpufreq_start_governor(struct cpufreq_policy *policy) pr_debug("%s: for CPU %u\n", __func__, policy->cpu); - if (cpufreq_driver->get && !cpufreq_driver->setpolicy) + if (cpufreq_driver->get) cpufreq_update_current_freq(policy); if (policy->governor->start) { From patchwork Wed Jun 19 11:35:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167224 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp500556ock; Wed, 19 Jun 2019 04:35:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqymjwy/Iynqf+9d+apugAJVIAIK/D8wUphFYV5xd/cfGm7Cu0gVTWqczlne/5E/WCH/09hY X-Received: by 2002:a17:90a:8c82:: with SMTP id b2mr10490182pjo.97.1560944159224; Wed, 19 Jun 2019 04:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944159; cv=none; d=google.com; s=arc-20160816; b=INvyQfEGoYGUXVP+5f3ElYFksVeovNX1nRpmBa0sCqho/+Wk/C63dc99wHXrvtwvIt GoE2TEHOHXk7c4RFnLCsWKX5KRRxFYT0sb6T2qjIkMfOSDdUz2ftYOzHSfg1q9YDYdyu ccQ5CJ0lXOMmRJw2OuyaUlpYOVkKludDFbejzjIyP7/HVoKLdJl94d9Xe778leLnJS2k uKKwCdvgGYob5Ht6vkwrqA39eQqTBLpjYwe/JIdZmp7DUGtFp8nVAglZVwFPcMnp3GJ/ /TfP+lkki5cpuevPD2cXXTCCc8aG0qsXk9l0TRsZMDB95sJS3Z6IVeRisSKjRuH64/+g UH0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WHo+CK98Hk560A324w9NgmPfYqiucAAoOc1YvZRRmoc=; b=KniALnjHMWbDMtmHQtX1AEgBsBzuAQPWil6cYaS4Nkl6lQ3qC4znz4pFMl3SNcwtXu nzon/Bma/D0Ey0wsvHDse2NyQ7MHlemxxPwlwSUhJ8PTLLXpZ9GSjsXZw4mEcBOuY8oy UUYidbWfaiZCQndkd/4dgkYs/DuGXpwFlOMZ50trXZ4iUCPLUt7zMyPaHt7lKIZuoiBj 5JVbMwN3XwdptLIVsWjX6OT4DOHJ/2Teunu9iB8K5HeVaj/WWcpqvTRy0ygKpRVKfKZ0 bGdW5KQocZPtj6/1s+bAwcDeVt12tTNKJHj+3FyTu9/vNocY43ULfUE9PNouWXTQ+CET Wb2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OiuBJyYM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si1551643pgm.219.2019.06.19.04.35.58; Wed, 19 Jun 2019 04:35:59 -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; dkim=pass header.i=@linaro.org header.s=google header.b=OiuBJyYM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731694AbfFSLf5 (ORCPT + 30 others); Wed, 19 Jun 2019 07:35:57 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33280 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731678AbfFSLfy (ORCPT ); Wed, 19 Jun 2019 07:35:54 -0400 Received: by mail-pf1-f193.google.com with SMTP id x15so9598077pfq.0 for ; Wed, 19 Jun 2019 04:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WHo+CK98Hk560A324w9NgmPfYqiucAAoOc1YvZRRmoc=; b=OiuBJyYMUwp7Feymf81ldAOyO51jCbmcCR+ngPCLcmMfJHERBLuEK/NtPFeN8+K+6T 5/0SjsluzJJsesg4+W5STJStN4hWNLIcBT1aCRImcHUGxT3RG/6WbQ5aLsJR13ptzBpD p+QEtCFBEOATUSVe2ryWCzsoIeDaI39Bm7GB0aMEfN6LG2nFoW2+vjpRABHRvUTCdlQy UYrE3MLG4Oosu0hnZIIBU8BwsjW479JrJxmnoQZ2dcvYeSFh2hoGcACQ4peHEKnfsiTW FXNHd+kydKJOwYyrxFX8yxTIV+2HiZ/7KSpYEGXw8jhg6+fMMEtFImqU237wWKj+1wQN N+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WHo+CK98Hk560A324w9NgmPfYqiucAAoOc1YvZRRmoc=; b=ZFwC4UGTPNI2i1xsnkSCgZb13RqbWx27TstZiGQvSfq+l+vhST445VadyowacEoV8z tVv/GilAvCq/tv+60Bif25Fw9KTe5VpSqOmIWeTlbCCS2hKbkY/CNEGpHyfO+mvM5gTg zaP5ya1zVy+quPm3VLB7m3n4nUNPSz3EWtr9IoXODCxCOS6wKVczNAnxp2tsKtKabBKV Jo5V3K4fxtux0gIHLOFtMkHVKmTZAgmaUfyiJ1jKHz/tzMn6Sv73lvU50jIBGvOEsCG4 h2XHVQEZlk8DsOHqzBztsDUgvCxmc6JzTs7lqOqnZLnK8ETUd3ZP0/5682UTALIxkmeF qJFw== X-Gm-Message-State: APjAAAWiFQ00QaQjSq62Q7y7YXQREiH6aTfxzD9o/kVok7wEiC7YZQ72 3lyzH6jg/957Wofx8sU5j0CkEg== X-Received: by 2002:a63:6f47:: with SMTP id k68mr7245648pgc.327.1560944154053; Wed, 19 Jun 2019 04:35:54 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id d9sm19205662pgj.34.2019.06.19.04.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 04:35:53 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 2/6] cpufreq: Replace few CPUFREQ_CONST_LOOPS checks with has_target() Date: Wed, 19 Jun 2019 17:05:38 +0530 Message-Id: <0660b023a0d80c63ec7a1f7fcb692de9a9f4d604.1560944014.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPUFREQ_CONST_LOOPS was introduced in a very old commit from pre-2.6 kernel release commit 6a4a93f9c0d5 ("[CPUFREQ] Fix 'out of sync' issue"). Probably the initial idea was to just avoid these checks for set_policy type drivers and then things got changed over the years. And it is very unclear why these checks are there at all. Replace the CPUFREQ_CONST_LOOPS check with has_target(), which makes more sense now. Also remove () around freq comparison statement as they aren't required and checkpatch also warns for them. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 54befd775bd6..e59194c2c613 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -359,12 +359,10 @@ static void cpufreq_notify_transition(struct cpufreq_policy *policy, * which is not equal to what the cpufreq core thinks is * "old frequency". */ - if (!(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { - if (policy->cur && (policy->cur != freqs->old)) { - pr_debug("Warning: CPU frequency is %u, cpufreq assumed %u kHz\n", - freqs->old, policy->cur); - freqs->old = policy->cur; - } + if (has_target() && policy->cur && policy->cur != freqs->old) { + pr_debug("Warning: CPU frequency is %u, cpufreq assumed %u kHz\n", + freqs->old, policy->cur); + freqs->old = policy->cur; } srcu_notifier_call_chain(&cpufreq_transition_notifier_list, @@ -1618,8 +1616,7 @@ static unsigned int __cpufreq_get(struct cpufreq_policy *policy) if (policy->fast_switch_enabled) return ret_freq; - if (ret_freq && policy->cur && - !(cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)) { + if (has_target() && ret_freq && policy->cur) { /* verify no discrepancy between actual and saved value exists */ if (unlikely(ret_freq != policy->cur)) { From patchwork Wed Jun 19 11:35:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167228 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp500861ock; Wed, 19 Jun 2019 04:36:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwK+8E01oc9y/a7qKWnm0D9dy8PU2ZcqDVJoZkQcj6A03mjwba4yBkZlAYslnw/GgVPbTMI X-Received: by 2002:a62:1652:: with SMTP id 79mr61937695pfw.20.1560944176706; Wed, 19 Jun 2019 04:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944176; cv=none; d=google.com; s=arc-20160816; b=NIvWYcQM1QsPBYFQPrQ7jIcEgeffmxrvX1mGKAOnjdTjswDO61bTWXMWaDiqAC7Uew 1XX2+troqpz3kmO+ljXgAfTF1cU+2MIK32WCvhkCBDJQiNaKWYFaK3VoUk9RzjTb/cmF aRGinEIrB0cT3rYriYwH/Zm3qNpHndLfzXkAon2xraXO9JNxS/Vh2HZOxRr6EBuTYnkF /izXIKFzawPcs1Db7LkDRKDHHz/1Q23xazJpIGgNDNzheAYVgwV+635JYU7yePkz+EmF pzG+Qf6oPh635NlREsP7gBkUqHIndkkI0hCxNyxlY/YvjCay1zqLekrhUefJt7llL9ku mOfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gOLcTvq7r2YFvtxjS8uMzw6EOaoZ+9nef/zKHoqPhZQ=; b=UT1nTNz8/37YLzLOXbicpbR7PevWsB2StLhT+GjVrExKz8S0kjR6ZRi3/5bL9pyy0Q JnL4/IXr6qvvIh3P5yNvaHkfleG9aKh8CdTUSs1A1QgJ0Sayd2U87JmLtZ1yhN3SMJaq S5K8QVssEOcy0uGl7IJD+c/FKrXyuM+2TP392CD+zIfU8wlNUV7fXkBjD61zUd/IO2NI LmI2Ba3Q427P0E9uwyV52mU0Tluy+IkQzwtQkm8M2FjzI2erlWBv+0q5gN7PGI294RMH irEWVziTI3aXNB5LsAbxbJVy4bbAogxNbl7sYSCLI7wEQRZ5H43WRu36KZfwh58p4WD/ 8jWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NcK4VqWs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si1158864pjp.26.2019.06.19.04.36.16; Wed, 19 Jun 2019 04:36:16 -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; dkim=pass header.i=@linaro.org header.s=google header.b=NcK4VqWs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731717AbfFSLgB (ORCPT + 30 others); Wed, 19 Jun 2019 07:36:01 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43934 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731706AbfFSLgA (ORCPT ); Wed, 19 Jun 2019 07:36:00 -0400 Received: by mail-pg1-f194.google.com with SMTP id f25so9496465pgv.10 for ; Wed, 19 Jun 2019 04:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gOLcTvq7r2YFvtxjS8uMzw6EOaoZ+9nef/zKHoqPhZQ=; b=NcK4VqWsbDFm9dietxUlHlc5OUPdr+DQm+9coLpsk4HrrQuKIwtiLCP0nVmCq/4VxJ NYqlr4K3ecz0zAtEiXQxQGhs1ksmfHu8IqjpJen1hRiOwHcGOueF2ef4xdBEL4y3H91i sJnc9IOrjoJ0KUO3Fs+I3UwUByYtjIKZJLeiAEGqpSD886CVu+23TlrogwrN/fhOb/EH zlto37kC+Cvu4LHB5ca+VIAY58mEfPNX3xHmmCoaHMy4SRFHzqKeBeeMT41qTnPn86sr fpKWziov0JvlaRgldzqEQJOoG18VV58hA87r7Qr63dvCjvNF8RWuGWK/KjU2wSOLo7m4 12xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gOLcTvq7r2YFvtxjS8uMzw6EOaoZ+9nef/zKHoqPhZQ=; b=h2lbXuE/JkHbIMcyAgiHZenMB9LI1nkc/ffDCRYANkYm8eEdvYCk6U9V6OFqmL/zO8 c/DCKslYyy2B3zi+Q2XEMMfH1yWafRi5ncYKbffKlDA9fnAkEibuONFgRGgQWOaKAqXt 72nLMVbh5gb9ZZP/1bc4nH1LzNx9kFuSgvM+W1+snLWIIwa7rKvjhNOUaBZ6O0vJq+as 64t5jXh6WZt/nxDTYQNfV6PFYqz/regOKhiD3Qs4AyVASB9QM1RTObLZ/RNGrAiE+ICb oZZmt6sI9IfRrqaaywIwote7e3wqYTmmHPt8Ri4Rpkj+cQYm+LPLDU5sbdJPEF7lj0Pk rnbQ== X-Gm-Message-State: APjAAAUwu1MLRRgk+BMiY79MQyyd2rca0jEJJWTufUjjGYzmyhwqjr51 kjzBRsQeklKqKU5KktwPisqdxw== X-Received: by 2002:a63:445b:: with SMTP id t27mr7352195pgk.56.1560944159424; Wed, 19 Jun 2019 04:35:59 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id 11sm17459849pfo.19.2019.06.19.04.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 04:35:59 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] cpufreq: Use has_target() instead of !setpolicy Date: Wed, 19 Jun 2019 17:05:40 +0530 Message-Id: <8c563c8f3515ceefd88875160302b6fd472c3dac.1560944014.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For code consistency, use has_target() instead of !setpolicy everywhere, as it is already done at several places. Maybe we should also use !has_target() for setpolicy case to use only one expression for this differentiation. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 41ac701e324f..5f5c7a516c74 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -632,7 +632,7 @@ static int cpufreq_parse_policy(char *str_governor, } /** - * cpufreq_parse_governor - parse a governor string only for !setpolicy + * cpufreq_parse_governor - parse a governor string only for has_target() */ static int cpufreq_parse_governor(char *str_governor, struct cpufreq_policy *policy) @@ -1301,7 +1301,7 @@ static int cpufreq_online(unsigned int cpu) policy->max = policy->user_policy.max; } - if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { + if (cpufreq_driver->get && has_target()) { policy->cur = cpufreq_driver->get(policy->cpu); if (!policy->cur) { pr_err("%s: ->get() failed\n", __func__); @@ -2401,7 +2401,7 @@ void cpufreq_update_policy(unsigned int cpu) * BIOS might change freq behind our back * -> ask driver for current freq and notify governors about a change */ - if (cpufreq_driver->get && !cpufreq_driver->setpolicy && + if (cpufreq_driver->get && has_target() && (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) goto unlock; From patchwork Wed Jun 19 11:35:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167226 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp500685ock; Wed, 19 Jun 2019 04:36:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBXVe2Ox7IWnvcRfQPMk+jQ/KdDDQXpFURv9MHy+BLMQ2Z43h37E0lH5YrxfxzVsO+VbOl X-Received: by 2002:a62:e71a:: with SMTP id s26mr78861190pfh.89.1560944166678; Wed, 19 Jun 2019 04:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944166; cv=none; d=google.com; s=arc-20160816; b=bPxTPmzsf+c4XgD5kk11GDfWBaIq+yARhMZvLs+zzEHgrjyVAR5aVw5uHr8B7+PshV EZZfSPNz0f7MMhGBZ8+REEdpIFiZo2GzrhhF/Gx4l5ez5SnpUCQ8U5hau9A7BCSbzFso 82Pp/+Fdd0kmaoAM2hns64WlXuPsHn2b/Yel0O+GXo9ZhZ0RvlyV9DQIu12t3VfmeYl8 rEksTDJJnhm/pRca7vk4SEwzEq2mxIdMcEjvX5U6HumE8XD7I+k449kXmY0ezgz3Kuxp yUKN6IN/u/ohO0IZRLsJR6zkkXkua8ZJtzBpEDbChLLXW1Hpn2Ubt4uBFywFPh+vWNrY qr4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TMflq8N+0gjwZQm7aaR4fEWjevpmJ2Km/I3/aGC/zcs=; b=Bg5oV/YsK0J06fnXeTzZYdM7L3r1FuRfTeAsfyyCwJ6L05Tfg2XmjHTKu74db+XUPQ +rqP9Vhs4ZyXDdXOWJ0RQMPKDKdGbJF5lLKNOzBuNeo30uKtGjGl3SWbcDfxTO4NhW89 9e5IqZtHSMAX39wDtoDWUkr6ocJ8AizbHbhtX+gFEsG4bXovZ+kCxVYJ5/qhiXF3+og+ zTdUZOO58CA+tc2eYUjms8T2rPLcD6eqSlyvMrsdllxCB6CuWqZi8U1ea7RkDRrV8nJ2 otD4KM6ZO4C+JNzA+rxW1ptpOVt6JMCeZOGIlNYxNsPEa2Sb0I4MVJrbc9GkgZdSIxVn BwyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FdhMZ5VF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si2866146pgh.51.2019.06.19.04.36.06; Wed, 19 Jun 2019 04:36:06 -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; dkim=pass header.i=@linaro.org header.s=google header.b=FdhMZ5VF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731741AbfFSLgE (ORCPT + 30 others); Wed, 19 Jun 2019 07:36:04 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33546 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731730AbfFSLgC (ORCPT ); Wed, 19 Jun 2019 07:36:02 -0400 Received: by mail-pg1-f196.google.com with SMTP id k187so9517726pga.0 for ; Wed, 19 Jun 2019 04:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TMflq8N+0gjwZQm7aaR4fEWjevpmJ2Km/I3/aGC/zcs=; b=FdhMZ5VF0ZlGiskIF3jgzAyN072YIAf8CvQqewDd0mnEaGbolSAhEnuX5Cq4LC5zRH aM31xTVnkg/TW7axh+cs9Fv1mqqGwLcliyaPdxkndf1u8/v1fc8dTAFuywqoCTp6QaLg 1QC1rXXUqHbJzrxS/e1mHKXet73M40N7pRUVBDVWIPaXoveXLHOZlNtBQM9lLKigUjMi YJZQuUY8NO6X4y28v4rZ0+exHioxdYQBGU4gzqp1Rp5Bdv4BopUg/slx70RceyBLWPrl 5pk8DEg5vDKH/ADqzJCnW0631EQGKVXqwnO41gTFGtOQJeZKB8RYvk26d89wm4YcT7gw Td4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TMflq8N+0gjwZQm7aaR4fEWjevpmJ2Km/I3/aGC/zcs=; b=t7MvC1iOUafpv7xC6n95Oylrb7iTyuu4JnEROxTWaTDcq35Oqtri5m1t79LiBdLCsq b8rjUnDRHN1imDxCQmz45rFuR8DqBF8zarmD6o5ltURlHikQ0zQmCVI6xVnWTwv1l+u+ qpHK22LbLYmKbBQFkwLzaLlYyef7J/+BO/bZhE9NS11hXS5m5HJWaK9arqECeS64SlbT XpW8CyfsVjjtmweiOM4S3DOaVE1KewafIcqBlnbEzsFosCZDBkxCW9nRdZaoOPEdj4bI b5F7oBsI4SMVN7q1tvrlaFG7Xtr2SKBJGBvpsBYBnz3AldAv1C6jV7++QZDbBzZ3wSMa XEDQ== X-Gm-Message-State: APjAAAUI5RvGMK7B/DKrXwDpNuBu+z07DTCgwz84r+0yMbWcZueM0ZIZ iISAaQNeuQt26Y+B11FvRO85Lg== X-Received: by 2002:aa7:9a8a:: with SMTP id w10mr9164646pfi.66.1560944162249; Wed, 19 Jun 2019 04:36:02 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id s24sm18124738pfh.133.2019.06.19.04.36.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 04:36:01 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] cpufreq: Reuse cpufreq_update_current_freq() in __cpufreq_get() Date: Wed, 19 Jun 2019 17:05:41 +0530 Message-Id: <3887524d339664c31b763963f1b34bda490cb1ac.1560944014.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Their implementations are quite similar, lets modify cpufreq_update_current_freq() a little and use it from __cpufreq_get(). Also rename cpufreq_update_current_freq() to cpufreq_verify_current_freq(), as that's what it is doing. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 70 ++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 42 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5f5c7a516c74..4556a53fc764 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1547,6 +1547,30 @@ static void cpufreq_out_of_sync(struct cpufreq_policy *policy, cpufreq_freq_transition_end(policy, &freqs, 0); } +static unsigned int cpufreq_verify_current_freq(struct cpufreq_policy *policy, bool update) +{ + unsigned int new_freq; + + new_freq = cpufreq_driver->get(policy->cpu); + if (!new_freq) + return 0; + + /* + * If fast frequency switching is used with the given policy, the check + * against policy->cur is pointless, so skip it in that case. + */ + if (policy->fast_switch_enabled || !has_target()) + return new_freq; + + if (policy->cur != new_freq) { + cpufreq_out_of_sync(policy, new_freq); + if (update) + schedule_work(&policy->update); + } + + return new_freq; +} + /** * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur * @cpu: CPU number @@ -1602,30 +1626,10 @@ EXPORT_SYMBOL(cpufreq_quick_get_max); static unsigned int __cpufreq_get(struct cpufreq_policy *policy) { - unsigned int ret_freq = 0; - if (unlikely(policy_is_inactive(policy))) - return ret_freq; - - ret_freq = cpufreq_driver->get(policy->cpu); - - /* - * If fast frequency switching is used with the given policy, the check - * against policy->cur is pointless, so skip it in that case too. - */ - if (policy->fast_switch_enabled) - return ret_freq; - - if (has_target() && ret_freq && policy->cur) { - /* verify no discrepancy between actual and - saved value exists */ - if (unlikely(ret_freq != policy->cur)) { - cpufreq_out_of_sync(policy, ret_freq); - schedule_work(&policy->update); - } - } + return 0; - return ret_freq; + return cpufreq_verify_current_freq(policy, true); } /** @@ -1652,24 +1656,6 @@ unsigned int cpufreq_get(unsigned int cpu) } EXPORT_SYMBOL(cpufreq_get); -static unsigned int cpufreq_update_current_freq(struct cpufreq_policy *policy) -{ - unsigned int new_freq; - - new_freq = cpufreq_driver->get(policy->cpu); - if (!new_freq) - return 0; - - if (!policy->cur) { - pr_debug("cpufreq: Driver did not initialize current freq\n"); - policy->cur = new_freq; - } else if (policy->cur != new_freq && has_target()) { - cpufreq_out_of_sync(policy, new_freq); - } - - return new_freq; -} - static struct subsys_interface cpufreq_interface = { .name = "cpufreq", .subsys = &cpu_subsys, @@ -2151,7 +2137,7 @@ static int cpufreq_start_governor(struct cpufreq_policy *policy) pr_debug("%s: for CPU %u\n", __func__, policy->cpu); if (cpufreq_driver->get) - cpufreq_update_current_freq(policy); + cpufreq_verify_current_freq(policy, false); if (policy->governor->start) { ret = policy->governor->start(policy); @@ -2402,7 +2388,7 @@ void cpufreq_update_policy(unsigned int cpu) * -> ask driver for current freq and notify governors about a change */ if (cpufreq_driver->get && has_target() && - (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy)))) + (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) goto unlock; pr_debug("updating policy for CPU %u\n", cpu); From patchwork Wed Jun 19 11:35:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167227 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp500726ock; Wed, 19 Jun 2019 04:36:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAmfm1hd+tPUgs0U7tyQVvuBx5WMbo3EqiRP2/IXGvEU9JL4Om8tfqPtVkFW+l2PcQ+ILM X-Received: by 2002:a17:90a:35e6:: with SMTP id r93mr10787550pjb.20.1560944169337; Wed, 19 Jun 2019 04:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560944169; cv=none; d=google.com; s=arc-20160816; b=tdJ+Z4aOv7GRpLuIK3WcK78YIDvo8Zpb2Vra+/+j4CA16jJ4tEQ17EwQmYPI2BHlVV WXqXNK2ydl4tU8L0kQhyMgbGwiVy6OUr5GMw6QpryLULir6Obttyi1u2D7OijBdnNkcg DctwtT1iE/oOe1KdNr4AIqbzKD+DzcvbqtCcryJ20IBhSsgjCkt94wdq5oRPGqz2ev6H c91s5bgpwzSxyobJqfrRcPyS4lakU/iXvhc2CzeCcaA5DbS959kEJ/D81Suv6VLlIHgE Ll9hKPvAi7qzVulvUPuOOPcCOuMnCYlhlNuWvrt6JtnY6+KQVHnE6jEw4PBRYKlc4xku JegQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e2RYmyEcM16uV8QAfPAD1VnbVzdNHH04eTPp0y1GpdE=; b=psXIl0hga4sSxOKhKOThfNaFkRepzpPtAEs69w2RgOb9es62qVNCw1bkl0WC2GjOWA 8sqKbWPV4A1FVTjUxmAreL3gEO7cuVTpKbKN+GZf8D4H6poqnmcQfAhVKNrLZGTJdkRE qCMS0Dy5R/p7Qe9q7r9JJelhGU4WsHGdtr+djhs28MlWmumpZNMhi9Fn5CnHYyeEC/3Q e9Ts3n0NjaNfdZOxOtZhKMskjBilv8hho/P2u3jXM+cXjei/zkC/NzXG6gzodFcj2IKb 5nkDdaRKvEPDTbAnvo1d+Wf1EmSB07LR1VBgIkAS/+mlnNgTChli79X0gu6Uu4nXn9bp KzDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zVOW+9TL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si2866146pgh.51.2019.06.19.04.36.09; Wed, 19 Jun 2019 04:36:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b=zVOW+9TL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731754AbfFSLgI (ORCPT + 30 others); Wed, 19 Jun 2019 07:36:08 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46403 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731743AbfFSLgF (ORCPT ); Wed, 19 Jun 2019 07:36:05 -0400 Received: by mail-pg1-f196.google.com with SMTP id v9so9484509pgr.13 for ; Wed, 19 Jun 2019 04:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e2RYmyEcM16uV8QAfPAD1VnbVzdNHH04eTPp0y1GpdE=; b=zVOW+9TLBbgrCy2ayvjj309DIcUy8Isl/jbni4YWmZwpa+P5KsEELYytIxnt+FC7lN dDsV4tWAtwZiyVyrcwibduuryY73DML3oL+dlnFKX+O2yiB7+uKgJUHzq7RV4o0MSLL+ cfFGac3xplbC+SP8kybt1kOHadOCK3YHUuu26GtorIEgRQzgGrHiZrYimgKcRu26O9M5 JykjfOtKMz31ughKph5Z5CLOp9fCVHt0gr2FUa7kaYmTFh9vXWEPmVWbuSJBE34GL15q d+YVPOmbAUrZM1jmDKiRuYvMxBgj2M/M72J/cSgtofN7h7Y2x0W6Lj35CdJcRtqjdOwV kBew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e2RYmyEcM16uV8QAfPAD1VnbVzdNHH04eTPp0y1GpdE=; b=VVpaFpfmChrPMNwroi9QBpO+Y28MsGclEzMht0Kl21o6BEiaBqJI4WynJka1srHRoX CcgjmKjjRYaVF+vRa7+3zs/fYG/FajMtrNwVR+/3Dn7PoPn90b36ld71ukOonVY12ppN U+/GobWZK1qfjiBKxkD8mmR16DbYIYkccSKmrIb7b+twXM7d7K2Bs1EQuiLyLOuuVnQi NUQVhl7H4kJmsU8qnovmDo/kAMK2AxMhLEVwFlbE4IDV1JzwC3pUYhYpsHfODXZZFUYP 2KWablcBpTI1EzoUGzuHL3JhDddDDbaf8CF7W/u/1eVqlelJgqVNdlmtL+LHW23Ce9WN djBA== X-Gm-Message-State: APjAAAUrl8ysEWN9gDkh7Yw+6uWURKMiUzYRoEr4V09mk9SVM4USC5LA kBAoFMLYH7oFBrhHtfqQYKWlhg== X-Received: by 2002:a63:1459:: with SMTP id 25mr7319713pgu.201.1560944164850; Wed, 19 Jun 2019 04:36:04 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id y22sm17954119pfm.70.2019.06.19.04.36.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 04:36:04 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update() Date: Wed, 19 Jun 2019 17:05:42 +0530 Message-Id: <5068dd1b268d5beb1c074ca97a3e031dbd560999.1560944014.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some occasions cpufreq_verify_current_freq() schedules a work whose callback is handle_update(), which further calls cpufreq_update_policy() which may end up calling cpufreq_verify_current_freq() again. On the other hand, when cpufreq_update_policy() is called from handle_update(), the pointer to the cpufreq policy is already available but we still call cpufreq_cpu_acquire() to get it in cpufreq_update_policy(), which should be avoided as well. Fix both the issues by creating another helper reeval_frequency_limits(). Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4556a53fc764..0a73de7aae54 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1115,13 +1115,25 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp return ret; } +static void reeval_frequency_limits(struct cpufreq_policy *policy) +{ + struct cpufreq_policy new_policy = *policy; + + pr_debug("updating policy for CPU %u\n", policy->cpu); + + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + + cpufreq_set_policy(policy, &new_policy); +} + static void handle_update(struct work_struct *work) { struct cpufreq_policy *policy = container_of(work, struct cpufreq_policy, update); - unsigned int cpu = policy->cpu; - pr_debug("handle_update for cpu %u called\n", cpu); - cpufreq_update_policy(cpu); + + pr_debug("handle_update for cpu %u called\n", policy->cpu); + reeval_frequency_limits(policy); } static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) @@ -2378,7 +2390,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, void cpufreq_update_policy(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu); - struct cpufreq_policy new_policy; if (!policy) return; @@ -2391,12 +2402,7 @@ void cpufreq_update_policy(unsigned int cpu) (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false)))) goto unlock; - pr_debug("updating policy for CPU %u\n", cpu); - memcpy(&new_policy, policy, sizeof(*policy)); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; - - cpufreq_set_policy(policy, &new_policy); + reeval_frequency_limits(policy); unlock: cpufreq_cpu_release(policy);