From patchwork Wed Aug 9 04:51:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9889503 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.web.codeaurora.org (Postfix) with ESMTP id 1CF2C602D7 for ; Wed, 9 Aug 2017 04:51:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CA4C289A9 for ; Wed, 9 Aug 2017 04:51:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B259289F1; Wed, 9 Aug 2017 04:51:57 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 719DD289A9 for ; Wed, 9 Aug 2017 04:51:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750866AbdHIEvy (ORCPT ); Wed, 9 Aug 2017 00:51:54 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:36594 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbdHIEvx (ORCPT ); Wed, 9 Aug 2017 00:51:53 -0400 Received: by mail-pf0-f174.google.com with SMTP id c28so23111455pfe.3 for ; Tue, 08 Aug 2017 21:51:53 -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; bh=my/QijTQkd5x69/vKcJH5JTGdqcvCtm+IZG1JHJDZTg=; b=NFZmwW10yM8c+Wlpy8+7Rml97HyKPA+l1WWGHsVl8x/Mh9RPPrYDUm6UtgTDXczLP6 MUKHVLu5WDsbxbYa+NfVVlQTbx8lBfSEDuDV6+DnVUEke39abh+VQbRi+rMC2mJi2UOw VOmYGbA58yWl+TXS6/Wj5ylH1rML8dt86ftLk= 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; bh=my/QijTQkd5x69/vKcJH5JTGdqcvCtm+IZG1JHJDZTg=; b=ETxzY31wLh3YigffhI1b1vSM4OQCEpEie8binzF1G92qF4Jt/fvcv38SRzxJtNlSgc XtLwRk7ZI/h/m2/t2/njQEH1et+jBjNe0sbb9Z664+NijVPHbklPjgyf35cScOnUqII/ 9X9477J1zHGwMONLE38zhembalMK/im9wAj3fMygbplGuaP21jKzSzn1x5iAdrr50hkK JcI5g4ZruH4x3JKvCJWRLr3fj2nbZLF+PBMHRgiRkv7RVsiwIoC7P/MF8bjxbQMOstw4 /FcDl1rnv5fyoNyVe1NkAcROG1cJiV5kuvrvInxLM+7M5QYTtLPscpBaKN++XHSAfJaT Eg7g== X-Gm-Message-State: AHYfb5hHQhoQ9vHDVfSLPav2YBU9g2immOXQDuTLV8rl7UtDnhW4FGe6 AXdE4Ojur5NBDgGI X-Received: by 10.99.112.86 with SMTP id a22mr6593724pgn.151.1502254313256; Tue, 08 Aug 2017 21:51:53 -0700 (PDT) Received: from localhost ([122.171.226.174]) by smtp.gmail.com with ESMTPSA id a87sm5321994pfg.18.2017.08.08.21.51.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Aug 2017 21:51:51 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Ingo Molnar , Peter Zijlstra Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , sudeep.holla@arm.com, Dietmar.Eggemann@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: Return 0 from ->fast_switch() on errors Date: Wed, 9 Aug 2017 10:21:46 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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_ENTRY_INVALID is a special symbol which is used to specify that an entry in the cpufreq table is invalid. But using it outside of the scope of the cpufreq table looks a bit incorrect. We can represent an invalid frequency by writing it as 0 instead if we need. Note that it is already done that way for the return value of the ->get() callback. Lets do the same for ->fast_switch() and not use CPUFREQ_ENTRY_INVALID outside of the scope of cpufreq table. Also update the comment over cpufreq_driver_fast_switch() to clearly mention what this returns. None of the drivers return CPUFREQ_ENTRY_INVALID as of now from ->fast_switch() callback and so we don't need to update any of those. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 7 ++++--- kernel/sched/cpufreq_schedutil.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b2cc98551fc3..9588e15da26b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1832,9 +1832,10 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); * twice in parallel for the same policy and that it will never be called in * parallel with either ->target() or ->target_index() for the same policy. * - * If CPUFREQ_ENTRY_INVALID is returned by the driver's ->fast_switch() - * callback to indicate an error condition, the hardware configuration must be - * preserved. + * Returns the actual frequency set for the CPU. + * + * If 0 is returned by the driver's ->fast_switch() callback to indicate an + * error condition, the hardware configuration must be preserved. */ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy, unsigned int target_freq) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 5465bf221e8f..2e74c49776be 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -123,7 +123,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, if (policy->fast_switch_enabled) { next_freq = cpufreq_driver_fast_switch(policy, next_freq); - if (next_freq == CPUFREQ_ENTRY_INVALID) + if (!next_freq) return; policy->cur = next_freq;