pass: Add the support for new struct pass_resource_nonstandard type 77/136377/4
authorChanwoo Choi <cw00.choi@samsung.com>
Mon, 26 Jun 2017 08:56:28 +0000 (17:56 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 4 Jul 2017 08:26:59 +0000 (17:26 +0900)
This patch support the new 'struct pass_resource_nonstandard'
in order to handle the nonstandard devices except for cpu/bus/gpu.
This h/w resource has the following functions:
- int set_pmqos_data(char *res_name, void *data)

And this patch adds the pass_set_pmqos_data() helper function
in order to bypass the PMQoS's data (scearnio name + 'Lock' or 'Unlock')
from platform to HAL layer. This function calls the .set_pmqos_data()
in the HAL pacakge.

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

index 74a28117a7d268b2ed7f861f5ab5d1f0d9bde35c..62505b24d487904abf25dad6f3cd9db28224bc27 100644 (file)
@@ -463,6 +463,32 @@ int pass_get_policy(struct pass_resource *res, char *policy)
        return tmu->get_policy(res_name, policy);
 }
 
+int pass_set_pmqos_data(struct pass_resource *res, void *data)
+{
+       struct pass_resource_nonstandard *nonstandard = NULL;
+       char *res_name;
+       int id;
+
+       if (!res)
+               return -EINVAL;
+
+       res_name = res->cdata.res_name;
+       id = res->cdata.res_type;
+
+       switch (id) {
+       case PASS_RESOURCE_NONSTANDARD_ID:
+               nonstandard  = (res->hal.nonstandard);
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       if (!nonstandard->set_pmqos_data || !res_name || !data)
+               return -EINVAL;
+
+       return nonstandard->set_pmqos_data(res_name, data);
+}
+
 int pass_get_resource(struct pass *pass)
 {
        struct pass_resource_info *info;
@@ -474,7 +500,7 @@ int pass_get_resource(struct pass *pass)
                struct pass_conf_data *cdata = &pass_res->cdata;
                int res_type = cdata->res_type;
                char *res_name = cdata->res_name;
-               char name[10];
+               char name[BUFF_MAX];
 
                switch (res_type) {
                case PASS_RESOURCE_CPU_ID:
@@ -489,6 +515,10 @@ int pass_get_resource(struct pass *pass)
                        len = strlen(PASS_RESOURCE_GPU_NAME);
                        strncpy(name, PASS_RESOURCE_GPU_NAME, len);
                        break;
+               case PASS_RESOURCE_NONSTANDARD_ID:
+                       len = strlen(PASS_RESOURCE_NONSTANDARD_NAME);
+                       strncpy(name, PASS_RESOURCE_NONSTANDARD_NAME, len);
+                       break;
                default:
                        _E("Unsupported resource type (type: %d)\n", res_type);
                        return -EINVAL;
@@ -521,6 +551,10 @@ int pass_get_resource(struct pass *pass)
                        ret = info->open(res_name, info,
                                (struct pass_resource_common**)&pass_res->hal.gpu);
                        break;
+               case PASS_RESOURCE_NONSTANDARD_ID:
+                       ret = info->open(res_name, info,
+                               (struct pass_resource_common**)&pass_res->hal.nonstandard);
+                       break;
                };
 
                if (ret < 0) {
@@ -564,6 +598,10 @@ int pass_put_resource(struct pass *pass)
                        info = pass_res->hal.gpu->common.info;
                        ret = info->close(res_name, common);
                        break;
+               case PASS_RESOURCE_NONSTANDARD_ID:
+                       common = (struct pass_resource_common*)pass_res->hal.nonstandard;
+                       info = pass_res->hal.nonstandard->common.info;
+                       ret = info->close(res_name, common);
                default:
                        return -EINVAL;
                };
index de4157be59f80ff937abc9868f9fa2229633873e..1afa8c1fafca029016c63cab742785a5dbe307c7 100644 (file)
@@ -74,4 +74,16 @@ int pass_set_online_max_num(struct pass_resource *res, int num);
 int pass_get_cpu_stats(struct pass_policy *policy);
 int64_t pass_get_time_ms(void);
 
+/***
+ * Functions for Nonstandard H/W resources
+ */
+/*
+ * NOTE: It is not propper method. But PASS must need to keep
+ * the backwards compatibility, set the PMQoS's data from
+ * platform to hal. So, It is not recommended to use it.
+ *
+ * This function will be removed after finding the proper method.
+ */
+int pass_set_pmqos_data(struct pass_resource *res, void *data);
+
 #endif /* __PASS_HAL__ */
index 43e4946b7d353ae086398589b78865a9474387ea..9d01ad20b5eb85bc8789d4185d9665b9ea88e740 100644 (file)
@@ -490,6 +490,8 @@ static int  pass_parse_resource_data(struct parse_result *result,
                        conf_data->res_type = PASS_RESOURCE_GPU_ID;
                else if (!strncmp(buf, PASS_RESOURCE_BUS_NAME, strlen(buf)))
                        conf_data->res_type = PASS_RESOURCE_BUS_ID;
+               else if (!strncmp(buf, PASS_RESOURCE_NONSTANDARD_NAME, strlen(buf)))
+                       conf_data->res_type = PASS_RESOURCE_NONSTANDARD_ID;
                else
                        return -EINVAL;
        } else if (MATCH(result->name, "pass_res_name")) {
index 8eaa82e7a2a31c921b9fcad1e059e0d23975ca83..a606e4bd70b8455edcfc2ef16e431c0c13660f84 100644 (file)
@@ -259,9 +259,10 @@ struct pass_policy {
  * Mandatory:
  * @res_type: the unique id for each h/w resource. The id can have
  *     the one value among following defined resource id.
- *     - 1: PASS_RESOURCE_CPU_ID
- *     - 2: PASS_RESOURCE_BUS_ID
- *     - 3: PASS_RESOURCE_GPU_ID
+ *     -  1: PASS_RESOURCE_CPU_ID
+ *     -  2: PASS_RESOURCE_BUS_ID
+ *     -  3: PASS_RESOURCE_GPU_ID
+ *     - 99: PASS_RESOURCE_NONSTANDARD_ID
  * @res_name: the unique name of sysfs entry.
  *     - In case of /sys/devices/system/cpu/cpu0, res_name is 'cpu0'
  *     - In case of /sys/devices/system/cpu/cpu4, res_name is 'cpu4'
@@ -289,9 +290,11 @@ struct pass_conf_data {
  *
  * @cdata: the parsed data from configuration file (pass.conf).
  * @hal: the hal instance of each h/w resource from pass_get_hal_info().
- *      - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
- *      - If res_type of cdata is PASS_RESOURCE_BUS_ID, hal.bus will be used.
- *      - If res_type of cdata is PASS_RESOURCE_GPU_ID, hal.gpu will be used.
+ * - If res_type of cdata is PASS_RESOURCE_CPU_ID, hal.cpu will be used.
+ * - If res_type of cdata is PASS_RESOURCE_BUS_ID, hal.bus will be used.
+ * - If res_type of cdata is PASS_RESOURCE_GPU_ID, hal.gpu will be used.
+ * - If res_type of cdata is PASS_RESOURCE_NONSTANDARD_ID,
+ *   hal.nonstandard will be used.
  * @policy: the policy data to handle the h/w resource
  */
 struct pass_resource {
@@ -302,6 +305,7 @@ struct pass_resource {
                struct pass_resource_cpu *cpu;
                struct pass_resource_bus *bus;
                struct pass_resource_gpu *gpu;
+               struct pass_resource_nonstandard *nonstandard;
        } hal;
 };