Skip to content

Commit a5de317

Browse files
committed
Temp test
1 parent 22fff1f commit a5de317

4 files changed

Lines changed: 64 additions & 36 deletions

File tree

src/thd_cdev.cpp

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,61 @@
4040
#include "thd_engine.h"
4141

4242
// Clamp to cdev min state or trip specific min if valid
43-
int cthd_cdev::thd_clamp_state_min(int _state, int temp_min_state)
43+
int cthd_cdev::thd_clamp_state_min(int _state, int temp_min_state, int temp_max_state)
4444
{
45-
int _min_state = min_state;
45+
if (min_state <= max_state) {
46+
int _min_state = min_state;
4647

47-
if (_min_state >= max_state) {
48-
if (temp_min_state && temp_min_state <= _min_state)
49-
_min_state = temp_min_state;
50-
} else {
51-
if (temp_min_state && temp_min_state >= _min_state)
48+
if (temp_min_state > min_state)
5249
_min_state = temp_min_state;
53-
}
5450

55-
thd_log_debug("def_min_state:%d curr_min_state:%d\n", min_state,
56-
_min_state);
51+
if (_state < _min_state)
52+
_state = _min_state;
5753

58-
if ((_min_state <= max_state && _state <= _min_state)
59-
|| (_min_state >= max_state && _state >= _min_state))
60-
return _min_state;
61-
else
54+
thd_log_debug("def_min_state:%d curr_min_state:%d _state:%d\n", min_state, temp_min_state, _state);
6255
return _state;
56+
}
57+
58+
int _max_state = max_state;
59+
60+
if (temp_max_state > max_state)
61+
_max_state = temp_max_state;
62+
63+
if (_state < _max_state)
64+
_state = _max_state;
65+
66+
thd_log_debug("def_max_state:%d curr_max_state:%d _state:%d\n", max_state, temp_max_state, _state);
67+
68+
return _state;
6369
}
6470

6571
// Clamp to cdev max state or trip specific max if valid
66-
int cthd_cdev::thd_clamp_state_max(int _state, int temp_max_state)
72+
int cthd_cdev::thd_clamp_state_max(int _state, int temp_min_state, int temp_max_state)
6773
{
68-
int _max_state = max_state;
74+
if (min_state <= max_state) {
75+
int _max_state = max_state;
6976

70-
if (min_state >= _max_state) {
71-
if (temp_max_state && temp_max_state >= _max_state)
77+
if (temp_max_state < max_state)
7278
_max_state = temp_max_state;
73-
} else {
74-
if (temp_max_state && temp_max_state <= _max_state)
75-
_max_state = temp_max_state;
76-
}
7779

78-
thd_log_debug("def_max_state:%d temp_max_state:%d curr_max_state:%d\n",
79-
max_state, temp_max_state, _max_state);
80+
if (_state > _max_state)
81+
_state = _max_state;
8082

81-
if ((min_state <= _max_state && _state >= _max_state)
82-
|| (min_state >= _max_state && _state <= _max_state))
83-
return _max_state;
84-
else
83+
thd_log_debug("def_max_state:%d curr_max_state:%d _state:%d\n", max_state, temp_max_state, _state);
8584
return _state;
85+
}
86+
87+
int _min_state = min_state;
88+
89+
if (temp_min_state > min_state)
90+
_min_state = temp_min_state;
91+
92+
if (_state > _min_state)
93+
_state = _min_state;
94+
95+
thd_log_debug("def_max_state:%d curr_max_state:%d _state:%d\n", min_state, temp_min_state, _state);
96+
97+
return _state;
8698
}
8799

88100
int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp,
@@ -98,7 +110,7 @@ int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp,
98110
_curr_state = get_curr_state(true);
99111
// Clamp the current state to min_state, as we start from min to max for
100112
// activation of a cooling device
101-
_curr_state = thd_clamp_state_min(_curr_state, temp_min_state);
113+
_curr_state = thd_clamp_state_min(_curr_state, temp_min_state, temp_max_state);
102114
thd_log_debug(
103115
"thd_cdev_set_%d:curr state %d max state %d temp_min:%d temp_max:%d\n",
104116
index, _curr_state, _max_state, temp_min_state, temp_max_state);
@@ -135,15 +147,16 @@ int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp,
135147
}
136148

137149
// Make sure that the state is not beyond max_state
138-
_state = thd_clamp_state_max(_state, temp_max_state);
150+
_state = thd_clamp_state_max(_state, temp_min_state, temp_max_state);
139151

