From patchwork Fri Jan 11 09:18:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 155310 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp347882jaa; Fri, 11 Jan 2019 01:18:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN7a3X7c9zA5UqsLT7hmgVt8dqNh5lJnQMvhfUr+S/8ARc/IuhOmCN40ZGwsZX6Quf7T4Mlt X-Received: by 2002:a63:f109:: with SMTP id f9mr2540794pgi.286.1547198334208; Fri, 11 Jan 2019 01:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547198334; cv=none; d=google.com; s=arc-20160816; b=ARlIGbQna/o23BWwbJCdnaKBnGT/pUuf30q33RXPteHhnyNPJQNG/aJgOCkrwaPQTw 9TrkoRqFR3CD27CXvOOkVBCeQFcFygQzysMl4YkGQTYBTDHH5lo2mHVngHMWFH97s7oh RXzCb+5pSUafbcKJ8f8rOd012pqjkw2hcix7ckHa8zsil7wKi7oasZ8Xl3TyNsAH/0Bz FHEKX4tFaX7RmvTNJqB1e37uzG4RWNndbHv2002qM5KovLHi79mhNg8mzAw/q/pkfgjr h3tKeCly3/ZEUa5Pe0AELbERjKdjez/sJKOzLu/H+UySdttcvvBSsJwsvKm+wXmaMLUK fyDw== 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=j+6233nv3v674fm7wJsKedOHZKQamoc11CkEUfZqX4M=; b=l/tdsCgflBQRyJ8WPCDgRLeo/h/KCfiQTIUSOgmWgjo/wxYt6dj0zKQywyG7ZLcWSp /7FwUuZvfYuyuJUe6PLQ52XRL+WHHPbLQrngxfWI74MVzF1BNVo1QKlTLcGXHZtdNPHo KOBxASX0LLJaYj1IZTduAvFDXxw/yOtnOjsxHK5nkRiJNSt7okurvQofgYb92CPWwd6b 6iaj8qS/XSG70Pj4yo1oOfUgAtb8ubixiaryaqau+cSnhQFg7hH49Csq0S+M/XnrLuBC 9Atv0sae5X0FREwYbggEKdOm5wuGKS9VuoPq7dzywmIl2nATnvM14dJ+fzj/1JGHJPVe 1BNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FwbyUPAU; 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 ce11si24501110plb.420.2019.01.11.01.18.53; Fri, 11 Jan 2019 01:18:54 -0800 (PST) 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=FwbyUPAU; 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 S1731472AbfAKJSw (ORCPT + 11 others); Fri, 11 Jan 2019 04:18:52 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42717 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731454AbfAKJSv (ORCPT ); Fri, 11 Jan 2019 04:18:51 -0500 Received: by mail-pf1-f196.google.com with SMTP id 64so6681685pfr.9 for ; Fri, 11 Jan 2019 01:18:51 -0800 (PST) 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=j+6233nv3v674fm7wJsKedOHZKQamoc11CkEUfZqX4M=; b=FwbyUPAUmpqC61yhz0XF4E2qHvR6Cdtuq/oGJ6LEvdual17YNidGP089pNN1OcdGhB K05rSCSYooEGkbYa2eWcYEC4of3smANzkOk9dYUA39f0+kWNsLPoBn5TzATaGfBnDcQ5 2opZHEx2LKv75FUC2Th8/jZWQHps3KQfSci3E= 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=j+6233nv3v674fm7wJsKedOHZKQamoc11CkEUfZqX4M=; b=Lm7TQSLKcXSDpPjyl588FL+7px/ThBwAO5xmOXhDjj3rirYSY5nOrQFQsFXUM9v/9B rxfrX2ho5XC3vDRR7cm3PgV0J/s0J6UmW7vo5qE4emzY92JPHIcaa8d+yhLSO5kRS1D/ nSNsV2+jerWSgYiAA/0YUF9k/Vitjl3xCnSpioF+w05Y7Uaibr7SRubenXxFlQS4IBm+ T9slk8J+iUnrwvlcgU2zVX0zng6osYPtkDHduKfuq5MZ30PoCt4sdKYkgtQlTk4tpSm/ BYNy8ulGRDx3DrxmShAHgnGD7LxxSrytfq1zzr8fDbGXKiFKN2PHvMXKxDfp7vR1n2mm zLng== X-Gm-Message-State: AJcUukekFDTepQR8RT6v83fd5g03LIuIgdNGQl9pZE+8Of4Na5XBPVq6 jv1BS9mqatMtr8gUiP5LneXiXA== X-Received: by 2002:a63:86c1:: with SMTP id x184mr10318302pgd.305.1547198330528; Fri, 11 Jan 2019 01:18:50 -0800 (PST) Received: from localhost ([122.172.34.203]) by smtp.gmail.com with ESMTPSA id h134sm158868104pfe.27.2019.01.11.01.18.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 01:18:49 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Greg Kroah-Hartman Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] cpufreq: Implement freq-constraint callback Date: Fri, 11 Jan 2019 14:48:35 +0530 Message-Id: X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 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 This implements the frequency constraint callback and registers it with the freq-constraint framework whenever a policy is created. On policy removal the callback is unregistered. The constraints are also taken into consideration in cpufreq_set_policy(). No constraints are added until now though. Signed-off-by: Viresh Kumar --- drivers/cpufreq/Kconfig | 1 + drivers/cpufreq/cpufreq.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) -- 2.7.4 diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 608af20a3494..2c2842cf2734 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig @@ -2,6 +2,7 @@ menu "CPU Frequency scaling" config CPU_FREQ bool "CPU Frequency scaling" + select DEVICE_FREQ_CONSTRAINT select SRCU help CPU Frequency scaling allows you to change the clock speed of diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a8fa684f5f90..63028612d011 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1163,6 +1164,7 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) per_cpu(cpufreq_cpu_data, cpu) = NULL; write_unlock_irqrestore(&cpufreq_driver_lock, flags); + freq_constraint_remove_cpumask_callback(policy->related_cpus); cpufreq_policy_put_kobj(policy); free_cpumask_var(policy->real_cpus); free_cpumask_var(policy->related_cpus); @@ -1170,6 +1172,24 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) kfree(policy); } +static void freq_constraint_callback(void *param) +{ + struct cpufreq_policy *policy = param; + struct cpufreq_policy new_policy = *policy; + + new_policy.min = policy->user_policy.min; + new_policy.max = policy->user_policy.max; + + down_write(&policy->rwsem); + if (policy_is_inactive(policy)) + goto unlock; + + cpufreq_set_policy(policy, &new_policy); + +unlock: + up_write(&policy->rwsem); +} + static int cpufreq_online(unsigned int cpu) { struct cpufreq_policy *policy; @@ -1236,6 +1256,14 @@ static int cpufreq_online(unsigned int cpu) per_cpu(cpufreq_cpu_data, j) = policy; add_cpu_dev_symlink(policy, j); } + + ret = freq_constraint_set_cpumask_callback(policy->related_cpus, + freq_constraint_callback, policy); + if (ret) { + pr_err("Failed to set freq-constraints: %d (%*pbl)\n", + ret, cpumask_pr_args(policy->cpus)); + goto out_destroy_policy; + } } else { policy->min = policy->user_policy.min; policy->max = policy->user_policy.max; @@ -2198,6 +2226,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, struct cpufreq_policy *new_policy) { struct cpufreq_governor *old_gov; + struct device *cpu_dev = get_cpu_device(policy->cpu); + unsigned long fc_min, fc_max; int ret; pr_debug("setting new policy for CPU %u: %u - %u kHz\n", @@ -2217,6 +2247,20 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, if (ret) return ret; + ret = freq_constraints_get(cpu_dev, &fc_min, &fc_max); + if (ret) { + dev_err(cpu_dev, "cpufreq: Failed to get freq-constraints\n"); + } else { + if (fc_min > new_policy->min) + new_policy->min = fc_min; + if (fc_max < new_policy->max) + new_policy->max = fc_max; + } + + /* + * The notifier-chain shall be removed once all the users of + * CPUFREQ_ADJUST are moved to use the freq-constraints. + */ /* adjust if necessary - all reasons */ blocking_notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_ADJUST, new_policy); From patchwork Fri Jan 11 09:18:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 155311 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp347937jaa; Fri, 11 Jan 2019 01:18:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN6BQNrWVKZmJRpPr4xyOlq+1VzYniGFdcy300UBnqPpQLwXnbCuZm2Gg5ZjW3D7v26V4HM4 X-Received: by 2002:a63:78cd:: with SMTP id t196mr12714545pgc.62.1547198337019; Fri, 11 Jan 2019 01:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547198337; cv=none; d=google.com; s=arc-20160816; b=xHgDyRntimn6UPQcLBSKwmWh8b/w7rrGoXmHhkEH62oVr+7kU+ZjCAZxS8LRTSNwT5 GI/twxLO4dDwVo6WFpgoafjBOrngo5HbDpOHtCkZzzHb5tNi+uY/Ob65OqaW3/X2ABKy Y55TXjGvAE7x5XH3ZkmSYBs1ifnyJxuqGOxNVzdphEF7AkL4KZAJqbsQ5N+Y8Oo0qTNW BrRRlG9B2DvfS4t8Bd0Bvz2JBgjXHF8y5vYRhuCnN+7DS4ctbBRhJAx4zh4rCFx9Febe h4W9Cuq+0H8DTA40h2OWXZN341mxoT2cvGvFknDvtpf2bw3nTbyX1Od2oLy4+zY3Niox Z3Yg== 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=5bDGXNrblFZtK7bw9oWvAOgjAK+XZW8hm/2AA9LBN04=; b=I491EsxXNV9IbhozPW4/nQjjz20d4kg8YrH/EfUTznqi+kkOpgOFUE0agvSWHlQO54 7Zz80nIUn20gB7eb1SQchpzO6HuDmVBOGMZBl1YZHsvpLdSL97xqBDcPSZE49yYiNr9P jgFVNiAGzZZ2JCrWeuv9S3B81+naGSm0eJLBO2w7HE043BWmjvIG76JYqNW8oovdRtSw rwBKrE0Q6P/PwKUbf308Q3nQwIWhOBj8OmdqNfGXjycbF7gPu5nXHCfpmDuQ0ymi3NI1 GM16LsnK0nqwDVXWdAgku/sOxU9a0TFW89D14w+EBuYC7KuIU4ZvjhhE3mDKg4cOYN4/ HzEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M73vvH9o; 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 o6si24617883plh.23.2019.01.11.01.18.56; Fri, 11 Jan 2019 01:18:57 -0800 (PST) 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=M73vvH9o; 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 S1731471AbfAKJSz (ORCPT + 11 others); Fri, 11 Jan 2019 04:18:55 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39887 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731482AbfAKJSy (ORCPT ); Fri, 11 Jan 2019 04:18:54 -0500 Received: by mail-pl1-f196.google.com with SMTP id 101so6516566pld.6 for ; Fri, 11 Jan 2019 01:18:54 -0800 (PST) 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=5bDGXNrblFZtK7bw9oWvAOgjAK+XZW8hm/2AA9LBN04=; b=M73vvH9oskBDtFhTprrzxcBTl5Pc1Op54bx6Q9UfoQ2JNFvvF4BAx2MdpBbzT14MHv 91E+VqfcO098IBpmiYZ7+scXh0ZYy31S6lPH3UDAr42xOFA6Q+lhviBNUn76eX9MVVfo ytzz+/hSVl9V0xxJwke6nms1cl87sPV/j1pLM= 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=5bDGXNrblFZtK7bw9oWvAOgjAK+XZW8hm/2AA9LBN04=; b=Bkzy/X/aO3JyOI8GaT8fEdM2f0BskOqZ/LcD2JscB4ebxFKjlXAPpWMM1G+bPm0Erv FE/8Ax/WzYN7z7VNm49U00/ce88a/V0QLzIsNmNEm+/6NQpbWq5SqTm48hSw3x2flwu8 yztZkt8Y1IbOXNwWJhRUkORdPJx7sR6zx306e2n2jnkTmfpABdfXfHn39xbk05erXDuW lXiP8bRH9rp5S89/6lWB2ga0ub3fiu7jjutLia0yU2kAiBDC9b+ufWeChnJdl5vSHvq7 pmlCnknc23Yzi1BrVOZdu5WAcFAtlX1wt9/QARehmlMlp9AWiHDSgY81Yg4JKNw5VLcM fAFg== X-Gm-Message-State: AJcUukePYtcAickkv5wP+o562DyCJO3tkfGJecLKE7MQy3LvytaQolMK Coo7yb3qKj/C3HR8ILylILbTXA== X-Received: by 2002:a17:902:24e7:: with SMTP id l36mr13941694plg.61.1547198333961; Fri, 11 Jan 2019 01:18:53 -0800 (PST) Received: from localhost ([122.172.34.203]) by smtp.gmail.com with ESMTPSA id n68sm128916923pfb.62.2019.01.11.01.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Jan 2019 01:18:53 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Greg Kroah-Hartman Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , mka@chromium.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] cpufreq: Implement USER constraint Date: Fri, 11 Jan 2019 14:48:36 +0530 Message-Id: <616457a8af14cb152a85e8e3b2b4c2eb54a38e09.1547197612.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.20.1.321.g9e740568ce00 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 This implements the FREQ_CONSTRAINT_USER constraint and removes the old style of doing the same. We just need to update the constraint on any modifications to scaling_{min|max}_frequency and the freq-constraint core will call cpufreq's callback which will call cpufreq_set_policy() eventually. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 62 ++++++++++++++++++----------------------------- include/linux/cpufreq.h | 8 ++---- 2 files changed, 26 insertions(+), 44 deletions(-) -- 2.7.4 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 63028612d011..6f66e1261b65 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -685,22 +685,15 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, static ssize_t store_##file_name \ (struct cpufreq_policy *policy, const char *buf, size_t count) \ { \ - int ret, temp; \ - struct cpufreq_policy new_policy; \ + unsigned long min = policy->min, max = policy->max; \ + int ret; \ \ - memcpy(&new_policy, policy, sizeof(*policy)); \ - new_policy.min = policy->user_policy.min; \ - new_policy.max = policy->user_policy.max; \ - \ - ret = sscanf(buf, "%u", &new_policy.object); \ + ret = sscanf(buf, "%lu", &object); \ if (ret != 1) \ return -EINVAL; \ \ - temp = new_policy.object; \ - ret = cpufreq_set_policy(policy, &new_policy); \ - if (!ret) \ - policy->user_policy.object = temp; \ - \ + ret = freq_constraint_update(get_cpu_device(policy->cpu), \ + policy->user_fc, min, max); \ return ret ? ret : count; \ } @@ -1164,6 +1157,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) per_cpu(cpufreq_cpu_data, cpu) = NULL; write_unlock_irqrestore(&cpufreq_driver_lock, flags); + if (!IS_ERR(policy->user_fc)) + freq_constraint_remove(get_cpu_device(policy->cpu), + policy->user_fc); freq_constraint_remove_cpumask_callback(policy->related_cpus); cpufreq_policy_put_kobj(policy); free_cpumask_var(policy->real_cpus); @@ -1177,9 +1173,6 @@ static void freq_constraint_callback(void *param) struct cpufreq_policy *policy = param; struct cpufreq_policy new_policy = *policy; - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; - down_write(&policy->rwsem); if (policy_is_inactive(policy)) goto unlock; @@ -1249,9 +1242,6 @@ static int cpufreq_online(unsigned int cpu) cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); if (new_policy) { - policy->user_policy.min = policy->min; - policy->user_policy.max = policy->max; - for_each_cpu(j, policy->related_cpus) { per_cpu(cpufreq_cpu_data, j) = policy; add_cpu_dev_symlink(policy, j); @@ -1264,9 +1254,15 @@ static int cpufreq_online(unsigned int cpu) ret, cpumask_pr_args(policy->cpus)); goto out_destroy_policy; } - } else { - policy->min = policy->user_policy.min; - policy->max = policy->user_policy.max; + + policy->user_fc = freq_constraint_add(get_cpu_device(cpu), + FREQ_CONSTRAINT_USER, + policy->min, policy->max); + if (IS_ERR(policy->user_fc)) { + ret = PTR_ERR(policy->user_fc); + pr_err("Failed to add user constraint: %d\n", ret); + goto out_destroy_policy; + } } if (cpufreq_driver->get && !cpufreq_driver->setpolicy) { @@ -2235,13 +2231,6 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); - /* - * This check works well when we store new min/max freq attributes, - * because new_policy is a copy of policy with one field updated. - */ - if (new_policy->min > new_policy->max) - return -EINVAL; - /* verify the cpu speed can be set within this limit */ ret = cpufreq_driver->verify(new_policy); if (ret) @@ -2251,10 +2240,8 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy, if (ret) { dev_err(cpu_dev, "cpufreq: Failed to get freq-constraints\n"); } else { - if (fc_min > new_policy->min) - new_policy->min = fc_min; - if (fc_max < new_policy->max) - new_policy->max = fc_max; + new_policy->min = fc_min; + new_policy->max = fc_max; } /* @@ -2356,8 +2343,6 @@ void cpufreq_update_policy(unsigned int cpu) 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; /* * BIOS might change freq behind our back @@ -2401,10 +2386,11 @@ static int cpufreq_boost_set_sw(int state) break; } - down_write(&policy->rwsem); - policy->user_policy.max = policy->max; - cpufreq_governor_limits(policy); - up_write(&policy->rwsem); + ret = freq_constraint_update(get_cpu_device(policy->cpu), + policy->user_fc, policy->min, + policy->max); + if (ret) + break; } return ret; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index c86d6d8bdfed..62bf33aafc6c 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -57,11 +58,6 @@ struct cpufreq_cpuinfo { unsigned int transition_latency; }; -struct cpufreq_user_policy { - unsigned int min; /* in kHz */ - unsigned int max; /* in kHz */ -}; - struct cpufreq_policy { /* CPUs sharing clock, require sw coordination */ cpumask_var_t cpus; /* Online CPUs only */ @@ -91,7 +87,7 @@ struct cpufreq_policy { struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ - struct cpufreq_user_policy user_policy; + struct freq_constraint *user_fc; struct cpufreq_frequency_table *freq_table; enum cpufreq_table_sorting freq_table_sorted;