Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 08 Jul 2011 15:20:46 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Vitaly Magerya <vmagerya@gmail.com>
Cc:        freebsd-acpi@FreeBSD.org
Subject:   Re: (Missing) power states of an Atom N455-based netbook
Message-ID:  <4E16F61E.80201@FreeBSD.org>
In-Reply-To: <CAL409KxL8S%2BzMOmSXghAQHLJRCS19ft%2BLiCKMPPm1dgEyMV%2BSQ@mail.gmail.com>
References:  <BANLkTim%2B1UwquMJ32WP8wZBGkYxPv78MLA@mail.gmail.com> <4E05EB91.9090509@FreeBSD.org> <BANLkTi=dyNx=TjyEqYMhSkRtddjVA4nAtw@mail.gmail.com> <4E0862A0.7060405@FreeBSD.org> <BANLkTikmVUtLyANBSqYb%2BL-xkwQ4Zo51Eg@mail.gmail.com> <4E09BADF.7050702@FreeBSD.org> <BANLkTin_%2BZH%2Bo7rdR9ijHMtrXcSdH9ZSdQ@mail.gmail.com> <4E0A41C8.3000904@FreeBSD.org> <BANLkTikwgy%2BKuA5E5zXQKGT-eyV35YAVag@mail.gmail.com> <4E0CE158.6030804@FreeBSD.org> <BANLkTinRY-h%2BkpXtwWJ_L86qVRdoynFSdg@mail.gmail.com> <4E0DB58F.4070906@FreeBSD.org> <CAL409Kw=rUnm9D56KvYiFWiU-bp59KqKnPcUXL38rZsW_Qh8AQ@mail.gmail.com> <4E130154.9080809@FreeBSD.org> <CAL409KyX0jDd9U=7GExvyPR1cDxPwsMHm2b%2B1Tvmijhpg0iWDQ@mail.gmail.com> <4E146FDB.2020602@FreeBSD.org> <CAL409KxL8S%2BzMOmSXghAQHLJRCS19ft%2BLiCKMPPm1dgEyMV%2BSQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
on 06/07/2011 22:20 Vitaly Magerya said the following:
> Actually, I have a simpler fix. We could allow setting hw.acpi.cx_lowest
> to any value, including states that are not currently present. Then,
> on updates to available Cx states, our ACPI code will automatically
> set dev.cpu.N.cx_lowest to the closest valid value without the need
> for a separate power_profile invocation.
> 
> Here's the diff:
> 
> --- acpi_cpu.c.orig     2011-07-05 19:50:31.000000000 +0000
> +++ acpi_cpu.c  2011-07-06 17:23:16.000000000 +0000
> @@ -1194,7 +1194,7 @@
>      if (strlen(state) < 2 || toupper(state[0]) != 'C')
>         return (EINVAL);
>      val = (int) strtol(state + 1, NULL, 10) - 1;
> -    if (val < 0 || val > cpu_cx_count - 1)
> +    if (val < 0)
>         return (EINVAL);
>      cpu_cx_lowest = val;

This change is a little bit more intrusive than I would like.
There are some things about cpu_cx_lowest handling in the code that make me a bit
unsure if this change is completely safe.  I suspect that there could be problems
on systems where number Cx states becomes smaller after some events (e.g. AC
connection).
I would prefer other developers to also comment on this.
Maybe it's worth while opening a PR for this proposed change.

> You can even simplify power_profile with this change:
> 
> --- power_profile.orig  2011-07-06 18:39:27.000000000 +0000
> +++ power_profile       2011-07-06 18:40:20.000000000 +0000
> @@ -81,8 +81,7 @@
>  # Set the various sysctls based on the profile's values.
>  node="hw.acpi.cpu.cx_lowest"
>  highest_value="C1"
> -lowest_value="`(sysctl -n dev.cpu.0.cx_supported | \
> -       awk '{ print "C" split($0, a) }' -) 2> /dev/null`"
> +lowest_value="C99"
>  eval value=\$${profile}_cx_lowest
>  sysctl_set

C99 looks too scary (and too familiar) :-)
I think that C6 would be sufficient here.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E16F61E.80201>