PASS supports CPUHP (CPU hotplug manager) and PMQoS features until now.
The pass-gov.c contains the CPU hotplug manager feature and a little
of PMQoS's code. In order to remove the tightly coupled code,
move PMQoS's code from pass-gov.c to pass-pmqos.c.
Change-Id: I2811414fbe99cea04d9f111dc61ec0a2e05cb21c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
return true;
}
-/*
- * pass_notifier_pmqos - Callback func of DEVICE_NOTIFIER_PMQOS
- * @data: the scenario name
- * @user_data: the instance of struct pass_resource
- */
-static int pass_notifier_pmqos(void *data, void *user_data)
-{
- struct pass_resource *res = user_data;
-
- if (res->policy.state == PASS_ON)
- pass_notifier_pmqos_func(res, data);
-
- return 0;
-}
-
-/*
- * pass_notifier_init - Register notifiers and init
- * @res: the instance of struct pass_resource
- */
-static int pass_notifier_init(struct pass_resource *res)
-{
- /* Register DEVICE_NOTIFIER_PMQOS */
- return register_notifier(DEVICE_NOTIFIER_PMQOS, pass_notifier_pmqos,
- res);
-}
-
-/*
- * pass_notifier_exit - Un-register notifiers and exit
- * @res: the instance of struct pass_resource
- */
-static int pass_notifier_exit(struct pass_resource *res)
-{
- /* Un-register DEVICE_NOTIFIER_PMQOS */
- unregister_notifier(DEVICE_NOTIFIER_PMQOS, pass_notifier_pmqos,
- res);
-
- return 0;
-}
-
/*****************************************************************************
* PASS CPU Hotplug *
****************************************************************************/
static int __pass_governor_init(struct pass_resource *res)
{
struct pass_policy *policy = &res->policy;
- int ret;
if (policy->gov_timeout < 0) {
_E("invalid timeout value [%d]!", policy->gov_timeout);
/* Set default PASS state */
policy->gov_state = PASS_GOV_STOP;
- ret = pass_notifier_init(res);
- if (ret < 0) {
- _E("cannot initialize notifier for the pmqos (%d)\n", ret);
- return ret;
- }
if (policy->state == PASS_ON)
pass_governor_update(res, PASS_GOV_START);
struct pass_policy *policy = &res->policy;
int i;
- /* Exit notifier */
- pass_notifier_exit(res);
-
/*
* Stop timer and
* Restore the frequency and the number of online resources
#include <pass/config-parser.h>
#include "pass.h"
-#include "pass-gov.h"
#include "pass-rescon.h"
/****************************************************************************
return ((int64_t) now.tv_sec * 1000 + (int64_t) now.tv_usec / 1000);
}
-/*
- * is_pmqos_enabled - Check state of whether to support PM_QOS for scenario
- * @policy: instance of pass_policy structure
- *
- * Return true if the state of PM_QOS is supported
- * Return false if the state of PM_QOS isn't supported
- */
-static bool is_pmqos_enabled(struct pass_policy *policy)
-{
- if (!policy)
- return false;
-
- if (!policy->pmqos.scenarios)
- return false;
-
- if (policy->pmqos.state != PASS_ON)
- return false;
-
- return true;
-}
-
static enum pass_state is_pmqos_locked(char *data, char *name)
{
char *unlock = NULL;
return -EINVAL;
}
-/*
- * pass_notifier_pmqos - Callback function of DEVICE_NOTIFIER_PMQOS notifier
- * @data: the scenario name
- */
-int pass_notifier_pmqos_func(struct pass_resource *res, void *data)
+static int pmqos_notifier_cb(void *data, void *user_data)
{
+ struct pass_resource *res = user_data;
struct pass_policy *policy;
struct pass_conf_data *cdata;
struct pass_pmqos *pmqos;
policy = &res->policy;
- if (!is_pmqos_enabled(policy))
+ if (!policy->pmqos.scenarios || policy->pmqos.state != PASS_ON)
return 0;
cdata = &res->cdata;
return 0;
}
+
+int pass_pmqos_init(struct pass_resource *res)
+{
+ int ret;
+
+ /* Register DEVICE_NOTIFIER_PMQOS */
+ ret = register_notifier(DEVICE_NOTIFIER_PMQOS, pmqos_notifier_cb, res);
+ if (ret < 0) {
+ _E("cannot initialize notifier for the pmqos (%d)\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+int pass_pmqos_exit(struct pass_resource *res)
+{
+ /* Un-register DEVICE_NOTIFIER_PMQOS */
+ unregister_notifier(DEVICE_NOTIFIER_PMQOS, pmqos_notifier_cb, res);
+
+ return 0;
+}
#ifndef __PASS_PMQOS__
#define __PASS_PMQOS__
-/*
- * pass_notifier_pmqos - Callback function of DEVICE_NOTIFIER_PMQOS notifier
- * @res : the instance of pass_resource
- * @data: the scenario name
- */
-int pass_notifier_pmqos_func(struct pass_resource *res, void *data);
+/* Initialize and exit the Scenario-based PMQoS */
+int pass_pmqos_init(struct pass_resource *res);
+int pass_pmqos_exit(struct pass_resource *res);
#endif /* __PASS_PMQOS__ */
#include "pass.h"
#include "pass-parser.h"
+#include "pass-pmqos.h"
#include "pass-hal.h"
#include "pass-gov.h"
return -1;
}
+ ret = pass_pmqos_init(res);
+ if (ret < 0) {
+ _E("cannot initialize PASS PMQoS");
+ goto err;
+ }
+
return 0;
+err:
+ if (pass_governor_exit(res) < 0)
+ _E("cannot exit PASS governor");
+
+ return ret;
}
static int pass_exit_resource(struct pass_resource *res)
return -1;
}
+ ret = pass_pmqos_exit(res);
+ if (ret < 0) {
+ _E("cannot exit PASS PMQoS");
+ return ret;
+ }
+
policy->governor = NULL;
return 0;