pmqos: Set max_duration_ms for each scenario 10/240510/2
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 6 Aug 2020 08:40:28 +0000 (17:40 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 7 Aug 2020 06:38:03 +0000 (15:38 +0900)
Until now, only support global max_duration_ms time. But, if each scenario
need to set the different maximum duration time, it is not supported.

Allow each scenario to set the default maximume duration time.

Change-Id: I6f294ab55d2157c251593c300cb04eefb598b751
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
scripts/pass-pmqos.conf
src/pmqos/pmqos-parser.c
src/pmqos/pmqos.c
src/pmqos/pmqos.h

index a47733cd28d85b4128dfc1ad611d3b95ace3193b..53c737794d37bb6fa6cf774af241da2d52048047 100644 (file)
@@ -1,19 +1,20 @@
 [PassScenario]
 # set to "yes" scenario_support (Default value is no)
 # set scenario_num to be tested
-# set scenario_max_timeout_ms (unit:millisecond, default timeout is 3000ms)
 scenario_support=yes
 scenario_num=2
-scenario_max_timeout_ms=3000
 
 # describe the scenario section as follows
 #[Scenario0]
 #name=AppLaunch # (dbus method name)
+#max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms)
 #support=yes
 [Scenario0]
 name=AppLaunch
+max_duration_ms=3000
 support=yes
 
 [Scenario1]
 name=UltraPowerSaving
+max_duration_ms=3000
 support=yes
index 5b32baea735478a120ccc09b803b81d6c29cf714..3e8ee97aacedf7bce305e0a93316385754846018 100644 (file)
@@ -90,15 +90,6 @@ static int pmqos_parse_scenario(struct parse_result *result, void *user_data, un
 
                                scenarios->num = num;
                        }
-               } else if (MATCH(result->name, "scenario_max_timeout_ms")) {
-                       int max_timeout_ms;
-
-                       max_timeout_ms = sys_strtol(result->value);
-                       if (max_timeout_ms < 0) {
-                               _E("failed to get maximum timeout of scenario");
-                               return -ERANGE;
-                       }
-                       scenarios->max_timeout_ms = max_timeout_ms;
                }
        }
 
@@ -120,6 +111,21 @@ static int pmqos_parse_scenario(struct parse_result *result, void *user_data, un
                                "%s", result->value);
        else if (MATCH(result->name, "support"))
                scenarios->list[index].support = is_supported(result->value);
+       else if (MATCH(result->name, "max_duration_ms")) {
+               int max_duration_ms = sys_strtol(result->value);
+
+               if (max_duration_ms < 0) {
+                       _E("failed to parse max_duration_ms property (%d)\n",
+                                       max_duration_ms);
+                       return -EINVAL;
+               }
+
+               /*
+                * If maximum duration is zero, it measn that this scenario is
+                * mode without any maximum duration.
+                */
+               scenarios->list[index].max_duration_ms = max_duration_ms;
+       }
 
        return 0;
 }
@@ -186,7 +192,6 @@ int pmqos_put_scenario(struct pmqos_scenario *scenarios)
 
        if (scenarios->num > 0 && scenarios->list) {
                scenarios->num = 0;
-               scenarios->max_timeout_ms = 0;
                free(scenarios->list);
                scenarios->list = NULL;
        }
@@ -207,7 +212,6 @@ int pmqos_get_scenario(const char *path, struct pmqos_scenario *scenarios)
 
        /* Initialize the variables before parsing the pass-pmqos.conf */
        scenarios->num = 0;
-       scenarios->max_timeout_ms = 0;
 
        /* get configuration file */
        ret = config_parse(path, pmqos_load_config, scenarios);
index 2ed67f7b13072d9233eec174b65799622373b0ce..3deae6e6f6c2415314b89c956a75fa425ae157bc 100644 (file)
@@ -39,8 +39,6 @@
 
 #include "pmqos.h"
 
-#define DEFAULT_PMQOS_TIMER            3000
-
 #define PMQOS_CONF_PATH                "/etc/pass/pass-pmqos.conf"
 #define MILLISECONDS(tv)       ((tv.tv_sec)*1000 + (tv.tv_nsec)/1000000)
 #define DELTA(a, b)            (MILLISECONDS(a) - MILLISECONDS(b))
