* Re: [PATCH v8 05/11] libata-eh: allow defer in ata_exec_internal
From: Aaron Lu @ 2012-10-30 3:00 UTC (permalink / raw)
To: Tejun Heo
Cc: Jeff Garzik, Rafael J. Wysocki, James Bottomley, Alan Stern,
Oliver Neukum, Jeff Wu, Aaron Lu, Shane Huang, linux-ide,
linux-pm, linux-scsi, linux-acpi
In-Reply-To: <20121029152051.GK5171@htj.dyndns.org>
On 10/29/2012 11:20 PM, Tejun Heo wrote:
> On Mon, Oct 29, 2012 at 05:01:32PM +0800, Aaron Lu wrote:
>> ata_exec_internal will preempt the ata link's active_tag and ata port's
>> qc_active flags, this is OK for error recovery, but if normal code path
>> wants to use ata_exec_internal, there is a problem: we need to check if
>> it is OK to issue a new command with the help of port_ops->defer.
>>
>> In ZPODD, I'll need to find out the loading mechanism of the ODD by
>> issuing a GET_CONFIGURATION command. And this command may very well
>> race with commands issued from SCSI layer. So instead of preempt the
>> current command, defer the new command if it's not OK to issue it, as
>> it is always wrong to issue a non-NCQ command when there is command(s)
>> in processing.
>
> Why not do the discovery from EH?
Do you mean set a device level EH flag and then schedule EH to do the
discovery?
Thanks,
Aaron
^ permalink raw reply
* Please add 2 categories
From: Len Brown @ 2012-10-30 2:52 UTC (permalink / raw)
To: bugme-admin; +Cc: Linux PM list
Dear Bugzilla Admins,
Please add 2 additional Categories under Product "Power Management":
Run-Time-PM - Issues related to Linux Device Run Time Power Management.
Thermal - Issues related to OS-visible Thermal Management, such as throttling.
thanks,
Len Brown
^ permalink raw reply
* Re: [PATCH 1/4] hwmon, fam15h_power: Change email address, MAINTAINERS entry
From: Guenter Roeck @ 2012-10-30 0:49 UTC (permalink / raw)
To: Andreas Herrmann
Cc: Rafael J. Wysocki, Jean Delvare, Ingo Molnar, Thomas Gleixner,
H Peter Anvin, lm-sensors, cpufreq, linux-pm, linux-kernel,
oprofile-list, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029175047.GB5024@tweety>
On Mon, Oct 29, 2012 at 06:50:47PM +0100, Andreas Herrmann wrote:
>
> Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
Applied.
Thanks,
Guenter
^ permalink raw reply
* Re: Linux 3.7-rc3
From: Rafael J. Wysocki @ 2012-10-30 0:10 UTC (permalink / raw)
To: Linux Kernel Mailing List
Cc: Linus Torvalds, Linux PM list, Greg Kroah-Hartman
In-Reply-To: <CA+55aFwwTc4QXKqiECgE9NOE2zjC6GsGHHydGP9YDbgQSbw9Aw@mail.gmail.com>
On Sunday, October 28, 2012 12:59:49 PM Linus Torvalds wrote:
> It's been a week, time for -rc3!
>
> Nothing particularly stands out here. Lots of small fixes, exemplified
> by the series of memory leak fixes in usb serial drivers. Just a lot
> of random stuff..
>
> Most of it is drivers (all over: drm, wireless, staging, usb, sound),
> but there's a few filesystem updates (nfs, btrfs, ext4), arch updates
> (arm, x86 and m68k) and just random stuff. Shortlog appended.
Unfortunately, s2disk is broken with this one and previous -rc. In the
majority of cases it just hangs the machine during hibernation, although
sometimes it returns to user space reporting freezing problems, suspicions
RCU usage and similar stuff, pretty much without any useful debug information.
I'm quite confident that v3.6 was OK (and -stable based on that too), so
it most likely is a recent regression. The in-kernel hibernation
(ie. "echo disk > /sys/power/state") works no problem. So does suspend to
RAM on my test boxes.
So far I have been able to reproduce this 100% of the time on two machines
with Intel CPUs and graphics driven by i915. I _suspect_ that this may be
related to VT switching, because s2disk does some ugly things in that area
which are not done by the in-kernel code. Dunno.
Anyway, it looks like nothing short of bisection is going to help debug this,
but I'm afraid I won't have the time to bisect within the next two weeks, so if
anyone can reproduce this issue and will be able to bisect it, please help
(openSUSE/Tumbleweed users anyone?).
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply
* Re: [PATCH 3/4] cpufreq, powernow-k8: Change email address
From: Rafael J. Wysocki @ 2012-10-29 23:33 UTC (permalink / raw)
To: Andreas Herrmann
Cc: Jean Delvare, Guenter Roeck, Ingo Molnar, Thomas Gleixner,
H Peter Anvin, lm-sensors, cpufreq, linux-pm, linux-kernel,
oprofile-list, Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029175221.GD5024@tweety>
On Monday, October 29, 2012 06:52:21 PM Andreas Herrmann wrote:
>
> Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
Am I supposed to take this one?
Rafael
> ---
> drivers/cpufreq/powernow-k8.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
> index c16a3a5..e3ebb4f 100644
> --- a/drivers/cpufreq/powernow-k8.c
> +++ b/drivers/cpufreq/powernow-k8.c
> @@ -5,7 +5,7 @@
> * http://www.gnu.org/licenses/gpl.html
> *
> * Maintainer:
> - * Andreas Herrmann <andreas.herrmann3@amd.com>
> + * Andreas Herrmann <herrmann.der.user@googlemail.com>
> *
> * Based on the powernow-k7.c module written by Dave Jones.
> * (C) 2003 Dave Jones on behalf of SuSE Labs
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply
* Re: [PATCH 3/4] cpufreq, powernow-k8: Change email address
From: Borislav Petkov @ 2012-10-29 23:31 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andreas Herrmann, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin, lm-sensors, cpufreq, linux-pm,
linux-kernel, oprofile-list, Stephane Eranian, Robert Richter,
Jörg Rödel
In-Reply-To: <2663527.sPyzc5AXi8@vostro.rjw.lan>
On Tue, Oct 30, 2012 at 12:33:15AM +0100, Rafael J. Wysocki wrote:
> On Monday, October 29, 2012 06:52:21 PM Andreas Herrmann wrote:
> >
> > Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
>
> Am I supposed to take this one?
Yes please.
Thanks.
--
Regards/Gruss,
Boris.
^ permalink raw reply
* Re: [PATCH v8 10/11] scsi: sr: support (un)block events
From: Alan Stern @ 2012-10-29 22:22 UTC (permalink / raw)
To: James Bottomley
Cc: Aaron Lu, Jeff Garzik, Rafael J. Wysocki, Tejun Heo,
Oliver Neukum, Jeff Wu, Aaron Lu, Shane Huang, linux-ide,
linux-pm, linux-scsi, linux-acpi
In-Reply-To: <1351534295.3051.9.camel@dabdike>
On Mon, 29 Oct 2012, James Bottomley wrote:
> On Mon, 2012-10-29 at 17:01 +0800, Aaron Lu wrote:
> > 2 interfaces are added to block/unblock events for the disk sr manages.
> > This is used by SATA ZPODD, when ODD is runtime powered off, the events
> > poll is no longer needed so better be blocked. And once powered on,
> > events poll will be unblocked.
> >
> > These 2 interfaces are needed here because SATA layer does not have
> > access to the gendisk structure sr manages.
>
> I'm afraid this is a nasty layering violation. You can't have a low
> level driver have knowledge of a call back in an upper layer one (in
> this case sr_block_events).
>
> This is all done it looks like because of the problem of getting access
> to the scsi_cd structure from libata, but it's not the right way to
> solve it.
>
> I also don't really think you need to do any blocking or unblocking. As
> I said in the previous thread, just fake the events the standard tells
> you to, so userspace can probe to its heart's content and you can keep
> the device powered off.
James, one of us has misunderstood the event-polling mechanism. As far
as I know, the polling calls that Aaron is concerned with are generated
by the kernel, not by userspace.
Alan Stern
^ permalink raw reply
* [linux-next PATCH 1/7] PM / devfreq: export update_devfreq
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
Allow update_devfreq to be used by devfreq governor built
as modules
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>
---
drivers/devfreq/devfreq.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index c071ea0..6d3070d 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -115,6 +115,7 @@ int update_devfreq(struct devfreq *devfreq)
devfreq->previous_freq = freq;
return err;
}
+EXPORT_SYMBOL(update_devfreq);
/**
* devfreq_monitor() - Periodically poll devfreq objects.
--
1.7.9.5
^ permalink raw reply related
* [linux-next PATCH 2/7] PM / devfreq: provide hooks for governors to be registered
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
Add devfreq_add_governor and devfreq_remove_governor which
can be invoked by governors to register with devfreq.
This sets up the stage to dynamically switch governors and
allow governors to be dynamically loaded as well.
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>
---
drivers/devfreq/devfreq.c | 91 ++++++++++++++++++++++++++++++++++++++++++++
drivers/devfreq/governor.h | 4 ++
include/linux/devfreq.h | 3 ++
3 files changed, 98 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6d3070d..9c079d2 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -36,6 +36,8 @@ static struct class *devfreq_class;
*/
static struct workqueue_struct *devfreq_wq;
+/* The list of all device-devfreq governors */
+static LIST_HEAD(devfreq_governor_list);
/* The list of all device-devfreq */
static LIST_HEAD(devfreq_list);
static DEFINE_MUTEX(devfreq_list_lock);
@@ -66,6 +68,32 @@ static struct devfreq *find_device_devfreq(struct device *dev)
return ERR_PTR(-ENODEV);
}
+/**
+ * find_devfreq_governor() - find devfreq governor from name
+ * @name: name of the governor
+ *
+ * Search the list of devfreq governors and return the matched
+ * governor's pointer. devfreq_list_lock should be held by the caller.
+ */
+static struct devfreq_governor *find_devfreq_governor(const char *name)
+{
+ struct devfreq_governor *tmp_governor;
+
+ if (unlikely(IS_ERR_OR_NULL(name))) {
+ pr_err("DEVFREQ: %s: Invalid parameters\n", __func__);
+ return ERR_PTR(-EINVAL);
+ }
+ WARN(!mutex_is_locked(&devfreq_list_lock),
+ "devfreq_list_lock must be locked.");
+
+ list_for_each_entry(tmp_governor, &devfreq_governor_list, node) {
+ if (!strncmp(tmp_governor->name, name, DEVFREQ_NAME_LEN))
+ return tmp_governor;
+ }
+
+ return ERR_PTR(-ENODEV);
+}
+
/* Load monitoring helper functions for governors use */
/**
@@ -456,6 +484,69 @@ int devfreq_resume_device(struct devfreq *devfreq)
}
EXPORT_SYMBOL(devfreq_resume_device);
+/**
+ * devfreq_add_governor() - Add devfreq governor
+ * @governor: the devfreq governor to be added
+ */
+int devfreq_add_governor(struct devfreq_governor *governor)
+{
+ struct devfreq_governor *g;
+ int err = 0;
+
+ if (!governor) {
+ pr_err("%s: Invalid parameters.\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&devfreq_list_lock);
+ g = find_devfreq_governor(governor->name);
+ if (!IS_ERR(g)) {
+ pr_err("%s: governor %s already registered\n", __func__,
+ g->name);
+ err = -EINVAL;
+ goto err_out;
+ }
+
+ list_add(&governor->node, &devfreq_governor_list);
+
+err_out:
+ mutex_unlock(&devfreq_list_lock);
+
+ return err;
+}
+EXPORT_SYMBOL(devfreq_add_governor);
+
+/**
+ * devfreq_remove_device() - Remove devfreq feature from a device.
+ * @governor: the devfreq governor to be removed
+ */
+int devfreq_remove_governor(struct devfreq_governor *governor)
+{
+ struct devfreq_governor *g;
+ int err = 0;
+
+ if (!governor) {
+ pr_err("%s: Invalid parameters.\n", __func__);
+ return -EINVAL;
+ }
+
+ mutex_lock(&devfreq_list_lock);
+ g = find_devfreq_governor(governor->name);
+ if (IS_ERR(g)) {
+ pr_err("%s: governor %s not registered\n", __func__,
+ g->name);
+ err = -EINVAL;
+ goto err_out;
+ }
+
+ list_del(&governor->node);
+err_out:
+ mutex_unlock(&devfreq_list_lock);
+
+ return err;
+}
+EXPORT_SYMBOL(devfreq_remove_governor);
+
static ssize_t show_governor(struct device *dev,
struct device_attribute *attr, char *buf)
{
diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 26432ac..fad7d63 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -34,4 +34,8 @@ extern void devfreq_monitor_suspend(struct devfreq *devfreq);
extern void devfreq_monitor_resume(struct devfreq *devfreq);
extern void devfreq_interval_update(struct devfreq *devfreq,
unsigned int *delay);
+
+extern int devfreq_add_governor(struct devfreq_governor *governor);
+extern int devfreq_remove_governor(struct devfreq_governor *governor);
+
#endif /* _GOVERNOR_H */
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index 1461fb2..a28d935 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -87,6 +87,7 @@ struct devfreq_dev_profile {
/**
* struct devfreq_governor - Devfreq policy governor
+ * @node: list node - contains registered devfreq governors
* @name: Governor's name
* @get_target_freq: Returns desired operating frequency for the device.
* Basically, get_target_freq will run
@@ -102,6 +103,8 @@ struct devfreq_dev_profile {
* Note that the callbacks are called with devfreq->lock locked by devfreq.
*/
struct devfreq_governor {
+ struct list_head node;
+
const char name[DEVFREQ_NAME_LEN];
int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
int (*event_handler)(struct devfreq *devfreq,
--
1.7.9.5
^ permalink raw reply related
* [linux-next PATCH 0/7] PM / devfreq: allow governors to be modules and switch dynamically
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
* [linux-next PATCH 7/7] PM / devfreq: Add sysfs node to expose available governors
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
Now that governor list can be variable, knowing the available governors
is useful to be able to select a governor using relevant sysfs node.
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 | 7 +++++++
drivers/devfreq/devfreq.c | 22 ++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq
index 293f6b2..0daa83f 100644
--- a/Documentation/ABI/testing/sysfs-class-devfreq
+++ b/Documentation/ABI/testing/sysfs-class-devfreq
@@ -60,3 +60,10 @@ Description:
the available frequencies of the corresponding devfreq object.
This is a snapshot of available frequencies and not limited
by the min/max frequency restrictions.
+
+What: /sys/class/devfreq/.../available_governors
+Date: October 2012
+Contact: Nishanth Menon <nm@ti.com>
+Description:
+ The /sys/class/devfreq/.../available_governors shows
+ currently available governors in the system.
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 8535f8c..9ed3ca5 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -666,6 +666,27 @@ out:
ret = count;
return ret;
}
+static ssize_t show_available_governors(struct device *d,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct devfreq_governor *tmp_governor;
+ ssize_t count = 0;
+
+ mutex_lock(&devfreq_list_lock);
+ list_for_each_entry(tmp_governor, &devfreq_governor_list, node)
+ count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
+ "%s ", tmp_governor->name);
+ mutex_unlock(&devfreq_list_lock);
+
+ /* Truncate the trailing space */
+ if (count)
+ count--;
+
+ count += sprintf(&buf[count], "\n");
+
+ return count;
+}
static ssize_t show_freq(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -812,6 +833,7 @@ static ssize_t show_available_freqs(struct device *d,
static struct device_attribute devfreq_attrs[] = {
__ATTR(governor, S_IRUGO | S_IWUSR, show_governor, store_governor),
+ __ATTR(available_governors, S_IRUGO, show_available_governors, NULL),
__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
* [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
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
* [linux-next PATCH 5/7] PM / devfreq: governors: add GPL module license and allow module build
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
Add GPL module license and remove the static build
restrictions for building governors. This allows governors now
to be loaded on a need basis and reloaded independently of kernel
build
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>
---
drivers/devfreq/Kconfig | 8 ++++----
drivers/devfreq/governor_performance.c | 2 ++
drivers/devfreq/governor_powersave.c | 2 ++
drivers/devfreq/governor_simpleondemand.c | 2 ++
drivers/devfreq/governor_userspace.c | 2 ++
5 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/devfreq/Kconfig b/drivers/devfreq/Kconfig
index f6b0a6e2..0f079be 100644
--- a/drivers/devfreq/Kconfig
+++ b/drivers/devfreq/Kconfig
@@ -30,7 +30,7 @@ if PM_DEVFREQ
comment "DEVFREQ Governors"
config DEVFREQ_GOV_SIMPLE_ONDEMAND
- bool "Simple Ondemand"
+ tristate "Simple Ondemand"
help
Chooses frequency based on the recent load on the device. Works
similar as ONDEMAND governor of CPUFREQ does. A device with
@@ -39,7 +39,7 @@ config DEVFREQ_GOV_SIMPLE_ONDEMAND
values to the governor with data field at devfreq_add_device().
config DEVFREQ_GOV_PERFORMANCE
- bool "Performance"
+ tristate "Performance"
help
Sets the frequency at the maximum available frequency.
This governor always returns UINT_MAX as frequency so that
@@ -47,7 +47,7 @@ config DEVFREQ_GOV_PERFORMANCE
at any time.
config DEVFREQ_GOV_POWERSAVE
- bool "Powersave"
+ tristate "Powersave"
help
Sets the frequency at the minimum available frequency.
This governor always returns 0 as frequency so that
@@ -55,7 +55,7 @@ config DEVFREQ_GOV_POWERSAVE
at any time.
config DEVFREQ_GOV_USERSPACE
- bool "Userspace"
+ tristate "Userspace"
help
Sets the frequency at the user specified one.
This governor returns the user configured frequency if there
diff --git a/drivers/devfreq/governor_performance.c b/drivers/devfreq/governor_performance.c
index 865a369..c72f942 100644
--- a/drivers/devfreq/governor_performance.c
+++ b/drivers/devfreq/governor_performance.c
@@ -10,6 +10,7 @@
*/
#include <linux/devfreq.h>
+#include <linux/module.h>
#include "governor.h"
static int devfreq_performance_func(struct devfreq *df,
@@ -63,3 +64,4 @@ static void __exit devfreq_performance_exit(void)
return;
}
module_exit(devfreq_performance_exit);
+MODULE_LICENSE("GPL");
diff --git a/drivers/devfreq/governor_powersave.c b/drivers/devfreq/governor_powersave.c
index 8612c0f..0c6bed5 100644
--- a/drivers/devfreq/governor_powersave.c
+++ b/drivers/devfreq/governor_powersave.c
@@ -10,6 +10,7 @@
*/
#include <linux/devfreq.h>
+#include <linux/module.h>
#include "governor.h"
static int devfreq_powersave_func(struct devfreq *df,
@@ -60,3 +61,4 @@ static void __exit devfreq_powersave_exit(void)
return;
}
module_exit(devfreq_powersave_exit);
+MODULE_LICENSE("GPL");
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index a870a24..0720ba8 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -10,6 +10,7 @@
*/
#include <linux/errno.h>
+#include <linux/module.h>
#include <linux/devfreq.h>
#include <linux/math64.h>
#include "governor.h"
@@ -143,3 +144,4 @@ static void __exit devfreq_simple_ondemand_exit(void)
return;
}
module_exit(devfreq_simple_ondemand_exit);
+MODULE_LICENSE("GPL");
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 34fb80f..35de6e8 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -14,6 +14,7 @@
#include <linux/devfreq.h>
#include <linux/pm.h>
#include <linux/mutex.h>
+#include <linux/module.h>
#include "governor.h"
struct userspace_data {
@@ -158,3 +159,4 @@ static void __exit devfreq_userspace_exit(void)
return;
}
module_exit(devfreq_userspace_exit);
+MODULE_LICENSE("GPL");
--
1.7.9.5
^ permalink raw reply related
* [linux-next PATCH 4/7] PM / devfreq: map devfreq drivers to governor using name
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
Allow devfreq drivers to register a preferred governor name
and when the devfreq governor loads itself at a later point
required drivers are managed appropriately, at the time of
unload of a devfreq governor, stop managing those drivers
as well.
Since the governor structures do not need to be exposed
anymore, remove the definitions and make them static
NOTE: devfreq_list_lock is now used to protect governor
start and stop - as this allows us to protect governors and
devfreq with the proper dependencies as needed.
As part of this change, change the registration of exynos
bus driver to request for ondemand using the governor name.
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>
---
drivers/devfreq/devfreq.c | 95 ++++++++++++++++++++++++++---
drivers/devfreq/exynos4_bus.c | 2 +-
drivers/devfreq/governor_performance.c | 2 +-
drivers/devfreq/governor_powersave.c | 2 +-
drivers/devfreq/governor_simpleondemand.c | 2 +-
drivers/devfreq/governor_userspace.c | 2 +-
include/linux/devfreq.h | 21 ++-----
7 files changed, 96 insertions(+), 30 deletions(-)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 9c079d2..bd96e32 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -114,6 +114,9 @@ int update_devfreq(struct devfreq *devfreq)
return -EINVAL;
}
+ if (!devfreq->governor)
+ return -EINVAL;
+
/* Reevaluate the proper frequency */
err = devfreq->governor->get_target_freq(devfreq, &freq);
if (err)
@@ -329,7 +332,9 @@ static void _remove_devfreq(struct devfreq *devfreq, bool skip)
list_del(&devfreq->node);
mutex_unlock(&devfreq_list_lock);
- devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_STOP, NULL);
+ if (devfreq->governor)
+ devfreq->governor->event_handler(devfreq,
+ DEVFREQ_GOV_STOP, NULL);
if (devfreq->profile->exit)
devfreq->profile->exit(devfreq->dev.parent);
@@ -362,19 +367,20 @@ static void devfreq_dev_release(struct device *dev)
* devfreq_add_device() - Add devfreq feature to the device
* @dev: the device to add devfreq feature.
* @profile: device-specific profile to run devfreq.
- * @governor: the policy to choose frequency.
+ * @governor_name: name of the policy to choose frequency.
* @data: private data for the governor. The devfreq framework does not
* touch this value.
*/
struct devfreq *devfreq_add_device(struct device *dev,
struct devfreq_dev_profile *profile,
- const struct devfreq_governor *governor,
+ const char *governor_name,
void *data)
{
struct devfreq *devfreq;
+ struct devfreq_governor *governor;
int err = 0;
- if (!dev || !profile || !governor) {
+ if (!dev || !profile || !governor_name) {
dev_err(dev, "%s: Invalid parameters.\n", __func__);
return ERR_PTR(-EINVAL);
}
@@ -402,7 +408,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
devfreq->dev.class = devfreq_class;
devfreq->dev.release = devfreq_dev_release;
devfreq->profile = profile;
- devfreq->governor = governor;
+ strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN);
devfreq->previous_freq = profile->initial_freq;
devfreq->data = data;
devfreq->nb.notifier_call = devfreq_notifier_call;
@@ -419,10 +425,14 @@ struct devfreq *devfreq_add_device(struct device *dev,
mutex_lock(&devfreq_list_lock);
list_add(&devfreq->node, &devfreq_list);
- mutex_unlock(&devfreq_list_lock);
- err = devfreq->governor->event_handler(devfreq,
- DEVFREQ_GOV_START, NULL);
+ governor = find_devfreq_governor(devfreq->governor_name);
+ if (!IS_ERR(governor))
+ devfreq->governor = governor;
+ if (devfreq->governor)
+ err = devfreq->governor->event_handler(devfreq,
+ DEVFREQ_GOV_START, NULL);
+ mutex_unlock(&devfreq_list_lock);
if (err) {
dev_err(dev, "%s: Unable to start governor for the device\n",
__func__);
@@ -465,6 +475,9 @@ int devfreq_suspend_device(struct devfreq *devfreq)
if (!devfreq)
return -EINVAL;
+ if (!devfreq->governor)
+ return 0;
+
return devfreq->governor->event_handler(devfreq,
DEVFREQ_GOV_SUSPEND, NULL);
}
@@ -479,6 +492,9 @@ int devfreq_resume_device(struct devfreq *devfreq)
if (!devfreq)
return -EINVAL;
+ if (!devfreq->governor)
+ return 0;
+
return devfreq->governor->event_handler(devfreq,
DEVFREQ_GOV_RESUME, NULL);
}
@@ -491,6 +507,7 @@ EXPORT_SYMBOL(devfreq_resume_device);
int devfreq_add_governor(struct devfreq_governor *governor)
{
struct devfreq_governor *g;
+ struct devfreq *devfreq;
int err = 0;
if (!governor) {
@@ -509,6 +526,38 @@ int devfreq_add_governor(struct devfreq_governor *governor)
list_add(&governor->node, &devfreq_governor_list);
+ list_for_each_entry(devfreq, &devfreq_list, node) {
+ int ret = 0;
+ struct device *dev = devfreq->dev.parent;
+
+ if (!strncmp(devfreq->governor_name, governor->name,
+ DEVFREQ_NAME_LEN)) {
+ /* The following should never occur */
+ if (devfreq->governor) {
+ dev_warn(dev,
+ "%s: Governor %s already present\n",
+ __func__, devfreq->governor->name);
+ ret = devfreq->governor->event_handler(devfreq,
+ DEVFREQ_GOV_STOP, NULL);
+ if (ret) {
+ dev_warn(dev,
+ "%s: Governor %s stop = %d\n",
+ __func__,
+ devfreq->governor->name, ret);
+ }
+ /* Fall through */
+ }
+ devfreq->governor = governor;
+ ret = devfreq->governor->event_handler(devfreq,
+ DEVFREQ_GOV_START, NULL);
+ if (ret) {
+ dev_warn(dev, "%s: Governor %s start=%d\n",
+ __func__, devfreq->governor->name,
+ ret);
+ }
+ }
+ }
+
err_out:
mutex_unlock(&devfreq_list_lock);
@@ -523,6 +572,7 @@ EXPORT_SYMBOL(devfreq_add_governor);
int devfreq_remove_governor(struct devfreq_governor *governor)
{
struct devfreq_governor *g;
+ struct devfreq *devfreq;
int err = 0;
if (!governor) {
@@ -538,6 +588,29 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
err = -EINVAL;
goto err_out;
}
+ list_for_each_entry(devfreq, &devfreq_list, node) {
+ int ret;
+ struct device *dev = devfreq->dev.parent;
+
+ if (!strncmp(devfreq->governor_name, governor->name,
+ DEVFREQ_NAME_LEN)) {
+ /* we should have a devfreq governor! */
+ if (!devfreq->governor) {
+ dev_warn(dev, "%s: Governor %s NOT present\n",
+ __func__, governor->name);
+ continue;
+ /* Fall through */
+ }
+ ret = devfreq->governor->event_handler(devfreq,
+ DEVFREQ_GOV_STOP, NULL);
+ if (ret) {
+ dev_warn(dev, "%s: Governor %s stop=%d\n",
+ __func__, devfreq->governor->name,
+ ret);
+ }
+ devfreq->governor = NULL;
+ }
+ }
list_del(&governor->node);
err_out:
@@ -550,6 +623,9 @@ EXPORT_SYMBOL(devfreq_remove_governor);
static ssize_t show_governor(struct device *dev,
struct device_attribute *attr, char *buf)
{
+ if (!to_devfreq(dev)->governor)
+ return -EINVAL;
+
return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
}
@@ -586,6 +662,9 @@ static ssize_t store_polling_interval(struct device *dev,
unsigned int value;
int ret;
+ if (!df->governor)
+ return -EINVAL;
+
ret = sscanf(buf, "%u", &value);
if (ret != 1)
return -EINVAL;
diff --git a/drivers/devfreq/exynos4_bus.c b/drivers/devfreq/exynos4_bus.c
index 88ddc77..b8b1a00 100644
--- a/drivers/devfreq/exynos4_bus.c
+++ b/drivers/devfreq/exynos4_bus.c
@@ -1045,7 +1045,7 @@ static __devinit int exynos4_busfreq_probe(struct platform_device *pdev)
busfreq_mon_reset(data);
data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile,
- &devfreq_simple_ondemand, NULL);
+ "simple_ondemand", NULL);
if (IS_ERR(data->devfreq)) {
err = PTR_ERR(data->devfreq);
goto err_opp_add;
diff --git a/drivers/devfreq/governor_performance.c b/drivers/devfreq/governor_performance.c
index db8ff77..865a369 100644
--- a/drivers/devfreq/governor_performance.c
+++ b/drivers/devfreq/governor_performance.c
@@ -40,7 +40,7 @@ static int devfreq_performance_handler(struct devfreq *devfreq,
return ret;
}
-const struct devfreq_governor devfreq_performance = {
+static struct devfreq_governor devfreq_performance = {
.name = "performance",
.get_target_freq = devfreq_performance_func,
.event_handler = devfreq_performance_handler,
diff --git a/drivers/devfreq/governor_powersave.c b/drivers/devfreq/governor_powersave.c
index 30f0fca..8612c0f 100644
--- a/drivers/devfreq/governor_powersave.c
+++ b/drivers/devfreq/governor_powersave.c
@@ -37,7 +37,7 @@ static int devfreq_powersave_handler(struct devfreq *devfreq,
return ret;
}
-const struct devfreq_governor devfreq_powersave = {
+static struct devfreq_governor devfreq_powersave = {
.name = "powersave",
.get_target_freq = devfreq_powersave_func,
.event_handler = devfreq_powersave_handler,
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index 85f9ed5..a870a24 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -120,7 +120,7 @@ static int devfreq_simple_ondemand_handler(struct devfreq *devfreq,
return 0;
}
-const struct devfreq_governor devfreq_simple_ondemand = {
+static struct devfreq_governor devfreq_simple_ondemand = {
.name = "simple_ondemand",
.get_target_freq = devfreq_simple_ondemand_func,
.event_handler = devfreq_simple_ondemand_handler,
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 110f178..34fb80f 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -135,7 +135,7 @@ static int devfreq_userspace_handler(struct devfreq *devfreq,
return ret;
}
-const struct devfreq_governor devfreq_userspace = {
+static struct devfreq_governor devfreq_userspace = {
.name = "userspace",
.get_target_freq = devfreq_userspace_func,
.event_handler = devfreq_userspace_handler,
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
index a28d935..092fe72 100644
--- a/include/linux/devfreq.h
+++ b/include/linux/devfreq.h
@@ -120,6 +120,7 @@ struct devfreq_governor {
* using devfreq.
* @profile: device-specific devfreq profile
* @governor: method how to choose frequency based on the usage.
+ * @governor_name: devfreq governor name for use with this devfreq
* @nb: notifier block used to notify devfreq object that it should
* reevaluate operable frequencies. Devfreq users may use
* devfreq.nb to the corresponding register notifier call chain.
@@ -146,6 +147,7 @@ struct devfreq {
struct device dev;
struct devfreq_dev_profile *profile;
const struct devfreq_governor *governor;
+ char governor_name[DEVFREQ_NAME_LEN];
struct notifier_block nb;
struct delayed_work work;
@@ -161,7 +163,7 @@ struct devfreq {
#if defined(CONFIG_PM_DEVFREQ)
extern struct devfreq *devfreq_add_device(struct device *dev,
struct devfreq_dev_profile *profile,
- const struct devfreq_governor *governor,
+ const char *governor_name,
void *data);
extern int devfreq_remove_device(struct devfreq *devfreq);
extern int devfreq_suspend_device(struct devfreq *devfreq);
@@ -175,17 +177,7 @@ extern int devfreq_register_opp_notifier(struct device *dev,
extern int devfreq_unregister_opp_notifier(struct device *dev,
struct devfreq *devfreq);
-#ifdef CONFIG_DEVFREQ_GOV_POWERSAVE
-extern const struct devfreq_governor devfreq_powersave;
-#endif
-#ifdef CONFIG_DEVFREQ_GOV_PERFORMANCE
-extern const struct devfreq_governor devfreq_performance;
-#endif
-#ifdef CONFIG_DEVFREQ_GOV_USERSPACE
-extern const struct devfreq_governor devfreq_userspace;
-#endif
#ifdef CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND
-extern const struct devfreq_governor devfreq_simple_ondemand;
/**
* struct devfreq_simple_ondemand_data - void *data fed to struct devfreq
* and devfreq_add_device
@@ -208,7 +200,7 @@ struct devfreq_simple_ondemand_data {
#else /* !CONFIG_PM_DEVFREQ */
static struct devfreq *devfreq_add_device(struct device *dev,
struct devfreq_dev_profile *profile,
- struct devfreq_governor *governor,
+ const char *governor_name,
void *data)
{
return NULL;
@@ -247,11 +239,6 @@ static int devfreq_unregister_opp_notifier(struct device *dev,
return -EINVAL;
}
-#define devfreq_powersave NULL
-#define devfreq_performance NULL
-#define devfreq_userspace NULL
-#define devfreq_simple_ondemand NULL
-
#endif /* CONFIG_PM_DEVFREQ */
#endif /* __LINUX_DEVFREQ_H__ */
--
1.7.9.5
^ permalink raw reply related
* [linux-next PATCH 3/7] PM / devfreq: register governors with devfreq framework
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
In-Reply-To: <1351540908-12195-1-git-send-email-nm@ti.com>
With the new registration functions, governors can be now
registered with devfreq framework.
NOTE: generates 'discards qualifiers from pointer target type'
build warnings, which the next patche in this series fixes
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>
---
drivers/devfreq/governor_performance.c | 18 ++++++++++++++++++
drivers/devfreq/governor_powersave.c | 18 ++++++++++++++++++
drivers/devfreq/governor_simpleondemand.c | 18 ++++++++++++++++++
drivers/devfreq/governor_userspace.c | 18 ++++++++++++++++++
4 files changed, 72 insertions(+)
diff --git a/drivers/devfreq/governor_performance.c b/drivers/devfreq/governor_performance.c
index eea3f9b..db8ff77 100644
--- a/drivers/devfreq/governor_performance.c
+++ b/drivers/devfreq/governor_performance.c
@@ -45,3 +45,21 @@ const struct devfreq_governor devfreq_performance = {
.get_target_freq = devfreq_performance_func,
.event_handler = devfreq_performance_handler,
};
+
+static int __init devfreq_performance_init(void)
+{
+ return devfreq_add_governor(&devfreq_performance);
+}
+subsys_initcall(devfreq_performance_init);
+
+static void __exit devfreq_performance_exit(void)
+{
+ int ret;
+
+ ret = devfreq_remove_governor(&devfreq_performance);
+ if (ret)
+ pr_err("%s: failed remove governor %d\n", __func__, ret);
+
+ return;
+}
+module_exit(devfreq_performance_exit);
diff --git a/drivers/devfreq/governor_powersave.c b/drivers/devfreq/governor_powersave.c
index 2868d98..30f0fca 100644
--- a/drivers/devfreq/governor_powersave.c
+++ b/drivers/devfreq/governor_powersave.c
@@ -42,3 +42,21 @@ const struct devfreq_governor devfreq_powersave = {
.get_target_freq = devfreq_powersave_func,
.event_handler = devfreq_powersave_handler,
};
+
+static int __init devfreq_powersave_init(void)
+{
+ return devfreq_add_governor(&devfreq_powersave);
+}
+subsys_initcall(devfreq_powersave_init);
+
+static void __exit devfreq_powersave_exit(void)
+{
+ int ret;
+
+ ret = devfreq_remove_governor(&devfreq_powersave);
+ if (ret)
+ pr_err("%s: failed remove governor %d\n", __func__, ret);
+
+ return;
+}
+module_exit(devfreq_powersave_exit);
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index b5cf0fb..85f9ed5 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -125,3 +125,21 @@ const struct devfreq_governor devfreq_simple_ondemand = {
.get_target_freq = devfreq_simple_ondemand_func,
.event_handler = devfreq_simple_ondemand_handler,
};
+
+static int __init devfreq_simple_ondemand_init(void)
+{
+ return devfreq_add_governor(&devfreq_simple_ondemand);
+}
+subsys_initcall(devfreq_simple_ondemand_init);
+
+static void __exit devfreq_simple_ondemand_exit(void)
+{
+ int ret;
+
+ ret = devfreq_remove_governor(&devfreq_simple_ondemand);
+ if (ret)
+ pr_err("%s: failed remove governor %d\n", __func__, ret);
+
+ return;
+}
+module_exit(devfreq_simple_ondemand_exit);
diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c
index 7067555..110f178 100644
--- a/drivers/devfreq/governor_userspace.c
+++ b/drivers/devfreq/governor_userspace.c
@@ -140,3 +140,21 @@ const struct devfreq_governor devfreq_userspace = {
.get_target_freq = devfreq_userspace_func,
.event_handler = devfreq_userspace_handler,
};
+
+static int __init devfreq_userspace_init(void)
+{
+ return devfreq_add_governor(&devfreq_userspace);
+}
+subsys_initcall(devfreq_userspace_init);
+
+static void __exit devfreq_userspace_exit(void)
+{
+ int ret;
+
+ ret = devfreq_remove_governor(&devfreq_userspace);
+ if (ret)
+ pr_err("%s: failed remove governor %d\n", __func__, ret);
+
+ return;
+}
+module_exit(devfreq_userspace_exit);
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v8 10/11] scsi: sr: support (un)block events
From: James Bottomley @ 2012-10-29 18:11 UTC (permalink / raw)
To: Aaron Lu
Cc: Jeff Garzik, Rafael J. Wysocki, Alan Stern, Tejun Heo,
Oliver Neukum, Jeff Wu, Aaron Lu, Shane Huang, linux-ide,
linux-pm, linux-scsi, linux-acpi
In-Reply-To: <1351501298-3716-11-git-send-email-aaron.lu@intel.com>
On Mon, 2012-10-29 at 17:01 +0800, Aaron Lu wrote:
> 2 interfaces are added to block/unblock events for the disk sr manages.
> This is used by SATA ZPODD, when ODD is runtime powered off, the events
> poll is no longer needed so better be blocked. And once powered on,
> events poll will be unblocked.
>
> These 2 interfaces are needed here because SATA layer does not have
> access to the gendisk structure sr manages.
I'm afraid this is a nasty layering violation. You can't have a low
level driver have knowledge of a call back in an upper layer one (in
this case sr_block_events).
This is all done it looks like because of the problem of getting access
to the scsi_cd structure from libata, but it's not the right way to
solve it.
I also don't really think you need to do any blocking or unblocking. As
I said in the previous thread, just fake the events the standard tells
you to, so userspace can probe to its heart's content and you can keep
the device powered off.
James
> Signed-off-by: Aaron Lu <aaron.lu@intel.com>
> ---
> drivers/scsi/Makefile | 1 +
> drivers/scsi/sr_zpodd.c | 21 +++++++++++++++++++++
> drivers/scsi/sr_zpodd.h | 9 +++++++++
> 3 files changed, 31 insertions(+)
> create mode 100644 drivers/scsi/sr_zpodd.c
> create mode 100644 drivers/scsi/sr_zpodd.h
>
> diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
> index 888f73a..474efe2 100644
> --- a/drivers/scsi/Makefile
> +++ b/drivers/scsi/Makefile
> @@ -177,6 +177,7 @@ sd_mod-objs := sd.o
> sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
>
> sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
> +sr_mod-$(CONFIG_SATA_ZPODD) += sr_zpodd.o
> ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
> := -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \
> -DCONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
> diff --git a/drivers/scsi/sr_zpodd.c b/drivers/scsi/sr_zpodd.c
> new file mode 100644
> index 0000000..0686e8c
> --- /dev/null
> +++ b/drivers/scsi/sr_zpodd.c
> @@ -0,0 +1,21 @@
> +#include <linux/module.h>
> +#include <linux/genhd.h>
> +#include <linux/cdrom.h>
> +#include "sr.h"
> +
> +bool sr_block_events(struct device *dev)
> +{
> + struct scsi_cd *cd = dev_get_drvdata(dev);
> + if (cd)
> + return disk_try_block_events(cd->disk);
> + return false;
> +}
> +EXPORT_SYMBOL(sr_block_events);
> +
> +void sr_unblock_events(struct device *dev)
> +{
> + struct scsi_cd *cd = dev_get_drvdata(dev);
> + if (cd)
> + disk_unblock_events(cd->disk);
> +}
> +EXPORT_SYMBOL(sr_unblock_events);
> diff --git a/drivers/scsi/sr_zpodd.h b/drivers/scsi/sr_zpodd.h
> new file mode 100644
> index 0000000..49c6a55
> --- /dev/null
> +++ b/drivers/scsi/sr_zpodd.h
> @@ -0,0 +1,9 @@
> +#ifndef __SR_ZPODD_H__
> +#define __SR_ZPODD_H__
> +
> +#include <linux/device.h>
> +
> +extern bool sr_block_events(struct device *dev);
> +extern void sr_unblock_events(struct device *dev);
> +
> +#endif
^ permalink raw reply
* Re: [PATCH v8 02/11] ata: zpodd: Add CONFIG_SATA_ZPODD
From: James Bottomley @ 2012-10-29 18:11 UTC (permalink / raw)
To: Aaron Lu
Cc: Jeff Garzik, Rafael J. Wysocki, Alan Stern, Tejun Heo,
Oliver Neukum, Jeff Wu, Aaron Lu, Shane Huang, linux-ide,
linux-pm, linux-scsi, linux-acpi
In-Reply-To: <1351501298-3716-3-git-send-email-aaron.lu@intel.com>
On Mon, 2012-10-29 at 17:01 +0800, Aaron Lu wrote:
> Added a new config CONFIG_SATA_ZPODD, which is ued to support
> SATA based zero power ODD. It depends on ACPI, and selects BLK_DEV_SR
> as the implementation of ZPODD depends on SCSI sr driver.
>
> 2 new files are added, which will be used to host ZPODD related code.
> They are empty for this commit.
I think you actually need to combine this with patch 3 to have it
compile ...
James
> Signed-off-by: Aaron Lu <aaron.lu@intel.com>
> ---
> drivers/ata/Kconfig | 12 ++++++++++++
> drivers/ata/Makefile | 1 +
> 2 files changed, 13 insertions(+)
> create mode 100644 drivers/ata/sata_zpodd.c
> create mode 100644 drivers/ata/sata_zpodd.h
>
> diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
> index e08d322..2cdecee 100644
> --- a/drivers/ata/Kconfig
> +++ b/drivers/ata/Kconfig
> @@ -58,6 +58,18 @@ config ATA_ACPI
> You can disable this at kernel boot time by using the
> option libata.noacpi=1
>
> +config SATA_ZPODD
> + bool "SATA Zero Power ODD Support"
> + depends on ACPI
> + select BLK_DEV_SR
> + default n
> + help
> + This option adds support for SATA ZPODD. It requires both
> + ODD and the platform support, and if enabled, will automatically
> + power on/off the ODD when certain condition is satisfied. This
> + does not impact user's experience of the ODD, only power is saved
> + when ODD is not in use(i.e. no disc inside).
> +
> config SATA_PMP
> bool "SATA Port Multiplier support"
> default y
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 9329daf..a5120ff 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -107,3 +107,4 @@ libata-y := libata-core.o libata-scsi.o libata-eh.o libata-transport.o
> libata-$(CONFIG_ATA_SFF) += libata-sff.o
> libata-$(CONFIG_SATA_PMP) += libata-pmp.o
> libata-$(CONFIG_ATA_ACPI) += libata-acpi.o
> +obj-$(CONFIG_SATA_ZPODD) += sata_zpodd.o
> diff --git a/drivers/ata/sata_zpodd.c b/drivers/ata/sata_zpodd.c
> new file mode 100644
> index 0000000..e69de29
> diff --git a/drivers/ata/sata_zpodd.h b/drivers/ata/sata_zpodd.h
> new file mode 100644
> index 0000000..e69de29
^ permalink raw reply
* [PATCH 4/4] MAINTAINERS: Update email address for Robert Richter
From: Andreas Herrmann @ 2012-10-29 17:53 UTC (permalink / raw)
To: Rafael J. Wysocki, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin
Cc: lm-sensors, cpufreq, linux-pm, linux-kernel, oprofile-list,
Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029174924.GA5024@tweety>
From: Robert Richter <rric@kernel.org>
Signed-off-by: Robert Richter <rric@kernel.org>
Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
---
MAINTAINERS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 5a66583..5b8935b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5363,7 +5363,7 @@ S: Maintained
F: sound/drivers/opl4/
OPROFILE
-M: Robert Richter <robert.richter@amd.com>
+M: Robert Richter <rric@kernel.org>
L: oprofile-list@lists.sf.net
S: Maintained
F: arch/*/include/asm/oprofile*.h
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/4] cpufreq, powernow-k8: Change email address
From: Andreas Herrmann @ 2012-10-29 17:52 UTC (permalink / raw)
To: Rafael J. Wysocki, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin
Cc: lm-sensors, cpufreq, linux-pm, linux-kernel, oprofile-list,
Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029174924.GA5024@tweety>
Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index c16a3a5..e3ebb4f 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -5,7 +5,7 @@
* http://www.gnu.org/licenses/gpl.html
*
* Maintainer:
- * Andreas Herrmann <andreas.herrmann3@amd.com>
+ * Andreas Herrmann <herrmann.der.user@googlemail.com>
*
* Based on the powernow-k7.c module written by Dave Jones.
* (C) 2003 Dave Jones on behalf of SuSE Labs
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/4] x86, microcode_amd: Change email addresses, MAINTAINERS entry
From: Andreas Herrmann @ 2012-10-29 17:51 UTC (permalink / raw)
To: Rafael J. Wysocki, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin
Cc: lm-sensors, cpufreq, linux-pm, linux-kernel, oprofile-list,
Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029174924.GA5024@tweety>
Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
---
MAINTAINERS | 4 ++--
| 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index a4e8136..5a66583 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -534,9 +534,9 @@ F: drivers/iommu/amd_iommu*.[ch]
F: include/linux/amd-iommu.h
AMD MICROCODE UPDATE SUPPORT
-M: Andreas Herrmann <andreas.herrmann3@amd.com>
+M: Andreas Herrmann <herrmann.der.user@googlemail.com>
L: amd64-microcode@amd64.org
-S: Supported
+S: Maintained
F: arch/x86/kernel/microcode_amd.c
AMS (Apple Motion Sensor) DRIVER
--git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 7720ff5..b3e67ba 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -8,8 +8,8 @@
* Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
*
* Maintainers:
- * Andreas Herrmann <andreas.herrmann3@amd.com>
- * Borislav Petkov <borislav.petkov@amd.com>
+ * Andreas Herrmann <herrmann.der.user@googlemail.com>
+ * Borislav Petkov <bp@alien8.de>
*
* This driver allows to upgrade microcode on F10h AMD
* CPUs and later.
--
1.7.9.5
^ permalink raw reply related
* [PATCH 1/4] hwmon, fam15h_power: Change email address, MAINTAINERS entry
From: Andreas Herrmann @ 2012-10-29 17:50 UTC (permalink / raw)
To: Rafael J. Wysocki, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin
Cc: lm-sensors, cpufreq, linux-pm, linux-kernel, oprofile-list,
Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
In-Reply-To: <20121029174924.GA5024@tweety>
Signed-off-by: Andreas Herrmann <herrmann.der.user@googlemail.com>
---
| 2 +-
MAINTAINERS | 2 +-
| 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
--git a/Documentation/hwmon/fam15h_power b/Documentation/hwmon/fam15h_power
index a92918e..8065481 100644
--- a/Documentation/hwmon/fam15h_power
+++ b/Documentation/hwmon/fam15h_power
@@ -10,7 +10,7 @@ Supported chips:
BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
(not yet published)
-Author: Andreas Herrmann <andreas.herrmann3@amd.com>
+Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
Description
-----------
diff --git a/MAINTAINERS b/MAINTAINERS
index 1fa9074..a4e8136 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -503,7 +503,7 @@ F: include/linux/altera_uart.h
F: include/linux/altera_jtaguart.h
AMD FAM15H PROCESSOR POWER MONITORING DRIVER
-M: Andreas Herrmann <andreas.herrmann3@amd.com>
+M: Andreas Herrmann <herrmann.der.user@googlemail.com>
L: lm-sensors@lm-sensors.org
S: Maintained
F: Documentation/hwmon/fam15h_power
--git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 68ad7d2..4f41104 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -2,7 +2,7 @@
* fam15h_power.c - AMD Family 15h processor power monitoring
*
* Copyright (c) 2011 Advanced Micro Devices, Inc.
- * Author: Andreas Herrmann <andreas.herrmann3@amd.com>
+ * Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
*
*
* This driver is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@
#include <asm/processor.h>
MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor");
-MODULE_AUTHOR("Andreas Herrmann <andreas.herrmann3@amd.com>");
+MODULE_AUTHOR("Andreas Herrmann <herrmann.der.user@googlemail.com>");
MODULE_LICENSE("GPL");
/* D18F3 */
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/4] MAINTAINERS et al: Change email addresses for misc stuff
From: Andreas Herrmann @ 2012-10-29 17:49 UTC (permalink / raw)
To: Rafael J. Wysocki, Jean Delvare, Guenter Roeck, Ingo Molnar,
Thomas Gleixner, H Peter Anvin
Cc: lm-sensors, cpufreq, linux-pm, linux-kernel, oprofile-list,
Stephane Eranian, Robert Richter, Borislav Petkov,
Jörg Rödel
Hi,
following patches are required to change Robert's, Boris' and my email
addresses as we won't have access to AMD email soon.
Regards,
Andreas
^ permalink raw reply
* Re: [PATCH] saa7134: Add pm_qos_request to fix video corruption
From: Simon Farnsworth @ 2012-10-29 16:03 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Andy Walls, linux-media, linux-pm
In-Reply-To: <20121029134445.1f58657e@infradead.org>
[-- Attachment #1: Type: text/plain, Size: 1163 bytes --]
On Monday 29 October 2012 13:44:45 Mauro Carvalho Chehab wrote:
> Thanks for digging into it and getting more data. Do you know if this change
> it also needed with USB devices that do DMA (isoc and/or bulk)? Or the USB
> core already handles that?
>
I'm not a huge expert - the linux-pm list (cc'd) will have people around who
know more.
If I've understood correctly, though, the USB core should take care of pm_qos
requests if they're needed for the hardware; remember that if the HCD has
enough buffering, there's no need for a pm_qos request. It's only needed for
devices like the SAA7134 where the buffer is small (1K split into pieces)
compared to the sample data rate (27 megabytes/second raw video).
For the benefit of the linux-pm list; this all starts with me providing a
patch to have the saa7134 driver request reduced cpu_dma_latency when
streaming, as I've seen buffer exhaustion. We've got far enough to know that
the value I chose was wrong for the saa7134, but Mauro also wants guidance on
whether USB devices (not host controllers) also need to request reduced
latency.
--
Simon Farnsworth
Software Engineer
ONELAN Ltd
http://www.onelan.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply
* Re: [PATCH v3 4/6] net/core: apply pm_runtime_set_memalloc_noio on network devices
From: Alan Stern @ 2012-10-29 15:44 UTC (permalink / raw)
To: Ming Lei
Cc: linux-kernel, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
netdev, linux-usb, linux-pm, linux-mm, Eric Dumazet,
David Decotigny, Tom Herbert, Ingo Molnar
In-Reply-To: <1351513440-9286-5-git-send-email-ming.lei@canonical.com>
On Mon, 29 Oct 2012, Ming Lei wrote:
> Deadlock might be caused by allocating memory with GFP_KERNEL in
> runtime_resume callback of network devices in iSCSI situation, so
> mark network devices and its ancestor as 'memalloc_noio_resume'
> with the introduced pm_runtime_set_memalloc_noio().
> @@ -1411,6 +1414,8 @@ int netdev_register_kobject(struct net_device *net)
> *groups++ = &netstat_group;
> #endif /* CONFIG_SYSFS */
>
> + pm_runtime_set_memalloc_noio(dev, true);
> +
> error = device_add(dev);
> if (error)
> return error;
This is an example of what I described earlier. The
pm_runtime_set_memalloc_noio() call should come after device_add(), not
before.
(Not to mention that this version of the code doesn't correctly handle
the case where device_add() fails.)
Alan Stern
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* Re: [PATCH v3 2/6] PM / Runtime: introduce pm_runtime_set[get]_memalloc_noio()
From: Alan Stern @ 2012-10-29 15:41 UTC (permalink / raw)
To: Ming Lei
Cc: linux-kernel, Oliver Neukum, Minchan Kim, Greg Kroah-Hartman,
Rafael J. Wysocki, Jens Axboe, David S. Miller, Andrew Morton,
netdev, linux-usb, linux-pm, linux-mm
In-Reply-To: <1351513440-9286-3-git-send-email-ming.lei@canonical.com>
On Mon, 29 Oct 2012, Ming Lei wrote:
> The patch introduces the flag of memalloc_noio_resume in
> 'struct dev_pm_info' to help PM core to teach mm not allocating
> memory with GFP_KERNEL flag for avoiding probable deadlock
> problem.
>
> As explained in the comment, any GFP_KERNEL allocation inside
> runtime_resume on any one of device in the path from one block
> or network device to the root device in the device tree may cause
> deadlock, the introduced pm_runtime_set_memalloc_noio() sets or
> clears the flag on device of the path recursively.
>
> This patch also introduces pm_runtime_get_memalloc_noio() because
> the flag may be accessed in block device's error handling path
> (for example, usb device reset)
> +/*
> + * pm_runtime_get_memalloc_noio - Get a device's memalloc_noio flag.
> + * @dev: Device to handle.
> + *
> + * Return the device's memalloc_noio flag.
> + *
> + * The device power lock is held because bitfield is not SMP-safe.
> + */
> +bool pm_runtime_get_memalloc_noio(struct device *dev)
> +{
> + bool ret;
> + spin_lock_irq(&dev->power.lock);
> + ret = dev->power.memalloc_noio_resume;
> + spin_unlock_irq(&dev->power.lock);
> + return ret;
> +}
You don't need to acquire and release a spinlock just to read the
value. Reading bitfields _is_ SMP-safe; writing them is not.
> +/*
> + * pm_runtime_set_memalloc_noio - Set a device's memalloc_noio flag.
> + * @dev: Device to handle.
> + * @enable: True for setting the flag and False for clearing the flag.
> + *
> + * Set the flag for all devices in the path from the device to the
> + * root device in the device tree if @enable is true, otherwise clear
> + * the flag for devices in the path which sibliings don't set the flag.
s/which/whose/
s/ii/i
> + *
> + * The function should only be called by block device, or network
> + * device driver for solving the deadlock problem during runtime
> + * resume:
> + * if memory allocation with GFP_KERNEL is called inside runtime
> + * resume callback of any one of its ancestors(or the block device
> + * itself), the deadlock may be triggered inside the memory
> + * allocation since it might not complete until the block device
> + * becomes active and the involed page I/O finishes. The situation
> + * is pointed out first by Alan Stern. Network device are involved
> + * in iSCSI kind of situation.
> + *
> + * The lock of dev_hotplug_mutex is held in the function for handling
> + * hotplug race because pm_runtime_set_memalloc_noio() may be called
> + * in async probe().
> + */
> +void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
> +{
> + static DEFINE_MUTEX(dev_hotplug_mutex);
> +
> + mutex_lock(&dev_hotplug_mutex);
> + while (dev) {
Unless you think somebody is likely to call this function with dev
equal to NULL, this can simply be
for (;;) {
> + /* hold power lock since bitfield is not SMP-safe. */
> + spin_lock_irq(&dev->power.lock);
> + dev->power.memalloc_noio_resume = enable;
> + spin_unlock_irq(&dev->power.lock);
> +
> + dev = dev->parent;
> +
> + /* only clear the flag for one device if all
> + * children of the device don't set the flag.
> + */
> + if (!dev || (!enable &&
... thanks to this test.
> + device_for_each_child(dev, NULL,
> + dev_memalloc_noio)))
> + break;
> + }
> + mutex_unlock(&dev_hotplug_mutex);
> +}
This might not work if somebody calls pm_runtime_set_memalloc_noio(dev,
true) and then afterwards registers dev at the same time as someone
else calls pm_runtime_set_memalloc_noio(dev2, false), if dev and dev2
have the same parent.
Perhaps the kerneldoc should mention that this function must not be
called until after dev is registered.
Alan Stern
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox