Skip to content

Commit b06c0b2

Browse files
committed
Revert "PM / runtime: Fixup reference counting of device link suppliers at probe"
Revert commit 1e83786 (PM / runtime: Fixup reference counting of device link suppliers at probe), as it has introduced a regression and the condition it was designed to address should be covered by the existing code. Reported-by: Marek Szyprowski <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2d5ed61 commit b06c0b2

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

drivers/base/dd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
580580
pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
581581
drv->bus->name, __func__, dev_name(dev), drv->name);
582582

583-
pm_runtime_resume_suppliers(dev);
583+
pm_runtime_get_suppliers(dev);
584584
if (dev->parent)
585585
pm_runtime_get_sync(dev->parent);
586586

@@ -591,6 +591,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
591591
if (dev->parent)
592592
pm_runtime_put(dev->parent);
593593

594+
pm_runtime_put_suppliers(dev);
594595
return ret;
595596
}
596597

drivers/base/power/runtime.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,16 +1563,37 @@ void pm_runtime_clean_up_links(struct device *dev)
15631563
}
15641564

15651565
/**
1566-
* pm_runtime_resume_suppliers - Resume supplier devices.
1566+
* pm_runtime_get_suppliers - Resume and reference-count supplier devices.
15671567
* @dev: Consumer device.
15681568
*/
1569-
void pm_runtime_resume_suppliers(struct device *dev)
1569+
void pm_runtime_get_suppliers(struct device *dev)
15701570
{
1571+
struct device_link *link;
15711572
int idx;
15721573

15731574
idx = device_links_read_lock();
15741575

1575-
rpm_get_suppliers(dev);
1576+
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
1577+
if (link->flags & DL_FLAG_PM_RUNTIME)
1578+
pm_runtime_get_sync(link->supplier);
1579+
1580+
device_links_read_unlock(idx);
1581+
}
1582+
1583+
/**
1584+
* pm_runtime_put_suppliers - Drop references to supplier devices.
1585+
* @dev: Consumer device.
1586+
*/
1587+
void pm_runtime_put_suppliers(struct device *dev)
1588+
{
1589+
struct device_link *link;
1590+
int idx;
1591+
1592+
idx = device_links_read_lock();
1593+
1594+
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
1595+
if (link->flags & DL_FLAG_PM_RUNTIME)
1596+
pm_runtime_put(link->supplier);
15761597

15771598
device_links_read_unlock(idx);
15781599
}

include/linux/pm_runtime.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ extern void pm_runtime_update_max_time_suspended(struct device *dev,
5656
s64 delta_ns);
5757
extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
5858
extern void pm_runtime_clean_up_links(struct device *dev);
59-
extern void pm_runtime_resume_suppliers(struct device *dev);
59+
extern void pm_runtime_get_suppliers(struct device *dev);
60+
extern void pm_runtime_put_suppliers(struct device *dev);
6061
extern void pm_runtime_new_link(struct device *dev);
6162
extern void pm_runtime_drop_link(struct device *dev);
6263

@@ -172,7 +173,8 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
172173
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
173174
bool enable){}
174175
static inline void pm_runtime_clean_up_links(struct device *dev) {}
175-
static inline void pm_runtime_resume_suppliers(struct device *dev) {}
176+
static inline void pm_runtime_get_suppliers(struct device *dev) {}
177+
static inline void pm_runtime_put_suppliers(struct device *dev) {}
176178
static inline void pm_runtime_new_link(struct device *dev) {}
177179
static inline void pm_runtime_drop_link(struct device *dev) {}
178180

0 commit comments

Comments
 (0)