From owner-svn-src-all@FreeBSD.ORG Fri Jun 27 20:57:13 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1A2B45FE; Fri, 27 Jun 2014 20:57:13 +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 06B7F2C0E; Fri, 27 Jun 2014 20:57:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5RKvC2i003452; Fri, 27 Jun 2014 20:57:12 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5RKvCAD003451; Fri, 27 Jun 2014 20:57:12 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201406272057.s5RKvCAD003451@svn.freebsd.org> From: John Baldwin Date: Fri, 27 Jun 2014 20:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r267983 - in stable: 10/sys/dev/acpica 9/sys/dev/acpica X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jun 2014 20:57:13 -0000 Author: jhb Date: Fri Jun 27 20:57:12 2014 New Revision: 267983 URL: http://svnweb.freebsd.org/changeset/base/267983 Log: MFC 267647: Trust the state of a power resource that we get from a working _STA method instead of trying to cache it. Modified: stable/10/sys/dev/acpica/acpi_powerres.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/9/sys/dev/acpica/acpi_powerres.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/10/sys/dev/acpica/acpi_powerres.c ============================================================================== --- stable/10/sys/dev/acpica/acpi_powerres.c Fri Jun 27 20:45:17 2014 (r267982) +++ stable/10/sys/dev/acpica/acpi_powerres.c Fri Jun 27 20:57:12 2014 (r267983) @@ -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))); }