From patchwork Fri Jun 26 02:06:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao, Yakui" X-Patchwork-Id: 32496 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5Q25hfu013277 for ; Fri, 26 Jun 2009 02:05:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752306AbZFZCFd (ORCPT ); Thu, 25 Jun 2009 22:05:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752666AbZFZCFd (ORCPT ); Thu, 25 Jun 2009 22:05:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:39746 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752306AbZFZCFc (ORCPT ); Thu, 25 Jun 2009 22:05:32 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 25 Jun 2009 18:56:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.42,294,1243839600"; d="scan'208";a="527941597" Received: from yakui_zhao.sh.intel.com (HELO [10.239.13.177]) ([10.239.13.177]) by orsmga001.jf.intel.com with ESMTP; 25 Jun 2009 19:05:23 -0700 Subject: [PATCH]: ACPI: Sort the ACPI P-state table in descending order by cpufre From: yakui_zhao To: lenb@kernel.org Cc: linux-acpi@vger.kernel.org, ming.m.lin@intel.com Organization: Intel Open Source Technology Center Date: Fri, 26 Jun 2009 10:06:41 +0800 Message-Id: <1245982001.7266.120.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Zhao Yakui According to ACPI spec the the _PSS object indicates to OSPM the supported processor performance states. And they should be sorted in descending order by cpufreq. But unfortunately on some boxes the cpufreq in _PSS object is sorted in ascending order, which causes that cpufreq driver can't work well. Sort the ACPI P-state table in descending order by cpufreq. http://bugzilla.kernel.org/show_bug.cgi?id=13529 Signed-off-by: Zhao Yakui tested-by: Mukik182 cc: Ling Ming --- drivers/acpi/processor_perflib.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6/drivers/acpi/processor_perflib.c =================================================================== --- linux-2.6.orig/drivers/acpi/processor_perflib.c 2009-06-25 09:00:40.000000000 +0800 +++ linux-2.6/drivers/acpi/processor_perflib.c 2009-06-26 09:59:54.000000000 +0800 @@ -38,6 +38,7 @@ #include #include #include +#include #define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" @@ -246,6 +247,25 @@ return result; } +static int pss_cmp_func(const void *a, const void *b) +{ + struct acpi_processor_px *pxa, *pxb; + acpi_integer acpi_value; + + pxa = (struct acpi_processor_px *)a; + pxb = (struct acpi_processor_px *)b; + + acpi_value = pxb->core_frequency - pxa->core_frequency; + return (int) acpi_value; +} +static void pss_swap_func(void *a, void *b, int size) +{ + struct acpi_processor_px temp_px; + + memcpy((void *)&temp_px, a, size); + memcpy(a, b, size); + memcpy(b, (void *)&temp_px, size); +} static int acpi_processor_get_performance_states(struct acpi_processor *pr) { int result = 0; @@ -323,7 +343,10 @@ goto end; } } - + sort((void *)(pr->performance->states), pr->performance->state_count, + sizeof(struct acpi_processor_px), + pss_cmp_func, + pss_swap_func); end: kfree(buffer.pointer);