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: 11005791 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CEC014B6 for ; Thu, 20 Jun 2019 03:06:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F26228174 for ; Thu, 20 Jun 2019 03:06:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E74281C3; Thu, 20 Jun 2019 03:06:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFA6328179 for ; Thu, 20 Jun 2019 03:06:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731307AbfFTDGY (ORCPT ); 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-Google-Smtp-Source: APXvYqwJTRDFmZNAIEaGMNDIRyAWQI1nd69Xf4gQfwcFrHb5UyE97h39NTtwabsG2oSB4Bjr2oCrzw== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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: 11005793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 156521580 for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079582818E for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEAEE281C3; Thu, 20 Jun 2019 03:06:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 872E028174 for ; Thu, 20 Jun 2019 03:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731363AbfFTDG2 (ORCPT ); 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-Google-Smtp-Source: APXvYqxFAhFFPNFzp204E1IW8iP5ZxzaHvAie5ju+82McHT0juXkxxe5Mzqm7beuZ+WBswCm00XCxg== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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: 11005795 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B20F186E for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E2FA28174 for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07E74281B7; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6A2728179 for ; Thu, 20 Jun 2019 03:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731433AbfFTDGb (ORCPT ); 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-Google-Smtp-Source: APXvYqyFe2XxI+QiBEDINmZXWdMAk2I0sa9y7G/GFHsXNqjmdZo6NTSGyBO8qHHU6VvwmqkIisH2KA== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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: 11005797 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6859D14B6 for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A64528174 for ; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB4E28179; Thu, 20 Jun 2019 03:06:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C649F2817F for ; Thu, 20 Jun 2019 03:06:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731493AbfFTDGe (ORCPT ); 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-Google-Smtp-Source: APXvYqzyolSilGn5mAiks5SpWxy27bF6gE3/LacDC38aiGw0cn3KR5TcrhZh5r96Dj41PBvC5QYvsQ== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 Thu Jun 20 03:05:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11005799 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A8BA1580 for ; Thu, 20 Jun 2019 03:06:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B8F628174 for ; Thu, 20 Jun 2019 03:06:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FABB2817F; Thu, 20 Jun 2019 03:06:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CD528174 for ; Thu, 20 Jun 2019 03:06:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731484AbfFTDGg (ORCPT ); Wed, 19 Jun 2019 23:06:36 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43963 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731567AbfFTDGf (ORCPT ); Wed, 19 Jun 2019 23:06:35 -0400 Received: by mail-pl1-f193.google.com with SMTP id cl9so744130plb.10 for ; Wed, 19 Jun 2019 20:06:35 -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=DZpCjpoaZQW45P9CeX3cDnXJU8tmgG817TlOWAKnWM3+mxcgfgm3MwAPNIg9q4WlvV mxtLg3/edOddOGSsNdFJOoqaFkOTbcpVBLqWc2jSUjY4oQRgpg6KvzAKnEV+JWGRuC73 OZ3oZSW5R8KBELMniexMbEYBACrBKo+9LhUcWFjJh9QdgMU9LnxJEAW8jFyse4XNhwdQ puK1HEQGkiyJ2onBQOeVMyTJniUw2w0lHWkbNeg5lHXSm+NdCw64T8mBHyJME0v1l889 DgFB1MSOoZ0JINkcsQMd7q1v31Qw6rjZ3u6h1O3/JhzIXaDbFFaoRiX+Ddv995jaznf2 CONw== 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=EsmnVOge4xNX3P57cJMeyqDF+8oOZL7aVVH/oAKjzmJng9bXepINDLP4bGC48izuE7 7i5d4Wz3JjZ9paf0YVkkKCCK5gKIRVdD33KPt/8CWNea3ceLXJey5Gjm2BUDWFLlSHCH zBl0nS7BKd4dF/NavDiNlrgQZuwyOZRbchyOCNWJNBjC2P4DtiXYJ8HcAYzjwTYVBK3X 2KgxTQjD63JXRdMQ8Wl2BG1Wun6+cj3Up0S6GH4mbilKh7B6FHQ8YYBFek4Le1WRbEn5 0j8FMyag40vxAxICrGJCOXQu9wk56rz8Sx0PgXxZeDdGxSncK9+6Ogupzxl3CKEbXOjJ hjAQ== X-Gm-Message-State: APjAAAUdBR3HzTmph4nq2cGlLl6n6Jv16OrtaS9LCy/QMsa9umcKNf2g 9c06cXM0WyQms1N7k1GWtXIXWQ== X-Google-Smtp-Source: APXvYqw3FncPDprKfdEYf7q4+OqbC8vh5kSAFntM0Xso4RIi81R/M+KB2gM8MIZO7WfCN0JX8cQd/A== X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr123268486plb.150.1560999995255; Wed, 19 Jun 2019 20:06:35 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id b135sm19459543pfb.44.2019.06.19.20.06.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2019 20:06:34 -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 5/5] cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update() Date: Thu, 20 Jun 2019 08:35:50 +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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);