pmqos: Add support of 'mode' like UltraPowerSaving 13/240513/3
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 7 Aug 2020 02:16:25 +0000 (11:16 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 10 Aug 2020 04:21:32 +0000 (13:21 +0900)
Priot to that support only 'scenario' with the maximum duration time
in order to prevent the misuse of scenario from client. Additionally,
'mode' is required to change the system status until receiving
the unlock request without any maximum duration time.

So, make 'max_duration_ms' property optional. If some scenario in
/etc/pass/pass-pmqos.conf' don't have the 'max_duration_ms' property
it considers the 'mode'.

Difference of both scenario and mode as following:
1. 'scenario' with the maximum duration time like AppLaunch
  - Lock case
  a. Client send dbus signal with both 'scenario' name and duration
  - Unlock case
  a. Client send dbus signal with both 'scenario' name and 0
  a. When timer with specific duration from client is expired,
     unlock scenario automatically.
  a. When timer with maximum duration is expired,
     unlock scenario automatically.

2. 'mode' without any duration time like UltraPowerSaving
  - Lock case
  a. Client send dbus signal with both 'mode' name and 1
  - Unlock case
  a. Client send dbus signal with both 'mode' name and 0

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

index 53c737794d37bb6fa6cf774af241da2d52048047..be9a4efacf99f93509487a0843079cc73c341f42 100644 (file)
@@ -6,9 +6,11 @@ scenario_num=2
 
 # describe the scenario section as follows
 #[Scenario0]
-#name=AppLaunch # (dbus method name)
-#max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms)
-#support=yes
+#[Mandatory properties]
+#      name=AppLaunch # (dbus method name)
+#      support=yes
+#[Optional properties]
+#      max_duration_ms=3000 # (unit:millisecond, max dururation is 3000ms)
 [Scenario0]
 name=AppLaunch
 max_duration_ms=3000
@@ -16,5 +18,4 @@ support=yes
 
 [Scenario1]
 name=UltraPowerSaving
-max_duration_ms=3000
 support=yes
index 7c9505476f4b538c75d96a2f1e8673b95cf8ec4c..7ea160fa7fa2cc4ba84c450c7988a227007d68a5 100644 (file)
@@ -158,6 +158,7 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj,
                gpointer user_data)
 {
        int i, ret = -ENOTSUP;
+       int max_duration_ms = -1;
        gboolean ret_out = TRUE;
 
        if (!g_pmqos) {
@@ -171,10 +172,7 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj,
                bool support = g_pmqos->list[i].support;
 
                if (!strcmp(supported_name, name) && support) {
-                       int max_duration_ms = g_pmqos->list[i].max_duration_ms;
-
-                       if (duration > max_duration_ms)
-                               duration = max_duration_ms;
+                       max_duration_ms = g_pmqos->list[i].max_duration_ms;
                        ret = 0;
                        break;
                }
@@ -187,10 +185,25 @@ static gboolean dbus_cb_pmqos_set_scenario(SystemPassPmqos *obj,
                goto out_dbus;
        }
 
-       if (duration)
+       /* Reqeust pmqos scenario with the maximum duration */
+       if (max_duration_ms > 0 && duration > 0) {
+               duration = (duration < max_duration_ms)
+                               ? duration : max_duration_ms;
                ret = pmqos_request(name, duration);
-       else
+
+       /*
+        * Request pmqos mode without the maximum duration.
+        * Instead, enter the minus value (-1). When entering the minus value,
+        * doesn't create the timeout timer for pmqos mode. Until receiving
+        * the cancel request, keep the pmqos mode like UltraPowerSaving.
+        */
+       } else if (max_duration_ms == 0 && duration > 0) {
+               ret = pmqos_request(name, INT_MAX);
+
+       /* Cancel both scenario and mode for pmqos */
+       } else {
                ret = pmqos_cancel(name);
+       }
 
 out_dbus:
        g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", ret));
@@ -326,6 +339,15 @@ static void pmqos_unlock_timeout_update(void)
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
                cpu = elem->data;
                cpu->timeout -= delta;
+
+               /*
+                * If timeout is INT_MAX, indicatte 'mode'.
+                * Don't need to update the timeout and cancel pmqos for mode
+                * until receiving the cancel request.
+                */
+               if (cpu->timeout == INT_MAX)
+                       continue;
+
                if (cpu->timeout < 0)
                        cpu->timeout = 0;
                if (cpu->timeout > 0)
@@ -406,6 +428,12 @@ static int pmqos_unlock_timer_start(void)
 
        for (elem = pmqos_head; elem != NULL; elem = elem->next) {
                cpu = elem->data;
+               /*
+                * If timeout is INT_MAX, indicate 'mode'.
+                * Don't need to add the timre for 'mode'.
+                */
+               if (cpu->timeout == INT_MAX)
+                       continue;
                if (cpu->timeout <= 0)
                        continue;
                memcpy(&unlock_timer_owner, cpu, sizeof(struct pmqos_cpu));