From nobody@FreeBSD.org  Sun Apr 25 13:08:17 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8FB0F16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 25 Apr 2004 13:08:17 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 72EAF43D46
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 25 Apr 2004 13:08:17 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i3PK8GIn031255
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 25 Apr 2004 13:08:16 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i3PK8GJg031254;
	Sun, 25 Apr 2004 13:08:16 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200404252008.i3PK8GJg031254@www.freebsd.org>
Date: Sun, 25 Apr 2004 13:08:16 -0700 (PDT)
From: Dmitry Remesov <dmitry@remesov.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Critical typos in setting power state routines
X-Send-Pr-Version: www-2.3

>Number:         65964
>Category:       kern
>Synopsis:       Critical typos in setting power state routines
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 25 13:10:21 PDT 2004
>Closed-Date:    Sun Apr 25 20:12:59 MDT 2004
>Last-Modified:  Sun Apr 25 20:12:59 MDT 2004
>Originator:     Dmitry Remesov
>Release:        5.2-CURRENT
>Organization:
>Environment:
FreeBSD dmitry.local-uga.dmz 5.2-CURRENT FreeBSD 5.2-CURRENT #4: Sun Apr 25 23:21:41 MSD 2004     root@dmitry.local-uga.dmz:/usr/src/sys/i386/compile/kernconf  i386
>Description:
1. There is an error in sys/dev/acpica/acpi_pci.c that prevents setting power state from high values to low (D3 -> D0).

2. In pci_set_powerstate_method(dev,child,state) in file sys/dev/pci/pci.c a check is made on current powerstate of device not for device child but for device dev

3. It is stated in UPDATING that the default is to do powerstate changes on startup and shutdown (hw.pci.do_powerstate is 1 by default) but it is not

These problems seem to be typos
>How-To-Repeat:
      
>Fix:
Here are pacthes


--- sys/dev/acpica/acpi_pci.c.orig      Wed Apr 14 21:46:21 2004
+++ sys/dev/acpica/acpi_pci.c   Sun Apr 25 23:35:13 2004
@@ -207,7 +207,7 @@
                            acpi_state, device_get_nameunit(child),
                            AcpiFormatException(status));
        }
-       if (state > old_state)
+       if (state < old_state)
                return (pci_set_powerstate_method(dev, child, state));
        else
                return (0);


--- sys/dev/pci/pci.c.orig      Fri Apr 23 19:48:48 2004
+++ sys/dev/pci/pci.c   Sun Apr 25 23:38:39 2004
@@ -176,10 +176,10 @@
 enable these bits correctly.  We'd like to do this all the time, but there\n\
 are some peripherals that this causes problems with.");

-static int pci_do_powerstate = 0;
+static int pci_do_powerstate = 1;
 TUNABLE_INT("hw.pci.do_powerstate", (int *)&pci_do_powerstate);
 SYSCTL_INT(_hw_pci, OID_AUTO, do_powerstate, CTLFLAG_RW,
-    &pci_do_powerstate, 0,
+    &pci_do_powerstate, 1,
     "Enable setting the power states of the PCI devices.  This means that we\n\
 set devices into D0 before probe/attach, and D3 if they fail to attach.  It\n\
 also means we set devices into D3 state before shutdown.");
@@ -495,7 +495,7 @@
        /*
         * Dx -> Dx is a nop always.
         */
-       if (pci_get_powerstate(dev) == state)
+       if (pci_get_powerstate(child) == state)
                return (0);

        if (cfg->pp.pp_cap != 0) {



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: nork 
Responsible-Changed-When: Sun Apr 25 18:56:41 PDT 2004 
Responsible-Changed-Why:  
Over to power specialist. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=65964 
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Sun Apr 25 20:12:44 MDT 2004 
State-Changed-Why:  
Fixed.  Thanks! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=65964 
>Unformatted:
