History

Revert "driver core: Add support for linking devices during device addition"

This reverts commit 5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886. Based on a lot of email and in-person discussions, this patch series is being reworked to address a number of issues that were pointed out that needed to be taken care of before it should be merged. It will be resubmitted with those changes hopefully soon.

Greg Kroah-Hartman committed 7 years ago

Commit bfb39431 parent 33cbfe52 files · +0 −97Browse files

Unified · Split

2 files
  1. drivers/base/core.c +0 −83
  2. include/linux/device.h +0 −14
drivers/base/core.c+0−83
@@ -44,8 +44,6 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup); · 43 unmodified lines
4444 #endif
4545
4646 /* Device links support. */
47−static LIST_HEAD(wait_for_suppliers);
48−static DEFINE_MUTEX(wfs_lock);
4947
5048 #ifdef CONFIG_SRCU
5149 static DEFINE_MUTEX(device_links_lock);
@@ -420,51 +418,6 @@ struct device_link *device_link_add(struct device *consumer, · 368 unmodified lines
420418 }
421419 EXPORT_SYMBOL_GPL(device_link_add);
422420
423−/**
424− * device_link_wait_for_supplier - Mark device as waiting for supplier
425− * @consumer: Consumer device
426− *
427− * Marks the consumer device as waiting for suppliers to become available. The
428− * consumer device will never be probed until it's unmarked as waiting for
429− * suppliers. The caller is responsible for adding the link to the supplier
430− * once the supplier device is present.
431− *
432− * This function is NOT meant to be called from the probe function of the
433− * consumer but rather from code that creates/adds the consumer device.
434− */
435−static void device_link_wait_for_supplier(struct device *consumer)
436−{
437− mutex_lock(&wfs_lock);
438− list_add_tail(&consumer->links.needs_suppliers, &wait_for_suppliers);
439− mutex_unlock(&wfs_lock);
440−}
441−
442−/**
443− * device_link_check_waiting_consumers - Try to unmark waiting consumers
444− *
445− * Loops through all consumers waiting on suppliers and tries to add all their
446− * supplier links. If that succeeds, the consumer device is unmarked as waiting
447− * for suppliers. Otherwise, they are left marked as waiting on suppliers,
448− *
449− * The add_links bus callback is expected to return 0 if it has found and added
450− * all the supplier links for the consumer device. It should return an error if
451− * it isn't able to do so.
452− *
453− * The caller of device_link_wait_for_supplier() is expected to call this once
454− * it's aware of potential suppliers becoming available.
455− */
456−static void device_link_check_waiting_consumers(void)
457−{
458− struct device *dev, *tmp;
459−
460− mutex_lock(&wfs_lock);
461− list_for_each_entry_safe(dev, tmp, &wait_for_suppliers,
462− links.needs_suppliers)
463− if (!dev->bus->add_links(dev))
464− list_del_init(&dev->links.needs_suppliers);
465− mutex_unlock(&wfs_lock);
466−}
467−
468421 static void device_link_free(struct device_link *link)
469422 {
470423 while (refcount_dec_not_one(&link->rpm_active))
@@ -599,19 +552,6 @@ int device_links_check_suppliers(struct device *dev) · 128 unmodified lines
599552 struct device_link *link;
600553 int ret = 0;
601554
602− /*
603− * If a device is waiting for one or more suppliers (in
604− * wait_for_suppliers list), it is not ready to probe yet. So just
605− * return -EPROBE_DEFER without having to check the links with existing
606− * suppliers.
607− */
608− mutex_lock(&wfs_lock);
609− if (!list_empty(&dev->links.needs_suppliers)) {
610− mutex_unlock(&wfs_lock);
611− return -EPROBE_DEFER;
612− }
613− mutex_unlock(&wfs_lock);
614−
615555 device_links_write_lock();
616556
617557 list_for_each_entry(link, &dev->links.suppliers, c_node) {
@@ -896,10 +836,6 @@ static void device_links_purge(struct device *dev) · 278 unmodified lines
896836 {
897837 struct device_link *link, *ln;
898838
899− mutex_lock(&wfs_lock);
900− list_del(&dev->links.needs_suppliers);
901− mutex_unlock(&wfs_lock);
902−
903839 /*
904840 * Delete all of the remaining links from this device to any other
905841 * devices (either consumers or suppliers).
@@ -1764,7 +1700,6 @@ void device_initialize(struct device *dev) · 858 unmodified lines
17641700 #endif
17651701 INIT_LIST_HEAD(&dev->links.consumers);
17661702 INIT_LIST_HEAD(&dev->links.suppliers);
1767− INIT_LIST_HEAD(&dev->links.needs_suppliers);
17681703 dev->links.status = DL_DEV_NO_DRIVER;
17691704 }
17701705 EXPORT_SYMBOL_GPL(device_initialize);
@@ -2251,24 +2186,6 @@ int device_add(struct device *dev) · 480 unmodified lines
22512186 BUS_NOTIFY_ADD_DEVICE, dev);
22522187
22532188 kobject_uevent(&dev->kobj, KOBJ_ADD);
2254−
2255− /*
2256− * Check if any of the other devices (consumers) have been waiting for
2257− * this device (supplier) to be added so that they can create a device
2258− * link to it.
2259− *
2260− * This needs to happen after device_pm_add() because device_link_add()
2261− * requires the supplier be registered before it's called.
2262− *
2263− * But this also needs to happe before bus_probe_device() to make sure
2264− * waiting consumers can link to it before the driver is bound to the
2265− * device and the driver sync_state callback is called for this device.
2266− */
2267− device_link_check_waiting_consumers();
2268−
2269− if (dev->bus && dev->bus->add_links && dev->bus->add_links(dev))
2270− device_link_wait_for_supplier(dev);
2271−
22722189 bus_probe_device(dev);
22732190 if (parent)
22742191 klist_add_tail(&dev->p->knode_parent,
include/linux/device.h+0−14
@@ -78,17 +78,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); · 77 unmodified lines
7878 * -EPROBE_DEFER it will queue the device for deferred probing.
7979 * @uevent: Called when a device is added, removed, or a few other things
8080 * that generate uevents to add the environment variables.
81− * @add_links: Called, perhaps multiple times per device, after a device is
82− * added to this bus. The function is expected to create device
83− * links to all the suppliers of the input device that are
84− * available at the time this function is called. As in, the
85− * function should NOT stop at the first failed device link if
86− * other unlinked supplier devices are present in the system.
87− *
88− * Return 0 if device links have been successfully created to all
89− * the suppliers of this device. Return an error if some of the
90− * suppliers are not yet available and this function needs to be
91− * reattempted in the future.
9281 * @probe: Called when a new device or driver add to this bus, and callback
9382 * the specific driver's probe to initial the matched device.
9483 * @remove: Called when a device removed from this bus.
@@ -133,7 +122,6 @@ struct bus_type { · 38 unmodified lines
133122
134123 int (*match)(struct device *dev, struct device_driver *drv);
135124 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
136− int (*add_links)(struct device *dev);
137125 int (*probe)(struct device *dev);
138126 int (*remove)(struct device *dev);
139127 void (*shutdown)(struct device *dev);
@@ -1143,13 +1131,11 @@ enum dl_dev_state { · 1003 unmodified lines
11431131 * struct dev_links_info - Device data related to device links.
11441132 * @suppliers: List of links to supplier devices.
11451133 * @consumers: List of links to consumer devices.
1146− * @needs_suppliers: Hook to global list of devices waiting for suppliers.
11471134 * @status: Driver status information.
11481135 */
11491136 struct dev_links_info {
11501137 struct list_head suppliers;
11511138 struct list_head consumers;
1152− struct list_head needs_suppliers;
11531139 enum dl_dev_state status;
11541140 };
11551141

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t