From patchwork Wed Jul 19 10:12: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: 9851249 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 628EF60388 for ; Wed, 19 Jul 2017 10:14:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54172285A8 for ; Wed, 19 Jul 2017 10:14:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E9E2863E; Wed, 19 Jul 2017 10:14:35 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 4A47D285A8 for ; Wed, 19 Jul 2017 10:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753950AbdGSKOc (ORCPT ); Wed, 19 Jul 2017 06:14:32 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34595 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754255AbdGSKN3 (ORCPT ); Wed, 19 Jul 2017 06:13:29 -0400 Received: by mail-pg0-f44.google.com with SMTP id 123so28704434pgj.1 for ; Wed, 19 Jul 2017 03:13:29 -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 :in-reply-to:references; bh=z5UNf7VrM+9cFdUN6YbY4wfTj6yz61m2f+fQfecyokw=; b=WwMhbrOjOz3gdKogLzocUfkTkT/wsd0H1pp1tXyURp1VNFBTWCChnDrbRxlgpJ/faK qERDfnGLT3NDamXO38aB0hShKs+QXowDBiS2oWJACWMey9yoTtLciBuFEa/8SbvqKrHf 4iVzd/kmdQZfz6e7nKox1WGH5Vbe64BPWUh4w= 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:in-reply-to:references; bh=z5UNf7VrM+9cFdUN6YbY4wfTj6yz61m2f+fQfecyokw=; b=D55mLQ/nbPIPRdZ9LyZKa5wyGpm2dQeCrxrIPQAOobbILY7OPlLUvgJU2vxW4AfBYB NX3xD3xd+SLZdPXN3jlIYCuj1NokeWvywBGW21gRgMzAQOe0rfH7eKbjqggIsSTTXs8t edetZiND/mNjllm3aPjMzYp1VRdCjLwkJMxkrIg+WxROFVK1NUZtEcxUDj4hyQyG+KBN 2VeE+ag/Mh783WGySv/UYCLuVqi/LbMw7Njmf9VgE5c7Rx2vyXTDItD/l2TNUnHdHpbw g/C6bMQdCW/sq5uZm72ryifyB3Ft3zgaJP5xA8I3z+dv/sNUMsNGfOY87kLzxgEDeq9Z CtpQ== X-Gm-Message-State: AIVw111BTc6vtgMHJzQncTlmzuWaz1sJNMFhNPCY47p/mfhdb+JKrU2h Jhd18pRxWVe4y6/c X-Received: by 10.84.224.141 with SMTP id s13mr2432345plj.212.1500459209198; Wed, 19 Jul 2017 03:13:29 -0700 (PDT) Received: from localhost ([122.167.171.93]) by smtp.gmail.com with ESMTPSA id x81sm5474658pfi.20.2017.07.19.03.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jul 2017 03:13:28 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linux-pm@vger.kernel.org, Vincent Guittot , linux@dominikbrodowski.net, linux-kernel@vger.kernel.org Subject: [PATCH V3 6/9] cpufreq: Replace "max_transition_latency" with "dynamic_switching" Date: Wed, 19 Jul 2017 15:42:46 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb In-Reply-To: References: In-Reply-To: References: 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 There is no limitation in the ondemand or conservative governors which disallow the transition_latency to be greater than 10 ms. The max_transition_latency field is rather used to disallow automatic dynamic frequency switching for platforms which didn't wanted these governors to run. Replace max_transition_latency with a boolean (dynamic_switching) and check for transition_latency == CPUFREQ_ETERNAL along with that. This makes it pretty straight forward to read/understand now. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 8 ++++---- drivers/cpufreq/cpufreq_governor.h | 2 +- include/linux/cpufreq.h | 9 ++------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d00cde871c15..2debfb5f9126 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2014,13 +2014,13 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy) if (!policy->governor) return -EINVAL; - if (policy->governor->max_transition_latency && - policy->cpuinfo.transition_latency > - policy->governor->max_transition_latency) { + /* Platform doesn't want dynamic frequency switching ? */ + if (policy->governor->dynamic_switching && + policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL) { struct cpufreq_governor *gov = cpufreq_fallback_governor(); if (gov) { - pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n", + pr_warn("Transition latency set to CPUFREQ_ETERNAL, can't use %s governor. Fallback to %s governor\n", policy->governor->name, gov->name); policy->governor = gov; } else { diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 95f207eb820e..8463f5def0f5 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -159,7 +159,7 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy); #define CPUFREQ_DBS_GOVERNOR_INITIALIZER(_name_) \ { \ .name = _name_, \ - .max_transition_latency = TRANSITION_LATENCY_LIMIT, \ + .dynamic_switching = true, \ .owner = THIS_MODULE, \ .init = cpufreq_dbs_governor_init, \ .exit = cpufreq_dbs_governor_exit, \ diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index aaadfc543f63..e141dbbb9d1c 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -487,12 +487,8 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, * polling frequency is 1000 times the transition latency of the processor. The * ondemand governor will work on any processor with transition latency <= 10ms, * using appropriate sampling rate. - * - * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL) - * the ondemand governor will not work. All times here are in us (microseconds). */ #define LATENCY_MULTIPLIER (1000) -#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) struct cpufreq_governor { char name[CPUFREQ_NAME_LEN]; @@ -505,9 +501,8 @@ struct cpufreq_governor { char *buf); int (*store_setspeed) (struct cpufreq_policy *policy, unsigned int freq); - unsigned int max_transition_latency; /* HW must be able to switch to - next freq faster than this value in nano secs or we - will fallback to performance governor */ + /* For governors which change frequency dynamically by themselves */ + bool dynamic_switching; struct list_head governor_list; struct module *owner; };