Skip to content

Commit 8375e74

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Add fw_devlink kernel commandline option
fwnode_operations.add_links allows creating device links from information provided by firmware. fwnode_operations.add_links is currently implemented only by OF/devicetree code and a specific case of efi. However, there's nothing preventing ACPI or other firmware types from implementing it. The OF implementation is currently controlled by a kernel commandline parameter called of_devlink. Since this feature is generic isn't limited to OF, add a generic fw_devlink kernel commandline parameter to control this feature across firmware types. Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1745d29 commit 8375e74

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,24 @@
13501350
can be changed at run time by the max_graph_depth file
13511351
in the tracefs tracing directory. default: 0 (no limit)
13521352

1353+
fw_devlink= [KNL] Create device links between consumer and supplier
1354+
devices by scanning the firmware to infer the
1355+
consumer/supplier relationships. This feature is
1356+
especially useful when drivers are loaded as modules as
1357+
it ensures proper ordering of tasks like device probing
1358+
(suppliers first, then consumers), supplier boot state
1359+
clean up (only after all consumers have probed),
1360+
suspend/resume & runtime PM (consumers first, then
1361+
suppliers).
1362+
Format: { off | permissive | on | rpm }
1363+
off -- Don't create device links from firmware info.
1364+
permissive -- Create device links from firmware info
1365+
but use it only for ordering boot state clean
1366+
up (sync_state() calls).
1367+
on -- Create device links from firmware info and use it
1368+
to enforce probe and suspend/resume ordering.
1369+
rpm -- Like "on", but also use to order runtime PM.
1370+
13531371
gamecon.map[2|3]=
13541372
[HW,JOY] Multisystem joystick and NES/SNES/PSX pad
13551373
support via parallel port (up to 5 devices per port)

drivers/base/core.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,31 @@ static int device_private_init(struct device *dev)
23322332
return 0;
23332333
}
23342334

2335+
u32 fw_devlink_flags;
2336+
static int __init fw_devlink_setup(char *arg)
2337+
{
2338+
if (!arg)
2339+
return -EINVAL;
2340+
2341+
if (strcmp(arg, "off") == 0) {
2342+
fw_devlink_flags = 0;
2343+
} else if (strcmp(arg, "permissive") == 0) {
2344+
fw_devlink_flags = DL_FLAG_SYNC_STATE_ONLY;
2345+
} else if (strcmp(arg, "on") == 0) {
2346+
fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER;
2347+
} else if (strcmp(arg, "rpm") == 0) {
2348+
fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER |
2349+
DL_FLAG_PM_RUNTIME;
2350+
}
2351+
return 0;
2352+
}
2353+
early_param("fw_devlink", fw_devlink_setup);
2354+
2355+
u32 fw_devlink_get_flags(void)
2356+
{
2357+
return fw_devlink_flags;
2358+
}
2359+
23352360
/**
23362361
* device_add - add device to device hierarchy.
23372362
* @dev: device.
@@ -2480,7 +2505,7 @@ int device_add(struct device *dev)
24802505
*/
24812506
device_link_add_missing_supplier_links();
24822507

2483-
if (fwnode_has_op(dev->fwnode, add_links)) {
2508+
if (fw_devlink_flags && fwnode_has_op(dev->fwnode, add_links)) {
24842509
fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
24852510
if (fw_ret == -ENODEV)
24862511
device_link_wait_for_mandatory_supplier(dev);

include/linux/fwnode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,6 @@ struct fwnode_operations {
170170
} while (false)
171171
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
172172

173+
extern u32 fw_devlink_get_flags(void);
174+
173175
#endif

0 commit comments

Comments
 (0)