aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpufreq.c4
-rw-r--r--cpufreq.h4
-rw-r--r--cputemp2maxfreq.c9
-rw-r--r--cputemp2maxfreq.h15
-rw-r--r--sysfs.c4
5 files changed, 22 insertions, 14 deletions
diff --git a/cpufreq.c b/cpufreq.c
index 1eab630..6497eff 100644
--- a/cpufreq.c
+++ b/cpufreq.c
@@ -22,7 +22,7 @@ int cpufreq_is_cpu(char *name)
}
// Set a cpufreq parameter to a value
-int cpufreq_set_str(char *parameter,char *value,int checkdelay)
+int cpufreq_set_str(char *parameter,char *value,long int checkdelay)
{
int fd;
char sysfs_file[128];
@@ -94,7 +94,7 @@ int cpufreq_set_str(char *parameter,char *value,int checkdelay)
// This is just a wrapper around cpufreq_set_str with long int to string
// convertion
-int cpufreq_set_long_int(char *parameter,long int value,int checkdelay)
+int cpufreq_set_long_int(char *parameter,long int value,long int checkdelay)
{
char buf[255];
diff --git a/cpufreq.h b/cpufreq.h
index 5b13010..de52bca 100644
--- a/cpufreq.h
+++ b/cpufreq.h
@@ -1,7 +1,7 @@
#ifndef HAVE_CPUFREQ_H
#define HAVE_CPUFREQ_H
-int cpufreq_set_str(char *parameter,char *value,int checkdelay);
-int cpufreq_set_long_int(char *parameter,long int value,int checkdelay);
+int cpufreq_set_str(char *parameter,char *value,long int checkdelay);
+int cpufreq_set_long_int(char *parameter,long int value,long int checkdelay);
#endif
diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c
index 556e404..9600d13 100644
--- a/cputemp2maxfreq.c
+++ b/cputemp2maxfreq.c
@@ -85,15 +85,18 @@ int main(int argc,char **argv)
cpudata.min_freq=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq");
cpudata.max_freq=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq");
cpudata.scale_max=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq");
+ cpudata.transition_latency=sysfs_read_long_int("/sys/devices/system/cpu/cpufreq/policy0/cpuinfo_transition_latency");
config.logger("CPU data:");
config.logger("Minimum frequency: %ld",cpudata.min_freq);
config.logger("Maximum frequency: %ld",cpudata.max_freq);
config.logger("Scaling maximum frequency: %ld",cpudata.scale_max);
+ config.logger("Transition Latency: %ld",cpudata.transition_latency);
if ((cpudata.min_freq<VALID_FREQ_MIN) || (cpudata.min_freq>VALID_FREQ_MAX) ||
(cpudata.max_freq<VALID_FREQ_MIN) || (cpudata.max_freq>VALID_FREQ_MAX) ||
- (cpudata.scale_max<VALID_FREQ_MIN) || (cpudata.scale_max>VALID_FREQ_MAX))
+ (cpudata.scale_max<VALID_FREQ_MIN) || (cpudata.scale_max>VALID_FREQ_MAX) ||
+ (cpudata.transition_latency<VALID_TRANS_MIN) || (cpudata.transition_latency>VALID_TRANS_MAX))
{
// If we have to fail now, there's not much we can do because we have no data
config.logger("Invalid CPU data, exiting");
@@ -166,7 +169,7 @@ int main(int argc,char **argv)
config.logger("Increase scaling_max_freq to %ld",newfreq);
// Set new value and validate
- if (cpufreq_set_long_int("scaling_max_freq",newfreq,100)<0)
+ if (cpufreq_set_long_int("scaling_max_freq",newfreq,cpudata.transition_latency)<0)
{
config.logger("Failed to set scaling_max_freq, exiting");
failsafe(1);
@@ -189,7 +192,7 @@ int main(int argc,char **argv)
config.logger("Decrease scaling_max_freq to %ld",newfreq);
// Set new value and validate
- if (cpufreq_set_long_int("scaling_max_freq",newfreq,100)<0)
+ if (cpufreq_set_long_int("scaling_max_freq",newfreq,cpudata.transition_latency)<0)
{
config.logger("Failed to set scaling_max_freq, exiting");
failsafe(1);
diff --git a/cputemp2maxfreq.h b/cputemp2maxfreq.h
index 984fabc..31f6da1 100644
--- a/cputemp2maxfreq.h
+++ b/cputemp2maxfreq.h
@@ -17,12 +17,17 @@
#define VALID_INTERVAL_MIN 1
#define VALID_INTERVAL_MAX 30
+// Valid transition delays between 0 and 100000
+#define VALID_TRANS_MIN 0
+#define VALID_TRANS_MAX 100000
+
struct s_cpudata {
- long int min_freq; // CPU's minimum frequency
- long int max_freq; // CPU's maximum frequency
- long int cur_freq; // CPU's current frequency
- long int cur_temp; // CPU's current temperature
- long int scale_max; // Governor's maximum scaling frequency
+ long int min_freq; // CPU's minimum frequency
+ long int max_freq; // CPU's maximum frequency
+ long int cur_freq; // CPU's current frequency
+ long int cur_temp; // CPU's current temperature
+ long int scale_max; // Governor's maximum scaling frequency
+ long int transition_latency; // CPU's transition latency
};
struct s_config {
diff --git a/sysfs.c b/sysfs.c
index e31aef2..ff3bb67 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -47,7 +47,7 @@ long int sysfs_read_long_int(char *sysfs_file)
return strtoll((char*)&buf,NULL,10);
}
-int sysfs_write_str(char *sysfs_file,char *value,int checkdelay)
+int sysfs_write_str(char *sysfs_file,char *value,long int checkdelay)
{
int sysfs_handle;
size_t len;
@@ -66,7 +66,7 @@ int sysfs_write_str(char *sysfs_file,char *value,int checkdelay)
DEBUG2_SYSFS("Written %zd bytes\n",len);
// What if instructed to
- if (checkdelay>0) usleep(checkdelay*1000);
+ if (checkdelay>0) usleep(checkdelay);
// Validate we actually set what we want to set
sysfs_read_str(sysfs_file,buf,sizeof(buf));