-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatic-cpufreq-envvar.patch
73 lines (69 loc) · 3.23 KB
/
static-cpufreq-envvar.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index 11111111111..11111111111 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -4225,24 +4225,32 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
char filename[128];
FILE* f;
+ static int fixed_cpufreq = -1;
+ if (fixed_cpufreq == -1)
+ {
+ fixed_cpufreq = !!getenv("WINE_STATIC_CPUFREQ");
+ }
for(i = 0; i < out_cpus; i++) {
- snprintf(filename, sizeof(filename), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i);
- f = fopen(filename, "r");
- if (f && (fscanf(f, "%u", &val) == 1)) {
- cpu_power[i].MaxMhz = val / 1000;
- fclose(f);
- cpu_power[i].CurrentMhz = cpu_power[i].MaxMhz;
- }
- else {
- if(i == 0) {
- cpu_power[0].CurrentMhz = mhz_from_cpuinfo();
- if(cpu_power[0].CurrentMhz == 0)
- cpu_power[0].CurrentMhz = cannedMHz;
+ if (!fixed_cpufreq)
+ {
+ snprintf(filename, sizeof(filename), "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i);
+ f = fopen(filename, "r");
+ if (f && (fscanf(f, "%u", &val) == 1)) {
+ cpu_power[i].MaxMhz = val / 1000;
+ fclose(f);
+ cpu_power[i].CurrentMhz = cpu_power[i].MaxMhz;
+ }
+ else {
+ if(i == 0) {
+ cpu_power[0].CurrentMhz = mhz_from_cpuinfo();
+ if(cpu_power[0].CurrentMhz == 0)
+ cpu_power[0].CurrentMhz = cannedMHz;
+ }
+ else
+ cpu_power[i].CurrentMhz = cpu_power[0].CurrentMhz;
+ cpu_power[i].MaxMhz = cpu_power[i].CurrentMhz;
+ if(f) fclose(f);
}
- else
- cpu_power[i].CurrentMhz = cpu_power[0].CurrentMhz;
- cpu_power[i].MaxMhz = cpu_power[i].CurrentMhz;
- if(f) fclose(f);
}
snprintf(filename, sizeof(filename), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_max_freq", i);
@@ -4253,10 +4261,15 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
}
else
{
- cpu_power[i].MhzLimit = cpu_power[i].MaxMhz;
+ cpu_power[i].MhzLimit = (cpu_power[i].MaxMhz > 0 ? cpu_power[i].MaxMhz : cannedMHz);
if(f) fclose(f);
}
+ if (fixed_cpufreq > 0)
+ {
+ cpu_power[i].CurrentMhz = cpu_power[i].MaxMhz = cpu_power[i].MhzLimit;
+ }
+
cpu_power[i].Number = i;
cpu_power[i].MaxIdleState = 0; /* FIXME */
cpu_power[i].CurrentIdleState = 0; /* FIXME */
--
0.0.0