base: core: Remove WARN_ON from link dependencies check
PATCH 1/1 base: core: Remove WARN_ON from link dependencies check
In some cases the link between between customer and supplier already exist. Do not warn about already existing dependencies because device_link_add() take care of this case.
--- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/base/core.c +2 -2
@@ -105,7 +105,7 @@ static int device_is_dependent(struct device *dev, void *target)struct device_link *link;int ret; -if (WARN_ON (dev == target)) +if (dev == target)return 1 ; ret =device_for_each_child (dev, target, device_is_dependent);
@@ -113,7 +113,7 @@ static int device_is_dependent(struct device *dev, void *target)return ret;list_for_each_entry (link, &dev->links.consumers, s_node) { -if (WARN_ON (link->consumer == target)) +if (link->consumer == target)return 1 ; ret =device_is_dependent (link->consumer, target);
Signature · 1 line
2.15.0
Greg KH
maintainerQuoted 3 lines · Benjamin Gaignard
In some cases the link between between customer and supplier already exist. Do not warn about already existing dependencies because
device_link_add()take care of this case.
Why would a link already exist that is asked to be created again? What code path causes this?
Quoted 21 lines
Reported-by Marek Szyprowski <[email protected]>Signed-off-by Benjamin Gaignard <[email protected]>--- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/base/core.c +1
-1@@ -105,7 +105,7 @@ static int device_is_dependent(struct device *dev, void *target)struct device_link *link;int ret; -if (WARN_ON (dev == target)) +if (dev == target)return 1 ; ret =device_for_each_child (dev, target, device_is_dependent);
drivers/base/core.c static int device_is_dependent(struct device *dev, void *target) · line 117
Quoted 6 lines
drivers/base/core.c +1
-1@@ -113,7 +113,7 @@ static int device_is_dependent(struct device *dev, void *target)return ret;list_for_each_entry (link, &dev->links.consumers, s_node) { -if (WARN_ON (link->consumer == target)) +if (link->consumer == target)return 1 ;
Both of these WARN_ON are for valid code? That feels really odd to me, I need more explanation here please.
thanks,
greg k-h
2018-07-12 10:55 GMT+02:00 Greg KH <[email protected]>:
Quoted 7 lines · Benjamin Gaignard
Quoted 3 lines
In some cases the link between between customer and supplier already exist. Do not warn about already existing dependencies because
device_link_add()take care of this case.Why would a link already exist that is asked to be created again? What code path causes this?
It could happen that the link exist because a device use it parent as supplier. That case has been describe by Marek in this thread (I forgot to add it in the commit message, sorry):
https://lkml.org/lkml/2018/7/9/356
Quoted 24 lines
Quoted 24 lines
Reported-by Marek Szyprowski <[email protected]>Signed-off-by Benjamin Gaignard <[email protected]>--- drivers/base/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/base/core.c +1
-1@@ -105,7 +105,7 @@ static int device_is_dependent(struct device *dev, void *target)struct device_link *link;int ret; -if (WARN_ON (dev == target)) +if (dev == target)return 1 ; ret =device_for_each_child (dev, target, device_is_dependent);@@ -113,7 +113,7 @@ static int device_is_dependent(struct device *dev, void *target)return ret;
Quoted 7 lines
drivers/base/core.c static int device_is_dependent(struct device *dev, void *target) · line 117
Quoted 4 lines
drivers/base/core.c +1
-1list_for_each_entry (link, &dev->links.consumers, s_node) { -if (WARN_ON (link->consumer == target)) +if (link->consumer == target)return 1 ;Both of these
WARN_ONare for valid code? That feels really odd to me, I need more explanation here please.
The documentation of the function is clear about return values:
"Check if @target depends on @dev or any device dependent on it (its child or ts consumer etc). Return 1 if that is the case or 0 otherwise."
so, for me, not need to warn user about something that is expected.
Benjamin
Quoted 4 lines
thanks,
greg k-h
Quoted 9 lines · Benjamin Gaignard
2018-07-12 10:55 GMT+02:00 Greg KH <[email protected]>:
Quoted 2 lines
Why would a link already exist that is asked to be created again? What code path causes this?
It could happen that the link exist because a device use it parent as supplier. That case has been describe by Marek in this thread (I forgot to add it in the commit message, sorry):
https://lkml.org/lkml/2018/7/9/356
If we don't remove the warning then we'd need to have some way for generic code to check if a link that it wants to create exists already since if more than one thing adds links there's always a chance that two of them will come up with the same idea for a link. We could export device_is_dependent() and have them check that, or add a new flag that skips the check for example. This is however probably going to affect a reasonable percentage of potential users.
Quoted 6 lines · CEST Benjamin Gaignard
2018-07-12 10:55 GMT+02:00 Greg KH <[email protected]>:
Quoted 5 lines · Benjamin Gaignard
Quoted 3 lines
In some cases the link between between customer and supplier already exist. Do not warn about already existing dependencies because
device_link_add()take care of this case.
Quoted 7 lines
Quoted 2 lines
Why would a link already exist that is asked to be created again? What code path causes this?
It could happen that the link exist because a device use it parent as supplier. That case has been describe by Marek in this thread (I forgot to add it in the commit message, sorry):
https://lkml.org/lkml/2018/7/9/356
So please add this information to the patch changelog and resend.
Thanks,
Rafael
Quoted 3 lines · Benjamin Gaignard
In some cases the link between between customer and supplier already exist. Do not warn about already existing dependencies because
device_link_add()take care of this case.