pass: hal: Add missing save/restore of initdata for cooling-device property 72/262472/1
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 11 Aug 2021 10:29:54 +0000 (19:29 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 11 Aug 2021 11:18:06 +0000 (20:18 +0900)
The commit 256425c1250a ("pass: Add support of cooling-device property")
added cooling-device property. But, this commit didn't add the
save/restore of initdata for cooling-device property. In order to
restore the initial value of cooling-device property after finishing
PASS daemon, add missing save/restore of initdata for cooling-device property.

Change-Id: I97317a11613bfc29851ef1eecd7b9d7b531c7578
Fixes: 256425c1250a ("pass: Add support of cooling-device property")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-hal.c
src/pass/pass.h

index 98e5ec6e1aaa27a3b103df94430899f6f44350f5..7c3759a4e59e49dbf687cbb698bfa4b841f48394 100644 (file)
@@ -608,6 +608,22 @@ static int pass_hal_save_memory_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Save the initial state of thermal for h/w resource
+ *             before PASS (Power Aware System Service) daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
+static int pass_hal_save_thermal_initdata(struct pass_resource *res)
+{
+       struct pass_resource_init_data *initdata = &res->init_data;
+
+       initdata->tmu.cooling_device_state
+               = pass_hal_get_cooling_device_state(res);
+
+       return 0;
+}
+
 /**
  * @brief      Restore the saved state of DVFS(Dynamic Voltage and Frequency
  *             Scaling) resource when PASS (Power Aware System Service) daemon
@@ -713,6 +729,27 @@ static int pass_hal_restore_memory_initdata(struct pass_resource *res)
        return 0;
 }
 
+/**
+ * @brief      Restore the saved state of thermal for h/w resource
+ *             before PASS (Power Aware System Service) daemon starting
+ * @param      [in] res Instance of h/w resource
+ * @return     @c 0 on success, otherwise error value
+ */
+static int pass_hal_restore_thermal_initdata(struct pass_resource *res)
+{
+       struct pass_resource_init_data *initdata = &res->init_data;
+       int cooling_device_state = initdata->tmu.cooling_device_state;
+       int ret;
+
+       if (cooling_device_state >= 0) {
+               ret = pass_hal_set_cooling_device_state(res, cooling_device_state);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
+}
+
 /**
  * @brief      Save the initial state of h/w resource before PASS
  *             (Power Aware System Service) daemon starting
@@ -743,6 +780,13 @@ int pass_hal_save_initdata(struct pass_resource *res)
                                                        res->config_data.res_name);
                        return ret;
                }
+
+               ret = pass_hal_save_thermal_initdata(res);
+               if (ret < 0) {
+                       _E("Failed to save thermal initdata for '%s' resource",
+                                                       res->config_data.res_name);
+                       return ret;
+               }
                break;
        case PASS_RESOURCE_MEMORY_ID:
                ret = pass_hal_save_memory_initdata(res);
@@ -793,6 +837,13 @@ int pass_hal_restore_initdata(struct pass_resource *res)
                                                        res->config_data.res_name);
                        return ret;
                }
+
+               ret = pass_hal_restore_thermal_initdata(res);
+               if (ret < 0) {
+                       _E("Failed to restore thermal initdata for '%s' resource",
+                                                       res->config_data.res_name);
+                       return ret;
+               }
                break;
        case PASS_RESOURCE_MEMORY_ID:
                ret = pass_hal_restore_memory_initdata(res);
index cb910c9a969b5069e776f6fc2b72f7e04117df74..3399167e534ad3713c91e16a670d6e7ecc24580b 100644 (file)
@@ -537,7 +537,8 @@ struct pass_resource_init_data {
 
        /** Initial state of thermal configuration */
        struct {
-               /* NOTE: tmu has no writable data yet. */
+               /** Initial cooling_device state */
+               int cooling_device_state;
        } tmu;
 
        /** Initial state of memory configuration */