aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-27 15:41:06 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-27 15:41:06 -0400
commit33cbfe54499338af08ab906a99afac247ea533f6 (patch)
treea2af0661254396449942ca00e9f770d073d39db7
parentd77b3f07a1d7127f1ecaf82a95a36b8a3e8fc689 (diff)
Revert "driver core: Add edit_links() callback for drivers"
This reverts commit 134b23eec9e3a3c795a6ceb0efe2fa63e87983b2. 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. Cc: Frank Rowand <frowand.list@gmail.com> Cc: Saravana Kannan <saravanak@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/core.c24
-rw-r--r--drivers/base/dd.c29
-rw-r--r--include/linux/device.h20
3 files changed, 2 insertions, 71 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index de775c7a4d7c..605905de0cca 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -440,19 +440,6 @@ static void device_link_wait_for_supplier(struct device *consumer)
440} 440}
441 441
442/** 442/**
443 * device_link_remove_from_wfs - Unmark device as waiting for supplier
444 * @consumer: Consumer device
445 *
446 * Unmark the consumer device as waiting for suppliers to become available.
447 */
448void device_link_remove_from_wfs(struct device *consumer)
449{
450 mutex_lock(&wfs_lock);
451 list_del_init(&consumer->links.needs_suppliers);
452 mutex_unlock(&wfs_lock);
453}
454
455/**
456 * device_link_check_waiting_consumers - Try to unmark waiting consumers 443 * device_link_check_waiting_consumers - Try to unmark waiting consumers
457 * 444 *
458 * Loops through all consumers waiting on suppliers and tries to add all their 445 * Loops through all consumers waiting on suppliers and tries to add all their
@@ -469,19 +456,12 @@ void device_link_remove_from_wfs(struct device *consumer)
469static void device_link_check_waiting_consumers(void) 456static void device_link_check_waiting_consumers(void)
470{ 457{
471 struct device *dev, *tmp; 458 struct device *dev, *tmp;
472 int ret;
473 459
474 mutex_lock(&wfs_lock); 460 mutex_lock(&wfs_lock);
475 list_for_each_entry_safe(dev, tmp, &wait_for_suppliers, 461 list_for_each_entry_safe(dev, tmp, &wait_for_suppliers,
476 links.needs_suppliers) { 462 links.needs_suppliers)
477 ret = 0; 463 if (!dev->bus->add_links(dev))
478 if (dev->has_edit_links)
479 ret = driver_edit_links(dev);
480 else if (dev->bus->add_links)
481 ret = dev->bus->add_links(dev);
482 if (!ret)
483 list_del_init(&dev->links.needs_suppliers); 464 list_del_init(&dev->links.needs_suppliers);
484 }
485 mutex_unlock(&wfs_lock); 465 mutex_unlock(&wfs_lock);
486} 466}
487 467
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 55fbc2467b37..d811e60610d3 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -710,12 +710,6 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
710 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 710 pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
711 drv->bus->name, __func__, dev_name(dev), drv->name); 711 drv->bus->name, __func__, dev_name(dev), drv->name);
712 712
713 if (drv->edit_links) {
714 if (drv->edit_links(dev))
715 dev->has_edit_links = true;
716 else
717 device_link_remove_from_wfs(dev);
718 }
719 pm_runtime_get_suppliers(dev); 713 pm_runtime_get_suppliers(dev);
720 if (dev->parent) 714 if (dev->parent)
721 pm_runtime_get_sync(dev->parent); 715 pm_runtime_get_sync(dev->parent);
@@ -804,29 +798,6 @@ struct device_attach_data {
804 bool have_async; 798 bool have_async;
805}; 799};
806 800
807static int __driver_edit_links(struct device_driver *drv, void *data)
808{
809 struct device *dev = data;
810
811 if (!drv->edit_links)
812 return 0;
813
814 if (driver_match_device(drv, dev) <= 0)
815 return 0;
816
817 return drv->edit_links(dev);
818}
819
820int driver_edit_links(struct device *dev)
821{
822 int ret;
823
824 device_lock(dev);
825 ret = bus_for_each_drv(dev->bus, NULL, dev, __driver_edit_links);
826 device_unlock(dev);
827 return ret;
828}
829
830static int __device_attach_driver(struct device_driver *drv, void *_data) 801static int __device_attach_driver(struct device_driver *drv, void *_data)
831{ 802{
832 struct device_attach_data *data = _data; 803 struct device_attach_data *data = _data;
diff --git a/include/linux/device.h b/include/linux/device.h
index 90142ec9ce84..73210745cc6b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -349,20 +349,6 @@ enum probe_type {
349 * @probe_type: Type of the probe (synchronous or asynchronous) to use. 349 * @probe_type: Type of the probe (synchronous or asynchronous) to use.
350 * @of_match_table: The open firmware table. 350 * @of_match_table: The open firmware table.
351 * @acpi_match_table: The ACPI match table. 351 * @acpi_match_table: The ACPI match table.
352 * @edit_links: Called to allow a matched driver to edit the device links the
353 * bus might have added incorrectly. This will be useful to handle
354 * cases where the bus incorrectly adds functional dependencies
355 * that aren't true or tries to create cyclic dependencies. But
356 * doesn't correctly handle functional dependencies that are
357 * missed by the bus as the supplier's sync_state might get to
358 * execute before the driver for a missing consumer is loaded and
359 * gets to edit the device links for the consumer.
360 *
361 * This function might be called multiple times after a new device
362 * is added. The function is expected to create all the device
363 * links for the new device and return 0 if it was completed
364 * successfully or return an error if it needs to be reattempted
365 * in the future.
366 * @probe: Called to query the existence of a specific device, 352 * @probe: Called to query the existence of a specific device,
367 * whether this driver can work with it, and bind the driver 353 * whether this driver can work with it, and bind the driver
368 * to a specific device. 354 * to a specific device.
@@ -404,7 +390,6 @@ struct device_driver {
404 const struct of_device_id *of_match_table; 390 const struct of_device_id *of_match_table;
405 const struct acpi_device_id *acpi_match_table; 391 const struct acpi_device_id *acpi_match_table;
406 392
407 int (*edit_links)(struct device *dev);
408 int (*probe) (struct device *dev); 393 int (*probe) (struct device *dev);
409 int (*remove) (struct device *dev); 394 int (*remove) (struct device *dev);
410 void (*shutdown) (struct device *dev); 395 void (*shutdown) (struct device *dev);
@@ -1240,8 +1225,6 @@ struct dev_links_info {
1240 * @offline: Set after successful invocation of bus type's .offline(). 1225 * @offline: Set after successful invocation of bus type's .offline().
1241 * @of_node_reused: Set if the device-tree node is shared with an ancestor 1226 * @of_node_reused: Set if the device-tree node is shared with an ancestor
1242 * device. 1227 * device.
1243 * @has_edit_links: This device has a driver than is capable of
1244 * editing the device links created by driver core.
1245 * @dma_coherent: this particular device is dma coherent, even if the 1228 * @dma_coherent: this particular device is dma coherent, even if the
1246 * architecture supports non-coherent devices. 1229 * architecture supports non-coherent devices.
1247 * 1230 *
@@ -1338,7 +1321,6 @@ struct device {
1338 bool offline_disabled:1; 1321 bool offline_disabled:1;
1339 bool offline:1; 1322 bool offline:1;
1340 bool of_node_reused:1; 1323 bool of_node_reused:1;
1341 bool has_edit_links:1;
1342#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ 1324#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
1343 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ 1325 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
1344 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) 1326 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
@@ -1590,7 +1572,6 @@ extern int __must_check device_attach(struct device *dev);
1590extern int __must_check driver_attach(struct device_driver *drv); 1572extern int __must_check driver_attach(struct device_driver *drv);
1591extern void device_initial_probe(struct device *dev); 1573extern void device_initial_probe(struct device *dev);
1592extern int __must_check device_reprobe(struct device *dev); 1574extern int __must_check device_reprobe(struct device *dev);
1593extern int driver_edit_links(struct device *dev);
1594 1575
1595extern bool device_is_bound(struct device *dev); 1576extern bool device_is_bound(struct device *dev);
1596 1577
@@ -1682,7 +1663,6 @@ struct device_link *device_link_add(struct device *consumer,
1682 struct device *supplier, u32 flags); 1663 struct device *supplier, u32 flags);
1683void device_link_del(struct device_link *link); 1664void device_link_del(struct device_link *link);
1684void device_link_remove(void *consumer, struct device *supplier); 1665void device_link_remove(void *consumer, struct device *supplier);
1685void device_link_remove_from_wfs(struct device *consumer);
1686 1666
1687#ifndef dev_fmt 1667#ifndef dev_fmt
1688#define dev_fmt(fmt) fmt 1668#define dev_fmt(fmt) fmt