Skip to contentSkip to conversation

patch "driver core: Reject pointless SYNC_STATE_ONLY device links" added to driver-core-linus

PATCH [email protected] 1 participant 1 message Oct 5, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

driver core: Reject pointless SYNC_STATE_ONLY device links

to my driver-core git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
in the driver-core-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From f729a592adb6760013c3e48622a5bf256b992452 Mon Sep 17 00:00:00 2001
From: Saravana Kannan <[email protected]>
Date: Wed, 29 Sep 2021 12:05:49 -0700
Subject: driver core: Reject pointless SYNC_STATE_ONLY device links

SYNC_STATE_ONLY device links intentionally allow cycles because cyclic sync_state() dependencies are valid and necessary.

However a SYNC_STATE_ONLY device link where the consumer and the supplier are the same device is pointless because the device link would be deleted as soon as the device probes (because it's also the consumer) and won't affect when the sync_state() callback is called. It's a waste of CPU cycles and memory to create this device link. So reject any attempts to create such a device link.

Fixes 05ef983e0d65 ("driver core: Add device link support for SYNC_STATE_ONLY flag")
Cc stable <[email protected]>
---
 drivers/base/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/core.c +2 -1
index 15986cc2fe5e..249da496581a 100644
@@ -687,7 +687,8 @@ struct device_link *device_link_add(struct device *consumer,
 {
 	struct device_link *link;
 
-	if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
+	if (!consumer || !supplier || consumer == supplier ||
+	    flags & ~DL_ADD_VALID_FLAGS ||
 	    (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
 	    (flags & DL_FLAG_SYNC_STATE_ONLY &&
 	     (flags & ~DL_FLAG_INFERRED) != DL_FLAG_SYNC_STATE_ONLY) ||
Signature · 1 line
2.33.0