Date: Fri, 11 Jun 2010 12:27:48 +0200 From: Giovanni Trematerra <giovanni.trematerra@gmail.com> To: freebsd-stable <freebsd-stable@freebsd.org>, John Baldwin <jhb@freebsd.org>, kib@freebsd.org, jkim@freebsd.org, avg@freebsd.org Cc: David DEMELIER <demelier.david@gmail.com>, Brandon Gooch <jamesbrandongooch@gmail.com>, Rui Paulo <rpaulo@freebsd.org>, Attilio Rao <attilio@freebsd.org> Subject: Re: Kernel panic when unpluggin AC adaptor Message-ID: <AANLkTinJuPX9CLW5RRYF8Xh8vX7uKacU9BpmX5uuFuxw@mail.gmail.com> In-Reply-To: <AANLkTikUzurYQE7-tDNT-Sd9DaeSp2YLGwUXoupkvQSV@mail.gmail.com> References: <g2mb3954bba1005031436g77215426n83ce7904e5ef321@mail.gmail.com> <m2mb3954bba1005031457h642b551fq5c9062af8cbdf7d1@mail.gmail.com> <20100503224206.GB9134@icarus.home.lan> <i2rb3954bba1005040132z817cc785gfbfd2bb520d87cfc@mail.gmail.com> <20100504083738.GA23820@icarus.home.lan> <i2mb3954bba1005040141m97cbd6b0u69651cb26992ee97@mail.gmail.com> <20100504085332.GA24219@icarus.home.lan> <n2gb3954bba1005040351o718a9508u8e992b0469137bdf@mail.gmail.com> <r2p4e6cba831005040836y43a0bb21x82b4b25334a755fa@mail.gmail.com> <y2yb3954bba1005040927l538ef077q20aea7a4c5121fdd@mail.gmail.com> <h2ub3954bba1005040935h7e5207b2o399c357a1cfd407@mail.gmail.com> <AANLkTikUzurYQE7-tDNT-Sd9DaeSp2YLGwUXoupkvQSV@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] On Thu, Jun 10, 2010 at 10:58 PM, Giovanni Trematerra <giovanni.trematerra@gmail.com> wrote: > On Tue, May 4, 2010 at 6:35 PM, David DEMELIER <demelier.david@gmail.com> wrote: >> Good news ! It worked, check the picture here : >> >> http://img63.imageshack.us/img63/4244/dsc00361g.jpg >> > > Into the file sys/dev/acpica/acpi_cpu.c at the end of acpi_cpu_notify > (a per cpu notification handler), called when _CST objects changing, > global cpu_cx_count is set to the greatest value of all sc->cpu_cx_count > per-cpu variables. That could result in a panic as David reported, > because that lets to invoke acpi_cpu_global_cx_lowest_sysctl from > /etc/rc.d/power_profile, when AC adapter is unplugged, with a value > that not all the CPUs could handle in the acpi_cpu_idle. > The patch also change global cpu_cx_lowest according to new value of > global cpu_cx_count if needed. > > David Demelier made a great work to test every patch I sent him > to identify the source of the problem. > > Please, let me know your comments and possibly commit the patch > if you think is good enough. As jhb@ pointed me out in private with the previous patch a CPU could never enter in the lowest Cx-state even if it gained. So I'd like to propose this new solution. When hw.acpi.cpu.cx_lowest sysctl is set, the global handler in sys/dev/acpi_cpu.c will set the greatest sc->cpu_cx_lowest value supported by the CPU and not the same value for all CPUs. Later, when CPU, possibly gain new Cx-states, the acpi_cpu_notify handler will set sc->cpu_cx_lowest accordingly with global cx_lowest and the Cx-states supported by the CPU. Now I think that /etc/rc.d/power_profile script has a problem but that is a different story. The script select the lowest_value only querying cx-states of the dev.cpu.0. If different CPUs may have different Cx-states, the script should use as lowest_value the lowest value between all the CPUs. Please, let me know your comments and possibly commit the patch if you think is good enough. -- Gianni [-- Attachment #2 --] diff -r ac95a73d358d sys/dev/acpica/acpi_cpu.c --- a/sys/dev/acpica/acpi_cpu.c Tue May 18 08:13:40 2010 -0400 +++ b/sys/dev/acpica/acpi_cpu.c Fri Jun 11 03:10:37 2010 -0400 @@ -1009,6 +1009,8 @@ acpi_cpu_notify(ACPI_HANDLE h, UINT32 no if (isc->cpu_cx_count > cpu_cx_count) cpu_cx_count = isc->cpu_cx_count; } + if (sc->cpu_cx_lowest < cpu_cx_lowest) + acpi_cpu_set_cx_lowest(sc, min(cpu_cx_lowest, sc->cpu_cx_count - 1)); ACPI_SERIAL_END(cpu); } @@ -1204,7 +1206,7 @@ acpi_cpu_global_cx_lowest_sysctl(SYSCTL_ ACPI_SERIAL_BEGIN(cpu); for (i = 0; i < cpu_ndevices; i++) { sc = device_get_softc(cpu_devices[i]); - acpi_cpu_set_cx_lowest(sc, val); + acpi_cpu_set_cx_lowest(sc, min(val, sc->cpu_cx_count - 1)); } ACPI_SERIAL_END(cpu);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinJuPX9CLW5RRYF8Xh8vX7uKacU9BpmX5uuFuxw>
