From patchwork Tue Apr 28 03:22:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francisco Jerez X-Patchwork-Id: 11513723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64E3E1667 for ; Tue, 28 Apr 2020 03:28:15 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 431BC2073C for ; Tue, 28 Apr 2020 03:28:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b="Q+JrTVUF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 431BC2073C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=riseup.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38C946E219; Tue, 28 Apr 2020 03:28:14 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by gabe.freedesktop.org (Postfix) with ESMTPS id 45C306E063 for ; Tue, 28 Apr 2020 03:27:51 +0000 (UTC) Received: from bell.riseup.net (unknown [10.0.1.178]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Sectigo RSA Domain Validation Secure Server CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 49B6Xl09yXzFfFH; Mon, 27 Apr 2020 20:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1588044471; bh=Jn/3Hh7+QKpOsjrz/1ry7Kkr0NliBM599QoG3E/jSq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+JrTVUF2gpIak/MKENvrPibE38ta319GGS+/vO1IJxWMc3MnSTgzQt199zfYGvCa 1Y3a49C6RqzNHIv0VNPAIA50ln5GRnTJOvIDSF2qeXgGDqki8lzAoW3g5yEtVkOc+x Hq4Y8JE6YVVj4n9oxKXr7T6jKHJHyEyY88c0BJAQ= X-Riseup-User-ID: 547A5229B4A1C176D71D349D0F1A9E9C1806DD9F22F331FDB485BCF7D9A4F8A9 Received: from [127.0.0.1] (localhost [127.0.0.1]) by bell.riseup.net (Postfix) with ESMTPSA id 49B6Xk5MFvzJqbk; Mon, 27 Apr 2020 20:27:50 -0700 (PDT) From: Francisco Jerez To: "Rafael J. Wysocki" , "Pandruvada\, Srinivas" Date: Mon, 27 Apr 2020 20:22:51 -0700 Message-Id: <20200428032258.2518-5-currojerez@riseup.net> In-Reply-To: <20200428032258.2518-1-currojerez@riseup.net> References: <20200428032258.2518-1-currojerez@riseup.net> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCHv2.99 04/11] cpufreq: Define ADAPTIVE frequency governor policy. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Zijlstra , intel-gfx@lists.freedesktop.org, chris.p.wilson@intel.com, linux-pm@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" This defines a generic policy in addition to the existing PERFORMANCE and POWERSAVE policies. The ADAPTIVE policy is expected to provide a variable trade-off between performance and energy efficiency based on the dynamic behavior of the workload -- E.g. whether the system has a bottleneck on the CPU or another IO device. Signed-off-by: Francisco Jerez --- drivers/cpufreq/cpufreq.c | 10 ++++++++-- drivers/cpufreq/longrun.c | 1 + include/linux/cpufreq.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 045f9fe157ce..e87285b6294c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -629,6 +629,9 @@ static unsigned int cpufreq_parse_policy(char *str_governor) if (!strncasecmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) return CPUFREQ_POLICY_POWERSAVE; + if (!strncasecmp(str_governor, "adaptive", CPUFREQ_NAME_LEN)) + return CPUFREQ_POLICY_ADAPTIVE; + return CPUFREQ_POLICY_UNKNOWN; } @@ -750,6 +753,8 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) return sprintf(buf, "powersave\n"); else if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) return sprintf(buf, "performance\n"); + else if (policy->policy == CPUFREQ_POLICY_ADAPTIVE) + return sprintf(buf, "adaptive\n"); else if (policy->governor) return scnprintf(buf, CPUFREQ_NAME_PLEN, "%s\n", policy->governor->name); @@ -811,7 +816,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, struct cpufreq_governor *t; if (!has_target()) { - i += sprintf(buf, "performance powersave"); + i += sprintf(buf, "performance powersave adaptive"); goto out; } @@ -1085,7 +1090,8 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy) pol = policy->policy; } if (pol != CPUFREQ_POLICY_PERFORMANCE && - pol != CPUFREQ_POLICY_POWERSAVE) + pol != CPUFREQ_POLICY_POWERSAVE && + pol != CPUFREQ_POLICY_ADAPTIVE) return -ENODATA; } diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c index 1caaec7c280b..cb70f0b7ff7a 100644 --- a/drivers/cpufreq/longrun.c +++ b/drivers/cpufreq/longrun.c @@ -99,6 +99,7 @@ static int longrun_set_policy(struct cpufreq_policy *policy) msr_lo |= 0x00000001; break; case CPUFREQ_POLICY_POWERSAVE: + case CPUFREQ_POLICY_ADAPTIVE: break; } wrmsr(MSR_TMTA_LONGRUN_FLAGS, msr_lo, msr_hi); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index f7240251a949..fa63df914f9f 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -536,6 +536,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, */ #define CPUFREQ_POLICY_POWERSAVE (1) #define CPUFREQ_POLICY_PERFORMANCE (2) +#define CPUFREQ_POLICY_ADAPTIVE (3) /* * The polling frequency depends on the capability of the processor. Default