From patchwork Tue Nov 27 19:55:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 1812481 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D1F503FC54 for ; Tue, 27 Nov 2012 19:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601Ab2K0Tuk (ORCPT ); Tue, 27 Nov 2012 14:50:40 -0500 Received: from hydra.sisk.pl ([212.160.235.94]:34535 "EHLO hydra.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755503Ab2K0Tuj (ORCPT ); Tue, 27 Nov 2012 14:50:39 -0500 Received: from vostro.rjw.lan (afbf225.neoplus.adsl.tpnet.pl [95.49.31.225]) by hydra.sisk.pl (Postfix) with ESMTPSA id 97D14E3DB8; Tue, 27 Nov 2012 20:52:30 +0100 (CET) From: "Rafael J. Wysocki" To: linux-acpi@vger.kernel.org Cc: Zhang Rui , "Matthew Garrett (mjg@redhat.com)" , katabami@lavabit.com Subject: Re: [PATCH] ACPI thermal: _TMP and _CRT/_HOT/_PSV/_ACx dependency fix Date: Tue, 27 Nov 2012 20:55:22 +0100 Message-ID: <13424597.Clh1ApcFoE@vostro.rjw.lan> User-Agent: KMail/4.9.3 (Linux/3.7.0-rc7; KDE/4.9.3; x86_64; ; ) In-Reply-To: <1353981690.2157.5.camel@rzhang1-mobl4> References: <1353981690.2157.5.camel@rzhang1-mobl4> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On Tuesday, November 27, 2012 10:01:30 AM Zhang Rui wrote: > From 391908867c2a500a9068aa9f2a8e74663fff75ac Mon Sep 17 00:00:00 2001 > From: Zhang Rui > Date: Fri, 23 Nov 2012 09:25:10 +0800 > Subject: [PATCH] ACPI thermal: _TMP and _CRT/_HOT/_PSV/_ACx dependency fix > > On some platforms, _TMP and _CRT/_HOT/_PSV/_ACx have dependency. > And there is no way for OS to detect this dependency. > > commit 9bcb8118965ab4631a65ee0726e6518f75cda6c5 shows us a problem > that _TMP must be evaluate after _CRT/_HOT/_PSV/_ACx, or esle > firmware will shutdown the system. > > But the machins in https://bugzilla.kernel.org/show_bug.cgi?id=43284 > shows us that _PSV would return valid value only if _TMP has been > evaluated once. > > With this patch, all of the control methods will be evaluated once, > in the order of _CRT/_HOT/_PSV/_CRT, _TMP, before they are actually used. I'm going to apply it, but with a few cleanups. The result is appended, please double check if it is still correct. Thanks, Rafael --- From: Zhang Rui Subject: ACPI / thermal: _TMP and _CRT/_HOT/_PSV/_ACx dependency fix On some platforms, _TMP and _CRT/_HOT/_PSV/_ACx have dependency. And there is no way for OS to detect this dependency. commit 9bcb8118965ab4631a65ee0726e6518f75cda6c5 shows us a problem that _TMP must be evaluate after _CRT/_HOT/_PSV/_ACx, or else firmware will shutdown the system. But the machine in https://bugzilla.kernel.org/show_bug.cgi?id=43284 shows us that _PSV would return valid value only if _TMP has been evaluated once. With this patch, all of the control methods will be evaluated once, in the _CRT/_HOT/_PSV/_CRT/_TMP order, before they are actually used. [rjw: Added a local variable for the handle and modified the loop slightly.] Signed-off-by: Zhang Rui Tested-by: katabami --- drivers/acpi/thermal.c | 31 +++++++++++++++++++++++++++++++ drivers/acpi/thermal.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) Index: linux/drivers/acpi/thermal.c =================================================================== --- linux.orig/drivers/acpi/thermal.c +++ linux/drivers/acpi/thermal.c @@ -984,6 +984,38 @@ static void acpi_thermal_notify(struct a } } +/* + * On some platforms, the AML code has dependency about + * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx. + * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after + * /_CRT/_HOT/_PSV/_ACx, or else system will be power off. + * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0 + * if _TMP has never been evaluated. + * + * As this dependency is totally transparent to OS, evaluate + * all of them once, in the order of _CRT/_HOT/_PSV/_ACx, + * _TMP, before they are actually used. + */ +static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) +{ + acpi_handle handle = tz->device->handle; + unsigned long long value; + int i; + + acpi_evaluate_integer(handle, "_CRT", NULL, &value); + acpi_evaluate_integer(handle, "_HOT", NULL, &value); + acpi_evaluate_integer(handle, "_PSV", NULL, &value); + for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { + char name[5] = { '_', 'A', 'C', ('0' + i), '\0' }; + acpi_status status; + + status = acpi_evaluate_integer(handle, name, NULL, &value); + if (status == AE_NOT_FOUND) + break; + } + acpi_evaluate_integer(handle, "_TMP", NULL, &value); +} + static int acpi_thermal_get_info(struct acpi_thermal *tz) { int result = 0; @@ -992,6 +1024,8 @@ static int acpi_thermal_get_info(struct if (!tz) return -EINVAL; + acpi_thermal_aml_dependency_fix(tz); + /* Get trip points [_CRT, _PSV, etc.] (required) */ result = acpi_thermal_get_trip_points(tz); if (result)