From e194d41b9cb8e8e7e780f05302b973166a8efd1a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Aug 2012 12:12:25 -0400 Subject: [PATCH] cpufreq: Don't complain if a CPU doesn't support the desired governor --- modules/tasks/cpu-freq.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/tasks/cpu-freq.nix b/modules/tasks/cpu-freq.nix index cb64f8ca2a35..59e74fa66603 100644 --- a/modules/tasks/cpu-freq.nix +++ b/modules/tasks/cpu-freq.nix @@ -6,7 +6,7 @@ with pkgs.lib; ###### interface options = { - + powerManagement.cpuFreqGovernor = mkOption { default = ""; example = "ondemand"; @@ -17,7 +17,7 @@ with pkgs.lib; "userspace". ''; }; - + }; @@ -30,11 +30,19 @@ with pkgs.lib; jobs.cpufreq = { description = "Initialize CPU frequency governor"; - startOn = "started udev"; + after = [ "systemd-modules-load.service" ]; + wantedBy = [ "multi-user.target" ]; + + path = [ pkgs.cpufrequtils ]; preStart = '' for i in $(seq 0 $(($(nproc) - 1))); do - ${pkgs.cpufrequtils}/bin/cpufreq-set -g ${config.powerManagement.cpuFreqGovernor} -c $i + for gov in $(cpufreq-info -c $i -g); do + if [ "$gov" = ${config.powerManagement.cpuFreqGovernor} ]; then + echo "<6>setting governor on CPU $i to ‘$gov’" + cpufreq-set -c $i -g $gov + fi + done done ''; };