driver core: fw_devlink: Don't create device links for devices not on a bus
PATCH 1/1 driver core: fw_devlink: Don't create device links for devices not on a bus
Devices that are not on a bus will never have a driver bound to it. So, fw_devlink should not create device links for it as it can cause probe issues[1] or sync_state() call back issues[2].
[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/
--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/base/core.c +16 -0
@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ; +/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; + sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* If a supplier device is not on a bus (i.e. a driver will +* never bind to it), it doesn't make sense for fw_devlink to +* create device links for it. +*/ +if (sup_dev->bus ==NULL ) +return -EINVAL ; +/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this
Signature · 1 line
2.33.0.259.gc128427fd7-goog
Greg Kroah-Hartman
maintainerQuoted 20 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +0
-0@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 1729
Quoted 10 lines
drivers/base/core.c +8
-0int ret =0 ; +/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; +
Why would a device not be on a bus that has to do with a driver needing it? What types of devices are these?
thanks,
greg k-h
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +0
-0@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ;
Quoted 11 lines
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 1729
Quoted 8 lines
drivers/base/core.c +8
-0+/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; +Why would a device not be on a bus that has to do with a driver needing it? What types of devices are these?
I'm not sure what you are asking, because it seems like a question you'd know the answer to. What I'm trying to say is that bus_probe_device() is obviously only possible if the device is on a bus. And fw_devlink creates managed device links that track if a device is bound to a driver. So it doesn't make sense to create the device link if the device is not on a bus.
There are plenty of examples for this -- like all the devices that get added to a class? For example the platform bus or the mdio bus itself are devices that are added to a class instead of a bus.
Not sure if I answered your question. Let me know.
-Saravana
Greg Kroah-Hartman
maintainerQuoted 45 lines · Saravana Kannan
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +0
-0@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ;Quoted 11 lines
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 1729
Quoted 8 lines
drivers/base/core.c +8
-0+/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; +Why would a device not be on a bus that has to do with a driver needing it? What types of devices are these?
I'm not sure what you are asking, because it seems like a question you'd know the answer to. What I'm trying to say is that
bus_probe_device()is obviously only possible if the device is on a bus. Andfw_devlinkcreates managed device links that track if a device is bound to a driver. So it doesn't make sense to create the device link if the device is not on a bus.
Quoted 5 lines
There are plenty of examples for this -- like all the devices that get added to a class? For example the platform bus or the mdio bus itself are devices that are added to a class instead of a bus.
Not sure if I answered your question. Let me know.
Sorry, that was a vague question.
I was trying to say, "how can a device that is not attached to a bus at all even be called for this?" Who would be making that type of connection, what subsystem is causing this to happen?
thanks,
greg k-h
Quoted 51 lines · Greg Kroah-Hartman
Quoted 49 lines · Saravana Kannan
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +0
-0@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ;Quoted 11 lines
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 1729
Quoted 8 lines
drivers/base/core.c +8
-0+/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; +Why would a device not be on a bus that has to do with a driver needing it? What types of devices are these?
I'm not sure what you are asking, because it seems like a question you'd know the answer to. What I'm trying to say is that
bus_probe_device()is obviously only possible if the device is on a bus. Andfw_devlinkcreates managed device links that track if a device is bound to a driver. So it doesn't make sense to create the device link if the device is not on a bus.There are plenty of examples for this -- like all the devices that get added to a class? For example the platform bus or the mdio bus itself are devices that are added to a class instead of a bus.
Quoted 6 lines
Quoted 1 line
Not sure if I answered your question. Let me know.
Sorry, that was a vague question.
I was trying to say, "how can a device that is not attached to a bus at all even be called for this?"
This code path is called for all device_add()s.
Quoted 2 lines
Who would be making that type of
connection, what subsystem is causing this to happen?
fw_devlink trying to interpret DT dependencies can sometimes end up in this situation for some uncommon cases. But it's not helping [1] or [2], so for now let's drop this patch. I'll come back to this if I need this to fix any real issue.
-Saravana
[...]
Quoted 4 lines
fw_devlinktrying to interpret DT dependencies can sometimes end up in this situation for some uncommon cases. But it's not helping [1] or [2], so for now let's drop this patch. I'll come back to this if I need this to fix any real issue.
Just to be clear, the issue is really there, with the psci power domain, for example.
I am working with an ARM vendor on a platform that has a child node below the common soc node and which child node is a consumer of the psci power domain provider node. We fail to get the ->sync_state() to be called, for reasons that have been explained by now, I think.
The reason for explaining the problem with a superficial example was to try to easier point out the problem.
That said, I would certainly appreciate your help to get this fixed, in one way or the other.
Quoted 2 lines
-Saravana
Kind regards
Uffe
Quoted 7 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/
Unfortunately, this doesn't fix my problem in [2].
When the "soctest" device is initialized, via of_platform_populate(), it will be attached to the platform bus, hence the check for the bus pointer that you suggest to add below, doesn't have an impact on my use case. I still get the below in the log:
"platform soctest: Linked as a sync state only consumer to pm_domain_test"
Kind regards
Uffe
Quoted 40 lines
Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +16
-1@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ; +/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; + sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* If a supplier device is not on a bus (i.e. a driver will +* never bind to it), it doesn't make sense for fw_devlink to +* create device links for it. +*/ +if (sup_dev->bus ==NULL ) +return -EINVAL ; +/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this -- 2.33.0.259.gc128427fd7-goog
Quoted 10 lines · Ulf Hansson
Quoted 7 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/
Quoted 6 lines
Unfortunately, this doesn't fix my problem in [2].
When the "soctest" device is initialized, via
of_platform_populate(), it will be attached to the platform bus, hence the check for the bus pointer that you suggest to add below, doesn't have an impact on my use case. I still get the below in the log:
*face palm* Right. I forgot that. I just read "bus" and my mind went to busses added as devices. It apparently also didn't help [1] which is surprising to me. I'll dig into that separately. I'll look into fixing this. The annoying part is that some devices have compatible property that's both "simple-bus" and some other string that a driver actually matches with.
-Saravana
Quoted 46 lines
"platform soctest: Linked as a sync state only consumer to
pm_domain_test"Kind regards
UffeQuoted 40 lines
Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +16
-1@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ; +/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; + sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* If a supplier device is not on a bus (i.e. a driver will +* never bind to it), it doesn't make sense for fw_devlink to +* create device links for it. +*/ +if (sup_dev->bus ==NULL ) +return -EINVAL ; +/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this -- 2.33.0.259.gc128427fd7-goog
Quoted 19 lines · Saravana Kannan
Quoted 10 lines · Ulf Hansson
Quoted 7 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Quoted 6 lines
Unfortunately, this doesn't fix my problem in [2].
When the "soctest" device is initialized, via
of_platform_populate(), it will be attached to the platform bus, hence the check for the bus pointer that you suggest to add below, doesn't have an impact on my use case. I still get the below in the log:
Quoted 6 lines
*face palm* Right. I forgot that. I just read "bus" and my mind went to busses added as devices. It apparently also didn't help [1] which is surprising to me. I'll dig into that separately. I'll look into fixing this. The annoying part is that some devices have compatible property that's both "simple-bus" and some other string that a driver actually matches with.
Yes, that is my view of the problem as well.
So perhaps we should do a more fine grained check for when the "simple-bus" compatible is present in the node, and then don't create a fw_devlink if we reach an ascendant with only this compatible?
Would that work, do you think?
Kind regards
Uffe
Quoted 49 lines
-Saravana
Quoted 46 lines
"platform soctest: Linked as a sync state only consumer to
pm_domain_test"Kind regards
UffeQuoted 40 lines
Fixes f9aa460672c9 ("driver core: Refactor fw_devlink feature")Reported-by Ulf Hansson <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Saravana Kannan <[email protected]>--- drivers/base/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/base/core.c +16
-1@@ -1719,8 +1719,24 @@ static int fw_devlink_create_devlink(struct device *con,struct device *sup_dev;int ret =0 ; +/* +* If a consumer device is not on a bus (i.e. a driver will never bind +* to it), it doesn't make sense for fw_devlink to create device links +* for it. +*/ +if (con->bus ==NULL ) +return -EINVAL ; + sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* If a supplier device is not on a bus (i.e. a driver will +* never bind to it), it doesn't make sense for fw_devlink to +* create device links for it. +*/ +if (sup_dev->bus ==NULL ) +return -EINVAL ; +/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this -- 2.33.0.259.gc128427fd7-goog
Quoted 28 lines · Ulf Hansson
Quoted 19 lines · Saravana Kannan
Quoted 10 lines · Ulf Hansson
Quoted 7 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Quoted 6 lines
Unfortunately, this doesn't fix my problem in [2].
When the "soctest" device is initialized, via
of_platform_populate(), it will be attached to the platform bus, hence the check for the bus pointer that you suggest to add below, doesn't have an impact on my use case. I still get the below in the log:Quoted 6 lines
*face palm* Right. I forgot that. I just read "bus" and my mind went to busses added as devices. It apparently also didn't help [1] which is surprising to me. I'll dig into that separately. I'll look into fixing this. The annoying part is that some devices have compatible property that's both "simple-bus" and some other string that a driver actually matches with.
Quoted 4 lines
Yes, that is my view of the problem as well.
So perhaps we should do a more fine grained check for when the "simple-bus" compatible is present in the node,
Exactly. Do you want to take a stab at this? There are too many things I want to work on, so if you can do this one, that'd be nice.
Quoted 2 lines
and then don't create
afw_devlinkif we reach an ascendant with only this compatible?
And you can achieve that by setting this flag for that DT node:fwnode->flags |= FWNODE_FLAG_NOT_DEVICE;
-Saravana
Quoted 30 lines · Saravana Kannan
Quoted 28 lines · Ulf Hansson
Quoted 25 lines · Saravana Kannan
Quoted 10 lines · Ulf Hansson
Quoted 7 lines · Saravana Kannan
Devices that are not on a bus will never have a driver bound to it. So,
fw_devlinkshould not create device links for it as it can cause probe issues[1] orsync_state()call back issues[2].[1] - https://lore.kernel.org/lkml/CAGETcx_xJCqOWtwZ9Ee2+0sPGNLM5=F=djtbdYENkAYZa0ynqQ@mail.gmail.com/
[2] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/Quoted 6 lines
Unfortunately, this doesn't fix my problem in [2].
When the "soctest" device is initialized, via
of_platform_populate(), it will be attached to the platform bus, hence the check for the bus pointer that you suggest to add below, doesn't have an impact on my use case. I still get the below in the log:*face palm* Right. I forgot that. I just read "bus" and my mind went to busses added as devices. It apparently also didn't help [1] which is surprising to me. I'll dig into that separately. I'll look into fixing this. The annoying part is that some devices have compatible property that's both "simple-bus" and some other string that a driver actually matches with.
Quoted 7 lines
Quoted 4 lines
Yes, that is my view of the problem as well.
So perhaps we should do a more fine grained check for when the "simple-bus" compatible is present in the node,
Exactly. Do you want to take a stab at this? There are too many things I want to work on, so if you can do this one, that'd be nice.
Nevermind. I already did most of it and it needs a little bit more massaging. I'll send out a patch later.
-Saravana
Quoted 8 lines
Quoted 3 lines
and then don't create
afw_devlinkif we reach an ascendant with only this compatible?And you can achieve that by setting this flag for that DT node:
fwnode->flags|=FWNODE_FLAG_NOT_DEVICE;-Saravana