提交 cdc8a64a 编写于 作者: R Rafael J. Wysocki 提交者: Yang Yingliang

driver core: Do not call rpm_put_suppliers() in pm_runtime_drop_link()

stable inclusion
from linux-4.19.99
commit 02f6982774e25ae57bca56e0062e53c304ba30dc

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

[ Upstream commit a1fdbfbb ]

Calling rpm_put_suppliers() from pm_runtime_drop_link() is excessive
as it affects all suppliers of the consumer device and not just the
one pointed to by the device link being dropped.  Worst case it may
cause the consumer device to stop working unexpectedly.  Moreover, in
principle it is racy with respect to runtime PM of the consumer
device.

To avoid these problems drop runtime PM references on the particular
supplier pointed to by the link in question only and do that after
the link has been dropped from the consumer device's list of links to
suppliers, which is in device_link_free().

Fixes: a0504aec ("PM / runtime: Drop usage count for suppliers at device link removal")
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d5495331
...@@ -357,6 +357,9 @@ EXPORT_SYMBOL_GPL(device_link_add); ...@@ -357,6 +357,9 @@ EXPORT_SYMBOL_GPL(device_link_add);
static void device_link_free(struct device_link *link) static void device_link_free(struct device_link *link)
{ {
while (refcount_dec_not_one(&link->rpm_active))
pm_runtime_put(link->supplier);
put_device(link->consumer); put_device(link->consumer);
put_device(link->supplier); put_device(link->supplier);
kfree(link); kfree(link);
......
...@@ -1603,8 +1603,6 @@ void pm_runtime_new_link(struct device *dev) ...@@ -1603,8 +1603,6 @@ void pm_runtime_new_link(struct device *dev)
void pm_runtime_drop_link(struct device *dev) void pm_runtime_drop_link(struct device *dev)
{ {
rpm_put_suppliers(dev);
spin_lock_irq(&dev->power.lock); spin_lock_irq(&dev->power.lock);
WARN_ON(dev->power.links_count == 0); WARN_ON(dev->power.links_count == 0);
dev->power.links_count--; dev->power.links_count--;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册