@@ -64,7 +62,6 @@ struct pmqos_cpu {
 
 static GList *pmqos_head;
 guint g_unlock_timeout_id;
-static int unlock_max_timeout_ms;
 static struct timespec unlock_timer_start_st;
 static struct timespec unlock_timer_end_st;
 static struct pmqos_cpu unlock_timer_owner = {"", 0};
@@ -161,6 +158,7 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj,
        const char *name_from;
        char *name;
        bool support;
+       int max_duration_ms;
        int i, ret = 0;
        gboolean ret_out = TRUE;
 
@@ -168,26 +166,30 @@ static gboolean dbus_cb_pmqos_legacy_scenario(SystemPassPmqos *obj,
                _E("PASS PMQoS is stopped\n");
                ret_out = FALSE;
                goto out;
-       } else {
-               name_from = g_dbus_method_invocation_get_method_name(invoc);
-               ret = -ENOTSUP;
-               if (g_pmqos) {
-                       for (i = 0; i < g_pmqos->num; i++) {
-                               name = g_pmqos->list[i].name;
-                               support = g_pmqos->list[i].support;
-                               if (!strcmp(name, name_from) && support) {
-                                       ret = 0;
-                                       break;
-                               }
+       }
+
+       name_from = g_dbus_method_invocation_get_method_name(invoc);
+       ret = -ENOTSUP;
+       if (g_pmqos) {
+               for (i = 0; i < g_pmqos->num; i++) {
+                       name = g_pmqos->list[i].name;
+                       support = g_pmqos->list[i].support;
+                       max_duration_ms = g_pmqos->list[i].max_duration_ms;
+
+                       if (!strcmp(name, name_from) && support) {
+                               ret = 0;
+                               if (duration > max_duration_ms)
+                                       duration = max_duration_ms;
+                               break;
                        }
                }
+       }
 
-               if (ret < 0) {
-                       _E("cannot set the PMQoS scenario: "
-                                       "%s is not supported\n", name_from);
-                       ret_out = FALSE;
-                       goto out_dbus;
-               }
+       if (ret < 0) {
+               _E("cannot set the PMQoS scenario: "
+                               "%s is not supported\n", name_from);
+               ret_out = FALSE;
+               goto out_dbus;
        }
 
        if (duration)
@@ -413,13 +415,6 @@ static int pmqos_request(const char *name, int val)
        int found = 0;
        int ret;
 
-       /* Check valid parameter */
-       if (val > unlock_max_timeout_ms) {
-               _I("Timeout cannot be higher than maximum timeout (%d ms)",
-                               unlock_max_timeout_ms);
-               val = unlock_max_timeout_ms;
-       }
-
        /* find cpu */
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
                cpu = elem->data;
@@ -497,16 +492,6 @@ static int pmqos_init_done(void *data, void *user_data)
                                        g_pmqos->list[i].name);
        }
 
-       /*
-        * Set maximum timeout for the scenario by using the parsed data from
-        * pass-pmqos.conf. But, if there is no setting from pass-pmqos.conf
-        * pmqos uses the default timeout value (3000 millisecond).
-        */
-       if (g_pmqos->max_timeout_ms)
-               unlock_max_timeout_ms = g_pmqos->max_timeout_ms;
-       else
-               unlock_max_timeout_ms = DEFAULT_PMQOS_TIMER;
-
        return 0;
 }
 
index 4058d4c4f4c755a2ac55b7032e7015cf9d816287..ffacd1055b4c483a2debc631373c9bcf456690cb 100644 (file)
@@ -41,12 +41,11 @@ struct pmqos_scenario {
        struct scenario {
                char name[NAME_MAX];    /** Unique scenario name */
                bool support;           /** State is either supported or not */
+               int max_duration_ms;    /** Maximum duration */
        } *list;
 
        /** The number of supported PMQoS scenarios */
        int num;
-       /** Maximum duration */
-       int max_timeout_ms;
        /** State of PMQoS feature is either supported or not*/
        bool support;
 };