aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorSaravana Kannan <saravanak@google.com>2019-07-31 18:17:14 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-01 10:04:13 -0400
commit5302dd7dd0b6d04c63cdce51d1e9fda9ef0be886 (patch)
treef168591fba3257dc48e79814cd60c6d49052659f /include/linux
parent313b46d831189f593840c625d7972092cb0088fc (diff)
driver core: Add support for linking devices during device addition
When devices are added, the bus might want to create device links to track functional dependencies between supplier and consumer devices. This tracking of supplier-consumer relationship allows optimizing device probe order and tracking whether all consumers of a supplier are active. The add_links bus callback is added to support this. However, when consumer devices are added, they might not have a supplier device to link to despite needing mandatory resources/functionality from one or more suppliers. A waiting_for_suppliers list is created to track such consumers and retry linking them when new devices get added. Signed-off-by: Saravana Kannan <saravanak@google.com> Link: https://lore.kernel.org/r/20190731221721.187713-2-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index bff46ce3bc3b..1e05911325f0 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -78,6 +78,17 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
78 * -EPROBE_DEFER it will queue the device for deferred probing. 78 * -EPROBE_DEFER it will queue the device for deferred probing.
79 * @uevent: Called when a device is added, removed, or a few other things 79 * @uevent: Called when a device is added, removed, or a few other things
80 * that generate uevents to add the environment variables. 80 * 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.
81 * @probe: Called when a new device or driver add to this bus, and callback 92 * @probe: Called when a new device or driver add to this bus, and callback
82 * the specific driver's probe to initial the matched device. 93 * the specific driver's probe to initial the matched device.
83 * @remove: Called when a device removed from this bus. 94 * @remove: Called when a device removed from this bus.
@@ -122,6 +133,7 @@ struct bus_type {
122 133
123 int (*match)(struct device *dev, struct device_driver *drv); 134 int (*match)(struct device *dev, struct device_driver *drv);
124 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 135 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
136 int (*add_links)(struct device *dev);
125 int (*probe)(struct device *dev); 137 int (*probe)(struct device *dev);
126 int (*remove)(struct device *dev); 138 int (*remove)(struct device *dev);
127 void (*shutdown)(struct device *dev); 139 void (*shutdown)(struct device *dev);
@@ -1128,11 +1140,13 @@ enum dl_dev_state {
1128 * struct dev_links_info - Device data related to device links. 1140 * struct dev_links_info - Device data related to device links.
1129 * @suppliers: List of links to supplier devices. 1141 * @suppliers: List of links to supplier devices.
1130 * @consumers: List of links to consumer devices. 1142 * @consumers: List of links to consumer devices.
1143 * @needs_suppliers: Hook to global list of devices waiting for suppliers.
1131 * @status: Driver status information. 1144 * @status: Driver status information.
1132 */ 1145 */
1133struct dev_links_info { 1146struct dev_links_info {
1134 struct list_head suppliers; 1147 struct list_head suppliers;
1135 struct list_head consumers; 1148 struct list_head consumers;
1149 struct list_head needs_suppliers;
1136 enum dl_dev_state status; 1150 enum dl_dev_state status;
1137}; 1151};
1138 1152