PM core fixes
Subsystems (4)
cover PM core fixes
Hi Greg,
The following series of patches contains some fixes of the PM core related to the suspending and resuming of devices. All of the details are (hopefully) described in the patches' changelogs.
These patches are targeted at 2.6.26, but we (the authors) would like them to get as much linux-next and -mm testing as possible, so please add them to your queue.
Thanks,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
PATCH 1/3 PM: Handle device registrations during suspend/resume
From: Rafael J. Wysocki <[email protected]>
Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong.
Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct.
Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.
Remove pm_sleep_rwsem which is not necessary any more.
Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.
--- Documentation/power/devices.txt | 5 +++ drivers/base/core.c | 6 +++- drivers/base/power/main.c | 57 ++++++++++++++++++---------------------- drivers/base/power/power.h | 23 ++-------------- include/linux/pm.h | 1 5 files changed, 40 insertions(+), 52 deletions(-)
include/linux/pm.h +1 -0
@@ -183,6 +183,7 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP unsigned should_wakeup:1 ;struct list_head entry;
drivers/base/power/main.c +26 -31
121 lines not on this page · raw message
drivers/base/power/power.h +3 -20
@@ -11,30 +11,13 @@ static inline struct device *to_device(s return container_of(entry, struct device, power.entry); } -extern void device_pm_add (struct device *); +extern int device_pm_add (struct device *);extern void device_pm_remove (struct device *); -extern int pm_sleep_lock (void ); -extern void pm_sleep_unlock (void );#else /* CONFIG_PM_SLEEP */ - -static inline void device_pm_add (struct device *dev) -{ -} - -static inline void device_pm_remove (struct device *dev) -{ -} - -static inline int pm_sleep_lock (void ) -{ -return 0 ; -} - -static inline void pm_sleep_unlock (void ) -{ -} +static inline int device_pm_add (struct device *dev) {return 0 ; } +static inline void device_pm_remove (struct device *dev) {}#endif
drivers/base/core.c +5 -1
@@ -815,7 +815,11 @@ int device_add(struct device *dev) error =dpm_sysfs_add (dev);if (error) goto PMError; -device_pm_add (dev); + error =device_pm_add (dev); +if (error) { +dpm_sysfs_remove (dev); + goto PMError; + } error =bus_add_device (dev);if (error) goto BusError;
Documentation/power/devices.txt +5 -0
@@ -196,6 +196,11 @@ its parent; and can't be removed or susp The policy is that the device tree should match hardware bus topology. (Or at least the control bus, for devices which use multiple busses.) +In particular, this means that a device registration may fail if the parent of +the device is suspending (ie. has been chosen by the PM core as the next +device to suspend) or has already suspended, as well as after all of the other +devices have been suspended. Device drivers must be prepared to cope with such +situations. Suspending Devices
PATCH 1/3 PM: Handle device registrations during suspend/resume
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong.
Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct.
Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.
Remove pm_sleep_rwsem which is not necessary any more.
Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.
--- Documentation/power/devices.txt | 5 +++ drivers/base/core.c | 6 +++- drivers/base/power/main.c | 57 ++++++++++++++++++---------------------- drivers/base/power/power.h | 23 ++-------------- include/linux/pm.h | 1 5 files changed, 40 insertions(+), 52 deletions(-)
include/linux/pm.h +1 -0
@@ -183,6 +183,7 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP unsigned should_wakeup:1 ;struct list_head entry;
drivers/base/power/main.c +26 -31
121 lines not on this page · raw message
drivers/base/power/power.h +3 -20
@@ -11,30 +11,13 @@ static inline struct device *to_device(s return container_of(entry, struct device, power.entry); } -extern void device_pm_add (struct device *); +extern int device_pm_add (struct device *);extern void device_pm_remove (struct device *); -extern int pm_sleep_lock (void ); -extern void pm_sleep_unlock (void );#else /* CONFIG_PM_SLEEP */ - -static inline void device_pm_add (struct device *dev) -{ -} - -static inline void device_pm_remove (struct device *dev) -{ -} - -static inline int pm_sleep_lock (void ) -{ -return 0 ; -} - -static inline void pm_sleep_unlock (void ) -{ -} +static inline int device_pm_add (struct device *dev) {return 0 ; } +static inline void device_pm_remove (struct device *dev) {}#endif
drivers/base/core.c +5 -1
@@ -815,7 +815,11 @@ int device_add(struct device *dev) error =dpm_sysfs_add (dev);if (error) goto PMError; -device_pm_add (dev); + error =device_pm_add (dev); +if (error) { +dpm_sysfs_remove (dev); + goto PMError; + } error =bus_add_device (dev);if (error) goto BusError;
Documentation/power/devices.txt +5 -0
@@ -196,6 +196,11 @@ its parent; and can't be removed or susp The policy is that the device tree should match hardware bus topology. (Or at least the control bus, for devices which use multiple busses.) +In particular, this means that a device registration may fail if the parent of +the device is suspending (ie. has been chosen by the PM core as the next +device to suspend) or has already suspended, as well as after all of the other +devices have been suspended. Device drivers must be prepared to cope with such +situations. Suspending Devices
Re: [PATCH 1/3] PM: Handle device registrations during suspend/resume
Quoted 20 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Modify the PM core to protect its data structures, specifically the
dpm_activelist, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added todpm_activeafter its parent, the PM core will attempt to suspend it after the parent, which is wrong.Introduce a new member of struct
dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added todpm_activehas been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices ondpm_activeis correct.Introduce variable '
all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.
Quoted 6 lines
Remove
pm_sleep_rwsemwhich is not necessary any more.Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.
Signed-off-by Rafael J. Wysocki <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[email protected]
Appliedpatch pm-handle-device-registrations-during-suspend-resume.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: PM: Handle device registrations during suspend/resume
to my gregkh-2.6 tree. Its filename is
pm-handle-device-registrations-during-suspend-resume.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:44:50 2008
From: "Rafael J. Wysocki" <[email protected]>
Date: Wed, 12 Mar 2008 00:57:22 +0100
Subject: PM: Handle device registrations during suspend/resume
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Rafael J. Wysocki <[email protected]>
Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong.
Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct.
Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.
Remove pm_sleep_rwsem which is not necessary any more.
Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.
--- Documentation/power/devices.txt | 5 +++ drivers/base/core.c | 6 +++- drivers/base/power/main.c | 57 ++++++++++++++++++---------------------- drivers/base/power/power.h | 23 ++-------------- include/linux/pm.h | 1 5 files changed, 40 insertions(+), 52 deletions(-)
Documentation/power/devices.txt +5 -0
@@ -196,6 +196,11 @@ its parent; and can't be removed or susp The policy is that the device tree should match hardware bus topology. (Or at least the control bus, for devices which use multiple busses.) +In particular, this means that a device registration may fail if the parent of +the device is suspending (ie. has been chosen by the PM core as the next +device to suspend) or has already suspended, as well as after all of the other +devices have been suspended. Device drivers must be prepared to cope with such +situations. Suspending Devices
drivers/base/core.c +5 -1
@@ -821,7 +821,11 @@ int device_add(struct device *dev) error =dpm_sysfs_add (dev);if (error) goto PMError; -device_pm_add (dev); + error =device_pm_add (dev); +if (error) { +dpm_sysfs_remove (dev); + goto PMError; + } error =bus_add_device (dev);if (error) goto BusError;
drivers/base/power/main.c +26 -31
121 lines not on this page · raw message
drivers/base/power/power.h +3 -20
@@ -11,30 +11,13 @@ static inline struct device *to_device(s return container_of(entry, struct device, power.entry); } -extern void device_pm_add (struct device *); +extern int device_pm_add (struct device *);extern void device_pm_remove (struct device *); -extern int pm_sleep_lock (void ); -extern void pm_sleep_unlock (void );#else /* CONFIG_PM_SLEEP */ - -static inline void device_pm_add (struct device *dev) -{ -} - -static inline void device_pm_remove (struct device *dev) -{ -} - -static inline int pm_sleep_lock (void ) -{ -return 0 ; -} - -static inline void pm_sleep_unlock (void ) -{ -} +static inline int device_pm_add (struct device *dev) {return 0 ; } +static inline void device_pm_remove (struct device *dev) {}#endif
include/linux/pm.h +1 -0
@@ -183,6 +183,7 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP unsigned should_wakeup:1 ;struct list_head entry;
Patches currently in gregkh-2.6 which might be from [email protected] are
driver-core/power_state-remove-it-from-driver-core.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
[email protected]
Appliedpatch pm-handle-device-registrations-during-suspend-resume.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: PM: Handle device registrations during suspend/resume
to my gregkh-2.6 tree. Its filename is
pm-handle-device-registrations-during-suspend-resume.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:44:50 2008
From: "Rafael J. Wysocki" <[email protected]>
Date: Wed, 12 Mar 2008 00:57:22 +0100
Subject: PM: Handle device registrations during suspend/resume
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Rafael J. Wysocki <[email protected]>
Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong.
Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct.
Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state.
Remove pm_sleep_rwsem which is not necessary any more.
Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch.
--- Documentation/power/devices.txt | 5 +++ drivers/base/core.c | 6 +++- drivers/base/power/main.c | 57 ++++++++++++++++++---------------------- drivers/base/power/power.h | 23 ++-------------- include/linux/pm.h | 1 5 files changed, 40 insertions(+), 52 deletions(-)
Documentation/power/devices.txt +5 -0
@@ -196,6 +196,11 @@ its parent; and can't be removed or susp The policy is that the device tree should match hardware bus topology. (Or at least the control bus, for devices which use multiple busses.) +In particular, this means that a device registration may fail if the parent of +the device is suspending (ie. has been chosen by the PM core as the next +device to suspend) or has already suspended, as well as after all of the other +devices have been suspended. Device drivers must be prepared to cope with such +situations. Suspending Devices
drivers/base/core.c +5 -1
@@ -821,7 +821,11 @@ int device_add(struct device *dev) error =dpm_sysfs_add (dev);if (error) goto PMError; -device_pm_add (dev); + error =device_pm_add (dev); +if (error) { +dpm_sysfs_remove (dev); + goto PMError; + } error =bus_add_device (dev);if (error) goto BusError;
drivers/base/power/main.c +26 -31
121 lines not on this page · raw message
drivers/base/power/power.h +3 -20
@@ -11,30 +11,13 @@ static inline struct device *to_device(s return container_of(entry, struct device, power.entry); } -extern void device_pm_add (struct device *); +extern int device_pm_add (struct device *);extern void device_pm_remove (struct device *); -extern int pm_sleep_lock (void ); -extern void pm_sleep_unlock (void );#else /* CONFIG_PM_SLEEP */ - -static inline void device_pm_add (struct device *dev) -{ -} - -static inline void device_pm_remove (struct device *dev) -{ -} - -static inline int pm_sleep_lock (void ) -{ -return 0 ; -} - -static inline void pm_sleep_unlock (void ) -{ -} +static inline int device_pm_add (struct device *dev) {return 0 ; } +static inline void device_pm_remove (struct device *dev) {}#endif
include/linux/pm.h +1 -0
@@ -183,6 +183,7 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP unsigned should_wakeup:1 ;struct list_head entry;
Patches currently in gregkh-2.6 which might be from [email protected] are
driver-core/power_state-remove-it-from-driver-core.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
PATCH 2/3 Driver core: Call device_pm_add() after bus_add_device() in device_add()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.
--- drivers/base/core.c | 15 +++++---------- drivers/base/power/main.c | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/base/core.c +5 -10
@@ -812,17 +812,12 @@ int device_add(struct device *dev) error =device_add_attrs (dev);if (error) goto AttrsError; - error =dpm_sysfs_add (dev); -if (error) - goto PMError; - error =device_pm_add (dev); -if (error) { -dpm_sysfs_remove (dev); - goto PMError; - } error =bus_add_device (dev);if (error) goto BusError; + error =device_pm_add (dev); +if (error) + goto PMError;kobject_uevent (&dev->kobj,KOBJ_ADD );bus_attach_device (dev);if (parent)
@@ -842,9 +837,9 @@ int device_add(struct device *dev) Done:put_device (dev);return error; - BusError: -device_pm_remove (dev); PMError: +bus_remove_device (dev); + BusError:if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);
drivers/base/power/main.c +3 -1
@@ -81,7 +81,9 @@ int device_pm_add(struct device *dev)WARN_ON (true); error = -EBUSY ; }else { -list_add_tail (&dev->power.entry, &dpm_active); + error =dpm_sysfs_add (dev); +if (!error) +list_add_tail (&dev->power.entry, &dpm_active); }mutex_unlock (&dpm_list_mtx);return error;
PATCH 2/3 Driver core: Call device_pm_add() after bus_add_device() in device_add()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.
--- drivers/base/core.c | 15 +++++---------- drivers/base/power/main.c | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/base/core.c +5 -10
@@ -812,17 +812,12 @@ int device_add(struct device *dev) error =device_add_attrs (dev);if (error) goto AttrsError; - error =dpm_sysfs_add (dev); -if (error) - goto PMError; - error =device_pm_add (dev); -if (error) { -dpm_sysfs_remove (dev); - goto PMError; - } error =bus_add_device (dev);if (error) goto BusError; + error =device_pm_add (dev); +if (error) + goto PMError;kobject_uevent (&dev->kobj,KOBJ_ADD );bus_attach_device (dev);if (parent)
@@ -842,9 +837,9 @@ int device_add(struct device *dev) Done:put_device (dev);return error; - BusError: -device_pm_remove (dev); PMError: +bus_remove_device (dev); + BusError:if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);
drivers/base/power/main.c +3 -1
@@ -81,7 +81,9 @@ int device_pm_add(struct device *dev)WARN_ON (true); error = -EBUSY ; }else { -list_add_tail (&dev->power.entry, &dpm_active); + error =dpm_sysfs_add (dev); +if (!error) +list_add_tail (&dev->power.entry, &dpm_active); }mutex_unlock (&dpm_list_mtx);return error;
Re: [PATCH 2/3] Driver core: Call device_pm_add() after bus_add_device() in device_add()
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Include
dpm_sysfs_add()intodevice_pm_add(), in analogy withdevice_pm_remove(), and modifydevice_add()to call the latter afterbus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.Signed-off-by Rafael J. Wysocki <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 2/3] Driver core: Call device_pm_add() after bus_add_device() in device_add()
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Include
dpm_sysfs_add()intodevice_pm_add(), in analogy withdevice_pm_remove(), and modifydevice_add()to call the latter afterbus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.Signed-off-by Rafael J. Wysocki <[email protected]>
ACK.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[email protected]
Appliedpatch driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: Driver core: Call device_pm_add() after bus_add_device() in device_add()
to my gregkh-2.6 tree. Its filename is
driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:45:38 2008
From: "Rafael J. Wysocki" <[email protected]>
Date: Wed, 12 Mar 2008 00:59:38 +0100
Subject: Driver core: Call device_pm_add() after bus_add_device() in device_add()
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Rafael J. Wysocki <[email protected]>
Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.
--- drivers/base/core.c | 15 +++++---------- drivers/base/power/main.c | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/base/core.c +5 -10
@@ -818,17 +818,12 @@ int device_add(struct device *dev) error =device_add_attrs (dev);if (error) goto AttrsError; - error =dpm_sysfs_add (dev); -if (error) - goto PMError; - error =device_pm_add (dev); -if (error) { -dpm_sysfs_remove (dev); - goto PMError; - } error =bus_add_device (dev);if (error) goto BusError; + error =device_pm_add (dev); +if (error) + goto PMError;kobject_uevent (&dev->kobj,KOBJ_ADD );bus_attach_device (dev);if (parent)
@@ -848,9 +843,9 @@ int device_add(struct device *dev) Done:put_device (dev);return error; - BusError: -device_pm_remove (dev); PMError: +bus_remove_device (dev); + BusError:if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);
drivers/base/power/main.c +3 -1
@@ -81,7 +81,9 @@ int device_pm_add(struct device *dev)WARN_ON (true); error = -EBUSY ; }else { -list_add_tail (&dev->power.entry, &dpm_active); + error =dpm_sysfs_add (dev); +if (!error) +list_add_tail (&dev->power.entry, &dpm_active); }mutex_unlock (&dpm_list_mtx);return error;
Patches currently in gregkh-2.6 which might be from [email protected] are
driver-core/power_state-remove-it-from-driver-core.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
[email protected]
Appliedpatch driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: Driver core: Call device_pm_add() after bus_add_device() in device_add()
to my gregkh-2.6 tree. Its filename is
driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:45:38 2008
From: "Rafael J. Wysocki" <[email protected]>
Date: Wed, 12 Mar 2008 00:59:38 +0100
Subject: Driver core: Call device_pm_add() after bus_add_device() in device_add()
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Rafael J. Wysocki <[email protected]>
Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful.
--- drivers/base/core.c | 15 +++++---------- drivers/base/power/main.c | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/base/core.c +5 -10
@@ -818,17 +818,12 @@ int device_add(struct device *dev) error =device_add_attrs (dev);if (error) goto AttrsError; - error =dpm_sysfs_add (dev); -if (error) - goto PMError; - error =device_pm_add (dev); -if (error) { -dpm_sysfs_remove (dev); - goto PMError; - } error =bus_add_device (dev);if (error) goto BusError; + error =device_pm_add (dev); +if (error) + goto PMError;kobject_uevent (&dev->kobj,KOBJ_ADD );bus_attach_device (dev);if (parent)
@@ -848,9 +843,9 @@ int device_add(struct device *dev) Done:put_device (dev);return error; - BusError: -device_pm_remove (dev); PMError: +bus_remove_device (dev); + BusError:if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);
drivers/base/power/main.c +3 -1
@@ -81,7 +81,9 @@ int device_pm_add(struct device *dev)WARN_ON (true); error = -EBUSY ; }else { -list_add_tail (&dev->power.entry, &dpm_active); + error =dpm_sysfs_add (dev); +if (!error) +list_add_tail (&dev->power.entry, &dpm_active); }mutex_unlock (&dpm_list_mtx);return error;
Patches currently in gregkh-2.6 which might be from [email protected] are
driver-core/power_state-remove-it-from-driver-core.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
PATCH 3/3 PM: make wakeup flags available whenever CONFIG_PM is set
In reply to Rafael J. WysockiFrom: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct dev_pm_info should be available whenever CONFIG_PM is enabled, not just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
[rjw: rebased the patch on top of the previous two.]
--- drivers/base/power/main.c | 2 - drivers/base/power/sysfs.c | 2 + include/linux/pm.h | 64 +++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-)
include/linux/pm.h +36 -28
@@ -183,9 +183,9 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +unsigned should_wakeup:1 ;bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP -unsigned should_wakeup:1 ;struct list_head entry;#endif };
@@ -198,11 +198,6 @@ extern void device_resume(void);extern int device_suspend (pm_message_t state);extern int device_prepare_suspend (pm_message_t state); -#define device_set_wakeup_enable (dev,val) \ - ((dev)->power.should_wakeup = !!(val)) -#define device_may_wakeup (dev) \ - (device_can_wakeup(dev) && (dev)->power.should_wakeup) -extern void __suspend_report_result (const char *function,void *fn,int ret);#define suspend_report_result (fn, ret) \
@@ -210,6 +205,35 @@ extern void __suspend_report_result(cons__suspend_report_result (__FUNCTION__, fn, ret); \ } while (0) +#else /* !CONFIG_PM_SLEEP */ + +static inline int device_suspend (pm_message_t state) +{ +return 0 ; +} + +#define suspend_report_result (fn, ret) do {} while (0) + +#endif /* !CONFIG_PM_SLEEP */ + +#ifdef CONFIG_PM + +/* changes to device_may_wakeup take effect on the next pm state change. +* by default, devices should wakeup if they can. +*/ +#define device_can_wakeup (dev) \ + ((dev)->power.can_wakeup) +#define device_init_wakeup (dev,val) \ + do { \ + device_can_wakeup(dev) = !!(val); \ + device_set_wakeup_enable(dev,val); \ + } while(0) + +#define device_set_wakeup_enable (dev,val) \ + ((dev)->power.should_wakeup = !!(val)) +#define device_may_wakeup (dev) \ + (device_can_wakeup(dev) && (dev)->power.should_wakeup) +/* * Platform hook to activate device wakeup capability, if that's not already * handled by enable_irq_wake() etc.
@@ -224,35 +248,19 @@ static inline int call_platform_enable_w return 0; } -#else /* !CONFIG_PM_SLEEP */ - -static inline int device_suspend (pm_message_t state) -{ -return 0 ; -} - -#define device_set_wakeup_enable (dev,val) do{}while(0) -#define device_may_wakeup (dev) (0) +#else /* !CONFIG_PM */ -#define suspend_report_result (fn, ret) do { } while (0) +#define device_can_wakeup (dev) 0 +#define device_init_wakeup (dev,val) do {} while (0) +#define device_set_wakeup_enable (dev,val) do {} while (0) +#define device_may_wakeup (dev) 0static inline int call_platform_enable_wakeup (struct device *dev,int is_on) {return 0 ; } -#endif /* !CONFIG_PM_SLEEP */ - -/* changes to device_may_wakeup take effect on the next pm state change. -* by default, devices should wakeup if they can. -*/ -#define device_can_wakeup (dev) \ - ((dev)->power.can_wakeup) -#define device_init_wakeup (dev,val) \ - do { \ - device_can_wakeup(dev) = !!(val); \ - device_set_wakeup_enable(dev,val); \ - } while(0) +#endif /* !CONFIG_PM */ /* * Global Power Management flags
drivers/base/power/main.c +0 -2
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);/* 'true' if all devices have been suspended, protected by dpm_list_mtx */ static bool all_sleeping; -int (*platform_enable_wakeup)(struct device *dev,int is_on); -/** * device_pm_add - add a device to the list of active devices * @dev: Device to be added to the list
drivers/base/power/sysfs.c +2 -0
@@ -6,6 +6,8 @@#include <linux/string.h> #include "power.h" +int (*platform_enable_wakeup)(struct device *dev,int is_on); +/* * wakeup - Report/change current wakeup option for device
PATCH 3/3 PM: make wakeup flags available whenever CONFIG_PM is set
In reply to Rafael J. WysockiFrom: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct dev_pm_info should be available whenever CONFIG_PM is enabled, not just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
[rjw: rebased the patch on top of the previous two.]
--- drivers/base/power/main.c | 2 - drivers/base/power/sysfs.c | 2 + include/linux/pm.h | 64 +++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-)
include/linux/pm.h +36 -28
@@ -183,9 +183,9 @@ typedef struct pm_message {struct dev_pm_info {pm_message_t power_state;unsigned can_wakeup:1 ; +unsigned should_wakeup:1 ;bool sleeping:1 ;/* Owned by the PM core */ #ifdef CONFIG_PM_SLEEP -unsigned should_wakeup:1 ;struct list_head entry;#endif };
@@ -198,11 +198,6 @@ extern void device_resume(void);extern int device_suspend (pm_message_t state);extern int device_prepare_suspend (pm_message_t state); -#define device_set_wakeup_enable (dev,val) \ - ((dev)->power.should_wakeup = !!(val)) -#define device_may_wakeup (dev) \ - (device_can_wakeup(dev) && (dev)->power.should_wakeup) -extern void __suspend_report_result (const char *function,void *fn,int ret);#define suspend_report_result (fn, ret) \
@@ -210,6 +205,35 @@ extern void __suspend_report_result(cons__suspend_report_result (__FUNCTION__, fn, ret); \ } while (0) +#else /* !CONFIG_PM_SLEEP */ + +static inline int device_suspend (pm_message_t state) +{ +return 0 ; +} + +#define suspend_report_result (fn, ret) do {} while (0) + +#endif /* !CONFIG_PM_SLEEP */ + +#ifdef CONFIG_PM + +/* changes to device_may_wakeup take effect on the next pm state change. +* by default, devices should wakeup if they can. +*/ +#define device_can_wakeup (dev) \ + ((dev)->power.can_wakeup) +#define device_init_wakeup (dev,val) \ + do { \ + device_can_wakeup(dev) = !!(val); \ + device_set_wakeup_enable(dev,val); \ + } while(0) + +#define device_set_wakeup_enable (dev,val) \ + ((dev)->power.should_wakeup = !!(val)) +#define device_may_wakeup (dev) \ + (device_can_wakeup(dev) && (dev)->power.should_wakeup) +/* * Platform hook to activate device wakeup capability, if that's not already * handled by enable_irq_wake() etc.
@@ -224,35 +248,19 @@ static inline int call_platform_enable_w return 0; } -#else /* !CONFIG_PM_SLEEP */ - -static inline int device_suspend (pm_message_t state) -{ -return 0 ; -} - -#define device_set_wakeup_enable (dev,val) do{}while(0) -#define device_may_wakeup (dev) (0) +#else /* !CONFIG_PM */ -#define suspend_report_result (fn, ret) do { } while (0) +#define device_can_wakeup (dev) 0 +#define device_init_wakeup (dev,val) do {} while (0) +#define device_set_wakeup_enable (dev,val) do {} while (0) +#define device_may_wakeup (dev) 0static inline int call_platform_enable_wakeup (struct device *dev,int is_on) {return 0 ; } -#endif /* !CONFIG_PM_SLEEP */ - -/* changes to device_may_wakeup take effect on the next pm state change. -* by default, devices should wakeup if they can. -*/ -#define device_can_wakeup (dev) \ - ((dev)->power.can_wakeup) -#define device_init_wakeup (dev,val) \ - do { \ - device_can_wakeup(dev) = !!(val); \ - device_set_wakeup_enable(dev,val); \ - } while(0) +#endif /* !CONFIG_PM */ /* * Global Power Management flags
drivers/base/power/main.c +0 -2
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);/* 'true' if all devices have been suspended, protected by dpm_list_mtx */ static bool all_sleeping; -int (*platform_enable_wakeup)(struct device *dev,int is_on); -/** * device_pm_add - add a device to the list of active devices * @dev: Device to be added to the list
drivers/base/power/sysfs.c +2 -0
@@ -6,6 +6,8 @@#include <linux/string.h> #include "power.h" +int (*platform_enable_wakeup)(struct device *dev,int is_on); +/* * wakeup - Report/change current wakeup option for device
Re: [PATCH 3/3] PM: make wakeup flags available whenever CONFIG_PM is set
Quoted 8 lines · Rafael J. Wysocki
From: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct
dev_pm_infoshould be available wheneverCONFIG_PMis enabled, not just whenCONFIG_PM_SLEEPis on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
Quoted 5 lines
[rjw: rebased the patch on top of the previous two.]
Signed-off-by Alan Stern <[email protected]>CC David Brownell <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
ACK. But I wonder if we should reduce ammount of config options we have in power management. All those combinations are hard to test...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH 3/3] PM: make wakeup flags available whenever CONFIG_PM is set
In reply to Rafael J. WysockiQuoted 8 lines · Rafael J. Wysocki
From: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct
dev_pm_infoshould be available wheneverCONFIG_PMis enabled, not just whenCONFIG_PM_SLEEPis on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
Quoted 5 lines
[rjw: rebased the patch on top of the previous two.]
Signed-off-by Alan Stern <[email protected]>CC David Brownell <[email protected]>Signed-off-by Rafael J. Wysocki <[email protected]>
ACK. But I wonder if we should reduce ammount of config options we have in power management. All those combinations are hard to test...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[email protected]
Appliedpatch pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: PM: make wakeup flags available whenever CONFIG_PM is set
to my gregkh-2.6 tree. Its filename is
pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:46:04 2008
From: Alan Stern <[email protected]>
Date: Wed, 12 Mar 2008 01:01:47 +0100
Subject: PM: make wakeup flags available whenever CONFIG_PM is set
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct dev_pm_info should be available whenever CONFIG_PM is enabled, not just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
[rjw: rebased the patch on top of the previous two.]
--- drivers/base/power/main.c | 2 - drivers/base/power/sysfs.c | 2 + include/linux/pm.h | 64 +++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-)
drivers/base/power/main.c +0 -2
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);/* 'true' if all devices have been suspended, protected by dpm_list_mtx */ static bool all_sleeping; -int (*platform_enable_wakeup)(struct device *dev,int is_on); -/** * device_pm_add - add a device to the list of active devices * @dev: Device to be added to the list
drivers/base/power/sysfs.c +2 -0
@@ -6,6 +6,8 @@#include <linux/string.h> #include "power.h" +int (*platform_enable_wakeup)(struct device *dev,int is_on); +/* * wakeup - Report/change current wakeup option for device
include/linux/pm.h +36 -28
97 lines not on this page · raw message
Patches currently in gregkh-2.6 which might be from [email protected] are
usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch usb/usb-make-usb_storage_onetouch-available-with-pm.patch usb/usb-usb-ohci-sm501-driver-use-the-conventional-convention-for-suspend-and-resume.patch usb/usb-reorganize-code-in-hub.c.patch usb/usb-ehci-carry-out-port-handover-during-each-root-hub-resume.patch usb/usb-new-quirk-flag-to-avoid-set-interface.patch usb/drivers-usb-core-devio.c-suppress-warning-with-64k-page_size.patch usb/usb-make-usb-persist-work-after-every-system-sleep.patch usb/usb-remove-config_usb_persist-setting.patch usb/usb-check-serial-number-string-after-device-reset.patch usb/usb-enable-usb-persist-by-default.patch usb/usb-remove-dev-power.power_state.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch
[email protected]
Appliedpatch pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch added to gregkh-2.6 tree
In reply to Rafael J. WysockiThis is a note to let you know that I've just added the patch titled
Subject: PM: make wakeup flags available whenever CONFIG_PM is set
to my gregkh-2.6 tree. Its filename is
pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From [email protected] Thu Mar 13 13:46:04 2008
From: Alan Stern <[email protected]>
Date: Wed, 12 Mar 2008 01:01:47 +0100
Subject: PM: make wakeup flags available whenever CONFIG_PM is set
To: Greg KH <[email protected]>
Cc: Alan Stern <[email protected]>, Andrew Morton <[email protected]>, David Brownell <[email protected]>, LKML <[email protected]>, Pavel Machek <[email protected]>, pm list <[email protected]>
Message-ID: <[email protected]>
Content-Disposition: inline
From: Alan Stern <[email protected]>
The various wakeup flags and their accessor macros in struct dev_pm_info should be available whenever CONFIG_PM is enabled, not just when CONFIG_PM_SLEEP is on. Otherwise remote wakeup won't always be configurable for runtime power management. This patch (as1056) fixes the oversight.
[rjw: rebased the patch on top of the previous two.]
--- drivers/base/power/main.c | 2 - drivers/base/power/sysfs.c | 2 + include/linux/pm.h | 64 +++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-)
drivers/base/power/main.c +0 -2
@@ -57,8 +57,6 @@ static DEFINE_MUTEX(dpm_list_mtx);/* 'true' if all devices have been suspended, protected by dpm_list_mtx */ static bool all_sleeping; -int (*platform_enable_wakeup)(struct device *dev,int is_on); -/** * device_pm_add - add a device to the list of active devices * @dev: Device to be added to the list
drivers/base/power/sysfs.c +2 -0
@@ -6,6 +6,8 @@#include <linux/string.h> #include "power.h" +int (*platform_enable_wakeup)(struct device *dev,int is_on); +/* * wakeup - Report/change current wakeup option for device
include/linux/pm.h +36 -28
97 lines not on this page · raw message
Patches currently in gregkh-2.6 which might be from [email protected] are
usb/usb-convert-usb.h-struct-usb_device-to-kernel-doc.patch usb/usb-make-usb_storage_onetouch-available-with-pm.patch usb/usb-usb-ohci-sm501-driver-use-the-conventional-convention-for-suspend-and-resume.patch usb/usb-reorganize-code-in-hub.c.patch usb/usb-ehci-carry-out-port-handover-during-each-root-hub-resume.patch usb/usb-new-quirk-flag-to-avoid-set-interface.patch usb/drivers-usb-core-devio.c-suppress-warning-with-64k-page_size.patch usb/usb-make-usb-persist-work-after-every-system-sleep.patch usb/usb-remove-config_usb_persist-setting.patch usb/usb-check-serial-number-string-after-device-reset.patch usb/usb-enable-usb-persist-by-default.patch usb/usb-remove-dev-power.power_state.patch driver-core/pm-handle-device-registrations-during-suspend-resume.patch driver-core/pm-make-wakeup-flags-available-whenever-config_pm-is-set.patch driver-core/driver-core-call-device_pm_add-after-bus_add_device-in-device_add.patch