pass: thermal: Determine scenario with range value 87/263887/5
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 31 Aug 2021 03:40:48 +0000 (12:40 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 16 Sep 2021 04:40:45 +0000 (13:40 +0900)
To prevent to be confused for determining scenario as following the
temperature, now it is settled with range of temperature.

Change-Id: Ic605a9b629da79129cbac8c5750316e16cc1c47e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/pass/pass-parser.c
src/pass/pass-thermal.c
src/pass/pass.h

index 8b14c0158f8e7742e3ae6444a524c8d08ad3a15e..323553097ff95439eb13cbb1e9752210a770c0ba 100644 (file)
@@ -88,7 +88,8 @@ static void init_scenario(struct pass_scenario *scenario)
        scenario->pmqos.max_level = INIT_VALUE;
 
        /* Private data for PASS_MODULE_THERMAL */
-       scenario->thermal.temperature = INIT_VALUE;
+       scenario->thermal.temp_start = INIT_VALUE;
+       scenario->thermal.temp_end = INIT_VALUE;
        scenario->thermal.timer_interval = INIT_VALUE;
 }
 
@@ -107,7 +108,9 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        int target_level;
        int cpuhp_min_level;
        int cpuhp_max_level;
-       int temperature;
+       json_object *temperature;
+       int temp_start;
+       int temp_end;
        int timer_interval_ms;
 
        /* Get property values */
@@ -120,7 +123,14 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        cpuhp_max_level = get_int_from_object(obj, "cpuhp_max_level");
 
        /* - property for only thermal module */
-       temperature = get_int_from_object(obj, "temperature");
+       temperature = get_object_from_object(obj, "temperature");
+       if (temperature) {
+               temp_start = get_int_from_object(temperature, "start");
+               temp_end = get_int_from_object(temperature, "end");
+       } else {
+               temp_start = temp_end = 0;
+       }
+
        timer_interval_ms = get_int_from_object(obj, "timer_interval_ms");
 
        /* Check the mandatory property values are valid or not */
@@ -130,6 +140,9 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        } else if (target_level < 0) {
                _E("Failed to get 'target_level' property in scenario section\n");
                return -EINVAL;
+       } else if (temp_start < 0 || temp_end < 0 || temp_end < temp_start) {
+               _E("Invalid values for temperature property\n");
+               return -EINVAL;
        }
 
        /* Initialize config_data from property values of confiugartion file */
@@ -142,7 +155,8 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        scenario->pmqos.max_level = cpuhp_max_level;
 
        /* - property for only thermal module */
-       scenario->thermal.temperature = temperature;
+       scenario->thermal.temp_start = temp_start;
+       scenario->thermal.temp_end = temp_end;
        scenario->thermal.timer_interval = timer_interval_ms;
 
        return 0;
index 26d7b74c7ac4b2be608a572e1aba0726127124e4..585cd8c60d9b84a6e92dca66007c993c88bc7f94 100644 (file)
@@ -59,15 +59,16 @@ static int thermal_update(struct pass_resource *res,
 
        new_scenario_idx = -1;
        for (i = 0; i < thermal->num_scenarios; i++) {
-               int temp = thermal->scenarios[i].thermal.temperature;
+               int temp_start = thermal->scenarios[i].thermal.temp_start;
+               int temp_end = thermal->scenarios[i].thermal.temp_end;
 
                if (thermal->scenarios[i].state != PASS_ON)
                        continue;
 
-               if (new_scenario_idx < 0 && new_temp < temp)
-                       new_scenario_idx = i;
-               else if (temp <= new_temp)
+               if (temp_start < new_temp && new_temp <= temp_end) {
                        new_scenario_idx = i;
+                       break;
+               }
        }
 
        /*
index 1149d271f855fd1e35238cb9095cb0caf33ee007..b2104f039df31901da08032b91aea35b7c8aa9a4 100644 (file)
@@ -259,8 +259,12 @@ struct pass_scenario {
 
        /** Private data for PASS_MODULE_THERMAL */
        struct {
-               /** Temperature of the scenario */
-               int temperature;
+               /**
+                * Range of temperature to determine scenario level represented
+                * as (temp_start, temp_end].
+                */
+               int temp_start;
+               int temp_end;
                /** Interval of timer-based monitor (unit: millisecond) */
                int timer_interval;
        } thermal;