+++ /dev/null
-/*
- * PASS (Power Aware System Service)
- *
- * Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __PASS_CORE__
-#define __PASS_CORE__
-
-/*
- * pass_get_governor - Return specific governor instance according to type
- *
- * @policy: the instance of struct pass_policy
- * @type: the type of PASS governor
- */
-struct pass_governor* pass_get_governor(struct pass_policy *policy,
- enum pass_gov_type type);
-
-/*
- * pass_get_hotplug - Return specific hotplug instance according to type
- *
- * @policy: the instance of struct pass_policy
- * @type: the type of PASS governor
- */
-struct pass_hotplug* pass_get_hotplug(struct pass_policy *policy,
- enum pass_gov_type type);
-
-/*
- * pass_governor_change_level_scope - Change the scope of cpufreq scaling
- *
- * @policy: the instance of struct pass_policy
- * @min_level: the minimum level of cpufreq scaling
- * @max_level: the maximum level of cpufreq scaling
- */
-int pass_governor_change_level_scope(struct pass_policy *policy,
- int min_level, int max_level);
-
-#endif /* __PASS_CORE__ */
/*
- * PASS (Power Aware System Service)
+ * PASS (Power Aware System Service) Governor
*
* Copyright (c) 2012 - 2017 Samsung Electronics Co., Ltd.
*
}
/*
- * pass_governor_stop - Stop PASS governor through D-Bus
- *
- * @policy: the instance of struct pass_policy
- */
-static void pass_governor_stop(struct pass_policy *policy)
-{
- struct pass_resource *res = to_pass_resource(policy);
- struct pass_conf_data *cdata = &res->cdata;
-
- if (!policy->governor) {
- _E("cannot stop PASS governor");
- return;
- }
-
- if (policy->gov_state == PASS_GOV_STOP) {
- _E("PASS governor is already inactive state");
- return;
- }
-
- /* Restore maximum cpu freq/the number of online cpu */
- pass_governor_change_level(policy, policy->num_levels - 1);
-
- pass_hotplug_stop(policy);
-
- if (policy->governor->gov_timer_id) {
- ecore_timer_del(policy->governor->gov_timer_id);
- policy->governor->gov_timer_id = NULL;
- }
-
- /* Set PASS state as PASS_GOV_STOP */
- policy->gov_state = PASS_GOV_STOP;
-
- _I("Stop governor for '%s' resource", cdata->res_name);
-}
-
-/*
* pass_governor_core_timer - Callback function of core timer for PASS governor
*
* @data: the instance of struct pass_policy
count = 0;
_E("cannot read 'pass_cpu_stats' sysfs entry");
- pass_governor_stop(policy);
+ pass_governor_update(policy, PASS_GOV_STOP);
return ECORE_CALLBACK_CANCEL;
}
pass_governor_change_level(policy, level);
} else {
_E("cannot execute governor function");
- pass_governor_stop(policy);
+ pass_governor_update(policy, PASS_GOV_STOP);
return ECORE_CALLBACK_CANCEL;
}
}
/*
- * pass_governor_start - Start PASS governor through D-Bus
+ * __pass_governor_start - Start PASS governor through D-Bus
*
* @policy: the instance of struct pass_policy
*/
-static void pass_governor_start(struct pass_policy *policy)
+static void __pass_governor_start(struct pass_policy *policy)
{
struct pass_resource *res = to_pass_resource(policy);
struct pass_conf_data *cdata = &res->cdata;
(void *)policy);
if (!policy->governor->gov_timer_id) {
_E("cannot add core timer for governor");
- pass_governor_stop(policy);
+ pass_governor_update(policy, PASS_GOV_STOP);
return;
}
}
/*
- * pass_governor_init - Initialize PASS governor
+ * __pass_governor_stop - Stop PASS governor through D-Bus
*
* @policy: the instance of struct pass_policy
*/
-static int pass_governor_init(struct pass_policy *policy)
+static void __pass_governor_stop(struct pass_policy *policy)
+{
+ struct pass_resource *res = to_pass_resource(policy);
+ struct pass_conf_data *cdata = &res->cdata;
+
+ if (!policy->governor) {
+ _E("cannot stop PASS governor");
+ return;
+ }
+
+ if (policy->gov_state == PASS_GOV_STOP) {
+ _E("PASS governor is already inactive state");
+ return;
+ }
+
+ /* Restore maximum cpu freq/the number of online cpu */
+ pass_governor_change_level(policy, policy->num_levels - 1);
+
+ pass_hotplug_stop(policy);
+
+ if (policy->governor->gov_timer_id) {
+ ecore_timer_del(policy->governor->gov_timer_id);
+ policy->governor->gov_timer_id = NULL;
+ }
+
+ /* Set PASS state as PASS_GOV_STOP */
+ policy->gov_state = PASS_GOV_STOP;
+
+ _I("Stop governor for '%s' resource", cdata->res_name);
+}
+
+static int __pass_governor_init(struct pass_policy *policy)
{
struct pass_resource *res = to_pass_resource(policy);
struct pass_conf_data *cdata = &res->cdata;
if(policy->governor->gov_timeout < 0) {
_E("invalid timeout value [%d]!",
policy->governor->gov_timeout);
- pass_governor_stop(policy);
+ pass_governor_update(policy, PASS_GOV_STOP);
return -EINVAL;
}
return 0;
}
-/*
- * pass_governor_exit - Exit PASS governor
- */
-static int pass_governor_exit(struct pass_policy *policy)
+static int __pass_governor_exit(struct pass_policy *policy)
{
struct pass_resource *res = to_pass_resource(policy);
struct pass_conf_data *cdata = &res->cdata;
* Stop core timer and
* Restore maximum online cpu/cpu frequency
*/
- pass_governor_stop(policy);
+ pass_governor_update(policy, PASS_GOV_STOP);
/* Free allocated memory */
for (i = 0; i < policy->num_pass_cpu_stats; i++) {
return 0;
}
-/*
- * pass_governor_update - Restart/Pause PASS governor
- *
- * @cond: the instance of struct pass_policy
- */
-static int pass_governor_update(struct pass_policy *policy,
+static int __pass_governor_update(struct pass_policy *policy,
enum pass_gov_state state)
{
if (!policy) {
switch (state) {
case PASS_GOV_START:
- pass_governor_start(policy);
+ __pass_governor_start(policy);
break;
case PASS_GOV_STOP:
- pass_governor_stop(policy);
+ __pass_governor_stop(policy);
break;
default:
_E("Unknown governor state");
*/
static struct pass_governor pass_gov_step = {
.name = "pass_step",
- .init = pass_governor_init,
- .exit = pass_governor_exit,
- .update = pass_governor_update,
+ .init = __pass_governor_init,
+ .exit = __pass_governor_exit,
+ .update = __pass_governor_update,
.governor = pass_step_governor,
};
static struct pass_governor pass_gov_radiation = {
.name = "pass_radiation",
- .init = pass_governor_init,
- .exit = pass_governor_exit,
- .update = pass_governor_update,
+ .init = __pass_governor_init,
+ .exit = __pass_governor_exit,
+ .update = __pass_governor_update,
.governor = pass_radiation_governor,
};
return NULL;
}
+
+/*
+ * __pass_governor_init - Initialize PASS governor
+ *
+ * @policy: the instance of struct pass_policy
+ */
+int pass_governor_init(struct pass_policy *policy)
+{
+ if (!policy || !policy->governor || !policy->governor->init)
+ return -EINVAL;
+
+ return policy->governor->init(policy);
+}
+
+/*
+ * __pass_governor_exit - Exit PASS governor
+ */
+int pass_governor_exit(struct pass_policy *policy)
+{
+ if (!policy || !policy->governor || !policy->governor->exit)
+ return -EINVAL;
+
+ return policy->governor->exit(policy);
+}
+
+/*
+ * __pass_governor_update - Restart/Pause PASS governor
+ *
+ * @policy: the instance of struct pass_policy
+ * @state: the state of governor
+ * PASS_GOV_START : start governor
+ * PASS_GOV_STOP: stop governor
+ */
+int pass_governor_update(struct pass_policy *policy,
+ enum pass_gov_state state)
+{
+ if (!policy || !policy->governor || !policy->governor->update)
+ return -EINVAL;
+
+ return policy->governor->update(policy, state);
+}
#include <stdlib.h>
#include "pass.h"
-#include "pass-core.h"
#include "pass-parser.h"
#include "pass-hal.h"
+#include "pass-gov.h"
#include "core/devices.h"
#include "core/common.h"
******************************************************/
static DBusMessage* e_dbus_start_cb(E_DBus_Object *obj, DBusMessage* msg)
{
- DBusMessage *ret = NULL;
- int i;
+ DBusMessage *ret_dbus = NULL;
+ int i, ret;
for (i = 0; i < g_pass.num_resources; i++) {
struct pass_resource *pass_res = &g_pass.res[i];
struct pass_policy *policy = &pass_res->policy;
- if (policy->governor)
- policy->governor->update(policy, PASS_GOV_START);
- ret = dbus_message_new_method_return(msg);
- if (!ret)
- return ret;
+ ret = pass_governor_update(policy, PASS_GOV_START);
+ if (ret < 0) {
+ _E("cannot start the governor with dbus");
+ return ret_dbus;
+ }
+ ret_dbus = dbus_message_new_method_return(msg);
+ if (!ret_dbus)
+ return ret_dbus;
}
- return ret;
+ return ret_dbus;
}
static DBusMessage* e_dbus_stop_cb(E_DBus_Object *obj, DBusMessage* msg)
{
- DBusMessage *ret = NULL;
- int i;
+ DBusMessage *ret_dbus = NULL;
+ int i, ret;
for (i = 0; i < g_pass.num_resources; i++) {
struct pass_resource *pass_res = &g_pass.res[i];
struct pass_policy *policy = &pass_res->policy;
- if (policy->governor)
- policy->governor->update(policy, PASS_GOV_STOP);
- ret = dbus_message_new_method_return(msg);
- if (!ret)
- return ret;
+ ret = pass_governor_update(policy, PASS_GOV_STOP);
+ if (ret < 0) {
+ _E("cannot stop the governor");
+ return ret_dbus;
+ }
+
+ ret_dbus = dbus_message_new_method_return(msg);
+ if (!ret_dbus)
+ return ret_dbus;
}
- return ret;
+ return ret_dbus;
}
static const struct edbus_method edbus_methods[] = {
policy->hotplug->sequence[i] = i + pass_res->cdata.cpu;
}
- if (policy->governor->init) {
- ret = policy->governor->init(policy);
- if (ret < 0) {
- _E("cannot initialize PASS governor");
- return -1;
- }
- } else {
- _E("cannot execute init() of PASS governor");
+ ret = pass_governor_init(policy);
+ if (ret < 0) {
+ _E("cannot initialize PASS governor");
return -1;
}
{
int ret;
- if (!policy->governor) {
- _E("cannot exit PASS");
- return -1;
- }
-
pass_put_table(policy);
- if (policy->governor->exit) {
- ret = policy->governor->exit(policy);
- if (ret < 0) {
- _E("cannot exit PASS governor");
- return -1;
- }
- } else {
- _E("cannot execute exit() of PASS governor");
+ ret = pass_governor_exit(policy);
+ if (ret < 0) {
+ _E("cannot exit PASS governor");
return -1;
}