pass: Allow level update only for overridable resources 60/265560/6
authorDongwoo Lee <dwlee08@gmail.com>
Wed, 20 Oct 2021 04:19:32 +0000 (21:19 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 27 Oct 2021 01:33:02 +0000 (01:33 +0000)
To prevent unoverridable state such as LimitAction of thermal, this
adds overridable property to resources. Target level of those
resources can be update only overridable is 'true'.

Change-Id: Ia8187b014c1b86fd5d3e3039046cc28c1c48a95b
Signed-off-by: Dongwoo Lee <dwlee08@gmail.com>
src/pass/pass-rescon.c
src/pass/pass-rescon.h
src/pass/pass-thermal.c
src/pass/pass.h

index c406d97..cdead23 100644 (file)
@@ -349,6 +349,12 @@ static void rescon_set_scenario_level(struct pass_resource *res,
        if (scenario_level < 0)
                return;
 
+       if (!res->overridable) {
+               _I("Scenario level of the resource %s is locked",
+                                       res->config_data.res_name);
+               return;
+       }
+
        g_mutex_lock(&rescon->scenario_level_mutex);
        rescon->scenario_level_list = g_list_append(rescon->scenario_level_list,
                                        GINT_TO_POINTER(scenario_level));
@@ -511,6 +517,22 @@ int pass_rescon_unset_scenario_level_sync(struct pass_resource *res,
 }
 
 /*
+ * @brief      Set the the scenario can be overridden or not.
+ * @param      [in] res Instance of struct pass_resource
+ * @param      [in] overridable representing that resource can be overridden
+ * @return     @c 0 on success, otherwise error value
+ */
+int pass_rescon_set_overridable(struct pass_resource *res, int overridable)
+{
+       if (!res)
+               return -EINVAL;
+
+       res->overridable = overridable;
+
+       return 0;
+}
+
+/*
  * @brief      Deprecated function to support backward compatibility with sync.
  *             Set up the scenario pass_level by PASS_MODULE_PMQOS with data.
  * @param      [in] res Instance of struct pass_resource
index 8227edf..f318b55 100644 (file)
@@ -43,6 +43,7 @@ int pass_rescon_set_scenario_level(struct pass_resource *res,
 int pass_rescon_unset_scenario_level(struct pass_resource *res,
                                        int scenario_level);
 
+int pass_rescon_set_overridable(struct pass_resource *res, int overridable);
 /*
  * Following APIs are deprecated. These functions are provided
  * for keeping the compatibility with legacy feature.
index efde403..0d5517c 100644 (file)
@@ -132,6 +132,14 @@ static int thermal_update(struct pass_resource *res,
                }
        }
 
+       ret = pass_rescon_set_overridable(res,
+                                         new_scenario->thermal.overridable);
+       if (ret < 0) {
+               _W("failed to set overridable property " \
+                       "(res_name:%s, src_type: 0x%x)\n",
+                       res->config_data.res_name, RESMON_SRC_THERMAL);
+       }
+
        ret = pass_rescon_sync(res);
        if (ret < 0) {
                _W("failed to synchronize h/w resource " \
index e50aa9a..f99e2de 100644 (file)
@@ -633,6 +633,9 @@ struct pass_resource {
        struct pass_pmqos pmqos;
        /** Instance of PASS_MODULE_THERMAL module */
        struct pass_thermal thermal;
+
+       /** Representing whether this resource can be overridden or not */
+       int overridable;
 };
 
 /******************************************************