From owner-svn-src-head@FreeBSD.ORG Thu Jun 19 18:35:14 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C4208E4; Thu, 19 Jun 2014 18:35:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B1B7C2D67; Thu, 19 Jun 2014 18:35:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5JIZEQp080195; Thu, 19 Jun 2014 18:35:14 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5JIZE5w080194; Thu, 19 Jun 2014 18:35:14 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201406191835.s5JIZE5w080194@svn.freebsd.org> From: John Baldwin Date: Thu, 19 Jun 2014 18:35:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267647 - head/sys/dev/acpica X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jun 2014 18:35:15 -0000 Author: jhb Date: Thu Jun 19 18:35:14 2014 New Revision: 267647 URL: http://svnweb.freebsd.org/changeset/base/267647 Log: Trust the state of a power resource that get from a working _STA method instead of trying to cache it. Previously, we only trusted the state if we did not have a cached state. However, once a state was cached, the _STA method was always ignored. Specifically, once a power resource had been turned on once (e.g. during resume), the driver assumed it was always on even if _STA said it was off and never turned it back on. This prevented the power resource from being turned back on if a laptop was resumed twice, for example. To fix, just remove the cached state entirely and always use the results of _STA. The loops already skip any resources where _STA fails. Submitted by: trasz (initial patch to invoke _ON) MFC after: 1 week Modified: head/sys/dev/acpica/acpi_powerres.c Modified: head/sys/dev/acpica/acpi_powerres.c ============================================================================== --- head/sys/dev/acpica/acpi_powerres.c Thu Jun 19 16:28:42 2014 (r267646) +++ head/sys/dev/acpica/acpi_powerres.c Thu Jun 19 18:35:14 2014 (r267647) @@ -64,7 +64,6 @@ ACPI_MODULE_NAME("POWERRES") /* Return values from _STA on a power resource */ #define ACPI_PWR_OFF 0 #define ACPI_PWR_ON 1 -#define ACPI_PWR_UNK (-1) /* A relationship between a power resource and a consumer. */ struct acpi_powerreference { @@ -90,7 +89,6 @@ struct acpi_powerresource { ACPI_HANDLE ap_resource; UINT64 ap_systemlevel; UINT64 ap_order; - int ap_state; }; static TAILQ_HEAD(acpi_powerresource_list, acpi_powerresource) @@ -173,7 +171,6 @@ acpi_pwr_register_resource(ACPI_HANDLE r } rp->ap_systemlevel = obj->PowerResource.SystemLevel; rp->ap_order = obj->PowerResource.ResourceOrder; - rp->ap_state = ACPI_PWR_UNK; /* Sort the resource into the list */ status = AE_OK; @@ -638,22 +635,20 @@ acpi_pwr_switch_power(void) continue; } - /* We could cache this if we trusted it not to change under us */ status = acpi_GetInteger(rp->ap_resource, "_STA", &cur); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n", acpi_name(rp->ap_resource), status)); /* XXX is this correct? Always switch if in doubt? */ continue; - } else if (rp->ap_state == ACPI_PWR_UNK) - rp->ap_state = cur; + } /* * Switch if required. Note that we ignore the result of the switch * effort; we don't know what to do if it fails, so checking wouldn't * help much. */ - if (rp->ap_state != ACPI_PWR_ON) { + if (cur != ACPI_PWR_ON) { status = AcpiEvaluateObject(rp->ap_resource, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, @@ -661,7 +656,6 @@ acpi_pwr_switch_power(void) acpi_name(rp->ap_resource), AcpiFormatException(status))); } else { - rp->ap_state = ACPI_PWR_ON; ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s on\n", acpi_name(rp->ap_resource))); } @@ -682,22 +676,20 @@ acpi_pwr_switch_power(void) continue; } - /* We could cache this if we trusted it not to change under us */ status = acpi_GetInteger(rp->ap_resource, "_STA", &cur); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "can't get status of %s - %d\n", acpi_name(rp->ap_resource), status)); /* XXX is this correct? Always switch if in doubt? */ continue; - } else if (rp->ap_state == ACPI_PWR_UNK) - rp->ap_state = cur; + } /* * Switch if required. Note that we ignore the result of the switch * effort; we don't know what to do if it fails, so checking wouldn't * help much. */ - if (rp->ap_state != ACPI_PWR_OFF) { + if (cur != ACPI_PWR_OFF) { status = AcpiEvaluateObject(rp->ap_resource, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, @@ -705,7 +697,6 @@ acpi_pwr_switch_power(void) acpi_name(rp->ap_resource), AcpiFormatException(status))); } else { - rp->ap_state = ACPI_PWR_OFF; ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "switched %s off\n", acpi_name(rp->ap_resource))); }