Skip to content

Commit 5e66693

Browse files
Saravana Kannangregkh
authored andcommitted
of/platform: Pause/resume sync state during init and of_platform_populate()
When all the top level devices are populated from DT during kernel init, the supplier devices could be added and probed before the consumer devices are added and linked to the suppliers. To avoid the sync_state() callback from being called prematurely, pause the sync_state() callbacks before populating the devices and resume them at late_initcall_sync(). Similarly, when children devices are populated from a module using of_platform_populate(), there could be supplier-consumer dependencies between the children devices that are populated. To avoid the same problem with sync_state() being called prematurely, pause and resume sync_state() callbacks across of_platform_populate(). Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20190904211126.47518-6-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fc5a251 commit 5e66693

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎drivers/of/platform.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,16 @@ int of_platform_populate(struct device_node *root,
480480
pr_debug("%s()\n", __func__);
481481
pr_debug(" starting at: %pOF\n", root);
482482

483+
device_links_supplier_sync_state_pause();
483484
for_each_child_of_node(root, child) {
484485
rc = of_platform_bus_create(child, matches, lookup, parent, true);
485486
if (rc) {
486487
of_node_put(child);
487488
break;
488489
}
489490
}
491+
device_links_supplier_sync_state_resume();
492+
490493
of_node_set_flag(root, OF_POPULATED_BUS);
491494

492495
of_node_put(root);
@@ -518,6 +521,7 @@ static int __init of_platform_default_populate_init(void)
518521
if (!of_have_populated_dt())
519522
return -ENODEV;
520523

524+
device_links_supplier_sync_state_pause();
521525
/*
522526
* Handle certain compatibles explicitly, since we don't want to create
523527
* platform_devices for every node in /reserved-memory with a
@@ -538,6 +542,14 @@ static int __init of_platform_default_populate_init(void)
538542
return 0;
539543
}
540544
arch_initcall_sync(of_platform_default_populate_init);
545+
546+
static int __init of_platform_sync_state_init(void)
547+
{
548+
if (of_have_populated_dt())
549+
device_links_supplier_sync_state_resume();
550+
return 0;
551+
}
552+
late_initcall_sync(of_platform_sync_state_init);
541553
#endif
542554

543555
int of_platform_device_destroy(struct device *dev, void *data)

0 commit comments

Comments
 (0)