PM / core: move device and its children to end of dpm list
Subsystems (2)
PATCH 1/1 PM / core: move device and its children to end of dpm list
When bridge and its endpoint is enumated the devices are added to the dpm list. Afterward, the bridge defers probe when IOMMU is not ready. This causes the bridge to be moved to the end of the dpm list when deferred probe kicks in. The order of the dpm list for bridge and endpoint is reversed.
Add reordering code to re-position the bridge and its children so the order for suspend and resume is not altered.
--- drivers/base/core.c | 20 ++++++++++++++++++++ drivers/base/dd.c | 8 ++++---- include/linux/device.h | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-)
drivers/base/core.c +20 -0
@@ -148,6 +148,26 @@ static int device_reorder_to_tail(struct device *dev, void *not_used) }/** +* device_pm_reorder - reorder device and its children to end of dpm list +* @dev: current device pointer +* +* This is a lock held version of reordering the device to dpm list tail. +* This will move the device to the end of the dpm list if it not registered. +* Afterward, it will iterate through its children and do the same for them. +*/ +void device_pm_reorder (struct device *dev) +{ +int idx; + + idx =device_links_read_lock (); +device_pm_lock (); +device_reorder_to_tail (dev,NULL ); +device_pm_unlock (); +device_links_read_unlock (idx); +} +EXPORT_SYMBOL_GPL (device_pm_reorder); + +/** * device_link_add - Create a link between two devices. * @consumer: Consumer end of the link. * @supplier: Supplier end of the link.
drivers/base/dd.c +4 -4
@@ -121,11 +121,11 @@ static void deferred_probe_work_func(struct work_struct *work)* Force the device to the end of the dpm_list since * the PM code assumes that the order we add things to * the list is a good order for suspend but deferred -* probe makes that very unsafe. +* probe makes that very unsafe. Also move any children +* belong to the device to the end of the list as well. +* This way the suspend resume order won't be corrupted. */ -device_pm_lock (); -device_pm_move_last (dev); -device_pm_unlock (); +device_pm_reorder (dev);dev_dbg (dev,"Retrying from deferred list\n" );if (initcall_debug && !initcalls_done)
include/linux/device.h +3 -0
@@ -1272,6 +1272,9 @@ extern void devm_device_remove_group(struct device *dev,/* debugging and troubleshooting/diagnostic helpers. */ extern const char *dev_driver_string (const struct device *dev); +/* reorder device and its children to end of dpm list */ +void device_pm_reorder (struct device *dev); +/* Device links interface. */ struct device_link *device_link_add (struct device *consumer,struct device *supplier,u32 flags);
Signature · 1 line
1.8.3.1
PATCH 1/1 PM / core: move device and its children to end of dpm list
Quoted 17 lines · Feng Kan
When bridge and its endpoint is enumated the devices are added to the dpm list. Afterward, the bridge defers probe when IOMMU is not ready. This causes the bridge to be moved to the end of the dpm list when deferred probe kicks in. The order of the dpm list for bridge and endpoint is reversed.
Add reordering code to re-position the bridge and its children so the order for suspend and resume is not altered.
Signed-off-by Feng Kan <[email protected]>Signed-off-by Toan Le <[email protected]>include/linux/device.h +0
-0
include/linux/device.h extern void devm_device_remove_group(struct device *dev, · line 1276
Quoted 5 lines
include/linux/device.h +2
-0@@ -1272,6 +1272,9 @@ extern void devm_device_remove_group(struct device *dev,/* debugging and troubleshooting/diagnostic helpers. */ extern const char *dev_driver_string (const struct device *dev); +/* reorder device and its children to end of dpm list */ +void device_pm_reorder (struct device *dev);
Do you expect drivers to use this, or only the driver core in drivers/base/? There is a drivers/base/base.h; maybe this would fit there rather than being exposed to the rest of the kernel via include/linux/device.h?
Quoted 11 lines
include/linux/device.h +0
-0/* Device links interface. */ struct device_link *device_link_add (struct device *consumer,struct device *supplier,u32 flags);Signature · 7 lines
1.8.3.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Rafael J. Wysocki
maintainerPATCH 1/1 PM / core: move device and its children to end of dpm list
In reply to Feng KanQuoted 22 lines · Feng Kan
When bridge and its endpoint is enumated the devices are added to the dpm list. Afterward, the bridge defers probe when IOMMU is not ready. This causes the bridge to be moved to the end of the dpm list when deferred probe kicks in. The order of the dpm list for bridge and endpoint is reversed.
Add reordering code to re-position the bridge and its children so the order for suspend and resume is not altered.
Signed-off-by Feng Kan <[email protected]>Signed-off-by Toan Le <[email protected]>--- drivers/base/core.c | 20 ++++++++++++++++++++ drivers/base/dd.c | 8 ++++---- include/linux/device.h | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-)drivers/base/core.c +0
-0
drivers/base/core.c static int device_reorder_to_tail(struct device *dev, void *not_used) · line 151
Quoted 4 lines
drivers/base/core.c +1
-0@@ -148,6 +148,26 @@ static int device_reorder_to_tail(struct device *dev, void *not_used) }/** +* device_pm_reorder - reorder device and its children to end of dpm list
Not just the children and not just dpm_list.
drivers/base/core.c static int device_reorder_to_tail(struct device *dev, void *not_used) · line 156
Quoted 5 lines
drivers/base/core.c +5
-0+* @dev: current device pointer +* +* This is a lock held version of reordering the device to dpm list tail. +* This will move the device to the end of the dpm list if it not registered. +* Afterward, it will iterate through its children and do the same for them.
This isn't entirely accurate as device_reorder_to_tail() does more than that.
drivers/base/core.c static int device_reorder_to_tail(struct device *dev, void *not_used) · line 158
Quoted 2 lines
drivers/base/core.c +2
-0+*/ +void device_pm_reorder (struct device *dev)
I'd call it device_pm_move_to_tail() as that's what it does.
"Reorder" is sort of overly generic IMO.
drivers/base/core.c static int device_reorder_to_tail(struct device *dev, void *not_used) · line 168
Quoted 10 lines
drivers/base/core.c +10
-0+{ +int idx; + + idx =device_links_read_lock (); +device_pm_lock (); +device_reorder_to_tail (dev,NULL ); +device_pm_unlock (); +device_links_read_unlock (idx); +} +EXPORT_SYMBOL_GPL (device_pm_reorder);
It is not necessary to export this symbol.
Quoted 30 lines
drivers/base/core.c +2
-0+ +/** * device_link_add - Create a link between two devices. * @consumer: Consumer end of the link. * @supplier: Supplier end of the link. drivers/base/dd.c +4
-4@@ -121,11 +121,11 @@ static void deferred_probe_work_func(struct work_struct *work)* Force the device to the end of the dpm_list since * the PM code assumes that the order we add things to * the list is a good order for suspend but deferred -* probe makes that very unsafe. +* probe makes that very unsafe. Also move any children +* belong to the device to the end of the list as well. +* This way the suspend resume order won't be corrupted. */ -device_pm_lock (); -device_pm_move_last (dev); -device_pm_unlock (); +device_pm_reorder (dev);dev_dbg (dev,"Retrying from deferred list\n" );if (initcall_debug && !initcalls_done)include/linux/device.h +0
-0
include/linux/device.h extern void devm_device_remove_group(struct device *dev, · line 1276
Quoted 5 lines
include/linux/device.h +2
-0@@ -1272,6 +1272,9 @@ extern void devm_device_remove_group(struct device *dev,/* debugging and troubleshooting/diagnostic helpers. */ extern const char *dev_driver_string (const struct device *dev); +/* reorder device and its children to end of dpm list */ +void device_pm_reorder (struct device *dev);
And this header can go into drivers/base/base.h as Bjorn said.
Quoted 7 lines
include/linux/device.h +1
-1+/* Device links interface. */ struct device_link *device_link_add (struct device *consumer,struct device *supplier,u32 flags); --1.8.3.1