pass: Initialize only supported module according to h/w resource 51/170451/4
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 12 Feb 2018 06:12:12 +0000 (15:12 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 15 Mar 2018 06:03:44 +0000 (15:03 +0900)
PASS handlse the h/w resource such as CPU, BUS, GPU, Memory and so on.
Also, PASS provides the multiple module such as CPUHP, PMQoS, Rescon, Resmon
and Parser. All modules provided by PASS are not used for each h/w resource.

Each h/w resource must need to have the supported module list and then
initialize/exit the module according to the defined their own list.

Change-Id: I0453a7cb247fcd52fdd2f18953d7df1d1406114e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass.c
src/pass/pass.h

index f93d27a..b599787 100644 (file)
 #define DBUS_CORE_PATH                         "/Org/Tizen/System/Pass/Core"
 #define PASS_CONF_PATH                         "/etc/pass/pass.conf"
 
+static uint64 supported_module[] = {
+       [PASS_RESOURCE_UNKNOWN]         = 0,
+       [PASS_RESOURCE_CPU_ID]          = PASS_MODULE_PARSER
+                                       | PASS_MODULE_RESCON
+                                       | PASS_MODULE_RESMON
+                                       | PASS_MODULE_PMQOS
+                                       | PASS_MODULE_CPUHP,
+
+       [PASS_RESOURCE_BUS_ID]          = PASS_MODULE_PARSER
+                                       | PASS_MODULE_RESCON
+                                       | PASS_MODULE_RESMON
+                                       | PASS_MODULE_PMQOS,
+
+       [PASS_RESOURCE_GPU_ID]          = PASS_MODULE_PARSER
+                                       | PASS_MODULE_RESCON
+                                       | PASS_MODULE_RESMON
+                                       | PASS_MODULE_PMQOS,
+
+       [PASS_RESOURCE_MEMORY_ID]       = PASS_MODULE_PARSER
+                                       | PASS_MODULE_RESCON
+                                       | PASS_MODULE_RESMON
+                                       | PASS_MODULE_PMQOS,
+
+       [PASS_RESOURCE_NONSTANDARD_ID]  = PASS_MODULE_PARSER
+                                       | PASS_MODULE_RESCON,
+};
+
 extern int pass_rescon_init(struct pass_resource *res);
 extern int pass_rescon_exit(struct pass_resource *res);
 extern int pass_resmon_init(struct pass_resource *res);
@@ -113,6 +140,13 @@ static struct pass_gdbus_signal_info g_gdbus_signal_infos[] = {
 /******************************************************
  *                PASS interface (Init/Exit)          *
  ******************************************************/
+
+static bool is_supported_module(struct pass_resource *res,
+                               enum pass_module_type type)
+{
+       return !!(supported_module[res->config_data.res_type] & type);
+}
+
 static int pass_init_resource(struct pass_resource *res)
 {
        int ret;
@@ -140,41 +174,53 @@ static int pass_init_resource(struct pass_resource *res)
         * Have to initialize ResCon (Resource-Controller) and ResMon
         * (Resource Monitor) before calling init() function of modules.
         */
-       ret = pass_rescon_init(res);
-       if (ret < 0) {
-               _E("cannot initialize PASS Resource-Controller");
-               return ret;
+
+       if (is_supported_module(res, PASS_MODULE_RESCON)) {
+               ret = pass_rescon_init(res);
+               if (ret < 0) {
+                       _E("cannot initialize PASS Resource-Controller");
+                       return ret;
+               }
        }
 
-       ret = pass_resmon_init(res);
-       if (ret < 0) {
-               _E("cannot initialize PASS Resource Monitor");
-               goto err_resmon;
+       if (is_supported_module(res, PASS_MODULE_RESMON)) {
+               ret = pass_resmon_init(res);
+               if (ret < 0) {
+                       _E("cannot initialize PASS Resource Monitor");
+                       goto err_resmon;
+               }
        }
 
-       ret = pass_cpuhp_init(res);
-       if (ret < 0) {
-               _E("cannot initialize PASS CPUHP");
-               goto err_cpuhp;
+       if (is_supported_module(res, PASS_MODULE_CPUHP)) {
+               ret = pass_cpuhp_init(res);
+               if (ret < 0) {
+                       _E("cannot initialize PASS CPUHP");
+                       goto err_cpuhp;
+               }
        }
 
-       ret = pass_pmqos_init(res);
-       if (ret < 0) {
-               _E("cannot initialize PASS PMQoS");
-               goto err_pmqos;
+       if (is_supported_module(res, PASS_MODULE_PMQOS)) {
+               ret = pass_pmqos_init(res);
+               if (ret < 0) {
+                       _E("cannot initialize PASS PMQoS");
+                       goto err_pmqos;
+               }
        }
 
        return 0;
 
 err_pmqos:
-       if (pass_cpuhp_exit(res) < 0)
-               _E("cannot exit PASS CPUHP");
+       if (is_supported_module(res, PASS_MODULE_CPUHP))
+               if (pass_cpuhp_exit(res) < 0)
+                       _E("cannot exit PASS CPUHP");
 err_cpuhp:
-       if (pass_resmon_exit(res) < 0)
-               _E("cannot exit PASS Resource Monitor");
+       if (is_supported_module(res, PASS_MODULE_RESMON))
+               if (pass_resmon_exit(res) < 0)
+                       _E("cannot exit PASS Resource Monitor");
 err_resmon:
-       if (pass_rescon_exit(res) < 0)
-               _E("cannot exit PASS Resource-Controller");
+       if (is_supported_module(res, PASS_MODULE_RESCON))
+               if (pass_rescon_exit(res) < 0)
+                       _E("cannot exit PASS Resource-Controller");
 
        return ret;
 }
@@ -186,32 +232,40 @@ static int pass_exit_resource(struct pass_resource *res)
        /* Put configuration of each resource from pass-resource*.conf */
        pass_put_each_resource_config(res);
 
-       ret = pass_cpuhp_exit(res);
-       if (ret < 0) {
-               _E("cannot exit PASS CPUHP");
-               return -1;
+       if (is_supported_module(res, PASS_MODULE_CPUHP)) {
+               ret = pass_cpuhp_exit(res);
+               if (ret < 0) {
+                       _E("cannot exit PASS CPUHP");
+                       return ret;
+               }
        }
 
-       ret = pass_pmqos_exit(res);
-       if (ret < 0) {
-               _E("cannot exit PASS PMQoS");
-               return ret;
+       if (is_supported_module(res, PASS_MODULE_PMQOS)) {
+               ret = pass_pmqos_exit(res);
+               if (ret < 0) {
+                       _E("cannot exit PASS PMQoS");
+                       return ret;
+               }
        }
 
        /*
         * Have to exit ResCon (Resource-Controller) and ResMon
         * (Resource Monitor) after called exit() function of modules.
         */
-       ret = pass_resmon_exit(res);
-       if (ret < 0) {
-               _E("cannot exit PASS Resource Monitor");
-               return ret;
+       if (is_supported_module(res, PASS_MODULE_RESMON)) {
+               ret = pass_resmon_exit(res);
+               if (ret < 0) {
+                       _E("cannot exit PASS Resource Monitor");
+                       return ret;
+               }
        }
 
-       ret = pass_rescon_exit(res);
-       if (ret < 0) {
-               _E("cannot exit PASS Resource-Controller");
-               return ret;
+       if (is_supported_module(res, PASS_MODULE_RESCON)) {
+               ret = pass_rescon_exit(res);
+               if (ret < 0) {
+                       _E("cannot exit PASS Resource-Controller");
+                       return ret;
+               }
        }
 
        return 0;
index 9c42ce3..398eb1f 100644 (file)
@@ -34,6 +34,25 @@ struct pass_resource;
 struct pass_cpuhp_governor;
 
 /*
+ * enum pass_module_type - Define supported modules of PASS
+ *
+ * PASS_MODULE_PARSER: Represents the parser module
+ * PASS_MODULE_RESCON: Represents the Resource Monitor module
+ * PASS_MODULE_RESMON: Represents the Resource Controller module
+ * PASS_MODULE_PMQOS: Represents the Scenario-based PMQoS module
+ * PASS_MODULE_CPUHP: Represents the CPU Hotplug Manager module
+ */
+enum pass_module_type {
+       PASS_MODULE_UNKNOWN             = 0x0,
+
+       PASS_MODULE_PARSER              = 0x1,
+       PASS_MODULE_RESCON              = 0x2,
+       PASS_MODULE_RESMON              = 0x4,
+       PASS_MODULE_PMQOS               = 0x8,
+       PASS_MODULE_CPUHP               = 0x10,
+};
+
+/*
  * PASS Governor type
  *
  * ---------------------------------------------------------------------------