pass: thermal: Fix bug of interval update until changed first thermal scenario 86/224286/3
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 7 Feb 2020 08:13:29 +0000 (17:13 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 10 Feb 2020 09:21:41 +0000 (18:21 +0900)
The commit 6e9640753a86 ("thermal: Support dbus activation for thermal f/w")
read the temperature and then updated the system early thermal scenario
on thermal_get_scenario() function. When updated the thermal scenario,
have to update the timer interval ('timer_interval_ms' property)
if each thernmal scenaior defines their own timer interval
in configuration file.

But, thermal_get_scenario() has missed the interval update for thermal
monitoring when detecting the ealy thermal scenario on initialization step.
Because each thermal scenario is able to have their own timer interval
('timer_interval_ms' property) for adjusting the timer interval of monitoring.

[Example how to define the thermal scenario information for each h/w resource]
[thermal.scenario1]
support=no
name=Warning
temperature=65
timer_interval_ms=2000

So that in order to fix this bug, update the timer interval of monitoring
when changing the thermal scenario information.

Change-Id: Ib909539ffac357d7a804f726ae43e61a7a044d60
Fixes: 6e9640753a86 ("thermal: Support dbus activation for thermal f/w")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-thermal.c

index 095a4c1c983ec6b4d0dfb6c43b153f153e2bdf84..16fd87cb2c97a00031f28d00dc30871d1a404ff1 100644 (file)
@@ -136,8 +136,10 @@ static int thermal_get_scenario(void *data, void *user_data)
        struct pass_resource *res = user_data;
        struct resmon_result_src_thermal *thermal_result;
        struct pass_thermal *thermal;
+       int timer_interval_of_scenario, timer_interval;
        int curr_temp, temp;
        int i, scenario_idx;
+       int ret;
 
        if (!res) {
                _E("invalid parameter\n");
@@ -163,8 +165,32 @@ static int thermal_get_scenario(void *data, void *user_data)
        }
        scenario_idx = i;
 
+       /*
+        * Inform the current thermal scenario name to
+        * DEVICE_NOTIFIER_THERMAL_GET_SCENARIO client.
+        */
        *scenario = (void *)thermal->scenarios[scenario_idx].name;
 
+       _I("Monitor '%s' scenario for '%s' resource ('%d' degrees Celsius)\n",
+                               thermal->scenarios[scenario_idx].name,
+                               res->config_data.res_name, curr_temp);
+
+       /* Get the new timer interval of each scenario */
+       timer_interval_of_scenario
+               = thermal->scenarios[scenario_idx].thermal.timer_interval;
+       if (timer_interval_of_scenario > 0)
+               timer_interval = timer_interval_of_scenario;
+       else
+               timer_interval = res->thermal.timer_interval;
+
+       ret = pass_resmon_update_timer_interval(res, RESMON_SRC_THERMAL,
+                               timer_interval);
+       if (ret < 0) {
+               _W("failed to update interval of timer-based monitor " \
+                       "(res_name:%s, src_type: 0x%x)\n",
+                       res->config_data.res_name, RESMON_SRC_THERMAL);
+       }
+
        thermal->curr_temp = curr_temp;
        thermal->curr_scenario_idx = scenario_idx;