From patchwork Thu Oct 31 15:24:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Huang X-Patchwork-Id: 3120831 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4DB289F2B7 for ; Thu, 31 Oct 2013 15:24:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D78420426 for ; Thu, 31 Oct 2013 15:24:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99C152045A for ; Thu, 31 Oct 2013 15:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753063Ab3JaPYO (ORCPT ); Thu, 31 Oct 2013 11:24:14 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:32599 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752852Ab3JaPYL (ORCPT ); Thu, 31 Oct 2013 11:24:11 -0400 Received: from g2t2360.austin.hp.com (txe01lbes9037-9038-vl451-snat0.austin.hp.com [15.216.28.90]) by g1t0029.austin.hp.com (Postfix) with ESMTP id 20E8938052; Thu, 31 Oct 2013 15:24:11 +0000 (UTC) Received: from [10.152.0.6] (openvpn.lnx.usa.hp.com [16.125.113.33]) by g2t2360.austin.hp.com (Postfix) with ESMTP id 4F13C52; Thu, 31 Oct 2013 15:24:07 +0000 (UTC) Message-ID: <1383233045.2462.7.camel@adrian-F6S> Subject: [PATCH v3] cpufreq: intel_pstate: skip the driver if ACPI has power mgmt option From: Adrian Huang To: "Rafael J. Wysocki" Cc: Dirk Brandewie , viresh.kumar@linaro.org, linux-pm@vger.kernel.org, linda.knippers@hp.com, adrianhuang0701@gmail.com Date: Thu, 31 Oct 2013 23:24:05 +0800 X-Mailer: Evolution 3.6.2-0ubuntu0.1 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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Do not load the Intel pstate driver if the platform firmware (ACPI BIOS) supports the power management alternatives. The ACPI BIOS indicates that the OS control mode can be used if the _PSS (Performance Supported States) is defined in ACPI table. For the OS control mode, the Intel pstate driver will be loaded. Signed-off-by: Adrian Huang --- Changes from v2: - Remove unnecessary assignments and parentheses (Thanks to Rafael) Changes from v1: - Minimize indentation levels (Thanks to Rafael) - Re-define some local variables (Thanks to by Rafael) - Return -ENODEV if platform FW has power management modes (Thanks to by Dirk) drivers/cpufreq/intel_pstate.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index eb3fdc7..9ec1d6c 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include @@ -129,6 +131,18 @@ static struct perf_limits limits = { .max_sysfs_pct = 100, }; +struct hw_vendor_info { + u16 valid; + char oem_id[ACPI_OEM_ID_SIZE]; + char oem_table_id[ACPI_OEM_TABLE_ID_SIZE]; +}; + +/* Hardware vendor-specific info that has its own power management modes */ +static struct hw_vendor_info vendor_info[] = { + {1, "HP ", "ProLiant"}, + {0, "", ""}, +}; + static inline void pid_reset(struct _pid *pid, int setpoint, int busy, int deadband, int integral) { pid->setpoint = setpoint; @@ -698,6 +712,55 @@ static int intel_pstate_msrs_not_valid(void) return 0; } + +static bool intel_pstate_no_acpi_pss(void) +{ + int i; + + for_each_possible_cpu(i) { + acpi_status status; + union acpi_object *pss; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_processor *pr = per_cpu(processors, i); + + if (!pr) + continue; + + status = acpi_evaluate_object(pr->handle, "_PSS", + NULL, &buffer); + if (ACPI_FAILURE(status)) + continue; + + pss = buffer.pointer; + if (pss && pss->type == ACPI_TYPE_PACKAGE) { + kfree(pss); + return false; + } + + kfree(pss); + } + + return true; +} + +static bool intel_pstate_platform_pwr_mgmt_exists(void) +{ + struct acpi_table_header hdr; + struct hw_vendor_info *v_info; + + if (ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr))) + return false; + + for (v_info = vendor_info; v_info->valid; v_info++) { + if (!strncmp(hdr.oem_id, v_info->oem_id, ACPI_OEM_ID_SIZE) + && !strncmp(hdr.oem_table_id, v_info->oem_table_id, ACPI_OEM_TABLE_ID_SIZE) + && intel_pstate_no_acpi_pss()) + return true; + } + + return false; +} + static int __init intel_pstate_init(void) { int cpu, rc = 0; @@ -706,6 +769,13 @@ static int __init intel_pstate_init(void) if (no_load) return -ENODEV; + /* + * The Intel pstate driver will be ignored if the platform + * firmware has its own power management modes. + */ + if (!acpi_disabled && intel_pstate_platform_pwr_mgmt_exists()) + return -ENODEV; + id = x86_match_cpu(intel_pstate_cpu_ids); if (!id) return -ENODEV;