Skip to contentSkip to conversation

driver core: Fix creation of device links with PM-runtime flags

PATCH In review Rafael J. Wysocki 3 participants 3 messages Jul 30, 2019 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: Fix creation of device links with PM-runtime flags

From: Rafael J. Wysocki <[email protected]>

After commit 515db266a9da ("driver core: Remove device link creation limitation"), if PM-runtime flags are passed to device_link_add(), it will fail (returning NULL) due to an overly restrictive flags check introduced by that commit.

Fix this issue by extending the check in question to cover the PM-runtime flags too.

Fixes 515db266a9da ("driver core: Remove device link creation limitation")
---
 drivers/base/core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/base/core.c +4 -2
Index: linux-pm/drivers/base/core.c
===================================================================
@@ -213,6 +213,9 @@ void device_pm_move_to_tail(struct devic
 			       DL_FLAG_AUTOREMOVE_SUPPLIER | \
 			       DL_FLAG_AUTOPROBE_CONSUMER)
 
+#define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
+			    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
+
 /**
  * device_link_add - Create a link between two devices.
  * @consumer: Consumer end of the link.
@@ -274,8 +277,7 @@ struct device_link *device_link_add(stru
 {
 	struct device_link *link;
 
-	if (!consumer || !supplier ||
-	    (flags & ~(DL_FLAG_STATELESS | DL_MANAGED_LINK_FLAGS)) ||
+	if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
 	    (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
 	    (flags & DL_FLAG_AUTOPROBE_CONSUMER &&
 	     flags & (DL_FLAG_AUTOREMOVE_CONSUMER |
Tested-by on v1 1/1
#1 lore raw

30.07.2019 12:28, Rafael J. Wysocki пишет:

Quoted 36 lines

From: Rafael J. Wysocki <[email protected]>

After commit 515db266a9da ("driver core: Remove device link creation limitation"), if PM-runtime flags are passed to device_link_add(), it will fail (returning NULL) due to an overly restrictive flags check introduced by that commit.

Fix this issue by extending the check in question to cover the PM-runtime flags too.

Fixes 515db266a9da ("driver core: Remove device link creation limitation")
---
 drivers/base/core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/base/core.c
===================================================================

drivers/base/core.c +3 -0
@@ -213,6 +213,9 @@ void device_pm_move_to_tail(struct devic
 			       DL_FLAG_AUTOREMOVE_SUPPLIER | \
 			       DL_FLAG_AUTOPROBE_CONSUMER)
 
+#define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
+			    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
+
 /**
  * device_link_add - Create a link between two devices.
  * @consumer: Consumer end of the link.

drivers/base/core.c struct device_link *device_link_add(stru · line 283

Quoted 9 lines
drivers/base/core.c +1 -2
@@ -274,8 +277,7 @@ struct device_link *device_link_add(stru
 {
 	struct device_link *link;
 
-	if (!consumer || !supplier ||
-	    (flags & ~(DL_FLAG_STATELESS | DL_MANAGED_LINK_FLAGS)) ||
+	if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
 	    (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
 	    (flags & DL_FLAG_AUTOPROBE_CONSUMER &&
 	     flags & (DL_FLAG_AUTOREMOVE_CONSUMER |

Thank you very much!

Tested-by on v1 1/1
#2 lore raw
In reply to Rafael J. Wysocki

Hi,

Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

After commit 515db266a9da ("driver core: Remove device link creation limitation"), if PM-runtime flags are passed to device_link_add(), it will fail (returning NULL) due to an overly restrictive flags check introduced by that commit.

Quoted 7 lines

Fix this issue by extending the check in question to cover the PM-runtime flags too.

Fixes 515db266a9da ("driver core: Remove device link creation limitation")

The merged commit also has my 'tested' tags, but I did my tests on v1, which worked fine. The offending check has been added in v2 while keeping the tags. Thanks for spotting this and fixing the issue, due to holidays time, I didn't manage to test v2 before it got merged.

Quoted 24 lines
---
  drivers/base/core.c |    6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/base/core.c
===================================================================

drivers/base/core.c +3 -0
@@ -213,6 +213,9 @@ void device_pm_move_to_tail(struct devic
  			       DL_FLAG_AUTOREMOVE_SUPPLIER | \
  			       DL_FLAG_AUTOPROBE_CONSUMER)
 
+#define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \
+			    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE)
+
  /**
   * device_link_add - Create a link between two devices.
   * @consumer: Consumer end of the link.

drivers/base/core.c struct device_link *device_link_add(stru · line 283

Quoted 9 lines
drivers/base/core.c +1 -2
@@ -274,8 +277,7 @@ struct device_link *device_link_add(stru
  {
  	struct device_link *link;
 
-	if (!consumer || !supplier ||
-	    (flags & ~(DL_FLAG_STATELESS | DL_MANAGED_LINK_FLAGS)) ||
+	if (!consumer || !supplier || flags & ~DL_ADD_VALID_FLAGS ||
  	    (flags & DL_FLAG_STATELESS && flags & DL_MANAGED_LINK_FLAGS) ||
  	    (flags & DL_FLAG_AUTOPROBE_CONSUMER &&
  	     flags & (DL_FLAG_AUTOREMOVE_CONSUMER |

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland