Revert "driver core: Add sync_state driver/bus callback"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Aug 2019 19:40:50 +0000 (21:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Aug 2019 19:40:50 +0000 (21:40 +0200)
This reverts commit 8f8184d6bf676a8680d6f441e40317d166b46f73.

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>
drivers/base/core.c
include/linux/device.h

index 75fd5936094080a6bc62bdd486d07e9f65b65c89..de775c7a4d7c10528f9ec1c06ef6432fd638cedc 100644 (file)
@@ -46,8 +46,6 @@ early_param("sysfs.deprecated", sysfs_deprecated_setup);
 /* Device links support. */
 static LIST_HEAD(wait_for_suppliers);
 static DEFINE_MUTEX(wfs_lock);
-static LIST_HEAD(deferred_sync);
-static unsigned int supplier_sync_state_disabled;
 
 #ifdef CONFIG_SRCU
 static DEFINE_MUTEX(device_links_lock);
@@ -653,62 +651,6 @@ int device_links_check_suppliers(struct device *dev)
        return ret;
 }
 
-static void __device_links_supplier_sync_state(struct device *dev)
-{
-       struct device_link *link;
-
-       if (dev->state_synced)
-               return;
-
-       list_for_each_entry(link, &dev->links.consumers, s_node) {
-               if (!(link->flags & DL_FLAG_MANAGED))
-                       continue;
-               if (link->status != DL_STATE_ACTIVE)
-                       return;
-       }
-
-       if (dev->bus->sync_state)
-               dev->bus->sync_state(dev);
-       else if (dev->driver && dev->driver->sync_state)
-               dev->driver->sync_state(dev);
-
-       dev->state_synced = true;
-}
-
-void device_links_supplier_sync_state_pause(void)
-{
-       device_links_write_lock();
-       supplier_sync_state_disabled++;
-       device_links_write_unlock();
-}
-
-void device_links_supplier_sync_state_resume(void)
-{
-       struct device *dev, *tmp;
-
-       device_links_write_lock();
-       if (!supplier_sync_state_disabled) {
-               WARN(true, "Unmatched sync_state pause/resume!");
-               goto out;
-       }
-       supplier_sync_state_disabled--;
-       if (supplier_sync_state_disabled)
-               goto out;
-
-       list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_sync) {
-               __device_links_supplier_sync_state(dev);
-               list_del_init(&dev->links.defer_sync);
-       }
-out:
-       device_links_write_unlock();
-}
-
-static void __device_links_supplier_defer_sync(struct device *sup)
-{
-       if (list_empty(&sup->links.defer_sync))
-               list_add_tail(&sup->links.defer_sync, &deferred_sync);
-}
-
 /**
  * device_links_driver_bound - Update device links after probing its driver.
  * @dev: Device to update the links for.
@@ -753,11 +695,6 @@ void device_links_driver_bound(struct device *dev)
 
                WARN_ON(link->status != DL_STATE_CONSUMER_PROBE);
                WRITE_ONCE(link->status, DL_STATE_ACTIVE);
-
-               if (supplier_sync_state_disabled)
-                       __device_links_supplier_defer_sync(link->supplier);
-               else
-                       __device_links_supplier_sync_state(link->supplier);
        }
 
        dev->links.status = DL_DEV_DRIVER_BOUND;
@@ -874,7 +811,6 @@ void device_links_driver_cleanup(struct device *dev)
                WRITE_ONCE(link->status, DL_STATE_DORMANT);
        }
 
-       list_del_init(&dev->links.defer_sync);
        __device_links_no_driver(dev);
 
        device_links_write_unlock();
@@ -1849,7 +1785,6 @@ void device_initialize(struct device *dev)
        INIT_LIST_HEAD(&dev->links.consumers);
        INIT_LIST_HEAD(&dev->links.suppliers);
        INIT_LIST_HEAD(&dev->links.needs_suppliers);
-       INIT_LIST_HEAD(&dev->links.defer_sync);
        dev->links.status = DL_DEV_NO_DRIVER;
 }
 EXPORT_SYMBOL_GPL(device_initialize);
index 76496497e7530fce4f7d315a16962f82ffa32525..90142ec9ce8417686cd1263ec4868bb6d49297e7 100644 (file)
@@ -84,8 +84,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
  *             available at the time this function is called.  As in, the
  *             function should NOT stop at the first failed device link if
  *             other unlinked supplier devices are present in the system.
- *             This is necessary for the sync_state() callback to work
- *             correctly.
  *
  *             Return 0 if device links have been successfully created to all
  *             the suppliers of this device.  Return an error if some of the
@@ -93,13 +91,6 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
  *             reattempted in the future.
  * @probe:     Called when a new device or driver add to this bus, and callback
  *             the specific driver's probe to initial the matched device.
- * @sync_state:        Called to sync device state to software state after all the
- *             state tracking consumers linked to this device (present at
- *             the time of late_initcall) have successfully bound to a
- *             driver. If the device has no consumers, this function will
- *             be called at late_initcall_sync level. If the device has
- *             consumers that are never bound to a driver, this function
- *             will never get called until they do.
  * @remove:    Called when a device removed from this bus.
  * @shutdown:  Called at shut-down time to quiesce the device.
  *
@@ -144,7 +135,6 @@ struct bus_type {
        int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
        int (*add_links)(struct device *dev);
        int (*probe)(struct device *dev);
-       void (*sync_state)(struct device *dev);
        int (*remove)(struct device *dev);
        void (*shutdown)(struct device *dev);
 
@@ -376,13 +366,6 @@ enum probe_type {
  * @probe:     Called to query the existence of a specific device,
  *             whether this driver can work with it, and bind the driver
  *             to a specific device.
- * @sync_state:        Called to sync device state to software state after all the
- *             state tracking consumers linked to this device (present at
- *             the time of late_initcall) have successfully bound to a
- *             driver. If the device has no consumers, this function will
- *             be called at late_initcall_sync level. If the device has
- *             consumers that are never bound to a driver, this function
- *             will never get called until they do.
  * @remove:    Called when the device is removed from the system to
  *             unbind a device from this driver.
  * @shutdown:  Called at shut-down time to quiesce the device.
@@ -423,7 +406,6 @@ struct device_driver {
 
        int (*edit_links)(struct device *dev);
        int (*probe) (struct device *dev);
-       void (*sync_state)(struct device *dev);
        int (*remove) (struct device *dev);
        void (*shutdown) (struct device *dev);
        int (*suspend) (struct device *dev, pm_message_t state);
@@ -1177,14 +1159,12 @@ enum dl_dev_state {
  * @suppliers: List of links to supplier devices.
  * @consumers: List of links to consumer devices.
  * @needs_suppliers: Hook to global list of devices waiting for suppliers.
- * @defer_sync: Hook to global list of devices that have deferred sync_state.
  * @status: Driver status information.
  */
 struct dev_links_info {
        struct list_head suppliers;
        struct list_head consumers;
        struct list_head needs_suppliers;
-       struct list_head defer_sync;
        enum dl_dev_state status;
 };
 
@@ -1262,9 +1242,6 @@ struct dev_links_info {
  *              device.
  * @has_edit_links: This device has a driver than is capable of
  *                 editing the device links created by driver core.
- * @state_synced: The hardware state of this device has been synced to match
- *               the software state of this device by calling the driver/bus
- *               sync_state() callback.
  * @dma_coherent: this particular device is dma coherent, even if the
  *             architecture supports non-coherent devices.
  *
@@ -1362,7 +1339,6 @@ struct device {
        bool                    offline:1;
        bool                    of_node_reused:1;
        bool                    has_edit_links:1;
-       bool                    state_synced:1;
 #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
     defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
     defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
@@ -1707,8 +1683,6 @@ struct device_link *device_link_add(struct device *consumer,
 void device_link_del(struct device_link *link);
 void device_link_remove(void *consumer, struct device *supplier);
 void device_link_remove_from_wfs(struct device *consumer);
-void device_links_supplier_sync_state_pause(void);
-void device_links_supplier_sync_state_resume(void);
 
 #ifndef dev_fmt
 #define dev_fmt(fmt) fmt