From patchwork Wed May 18 12:25:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 68044 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2604752qge; Wed, 18 May 2016 05:26:16 -0700 (PDT) X-Received: by 10.98.113.1 with SMTP id m1mr10527104pfc.150.1463574370340; Wed, 18 May 2016 05:26:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 74si11901390pfp.87.2016.05.18.05.26.10; Wed, 18 May 2016 05:26:10 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753271AbcERM0A (ORCPT + 29 others); Wed, 18 May 2016 08:26:00 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:34146 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753241AbcERMZ6 (ORCPT ); Wed, 18 May 2016 08:25:58 -0400 Received: by mail-pa0-f46.google.com with SMTP id qo8so17741825pab.1 for ; Wed, 18 May 2016 05:25:57 -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=nCPBMSn18gAz2x8JcFZ6V2oD7SFU2SzHxuQN0Gw2C4g=; b=OogSmTt12YlxlykEwo64jXE1KEA4BmKQLsroppaiK32cIQBAsvl3NfcShCeunZKvpv nRb7MSsX0Fy1g1xrUmPYfTc7r4Mte8YwyP4N0x5RZhXTNA+Ta+JbgHSrNtXsl76gysfM l1rUYuUVMWm2WnwNTElxPYwA89jhTJ7umumuc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=nCPBMSn18gAz2x8JcFZ6V2oD7SFU2SzHxuQN0Gw2C4g=; b=XAIAbusevaFs2JwAsFiQNa4r4TgO0Dwv/3oy/XQysJNOCM3IvTu/WoiqwdnIsOm94H 5+ZkxtULs5ICO63YoIi9bamd2nbwz8cOxEq6lSgHZ+XZon24bXciOHR6vbkFgp7UN0U3 ny/c1ZrvWQn9OCjWtIUthrBbuCiWQb6jD/JwfOuCG4c4G2gISQGYq1pKdTe0SFtqIASJ 8NkI0jufGmh77CNqeMD/PYBCrDe8M+0gCvAtScLfI+bS5/3wY9uMJgDIqf+EU78JfT81 DpeqDB8eabrd7J5xjyrItFSpamU3MEXWQe7MaOVkPaZJyitLaAIJMWasx3Q286OfTycd arIA== X-Gm-Message-State: AOPr4FX+JPk2KdPc6WbLH1V96z1NdGqck2XNjXa7IVacU7E/gg0Ne08zpjvPAGEEHm1YjOUJ X-Received: by 10.66.183.168 with SMTP id en8mr10556825pac.64.1463574357241; Wed, 18 May 2016 05:25:57 -0700 (PDT) Received: from localhost ([122.172.42.124]) by smtp.gmail.com with ESMTPSA id l123sm12105917pfl.36.2016.05.18.05.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2016 05:25:56 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] cpufreq: governor: Create cpufreq_policy_apply_limits() Date: Wed, 18 May 2016 17:55:31 +0530 Message-Id: <6f25deee2fff9e5f5081e457d606d85d670fa7ed.1463574213.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create a new helper to avoid code duplication across governors. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 7 +------ include/linux/cpufreq.h | 8 ++++++++ kernel/sched/cpufreq_schedutil.c | 9 +-------- 3 files changed, 10 insertions(+), 14 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index 45ca5aff88b2..10cf91cadb97 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -551,12 +551,7 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy) struct policy_dbs_info *policy_dbs = policy->governor_data; mutex_lock(&policy_dbs->timer_mutex); - - if (policy->max < policy->cur) - __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); - else if (policy->min > policy->cur) - __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); - + cpufreq_policy_apply_limits(policy); gov_update_sample_delay(policy_dbs, 0); mutex_unlock(&policy_dbs->timer_mutex); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index fe4c48b0fa40..2c0c5177f3e1 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -493,6 +493,14 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor); struct cpufreq_governor *cpufreq_default_governor(void); struct cpufreq_governor *cpufreq_fallback_governor(void); +static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy) +{ + if (policy->max < policy->cur) + __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H); + else if (policy->min > policy->cur) + __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L); +} + /* Governor attribute set */ struct gov_attr_set { struct kobject kobj; diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4035765deafc..7699f88234ce 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -465,14 +465,7 @@ static int sugov_limits(struct cpufreq_policy *policy) if (!policy->fast_switch_enabled) { mutex_lock(&sg_policy->work_lock); - - if (policy->max < policy->cur) - __cpufreq_driver_target(policy, policy->max, - CPUFREQ_RELATION_H); - else if (policy->min > policy->cur) - __cpufreq_driver_target(policy, policy->min, - CPUFREQ_RELATION_L); - + cpufreq_policy_apply_limits(policy); mutex_unlock(&sg_policy->work_lock); }