From owner-freebsd-acpi@FreeBSD.ORG Thu Mar 26 14:51:11 2009 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B99B310656D0 for ; Thu, 26 Mar 2009 14:51:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 7D1858FC1E for ; Thu, 26 Mar 2009 14:51:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 0A19146B46; Thu, 26 Mar 2009 10:51:11 -0400 (EDT) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n2QEowM6083075; Thu, 26 Mar 2009 10:51:04 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Bruce Cran Date: Thu, 26 Mar 2009 10:49:02 -0400 User-Agent: KMail/1.9.7 References: <200903200030.n2K0U3iG011009@freefall.freebsd.org> <200903260937.51028.jhb@freebsd.org> <20090326142456.042ea2f0@gluon.draftnet> In-Reply-To: <20090326142456.042ea2f0@gluon.draftnet> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200903261049.02977.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 26 Mar 2009 10:51:04 -0400 (EDT) X-Virus-Scanned: ClamAV 0.94.2/9169/Thu Mar 26 00:13:48 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Daniel =?utf-8?q?Dvo=C5=99=C3=A1k?= , freebsd-acpi@freebsd.org Subject: Re: kern/108581: [sysctl] sysctl: hw.acpi.cpu.cx_lowest: Invalid argument X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2009 14:51:13 -0000 On Thursday 26 March 2009 10:24:56 am Bruce Cran wrote: > On Thu, 26 Mar 2009 09:37:50 -0400 > John Baldwin wrote: >=20 > > On Wednesday 25 March 2009 6:39:14 pm Bruce Cran wrote: > > > On Fri, 20 Mar 2009 00:30:03 GMT > > > Daniel Dvo=C5=99=C3=A1k wrote: > > >=20 > > > > The following reply was made to PR kern/108581; it has been noted > > > > by GNATS. > > > >=20 > > > > From: =3D?UTF-8?Q?Daniel_Dvo=3DC5=3D99=3DC3=3DA1k?=3D > > > > To: , > > > > > > > > Cc: =20 > > > > Subject: Re: kern/108581: [sysctl] sysctl: hw.acpi.cpu.cx_lowest: > > > > Invalid argument Date: Fri, 20 Mar 2009 01:01:51 +0100 > > > >=20 > > > > This is a multi-part message in MIME format. > > > > =20 > > > > ------=3D_NextPart_000_0007_01C9A8F7.746C4190 > > > > Content-Type: text/plain; > > > > charset=3D"UTF-8" > > > > Content-Transfer-Encoding: quoted-printable > > > > =20 > > > > Hi acpi team, > > > > =3D20 > > > > today I have installed fbsd 7.1R on one box with this relativly > > > > old =3D error and I was surprised about results .. it is the same: > > > > =3D20 > > > > # uname -a > > > > FreeBSD X.Y.Z 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 > > > > 14:37:25 =3D UTC 2009 > > > > root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC =3D i386 > > > > =20 > > > > # sysctl dev.cpu.0.cx_supported > > > > dev.cpu.0.cx_supported: C1/0 > > > > =20 > > > > # sysctl hw.acpi.cpu.cx_lowest=3D3DC1 > > > > hw.acpi.cpu.cx_lowest: C1 > > > > sysctl: hw.acpi.cpu.cx_lowest: Invalid argument > > > > =3D20 > > > > # sysctl hw.acpi.cpu.cx_lowest=3D3DC0 > > > > hw.acpi.cpu.cx_lowest: C1 > > > > sysctl: hw.acpi.cpu.cx_lowest: Invalid argument > > > > =3D20 > > > > # sysctl hw.acpi.cpu.cx_lowest=3D3DC1/0 > > > > hw.acpi.cpu.cx_lowest: C1 > > > > sysctl: hw.acpi.cpu.cx_lowest: Invalid argument > > > > =20 > > > > # dmesg -a | grep "acpi" > > > > acpi0: on motherboard > > > > acpi0: Overriding SCI Interrupt from IRQ 9 to IRQ 20 > > > > acpi0: [ITHREAD] > > > > acpi0: Power Button (fixed) > > > > acpi0: reservation of 0, a0000 (3) failed > > > > acpi0: reservation of 100000, ff00000 (3) failed > > > > acpi_timer0: <24-bit timer at 3.579545MHz> port 0xe408-0xe40b on > > > > acpi0 acpi_button0: on acpi0 > > > > pcib0: port 0xcf8-0xcff on acpi0 > > > > atkbdc0: port 0x60,0x64 irq 1 on > > > > acpi0 cpu0: on acpi0 > > > > hw.acpi.cpu.cx_lowest: > > > > hw.acpi.cpu.cx_lowest > > >=20 > > > I think I've found the problem and have updated the PR kern/108581 > > > (http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/108581). The global > > > cpu_cx_count was being initialized to 0 in acpi_cpu_startup > > > (in /sys/dev/acpica/acpi_cpu.c) but code below it appears to assume > > > that it's been intialized to 3 because it only sets it if it's > > > higher than the current CPU supports - that is, cpu_cx_count should > > > reflect the highest Cx state that all CPUs support. > > >=20 > > > There's also a bug in the _CST section just below it; I think the > > > line: > > >=20 > > > if (sc->cpu_cx_count > cpu_cx_count) > > >=20 > > > should be > > >=20 > > > if (sc->cpu_cx_count < cpu_cx_count) > >=20 > > No, the code is doing things differently on purpose (though I'm not > > completely sure why). For _CST it sets cpu_cx_count to the maximum > > Cx level supported by any CPU in the system. For non-_CST it sets it > > to the maximum Cx level supported by all CPUs in the system. I think > > it is correct for cpu_cx_count to always start at 0 and only be > > bumped up to a higher setting. Setting it to 3 would be very wrong > > for the _CST case as I've seen CPUs that support C4. > >=20 > > Note that C1 _always_ exists as it is simply the "hlt" instruction > > that has existed since the 8086. Only C2+ require power-saving > > extension support in the CPU, so cpu_cx_count should always end up >=3D > > 1. It would be interesting if you could add some debug printfs to > > print out the values that acpi_cpu_generic_cx_probe() computes for > > 'sc->cpu_cx_count' (sysctl dev.cpu could be useful for this) as well > > as all changes to the 'cpu_cx_count' global variable. > >=20 >=20 > For my Athlon XP CPU, acpi_cpu_generic_cx_probe sets sc->cpu_cx_count > to 1, and subsequently dev.cpu.0.cx_lowest has always worked. After > adding printfs I found that the problem is that the cpu_cx_generic > block in acpi_cpu_startup is being run and because cpu_cx_count is set > to 0 it never gets updated; the statement "if (sc->cpu_cx_count < > cpu_cx_count)" is never true. Err, you missed the end of acpi_cpu_generic_cx_probe() where it does this: /* Update the largest cx_count seen so far */ if (sc->cpu_cx_count > cpu_cx_count) cpu_cx_count =3D sc->cpu_cx_count; That is effectively the same as the for loop in the _CST case that finds th= e=20 maximum supported state of all CPUs. It would probably be clearer to move= =20 that into acpi_cpu_startup() instead. =2D-=20 John Baldwin