* Re: [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor
@ 2012-11-06 9:02 MyungJoo Ham
[not found] ` <CAJ0PZbSe7Orhww-amHNRkbvUvJr6x9CtisHw2hoLpcJdyBSKCA@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: MyungJoo Ham @ 2012-11-06 9:02 UTC (permalink / raw)
To: Nishanth Menon, linux-pm
Cc: Rajagopal Venkat, 박경민, Rafael J. Wysocki,
Kevin Hilman, linux-kernel@vger.kernel.org
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -629,6 +629,44 @@ static ssize_t show_governor(struct device *dev,
> return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
> }
>
> +static ssize_t store_governor(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct devfreq *df = to_devfreq(dev);
> + int ret = 0;
> + struct devfreq_governor *governor;
> +
> + mutex_lock(&devfreq_list_lock);
Please remove the trailing \n from buf here.
When user enters "userspace", buf gets "userspace\n".
With some printks in find_devfreq_governor (printing the buf and governor names):
# echo userspace > /sys/class/devfreq/exynos4210-busfreq.0/governor
[ 65.975000] [userspace
[ 65.975000] ].[userspace]
[ 65.980000] [userspace
[ 65.980000] ].[powersave]
[ 65.985000] [userspace
[ 65.985000] ].[performance]
[ 65.990000] [userspace
[ 65.990000] ].[simple_ondemand]
[ 65.995000] err no = -19
#
Cheers,
MyungJoo
> + governor = find_devfreq_governor(buf);
> + if (IS_ERR(governor)) {
> + ret = PTR_ERR(governor);
> + goto out;
> + }
> + if (df->governor == governor)
> + goto out;
> +
> + if (df->governor) {
> + ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL);
> + if (ret) {
> + dev_warn(dev, "%s: Governor %s not stopped(%d)\n",
> + __func__, df->governor->name, ret);
> + goto out;
> + }
> + }
> + df->governor = governor;
> + strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN);
> + ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
> + if (ret)
> + dev_warn(dev, "%s: Governor %s not started(%d)\n",
> + __func__, df->governor->name, ret);
> +out:
> + mutex_unlock(&devfreq_list_lock);
> +
> + if (!ret)
> + ret = count;
> + return ret;
> +}
> +
[]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [linux-next PATCH 0/7] PM / devfreq: allow governors to be modules and switch dynamically
@ 2012-10-29 20:01 Nishanth Menon
2012-10-29 20:01 ` [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor Nishanth Menon
0 siblings, 1 reply; 3+ messages in thread
From: Nishanth Menon @ 2012-10-29 20:01 UTC (permalink / raw)
To: linux-pm
Cc: Nishanth Menon, Rajagopal Venkat, MyungJoo Ham, Kyungmin Park,
Rafael J. Wysocki, Kevin Hilman, linux-kernel
The following series is based on:
linux-next e083feb Merge branch 'acpi-next' into linux-next
from git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
In addition, this series depends on the following to apply cleanly:
https://patchwork.kernel.org/patch/1649621/
https://patchwork.kernel.org/patch/1663331/
This series allows the devfreq governors to be built as modules and switched
on the fly using sysfs controls (inspired by cpufreq's ability to do the same).
Tested on BeagleBoard XM(3730) with dummy driver[1]:
/sys/devices/platform/iva.0/devfreq/iva.0 # ls
available_frequencies governor power
available_governors max_freq subsystem
cur_freq min_freq target_freq
device polling_interval uevent
/sys/devices/platform/iva.0/devfreq/iva.0 # cat available_governors
simple_ondemand
/sys/devices/platform/iva.0/devfreq/iva.0 # modprobe governor_userspace
/sys/devices/platform/iva.0/devfreq/iva.0 # cat available_governors
userspace simple_ondemand
/sys/devices/platform/iva.0/devfreq/iva.0 #
/sys/devices/platform/iva.0/devfreq/iva.0 # echo -n "userspace">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # ls
available_frequencies max_freq target_freq
available_governors min_freq uevent
cur_freq polling_interval userspace
device power
governor subsystem
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
userspace
/sys/devices/platform/iva.0/devfreq/iva.0 # echo -n "simple_ondemand">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
simple_ondemand
/sys/devices/platform/iva.0/devfreq/iva.0 # ls
available_frequencies governor power
available_governors max_freq subsystem
cur_freq min_freq target_freq
device polling_interval uevent
Nishanth Menon (7):
PM / devfreq: export update_devfreq
PM / devfreq: provide hooks for governors to be registered
PM / devfreq: register governors with devfreq framework
PM / devfreq: map devfreq drivers to governor using name
PM / devfreq: governors: add GPL module license and allow module
build
PM / devfreq: allow sysfs governor node to switch governor
PM / devfreq: Add sysfs node to expose available governors
Documentation/ABI/testing/sysfs-class-devfreq | 9 +-
drivers/devfreq/Kconfig | 8 +-
drivers/devfreq/devfreq.c | 249 ++++++++++++++++++++++++-
drivers/devfreq/exynos4_bus.c | 2 +-
drivers/devfreq/governor.h | 4 +
drivers/devfreq/governor_performance.c | 22 ++-
drivers/devfreq/governor_powersave.c | 22 ++-
drivers/devfreq/governor_simpleondemand.c | 22 ++-
drivers/devfreq/governor_userspace.c | 22 ++-
include/linux/devfreq.h | 24 +--
10 files changed, 348 insertions(+), 36 deletions(-)
Cc: Rajagopal Venkat <rajagopal.venkat@linaro.org>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Kevin Hilman <khilman@ti.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
[1] http://pastebin.pandaboard.org/index.php/view/85100576
Regards,
Nishanth Menon
--
1.7.9.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor
2012-10-29 20:01 [linux-next PATCH 0/7] PM / devfreq: allow governors to be modules and switch dynamically Nishanth Menon
@ 2012-10-29 20:01 ` Nishanth Menon
0 siblings, 0 replies; 3+ messages in thread
From: Nishanth Menon @ 2012-10-29 20:01 UTC (permalink / raw)
To: linux-pm
Cc: Nishanth Menon, Rajagopal Venkat, MyungJoo Ham, Kyungmin Park,
Rafael J. Wysocki, Kevin Hilman, linux-kernel
This allows us to select governor runtime from the
default configuration without having to rebuild kernel
or the devfreq driver using the sysfs node:
/sys/class/devfreq/.../governor
cat of the governor will return valid governor
and an echo 'governor_name'>governor will switch
governor
Cc: Rajagopal Venkat <rajagopal.venkat@linaro.org>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Kevin Hilman <khilman@ti.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Documentation/ABI/testing/sysfs-class-devfreq | 2 +-
drivers/devfreq/devfreq.c | 40 ++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
index e672ccb..293f6b2 100644
--- a/Documentation/ABI/testing/sysfs-class-devfreq
+++ b/Documentation/ABI/testing/sysfs-class-devfreq
@@ -11,7 +11,7 @@ What: /sys/class/devfreq/.../governor
Date: September 2011
Contact: MyungJoo Ham <myungjoo.ham@samsung.com>
Description:
- The /sys/class/devfreq/.../governor shows the name of the
+ The /sys/class/devfreq/.../governor show or set the name of the
governor used by the corresponding devfreq object.
What: /sys/class/devfreq/.../cur_freq
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index bd96e32..8535f8c 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -629,6 +629,44 @@ static ssize_t show_governor(struct device *dev,
return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
}
+static ssize_t store_governor(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct devfreq *df = to_devfreq(dev);
+ int ret = 0;
+ struct devfreq_governor *governor;
+
+ mutex_lock(&devfreq_list_lock);
+ governor = find_devfreq_governor(buf);
+ if (IS_ERR(governor)) {
+ ret = PTR_ERR(governor);
+ goto out;
+ }
+ if (df->governor == governor)
+ goto out;
+
+ if (df->governor) {
+ ret = df->governor->event_handler(df, DEVFREQ_GOV_STOP, NULL);
+ if (ret) {
+ dev_warn(dev, "%s: Governor %s not stopped(%d)\n",
+ __func__, df->governor->name, ret);
+ goto out;
+ }
+ }
+ df->governor = governor;
+ strncpy(df->governor_name, governor->name, DEVFREQ_NAME_LEN);
+ ret = df->governor->event_handler(df, DEVFREQ_GOV_START, NULL);
+ if (ret)
+ dev_warn(dev, "%s: Governor %s not started(%d)\n",
+ __func__, df->governor->name, ret);
+out:
+ mutex_unlock(&devfreq_list_lock);
+
+ if (!ret)
+ ret = count;
+ return ret;
+}
+
static ssize_t show_freq(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -773,7 +811,7 @@ static ssize_t show_available_freqs(struct device *d,
}
static struct device_attribute devfreq_attrs[] = {
- __ATTR(governor, S_IRUGO, show_governor, NULL),
+ __ATTR(governor, S_IRUGO | S_IWUSR, show_governor, store_governor),
__ATTR(cur_freq, S_IRUGO, show_freq, NULL),
__ATTR(available_frequencies, S_IRUGO, show_available_freqs, NULL),
__ATTR(target_freq, S_IRUGO, show_target_freq, NULL),
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-06 21:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-06 9:02 [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor MyungJoo Ham
[not found] ` <CAJ0PZbSe7Orhww-amHNRkbvUvJr6x9CtisHw2hoLpcJdyBSKCA@mail.gmail.com>
2012-11-06 21:28 ` Nishanth Menon
-- strict thread matches above, loose matches on Subject: below --
2012-10-29 20:01 [linux-next PATCH 0/7] PM / devfreq: allow governors to be modules and switch dynamically Nishanth Menon
2012-10-29 20:01 ` [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor Nishanth Menon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).