140152
trend_increase = true;
141153
thd_log_debug("op->device:%s %d\n", type_str.c_str(), _state);
142154
set_curr_state(_state, control);
143155
} else {
144156
// Get the latest state, which is not the latest from the hardware but last set state to the device
145157
_curr_state = get_curr_state();
146-
_curr_state = thd_clamp_state_max(_curr_state);
158+
//_curr_state = thd_clamp_state_max(_curr_state);
159+
_curr_state = thd_clamp_state_max(_curr_state, temp_min_state, temp_max_state);
147160

148161
thd_log_debug("thd_cdev_set_%d:curr state %d max state %d\n", index,
149162
_curr_state, _max_state);
@@ -159,13 +172,15 @@ int cthd_cdev::thd_cdev_exponential_controller(int set_point, int target_temp,
159172
_state = _curr_state - inc_dec_val;
160173

161174
// Make sure that it is not beyond min_state
162-
_state = thd_clamp_state_min(_state);
175+
_state = thd_clamp_state_min(_state, temp_min_state, temp_max_state);
176+
// _state = thd_clamp_state_min(_state);
163177
thd_log_info("op->device:%s %d\n", type_str.c_str(), _state);
164178
set_curr_state(_state, control);
165179
} else {
180+
_state = thd_clamp_state_min(min_state, temp_min_state, temp_max_state);
166181
thd_log_debug("op->device: force min %s %d\n", type_str.c_str(),
167-
min_state);
168-
set_curr_state(min_state, control);
182+
_state);
183+
set_curr_state(_state, control);
169184
}
170185
}
171186

src/thd_cdev.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class cthd_cdev {
9898
int thd_cdev_exponential_controller(int set_point, int target_temp,
9999
int temperature, int state, int arg, int temp_min_state = 0,
100100
int temp_max_state = 0);
101-
int thd_clamp_state_min(int _state, int temp_min_state = 0);
102-
int thd_clamp_state_max(int _state, int temp_max_state = 0);
101+
int thd_clamp_state_min(int _state, int temp_min_state = 0, int temp_max_state = 0);
102+
int thd_clamp_state_max(int _state, int temp_min_state = 0, int temp_max_state = 0);
103103
public:
104104
static const int default_debounce_interval = 2; // In seconds
105105
static const int default_max_exponent = 20; // Max 2 power (x) is raised

src/thd_engine_adaptive.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,19 @@ int cthd_engine_adaptive::install_itmt(struct itmt_entry *itmt_entry, int& pl1_m
342342
* Which is opposite of the argument order in the
343343
* thd_trip_point_add_cdev()
344344
*/
345+
346+
if (itmt_zone == "BSKN") {
347+
trip_pt.thd_trip_point_add_cdev(*cdev, cthd_trip_point::default_influence,
348+
DEFAULT_SAMPLE_TIME_SEC, 0, 0,
349+
NULL, 1, 50000000, 30000000);
350+
351+
} else {
352+
353+
345354
trip_pt.thd_trip_point_add_cdev(*cdev, cthd_trip_point::default_influence,
346355
DEFAULT_SAMPLE_TIME_SEC, 0, 0,
347356
NULL, 1, _max_state, _min_state);
357+
}
348358

349359
zone->add_trip(trip_pt, 1);
350360
zone->zone_cdev_set_binded();
@@ -598,6 +608,7 @@ void cthd_engine_adaptive::update_engine_state() {
598608
policy_active = 1;
599609

600610
if (itmt_target_pl1_max != TRIP_PT_INVALID_TARGET_STATE) {
611+
itmt_target_pl1_max = 50000000;
601612
int _pl1_val = itmt_target_pl1_max / 1000;
602613

603614
if (target_pl_max == TRIP_PT_INVALID_TARGET_STATE || target_pl_max > _pl1_val) {
@@ -608,6 +619,7 @@ void cthd_engine_adaptive::update_engine_state() {
608619
thd_log_info("RAPL MMIO device not found\n");
609620
return;
610621
}
622+
611623
thd_log_info("Set PL1 max based on ITMT :%d\n", itmt_target_pl1_max);
612624
adaptive_target.code = "PL1MAX";
613625
adaptive_target.argument = std::to_string(_pl1_val);

src/thd_sensor_virtual.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ unsigned int cthd_sensor_virtual::_read_temperature() {
126126

127127
temp = link_sensor->sensor->read_temperature();
128128

129+
//temp = 70000;
129130
if (!link_sensor->power_sensor)
130131
temp = temp / 1000; //convert to degree C
131132

0 commit comments

Comments
 (0)