aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorLongX Zhang <longx.zhang@intel.com>2012-10-24 18:21:28 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-14 18:37:09 -0500
commit4b6d1f12f9c4e0e420d5747d3ae285d8f66d627f (patch)
tree35e42ef09ceb06f6b3973b12fbe6ba33129afc86 /drivers/base/core.c
parent8316bd72c0248adbb9572abf2dd045a95f682bcd (diff)
driver core / PM: move the calling to device_pm_remove behind the calling to bus_remove_device
We hit an hang issue when removing a mmc device on Medfield Android phone by sysfs interface. device_pm_remove will call pm_runtime_remove which would disable runtime PM of the device. After that pm_runtime_get* or pm_runtime_put* will be ignored. So if we disable the runtime PM before device really be removed, drivers' _remove callback may access HW even pm_runtime_get* fails. That is bad. Consider below call sequence when removing a device: device_del => device_pm_remove => class_intf->remove_dev(dev, class_intf) => pm_runtime_get_sync/put_sync => bus_remove_device => device_release_driver => pm_runtime_get_sync/put_sync remove_dev might call pm_runtime_get_sync/put_sync. Then, generic device_release_driver also calls pm_runtime_get_sync/put_sync. Since device_del => device_pm_remove firstly, later _get_sync wouldn't really wake up the device. I git log -p to find the patch which moves the calling to device_pm_remove ahead. It's below patch: commit 775b64d2b6ca37697de925f70799c710aab5849a Author: Rafael J. Wysocki <rjw@sisk.pl> Date: Sat Jan 12 20:40:46 2008 +0100 PM: Acquire device locks on suspend This patch reorganizes the way suspend and resume notifications are sent to drivers. The major changes are that now the PM core acquires every device semaphore before calling the methods, and calls to device_add() during suspends will fail, while calls to device_del() during suspends will block. It also provides a way to safely remove a suspended device with the help of the PM core, by using the device_pm_schedule_removal() callback introduced specifically for this purpose, and updates two drivers (msr and cpuid) that need to use it. As device_pm_schedule_removal is deleted by another patch, we need also revert other parts of the patch, i.e. move the calling of device_pm_remove after the calling to bus_remove_device. Signed-off-by: LongX Zhang <longx.zhang@intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index abea76c36a4b..150a41580fad 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1180,7 +1180,6 @@ void device_del(struct device *dev)
1180 if (dev->bus) 1180 if (dev->bus)
1181 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 1181 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
1182 BUS_NOTIFY_DEL_DEVICE, dev); 1182 BUS_NOTIFY_DEL_DEVICE, dev);
1183 device_pm_remove(dev);
1184 dpm_sysfs_remove(dev); 1183 dpm_sysfs_remove(dev);
1185 if (parent) 1184 if (parent)
1186 klist_del(&dev->p->knode_parent); 1185 klist_del(&dev->p->knode_parent);
@@ -1205,6 +1204,7 @@ void device_del(struct device *dev)
1205 device_remove_file(dev, &uevent_attr); 1204 device_remove_file(dev, &uevent_attr);
1206 device_remove_attrs(dev); 1205 device_remove_attrs(dev);
1207 bus_remove_device(dev); 1206 bus_remove_device(dev);
1207 device_pm_remove(dev);
1208 driver_deferred_probe_del(dev); 1208 driver_deferred_probe_del(dev);
1209 1209
1210 /* Notify the platform of the removal, in case they 1210 /* Notify the platform of the removal, in case they