From patchwork Thu Jun 20 03:05:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167282 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1492145ilk; Wed, 19 Jun 2019 20:06:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD13phjb3+TtcV19C3FiqxVZhFx1ubRzXAbPyMUI+3BgOgOzcL8eVIRRVs6dP0u3VcYZTj X-Received: by 2002:a62:1750:: with SMTP id 77mr60613294pfx.172.1560999987050; Wed, 19 Jun 2019 20:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560999987; cv=none; d=google.com; s=arc-20160816; b=imi/eVmO36uDhisV8+URwdePzrHpmx6kVA41TDcJ3KEEwWMsA4xUyUducWACrZSpko 2kKO/QuzrZ9YA6kjXNrIBxdbcVKNxdtSewM4/ICX2gx/bvp0L4oRB0hw8g6yJMaRyQVm pYYhIC7pjP/s9pT9AIpUdarleS82iBFKSMevEHMFA04J2NaXO9VoZJV1xhEzxlVcMjZP CFefVW12byH7tRzlyP63uRBoo3uo4vosakJsm3z5fyK0F6KzJBEtn1ebB/sGMotC+T+r bcGNrHOjg3+XPH/aIcLfneOrMYT+OUTO9wFGUsf/Zv0S2j/Pq6oIzHI7faFvng2cjI2/ O7jA== 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=V/2hN5W7vDiURb+9TeuTf5xlFS50GG9fETsA1MIFuX4zBe2I+1zxea8d1k9kITnth8 ajD1vYl0EBU9JzYLr8QOasY+qmZxYOvi/NgIjIfccS3KFQZ4NoAKXrxOXz9z0AB1hFnf MoDjKasu2nEgdJNapgxQXnPAJD7FDdDY9ofSF70vUHA6X5I3FkRjxQ9jHQ03MZbpZzJF X9vIj3saDAJ1cuCR8HgHhSCB/cT+uRbaXY/ERHIEP6jesqt9gH7R9utxEHeIzTWiU+Bu AtIuRpeQkasYHNrbSPpJ9jcogcUU+0tXfCW+sQyJldkJ4M5kRizZO7pr88e931mh6vaZ MiCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UT17hYIw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 b26si4724943pgw.202.2019.06.19.20.06.26; Wed, 19 Jun 2019 20:06:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=UT17hYIw; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1731307AbfFTDGY (ORCPT + 11 others); Wed, 19 Jun 2019 23:06:24 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44121 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731303AbfFTDGY (ORCPT ); Wed, 19 Jun 2019 23:06:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id n2so747518pgp.11 for ; Wed, 19 Jun 2019 20:06:24 -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=UT17hYIwO07T+JXmCNzUy25KZuNg7TFnGECmDQriV9z5Zc5iK/562PnnVfxwrM6+/z NN9S6GFPYLifZ84Wh7XCcbJGNkV5Y7UWS40WSuZzMCL7Z0Qt34GwRoKObd+F35Ng7MKB D1UOxmySiMuh5cLXRmvJ0EuTneYj6dlX84Fg5tPOac5vsS/WUkniFmlUUTY2F8CnwDM1 NrPVz78uVqELIPnN25wEg7YF4YXExqJvtPk8NbE+K8yrNvtiY47q8cUYa8GpX0KWbK4i ded7OAYwOaUzU6wiTK/rOLNSus+CjQO6rUy5BKlxEdZn8ZA3EkBVeMThnnUkTQDmTfrb OLrg== 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=pU+OEoPMf6C4HnLByy3enS+sDHRXcmV7MR5Gy0PM/UxaCApB1pgh/EQ6u5X14fFvoK nZa5nhUrtM2zqCu5dqEpoEtH5dWYlHasl79FBFp/aEN02PECsM/mTbkko8rya2pt7djO YnkP55ctJJm7edjxmTONusjaBwKUE2P6Lv5q+nrBYHdcaTc5h/eQIsTB3X1ujNZg2RKw +LqGMadEu+a2dPFN7lvyIyNpKSG3vRvVHLK8v/NreAKiLwkJFa9xMb8p8rozw1tVgcSt 5dvQMvUBzrq8KX5lWitCDL5qYK4XJyhF/X0jRL9pMGOchbMiholFNLlqrsCdC/wqgguM rkHg== X-Gm-Message-State: APjAAAWB9a5oUZ3m4YKjNNDNNcdcrd/leA1XjuohmnXgQ7VYWsdMEcpw stt9X4y/518lT70CqboQurR56/ixwVA= X-Received: by 2002:a62:28b:: with SMTP id 133mr5409487pfc.251.1560999983761; Wed, 19 Jun 2019 20:06:23 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id g2sm18949048pgi.92.2019.06.19.20.06.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 20:06:23 -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 V2 1/5] cpufreq: Remove the redundant !setpolicy check Date: Thu, 20 Jun 2019 08:35:46 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Thu Jun 20 03:05:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167283 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1492326ilk; Wed, 19 Jun 2019 20:06:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaW+rlNxx2xvbyYpDvWhjQhavGodo9Rb1hRS22d61l8U//IxFSnKiWaODe6IlOv8AKLHjT X-Received: by 2002:a62:7656:: with SMTP id r83mr101159814pfc.56.1560999998574; Wed, 19 Jun 2019 20:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560999998; cv=none; d=google.com; s=arc-20160816; b=RL2JHnX+URFzmUErtlRQkZ/+vsxJES8JUifCgEsqcGE93Ec9mGBtwL883ojFg7ex5w brUBAiezqD+VSg5tIPGoxLrULhveVRtKolyZWUgK9HZF0lZ+f1bjFq/8yHbP+6nxbAjt Tfci95nHyDstkEWNoSaqTV0nzo8d+p/bzwuqoLsj0mb5Nj1l74coyHj62Gp4ph9nWQVu B9UFEZqiGH+wbCm0lxQ28a9ZtlXwNhmV70Fyr5dNt4mpSKXQI22C1K2EreJ4tHXFA7Gi 3qVS/xxyfAREVx5bl+ItWHuwUdu+6+4YgWZe7nuhXosp+zUAM4kPh+V6EOSRgeOtjQiV 9uvw== 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=p8q7duu3NM5D7B0/JJEPNRH7AiTiNoUPeRHE8XCCFpc=; b=mhaztsw1eNHnGZKcOqyFF+WtDAhAqHKS44DJCCiqfq9EkbKYauL6VR/kYPceJ0Yd3U ydGzpYSnwZ8nuleySttR2Bs8q0SZC+pitvO+vorRYwgSXwuWiYw3qt9GWDfSmsXnYupe BKvHzipr1FxgGD2HN40UuGjou3/o9dt6MhdmDJ0L1I+mAcg1pByahf/OIqlSvTl3ltlH gd5a0FPolrS5LjUbX2SYbu+K4Eso1OkvkWBGexBnJdbz2laAG6vdEmEuaHBi2OfMIDWQ 5JvVstb+u5B+8+s9HwrTfdMJe7uD+t1bAamBR+/nZ9kcgaeVaTC7SzmKETx+QZ6/J/4N g6tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pi9g95KX; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 i22si3040101pjx.13.2019.06.19.20.06.38; Wed, 19 Jun 2019 20:06:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=pi9g95KX; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1731363AbfFTDG2 (ORCPT + 11 others); Wed, 19 Jun 2019 23:06:28 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40184 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbfFTDG1 (ORCPT ); Wed, 19 Jun 2019 23:06:27 -0400 Received: by mail-pg1-f195.google.com with SMTP id w10so757264pgj.7 for ; Wed, 19 Jun 2019 20:06:27 -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=p8q7duu3NM5D7B0/JJEPNRH7AiTiNoUPeRHE8XCCFpc=; b=pi9g95KXO8T2J62vjV8PPB7VJfoSs9c6QwY71RXsD9brl+T2e/1eGRO3sjle2j1XQ+ 79PG7kurlPGO8rSAzq+FCPPsyvxIXduSBxqvxKch5MjoumOWdYsue+oY+ontfPUIRE1d td/3JGqWefy6RUFofSUzIWdRy2ez/S2fkFPNcADiit7knMzt6PmgtaoNaaXHswygLFh3 xCOw1TPLwojNrUEmXwXhclxKxHVYcEaKfCm9aynndRo6HjwdInS2IDrK/FIcUaYaY67J I04Cyu4DqdjbMZI1OZHzFjYUY00KZPKff4relP1bI6YkZ+bB1pnDUaljewOnVXX5gZ7Z gJAQ== 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=p8q7duu3NM5D7B0/JJEPNRH7AiTiNoUPeRHE8XCCFpc=; b=bUj6C1FihLIZs+kjzJrjlRjuzPPzpNOJTl576c1ciT4CwgHyl1Ytqo/vdTLcRBTP/W k5X7RKnuZM6UrajSFxi2oa5MWUZ7yDOEJUBrcRl8n7d6lwnJe7JfiJgkcl5AEsUYjDid eV1QHM2Dwo94T5VZOXgci0M4Si1G7F1J1niUm9IVIYFazI33F+D69z6gwTiv2OGUNfRP QbevJeSKwglK8gXJ0bqaeHV/x/pQlVQVDeuFw3Z0FuzVkAPbAysZI42WbOQYyQZQVBrB 2lMTE8CcnqgqipLMdVgdDrXr4hJ3JnWZ3bLVZSeLWsTsmfVkRF2y9aW+M38cRCSk/jMb 1Q8A== X-Gm-Message-State: APjAAAWe2st3OguR36CNzb79dRPgPNrJJ10BwWNreEFHsI/dVem/cGkd lzF1WQx7lxxQOZZDvyTCKOJjPg== X-Received: by 2002:a62:82c2:: with SMTP id w185mr109064201pfd.202.1560999986860; Wed, 19 Jun 2019 20:06:26 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id g8sm19236053pfi.8.2019.06.19.20.06.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 20:06:26 -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 V2 2/5] cpufreq: Replace few CPUFREQ_CONST_LOOPS checks with has_target() Date: Thu, 20 Jun 2019 08:35:47 +0530 Message-Id: <88da7cfabad5e19a361fe2843e5ef547d50fd221.1560999838.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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. cpufreq_notify_transition() is only called for has_target() type driver and not for set_policy type, and the check is simply redundant. Remove it as well. 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..41ac701e324f 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 (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 Thu Jun 20 03:05:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167284 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1492346ilk; Wed, 19 Jun 2019 20:06:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIcP1CMz3OruTEXQXSViYmkgvbzbgiH+TOzYex/lNSaHABH5IrEP+WNbkqaRIWw5nt2SGp X-Received: by 2002:a62:1652:: with SMTP id 79mr64679118pfw.20.1560999999255; Wed, 19 Jun 2019 20:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560999999; cv=none; d=google.com; s=arc-20160816; b=WCDLhTBIRVyjo1tREo+ShYvN78wVDYuXQVoi+2lnbyFsSXUZGpsQs7NkyA2c5Ub6EP 57cV76Z2MUk2aDz1ZMLSsJx4lrB2TLOkw8PYIl+59CQKMaRVv0qFAsEfJTcJZlt0yNtc JDHaUJCk6OAZidAZsT8yOj0KK2LMm+RQJNgBf6n2H5UHEufib9OXhAEnhJfdA8pPhYYh wg0LUbB3sMShwLCJR52ZIZY9zYm/6FIzS+Jlgpjc/qKnzXhQqWixU3TSijBfmNnsUDPe 3SsSOzAaWYXG1DJKBX6bLb/msI5z0k5QVAG8fXSUSXO8bicYHSlbBCLOuJ1o1bbIztb+ L99Q== 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=V98tUwwV6g6TL0oXF4qejJSzRWuC3JVirQic0+jf+LQ=; b=swZ+eV8n2sZYZH6cnLpmpMO4+10wHB1C19KyEaYDE0FR2djDuWsclYm1IKNRhJcsoz Ws5PWzOvAeaYdgYxkRBl5yrgA4D7FvV2omoXqebt8bY9K38pW/tu9hLA/ulqaPKrsqD/ HLNuzyrMvm7kDanmHZFQtSrXdprRLTSL+0O04joH2lSYoAE6MFdxVnb2O3AKbbPYBWR8 GkvU6nXgXA/YIAs7KFYzaxm2npwVZq7dYohMqNxPMQyT4ik0grhs5jFyH+ufiMo6BRRk 4Tsn3kaq8zMM/n+oX1kKZ0lZdwZTQOePnenSWtjQGFwEVfb8qkkY4OriDe/VDZm8zgSk QMtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mlHwhEeS; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 i22si3040101pjx.13.2019.06.19.20.06.39; Wed, 19 Jun 2019 20:06:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=mlHwhEeS; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1731433AbfFTDGb (ORCPT + 11 others); Wed, 19 Jun 2019 23:06:31 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43179 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731428AbfFTDGa (ORCPT ); Wed, 19 Jun 2019 23:06:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id i189so780560pfg.10 for ; Wed, 19 Jun 2019 20:06:30 -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=V98tUwwV6g6TL0oXF4qejJSzRWuC3JVirQic0+jf+LQ=; b=mlHwhEeSUqJF17X4t3Ni9g83PNe8Y5jIUjeDUaIW+0wc1+yy+t6cg8koZ2zwd8tSlT V3vDuVK0+Rn83OifBrN6paB0Z4AurjNPXWFMaYP+FfqotIVynyr6uy6p0HEUMOcB9cyq K/4geXzoVLMdjzwsCaiAngcZZ/71nwDJSpVMmWqYFS5Bd+B69GlNrYkn+zjR4WJ+2n9R l3k8DvZTKsdTL6fjpLP8Vvr2XLwVNr8oaL8KwqeAl8miWVfiMD/YclntsbDo7Cu4A3J0 jQ5y+QTSTjL/RI5SCRBfBj6U6+lNxH2l9kOXB2eSw4SCkIYrnQdMH2hQh/y9bomIaTZ6 sQsw== 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=V98tUwwV6g6TL0oXF4qejJSzRWuC3JVirQic0+jf+LQ=; b=e7o5zzMMCH6ZUWRKj9uWpsqsn0IHBr1DcOmFxuzb+fcNh+NbaNvMwcqJt9LdaZm5zb gvghdkIBYid1+lhY0+e5Wdz2D1tem3MB+OWmCku0EQvGAwJ3X57sjb0c4ovTBLeqjMdc CDsH64qCJTo58ECmH5pKEfp0ZACPaHcfqHcfBFzlpo+dpc2WI4X6cxwatam7dVvbKEx/ 2R1IHe4HkJHnIyPreXzhfCNaThcVTi6AIci0n6bDh3L1OCT4Elb/caxckrtRxCRaI+kG OT4jRhI4bYpMosExcmBgHbKpX7iHWRzz5PLRLkdc3SagkhPqPBG3Uj+PjG9hZTgO3InM YI4A== X-Gm-Message-State: APjAAAVq5lPNsdAPz/7Obnrmug6b3RvMdRK8x3IaQRyX3DRubESyk3C9 noA4LK+ndtsnJFUzGV3uWSxw4A== X-Received: by 2002:a17:90a:3210:: with SMTP id k16mr593435pjb.13.1560999989797; Wed, 19 Jun 2019 20:06:29 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id d6sm18066742pgv.4.2019.06.19.20.06.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 20:06:29 -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 V2 3/5] cpufreq: Use has_target() instead of !setpolicy Date: Thu, 20 Jun 2019 08:35:48 +0530 Message-Id: <56d8e01d8febb81917aded319249145fdc73daec.1560999838.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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()" instead of "cpufreq_driver->setpolicy" where we need to check if the driver supports setpolicy, so to use only one expression for this kind of 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 Thu Jun 20 03:05:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 167285 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1492366ilk; Wed, 19 Jun 2019 20:06:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOh7wFySECxWp7JG5A9Qf6cO/C6kK8UgVSzcXOBhr2rysp9IxVSsEOJ+V0XEsrN+Is3ad7 X-Received: by 2002:a63:ed06:: with SMTP id d6mr10822919pgi.267.1560999999982; Wed, 19 Jun 2019 20:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560999999; cv=none; d=google.com; s=arc-20160816; b=FC6tx7cGAKJv+ZjQR2J7i1u3Lx8BiLIu73EY0LXw8GxsVbXdbMjU2eYxMIzSMrYVJS JTFmEtl9WWmCHGmBTh8M8jNT9qUW8S6AKrJXVcrFxBh2W+sBfJkrh0Ueu7GVmXWMbQIx HhHZ+CK+HsYiMuKnHXnrYYk8bsSyF8jlQnDNpZpexgx66L/2J1C6CU3BnT4pLjr+LMph QBI48+LgPULK8aqUR7QFWrwmfXMuManeiSjabCIpC5zE47+MspVa3wk4plwQ+KQGwuw3 lqkH7foqPkWs668kGNIaFkFj6Nob29WtE9j3SXCRce6p248z1dww7ENQRtApyCfv109B hT2A== 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=0wNpV+pFKazBt7qCinINsSEC2X7K1YQBPTLI/C1uF0LpbRGr0bfUI+X22yS+TXihtD VqxAK5vi9tRv5BGQbjAdB1VF9R9O1t1suODy82NK2JdflS7vq3c6GSFaqI2ueQq0jzRx +gM1/thQMm6DcsJ4KgA9R+LLmw4eBS34YxbXi+S/TE5B5nbwBox5DkXFxTNLGBd2NbNm cM9ZTyMjoZRx4R3Y6EnhCwFBGbyTClm/Ukrsi0eKVtitJpcOSQSrHodfJz1EAAhmaBoM Oh7dZvJOcNjDsFmLnD2Zfj5Ut+IFaq5YW7LysvCu/Kz3ZbWuDy/CQ0Kg74ReQtQc6xYe IYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZNUy2MON; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 i22si3040101pjx.13.2019.06.19.20.06.39; Wed, 19 Jun 2019 20:06:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=ZNUy2MON; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1731493AbfFTDGe (ORCPT + 11 others); Wed, 19 Jun 2019 23:06:34 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46730 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731356AbfFTDGd (ORCPT ); Wed, 19 Jun 2019 23:06:33 -0400 Received: by mail-pl1-f196.google.com with SMTP id e5so741670pls.13 for ; Wed, 19 Jun 2019 20:06:33 -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=ZNUy2MONhgLF1lafsmoV82IjMwCDRyO67e6vU6uxmW8r8mR9TMabEg8rxq+V2PPMoF BNhUteqN7mXp+M0efsJ5FV5HmzazwLknBYJZHwGjEeMWx/NgEuVSEM5e0UPMgTeZUdJI +trRM8DLhvF9TNqIB66tlgWzAvnPgpQ0R6RkP7C7Vi7FeuwBhop9Fzty0WCAIHZ7UeJd lY/kj4RpQ1LjllGKuzXvi8+8tmvjzLlabA7bEXcaEZPlaTQpSyfm1y1d1ydy026YP5Wi O1DSLajERamfdYeYivu9LH/caoZIbU0uvn+2/MaLe6ChED57WXGHaKDR+ycoT0JPLxHB AIqA== 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=C44Qae2W4XmhidF8uTqHem+VWoOaWqEBwHLtTB2EmcbycdEFiuUHnsBl/aF3FsAky9 qQ8JH53hCo9xTn+8aJ04rzhi9/uNxu05pVxl3CkdUbFBLfxHyf8WBxlmUMj2ePAfeBzj OTXwJE4WAHQB9eaktAEfxlebNBgvVtxhy12ZM47iuabCVb/by5crP3tY0fl8ggaUO2es fCi4j198/kTyVpSbZ5vxr10HnsZ2fkZ1YvFegZ5IoElxH2PGKfamx8b9WiV1PnpN9bUK qpzy3s3HHkPBLeGAJdCFzba6De9kqXkb3VxmbN/YNkV20Ugxa2k3jlngeMmBp6IWUVpl Mcrw== X-Gm-Message-State: APjAAAVonoM9k4hvodbQ1yCvk0qma4fhV+W/3dkb1w11NuhsZU78ycih IuOuTWZ80HaPYVQ+/JvI+dUzNaKVeO0= X-Received: by 2002:a17:902:9689:: with SMTP id n9mr26502959plp.241.1560999992550; Wed, 19 Jun 2019 20:06:32 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id f14sm26149488pfn.53.2019.06.19.20.06.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 20:06:32 -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 V2 4/5] cpufreq: Reuse cpufreq_update_current_freq() in __cpufreq_get() Date: Thu, 20 Jun 2019 08:35:49 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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);