History

driver core: Add support for linking devices during device addition

The firmware corresponding to a device (dev.fwnode) might be able to provide functional dependency information between a device and its supplier and consumer devices. Tracking this functional dependency allows optimizing device probe order and informing a supplier when all its consumers have probed (and thereby actively managing their resources). The existing device links feature allows tracking and using supplier-consumer relationships. So, this patch adds the add_links() fwnode callback to allow firmware to create device links for each device as the device is added. 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.

Saravana Kannan committed 7 years ago

Commit e2ae9bc1 parent 372a67c4 files · +109 −1Browse files

Showing the changes to include/linux (2 of 4 files). Show all

Unified · Split

2 files
  1. include/linux/device.h +2 −0
  2. include/linux/fwnode.h +17 −0
include/linux/device.h+2−0
@@ -1135,11 +1135,13 @@ enum dl_dev_state { · 1134 unmodified lines
11351135 * struct dev_links_info - Device data related to device links.
11361136 * @suppliers: List of links to supplier devices.
11371137 * @consumers: List of links to consumer devices.
1138+ * @needs_suppliers: Hook to global list of devices waiting for suppliers.
11381139 * @status: Driver status information.
11391140 */
11401141 struct dev_links_info {
11411142 struct list_head suppliers;
11421143 struct list_head consumers;
1144+ struct list_head needs_suppliers;
11431145 enum dl_dev_state status;
11441146 };
11451147
include/linux/fwnode.h+17−0
@@ -66,6 +66,21 @@ struct fwnode_reference_args { · 65 unmodified lines
6666 * endpoint node.
6767 * @graph_get_port_parent: Return the parent node of a port node.
6868 * @graph_parse_endpoint: Parse endpoint for port and endpoint id.
69+ * @add_links: Called after the device corresponding to the fwnode is added
70+ * using device_add(). The function is expected to create device
71+ * links to all the suppliers of the device that are available at
72+ * the time this function is called. The function must NOT stop
73+ * at the first failed device link if other unlinked supplier
74+ * devices are present in the system. If some suppliers are not
75+ * yet available, this function will be called again when other
76+ * devices are added to allow creating device links to any newly
77+ * available suppliers.
78+ *
79+ * Return 0 if device links have been successfully created to all
80+ * the suppliers of this device or if the supplier information is
81+ * not known. Return an error if and only if the supplier
82+ * information is known but some of the suppliers are not yet
83+ * available to create device links to.
6984 */
7085 struct fwnode_operations {
7186 struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);
@@ -103,6 +118,8 @@ struct fwnode_operations { · 31 unmodified lines
103118 (*graph_get_port_parent)(struct fwnode_handle *fwnode);
104119 int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
105120 struct fwnode_endpoint *endpoint);
121+ int (*add_links)(const struct fwnode_handle *fwnode,
122+ struct device *dev);
106123 };
107124
108125 #define fwnode_has_op(fwnode, op) \

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