提交 caaba929 编写于 作者: Y Yang Yingliang 提交者: Xie XiuQi

device: add device_shutdown_one() helper

euler inclusion
category: bugfix
bugzilla: 5452
CVE: NA

This patchset is add a kernel parameter to avoid kdump
problem on Hi1620ES. It will be revert when we have better
solution on Hi1620CS.

[PATCH 1/4] Revert "iommu/arm-smmu-v3: Abort all transactions if SMMU is enabled in kdump kernel"
[PATCH 2/4] device: add device_shutdown_one() helper
[PATCH 3/4] device: add device_shutdown_by_driver() helper
[PATCH 4/4] kexec: add kexec_device_shutdown()

------------------------------------------------

Move the shutdown device code into a new function
device_shutdown_one().
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 2a189488
...@@ -2854,6 +2854,40 @@ int device_move(struct device *dev, struct device *new_parent, ...@@ -2854,6 +2854,40 @@ int device_move(struct device *dev, struct device *new_parent,
} }
EXPORT_SYMBOL_GPL(device_move); EXPORT_SYMBOL_GPL(device_move);
static void device_shutdown_one(struct device *dev, struct device *parent)
{
/* hold lock to avoid race with probe/release */
if (parent)
device_lock(parent);
device_lock(dev);
/* Don't allow any more runtime suspends */
pm_runtime_get_noresume(dev);
pm_runtime_barrier(dev);
if (dev->class && dev->class->shutdown_pre) {
if (initcall_debug)
dev_info(dev, "shutdown_pre\n");
dev->class->shutdown_pre(dev);
}
if (dev->bus && dev->bus->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->bus->shutdown(dev);
} else if (dev->driver && dev->driver->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->driver->shutdown(dev);
}
device_unlock(dev);
if (parent)
device_unlock(parent);
put_device(dev);
put_device(parent);
}
/** /**
* device_shutdown - call ->shutdown() on each device to shutdown. * device_shutdown - call ->shutdown() on each device to shutdown.
*/ */
...@@ -2888,36 +2922,7 @@ void device_shutdown(void) ...@@ -2888,36 +2922,7 @@ void device_shutdown(void)
list_del_init(&dev->kobj.entry); list_del_init(&dev->kobj.entry);
spin_unlock(&devices_kset->list_lock); spin_unlock(&devices_kset->list_lock);
/* hold lock to avoid race with probe/release */ device_shutdown_one(dev, parent);
if (parent)
device_lock(parent);
device_lock(dev);
/* Don't allow any more runtime suspends */
pm_runtime_get_noresume(dev);
pm_runtime_barrier(dev);
if (dev->class && dev->class->shutdown_pre) {
if (initcall_debug)
dev_info(dev, "shutdown_pre\n");
dev->class->shutdown_pre(dev);
}
if (dev->bus && dev->bus->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->bus->shutdown(dev);
} else if (dev->driver && dev->driver->shutdown) {
if (initcall_debug)
dev_info(dev, "shutdown\n");
dev->driver->shutdown(dev);
}
device_unlock(dev);
if (parent)
device_unlock(parent);
put_device(dev);
put_device(parent);
spin_lock(&devices_kset->list_lock); spin_lock(&devices_kset->list_lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册