From patchwork Thu Jul 16 18:17:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 6810441 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 07F289F44B for ; Thu, 16 Jul 2015 18:25:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21B492066C for ; Thu, 16 Jul 2015 18:25:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14C2A20674 for ; Thu, 16 Jul 2015 18:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755921AbbGPSY6 (ORCPT ); Thu, 16 Jul 2015 14:24:58 -0400 Received: from forward-corp1f.mail.yandex.net ([95.108.130.40]:51360 "EHLO forward-corp1f.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755850AbbGPSY4 (ORCPT ); Thu, 16 Jul 2015 14:24:56 -0400 X-Greylist: delayed 465 seconds by postgrey-1.27 at vger.kernel.org; Thu, 16 Jul 2015 14:24:55 EDT Received: from smtpcorp4.mail.yandex.net (smtpcorp4.mail.yandex.net [95.108.252.2]) by forward-corp1f.mail.yandex.net (Yandex) with ESMTP id 917CD2420FDE; Thu, 16 Jul 2015 21:17:06 +0300 (MSK) Received: from smtpcorp4.mail.yandex.net (localhost [127.0.0.1]) by smtpcorp4.mail.yandex.net (Yandex) with ESMTP id 6589F2C0604; Thu, 16 Jul 2015 21:17:06 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:408:4567:37a9:80ac:7d4e]) by smtpcorp4.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id sfK7vZLWts-H69ORbDI; Thu, 16 Jul 2015 21:17:06 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1437070626; bh=Df87iOXAkcMtppAz+OmPn+so0L82X1qToZDUaUp2zWg=; h=Subject:From:To:Cc:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding; b=phufPYA4gxfBDl33iXPcIOncy7A6gUAJw2jlQ9njiZY8Q556+8Ja/s3IFoI/7waRi dTZKBZ7bCxJosbGU8OY6apq7749Qv3XJgduAmI05Xm9ovzt+yr4xqNl98sNhKOPe4+ Vr4R9M++DTKpOEsp2fqj984cy5iOUh7XZ3CUio5E= Authentication-Results: smtpcorp4.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH RFC] intel_pstate: play well with frequency limits set by acpi From: Konstantin Khlebnikov To: linux-pm@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Kristen Carlson Accardi , Len Brown Cc: Ethan Zhao Date: Thu, 16 Jul 2015 21:17:06 +0300 Message-ID: <20150716181706.6500.64386.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP IPMI can control CPU P-states remotely: configuration is reported via common ACPI interface (_PPC/_PSS/etc). This patch adds required minimal support in intel_pstate to receive and use these P-state limits. * ignore limit of top state in _PPC: it lower than turbo boost frequency * register intel_pstate in acpi-processor to get states from _PSS * link acpi_processor_get_bios_limit: this adds attribute "bios_limit" Signed-off-by: Konstantin Khlebnikov --- drivers/acpi/processor_perflib.c | 3 +- drivers/cpufreq/intel_pstate.c | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index cfc8aba72f86..781e328c9d5f 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c @@ -98,7 +98,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb, ppc = (unsigned int)pr->performance_platform_limit; - if (ppc >= pr->performance->state_count) + /* Ignore limit of top state: it lower than turbo boost frequency */ + if (!ppc || ppc >= pr->performance->state_count) goto out; cpufreq_verify_within_limits(policy, 0, diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 15ada47bb720..4a34ddf4fa73 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -113,6 +114,9 @@ struct cpudata { u64 prev_mperf; u64 prev_tsc; struct sample sample; +#ifdef CONFIG_ACPI_PROCESSOR + struct acpi_processor_performance acpi_data; +#endif }; static struct cpudata **all_cpu_data; @@ -145,6 +149,7 @@ static int hwp_active; struct perf_limits { int no_turbo; + int no_acpi; int turbo_disabled; int max_perf_pct; int min_perf_pct; @@ -158,6 +163,7 @@ struct perf_limits { static struct perf_limits limits = { .no_turbo = 0, + .no_acpi = !IS_ENABLED(CONFIG_ACPI_PROCESSOR), .turbo_disabled = 0, .max_perf_pct = 100, .max_perf = int_tofp(1), @@ -449,6 +455,18 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, return count; } +static ssize_t store_no_acpi(struct kobject *a, struct attribute *b, + const char *buf, size_t count) +{ +#ifdef CONFIG_ACPI_PROCESSOR + return kstrtouint(buf, 0, &limits.no_acpi) ?: count; +#else + return -ENODEV; +#endif +} +show_one(no_acpi, no_acpi); +define_one_global_rw(no_acpi); + show_one(max_perf_pct, max_perf_pct); show_one(min_perf_pct, min_perf_pct); @@ -460,6 +478,7 @@ define_one_global_ro(num_pstates); static struct attribute *intel_pstate_attributes[] = { &no_turbo.attr, + &no_acpi.attr, &max_perf_pct.attr, &min_perf_pct.attr, &turbo_pct.attr, @@ -1049,6 +1068,38 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; cpumask_set_cpu(policy->cpu, policy->cpus); +#ifdef CONFIG_ACPI_PROCESSOR + if (!limits.no_acpi) { + /* + * Minimum necessary to get acpi_processor_ppc_notifier() and + * acpi_processor_get_bios_limit() working. + */ + if (!zalloc_cpumask_var(&cpu->acpi_data.shared_cpu_map, + GFP_KERNEL)) + rc = -ENOMEM; + else + rc = acpi_processor_register_performance( + &cpu->acpi_data, policy->cpu); + if (rc) { + pr_err("intel_pstate: acpi init failed: %d\n", rc); + free_cpumask_var(cpu->acpi_data.shared_cpu_map); + limits.no_acpi = 1; + } + } +#endif + return 0; +} + +static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) +{ +#ifdef CONFIG_ACPI_PROCESSOR + struct cpudata *cpu = all_cpu_data[policy->cpu]; + + if (cpu->acpi_data.state_count) + acpi_processor_unregister_performance(&cpu->acpi_data, + policy->cpu); + free_cpumask_var(cpu->acpi_data.shared_cpu_map); +#endif return 0; } @@ -1057,7 +1108,11 @@ static struct cpufreq_driver intel_pstate_driver = { .verify = intel_pstate_verify_policy, .setpolicy = intel_pstate_set_policy, .get = intel_pstate_get, +#ifdef CONFIG_ACPI_PROCESSOR + .bios_limit = acpi_processor_get_bios_limit, +#endif .init = intel_pstate_cpu_init, + .exit = intel_pstate_cpu_exit, .stop_cpu = intel_pstate_stop_cpu, .name = "intel_pstate", }; @@ -1286,6 +1341,8 @@ static int __init intel_pstate_setup(char *str) force_load = 1; if (!strcmp(str, "hwp_only")) hwp_only = 1; + if (!strcmp(str, "no_acpi")) + limits.no_acpi = 1; return 0; } early_param("intel_pstate", intel_pstate_setup);