From patchwork Thu Aug 16 12:12:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Huang X-Patchwork-Id: 2904411 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 296CFBFF05 for ; Wed, 18 Sep 2013 01:14:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D3E320256 for ; Wed, 18 Sep 2013 01:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BD7E2021B for ; Wed, 18 Sep 2013 01:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751054Ab3IRBOu (ORCPT ); Tue, 17 Sep 2013 21:14:50 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:21039 "EHLO g4t0016.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040Ab3IRBOt (ORCPT ); Tue, 17 Sep 2013 21:14:49 -0400 Received: from g4t0009.houston.hp.com (g4t0009.houston.hp.com [16.234.32.26]) by g4t0016.houston.hp.com (Postfix) with ESMTP id 65DF714129; Wed, 18 Sep 2013 01:14:49 +0000 (UTC) Received: from localhost.localdomain (unknown [16.153.113.42]) by g4t0009.houston.hp.com (Postfix) with ESMTP id D7DF6C19C; Wed, 18 Sep 2013 01:14:47 +0000 (UTC) From: Adrian Huang To: "Rafael J. Wysocki" , Viresh Kumar Cc: cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linda.knippers@hp.com, Adrian Huang Subject: [PATCH 1/1] Skip the driver if ACPI has power mgmt option Date: Thu, 16 Aug 2012 20:12:04 +0800 Message-Id: <1345119124-32673-1-git-send-email-adrian.huang@hp.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, 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 alternative. 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 --- drivers/cpufreq/intel_pstate.c | 84 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 6efd96c..c181109 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include + #include #include @@ -129,6 +132,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; @@ -692,6 +707,66 @@ static int intel_pstate_msrs_not_valid(void) return 0; } + +static bool intel_pstate_no_acpi_pss(void) +{ + struct acpi_processor *pr; + acpi_status status = AE_OK; + union acpi_object *pss = NULL; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + int i; + + for_each_possible_cpu(i) { + pr = per_cpu(processors, i); + + if (pr) { + status = acpi_evaluate_object(pr->handle, "_PSS", + NULL, &buffer); + + pss = buffer.pointer; + + if (ACPI_SUCCESS(status) && pss) { + /* Found _PSS */ + if (pss->type == ACPI_TYPE_PACKAGE) + return false; + } + } + } + + /* No _PSS */ + return true; +} + +static bool intel_pstate_check_platform_pwr_mgmt(void) +{ + struct acpi_table_header hdr; + struct hw_vendor_info *v_info; + + if (acpi_get_table_header(ACPI_SIG_FADT, 0, &hdr) == AE_OK) { + for (v_info = vendor_info; v_info->valid; v_info++) { + /* + * Check if the hardware/platform is in the + * predefined vendor data. + */ + 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)) { + + /* + * No _PSS defintion in ACPI BIOS means that + * the platform firmware has its own power + * management modes. + */ + if (intel_pstate_no_acpi_pss()) + return true; + } + } + } + + return false; +} + static int __init intel_pstate_init(void) { int cpu, rc = 0; @@ -700,6 +775,15 @@ static int __init intel_pstate_init(void) if (no_load) return -ENODEV; + if (!acpi_disabled) { + /* + * Check if the platform has its own power management modes. + * If so, the pstate cpufreq driver will be ignored. + */ + if (intel_pstate_check_platform_pwr_mgmt()) + return 0; + } + id = x86_match_cpu(intel_pstate_cpu_ids); if (!id) return -ENODEV;