driver core: export device_is_bound() to fix build failure
PATCH RESEND 1/1 driver core: export device_is_bound() to fix build failure
When CONFIG_MXC_CLK_SCU is configured as 'm' the build fails as it is unable to find device_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!
Export the symbol so that the module finds it.
---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/dd.c +1 -0
@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);static void driver_bound (struct device *dev) {
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerQuoted 21 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells binding support")Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c +0
-0
drivers/base/dd.c bool device_is_bound(struct device *dev) · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL() please, like all the other exports in this file.
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
thanks,
greg k-h
Hi Greg,
Quoted 30 lines · Greg Kroah-Hartman
Quoted 21 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells binding support")Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c +0
-0drivers/base/dd.c bool device_is_bound(struct device *dev) · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.
Quoted 2 lines
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
I have not checked fully but since it is being called from probe() I assume the lock will be held at that time.
This is from linux-next and the original commit is in "for-next" branch of git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git
repo. I came across this problem while doing my daily allmodconfig builds. The build log is at
https://travis-ci.com/github/sudipm-mukherjee/linux-test/jobs/429382451#L24431
Signature · 2 lines
Regards Sudip
Greg Kroah-Hartman
maintainerQuoted 34 lines · Sudip Mukherjee
Hi Greg,
Quoted 30 lines · Greg Kroah-Hartman
Quoted 21 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells binding support")Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c +0
-0drivers/base/dd.c bool device_is_bound(struct device *dev) · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.
Quoted 5 lines
Quoted 2 lines
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe() should never call this function as it makes no sense at all at that point in time. The driver should be fixed.
This function should not be exported, sorry.
thanks,
greg k-h
Hi Greg,
Quoted 40 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 34 lines · Sudip Mukherjee
Hi Greg,
Quoted 30 lines · Greg Kroah-Hartman
Quoted 22 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c bool device_is_bound(struct device *dev) { · line 355
Quoted 3 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.
Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT for a single clock controller node.
That's why we wanted to use device_is_bound() before to check if scu power domain is ready or not to support defer probe.
Regards
Aisheng
Quoted 6 lines
This function should not be exported, sorry.
thanks,
greg k-h
Hi Aisheng,
Quoted 22 lines · Aisheng Dong
Hi Greg,
Quoted 19 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 13 lines · Sudip Mukherjee
Hi Greg,
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
<snip>
Quoted 7 lines
Quoted 3 lines
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
Quoted 6 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT for a single clock controller node.
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.
iiuc, you are waiting for "fsl,scu-pd" to be registered.
I think you might be able to use bus_for_each_dev() to check if the device has registered with the bus or not. It will be on the bus only after bind was successful. The bus will be "platform_bus_type". But I am sure Greg can give you better suggestion than this. :)
Signature · 2 lines
Regards Sudip
Quoted 44 lines
From: Sudip Mukherjee <[email protected]>
Sent: Monday, November 9, 2020 7:19 PMHi Aisheng,
Quoted 22 lines · Aisheng Dong
Hi Greg,
Quoted 19 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 13 lines · Sudip Mukherjee
Hi Greg,
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
<snip>
Quoted 10 lines
Quoted 3 lines
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT
for a single clock controller node.
Quoted 1 line
Quoted 9 lines
Quoted 2 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.iiuc, you are waiting for "fsl,scu-pd" to be registered.
I think you might be able to usebus_for_each_dev()to check if the device has registered with the bus or not. It will be on the bus only after bind was successful. The bus will be "platform_bus_type".
But I am sure Greg can give you better suggestion than this. :)
Thanks for the suggestion. Seems like a working tricky method. :-)
For a possible easier way, I wonder if we can use dev_driver_string() which is already exported in kernel.
Waiting for Greg's suggestions on which way to go.
Regards
Aisheng
Quoted 4 lines
--
Regards
Sudip
Greg Kroah-Hartman
maintainerQuoted 39 lines · Sudip Mukherjee
Hi Aisheng,
Quoted 22 lines · Aisheng Dong
Hi Greg,
Quoted 19 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 13 lines · Sudip Mukherjee
Hi Greg,
Quoted 9 lines · Greg Kroah-Hartman
Quoted 7 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
<snip>
Quoted 11 lines
Quoted 3 lines
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT for a single clock controller node.
Quoted 7 lines
Quoted 2 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.iiuc, you are waiting for "fsl,scu-pd" to be registered.
I think you might be able to usebus_for_each_dev()to check if the device has registered with the bus or not. It will be on the bus only after bind was successful. The bus will be "platform_bus_type".
No, do not do that, again, no individual driver should ever have to do that. Think about what would be involved if _every_ driver started doing this.
Quoted 1 line
But I am sure Greg can give you better suggestion than this. :)
device link :)
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 45 lines · Aisheng Dong
Hi Greg,
Quoted 43 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 37 lines · Sudip Mukherjee
Hi Greg,
Quoted 32 lines · Greg Kroah-Hartman
Quoted 22 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c bool device_is_bound(struct device *dev) { · line 355
Quoted 3 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 6 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT for a single clock controller node.
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.
Use the device link functionality for this type of thing, that is what it was created for.
thanks,
greg k-h
Quoted 64 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 46 lines · Aisheng Dong
Hi Greg,
Quoted 44 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 38 lines · Sudip Mukherjee
Hi Greg,
Quoted 33 lines · Greg Kroah-Hartman
Quoted 22 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c bool device_is_bound(struct device *dev) { · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 3 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT
Quoted 8 lines
for a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Thanks for the suggestion. I will check it how to use.
BTW, I wonder if dev_driver_string() could be an optional solution which seems a more simple way?
Regards
Aisheng
Quoted 3 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 69 lines · Aisheng Dong
Quoted 69 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 46 lines · Aisheng Dong
Hi Greg,
Quoted 44 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 38 lines · Sudip Mukherjee
Hi Greg,
Quoted 33 lines · Greg Kroah-Hartman
Quoted 22 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c bool device_is_bound(struct device *dev) { · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 3 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT
for a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.
Quoted 7 lines
Quoted 3 lines
Use the device link functionality for this type of thing, that is what it was created for.
Thanks for the suggestion. I will check it how to use.
BTW, I wonder ifdev_driver_string()could be an optional solution which seems a more simple way?
No, that's a horrible hack, do not do that, it will not work properly. Fix this correctly.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 69 lines · Aisheng Dong
Quoted 69 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 46 lines · Aisheng Dong
Hi Greg,
Quoted 44 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 38 lines · Sudip Mukherjee
Hi Greg,
Quoted 33 lines · Greg Kroah-Hartman
Quoted 22 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound" [drivers/clk/imx/clk-imx-scu.ko]
undefined!Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by Sudip Mukherjee <[email protected]>---
resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c bool device_is_bound(struct device *dev) { · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) {return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above commit in?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 3 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT
for a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.
Quoted 7 lines
Quoted 3 lines
Use the device link functionality for this type of thing, that is what it was created for.
Thanks for the suggestion. I will check it how to use.
BTW, I wonder ifdev_driver_string()could be an optional solution which seems a more simple way?
Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
thanks,
greg k-h
Quoted 83 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 14 lines · Aisheng Dong
Quoted 14 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 10 lines · Aisheng Dong
Hi Greg,
Quoted 8 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 2 lines · Sudip Mukherjee
Hi Greg,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound"[
drivers/clk/imx/clk-imx-scu.ko]Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
undefined!
Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/base/dd.c bool device_is_bound(struct device *dev)
Quoted 8 lines
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c +0
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev){
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/base/dd.c bool device_is_bound(struct device *dev) · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above
commit in?
Quoted 26 lines
Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
pd_np = of_find_compatible_node(NULL, NULL, "fsl,scu-pd"); pd_dev = of_find_device_by_node(pd_np);
if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||
strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) {
of_node_put(pd_np);
return -EPROBE_DEFER;
}const char *dev_driver_string(const struct device *dev)
{
struct device_driver *drv;
/* dev->driver can change to NULL underneath us because of unbinding,
* so be careful about accessing it. dev->bus and dev->class should
* never change once they are set, so they don't need special care.
*/
drv = READ_ONCE(dev->driver);
return drv ? drv->name :
(dev->bus ? dev->bus->name :
(dev->class ? dev->class->name : ""));
} EXPORT_SYMBOL(dev_driver_string);
Anyway, I will continue to investigate device_link according to your suggestions.
Regards
Aisheng
Quoted 3 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 94 lines · Aisheng Dong
Quoted 83 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 14 lines · Aisheng Dong
Quoted 14 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 10 lines · Aisheng Dong
Hi Greg,
Quoted 8 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureQuoted 2 lines · Sudip Mukherjee
Hi Greg,
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · Sudip Mukherjee
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound"[
drivers/clk/imx/clk-imx-scu.ko]Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
undefined!
Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cells bindingsupport")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/base/dd.c bool device_is_bound(struct device *dev)
Quoted 8 lines
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)drivers/base/dd.c index renamed from drivers/base/dd.c +0
-0
148e81969e04..a796a57e5efb100644drivers/base/dd.c +0
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev){
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/base/dd.c bool device_is_bound(struct device *dev) · line 356
Quoted 4 lines
drivers/base/dd.c +1
-0return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in this file.Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above
commit in?
Quoted 26 lines
Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
Quoted 7 lines
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np);
if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
greg k-h
Hi Greg,
Quoted 112 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:48 PMQuoted 16 lines · Aisheng Dong
Quoted 16 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 12 lines · Aisheng Dong
Quoted 12 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 8 lines · Aisheng Dong
Hi Greg,
Quoted 6 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureOn Mon, Nov 09, 2020 at 10:14:46AM +0000, Sudip Mukherjee
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hi Greg,
Quoted 2 lines · Greg Kroah-Hartman
On Sat, Nov 07, 2020 at 10:47:27PM +0000, Sudip Mukherjee
Quoted 27 lines · wrote:
Quoted 27 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound"[
drivers/clk/imx/clk-imx-scu.ko]Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
undefined!
Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cellsbinding
support")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/base/dd.c bool device_is_bound(struct device · line 353
Quoted 6 lines
drivers/base/dd.c +0
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev){
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/base/dd.c bool device_is_bound(struct device · line 357
Quoted 4 lines
drivers/base/dd.c +1
-0return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in thisfile.
Quoted 42 lines
Quoted 31 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above
commit in?
Quoted 26 lines
Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
Quoted 7 lines
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np); if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }
Quoted 2 lines
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
I tried to understand how to use devlink for this case by diving deep into the devlink code, however, it looked to me there're a few limitations on the current devlink usage. We can't create driver presence dependency link in consumer's probe function while the supplier driver is still not probed or even not created yet.
(we're the later case that supplier device scu-pd may be created after scu-clk device).
The kernel doc Documentation/driver-api/device_link.rst also mentioned this limitation and the suggested solution is:
"The onus is thus on the consumer to check presence of the supplier after adding the link, and defer probing on non-presence."
Then the question is , back again, , how to check the presense of other device driver if we can't use device_is_bound() API in module?
The dev_driver_string() seems be a quick and dirty solution for the this build break issue as the driver name is less possible to be changed and under control.
How would you suggest for current situation?
Regards
Aisheng
Quoted 2 lines
greg k-h
Greg Kroah-Hartman
maintainerQuoted 114 lines · Aisheng Dong
Hi Greg,
Quoted 112 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:48 PMQuoted 16 lines · Aisheng Dong
Quoted 16 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 12 lines · Aisheng Dong
Quoted 12 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 8 lines · Aisheng Dong
Hi Greg,
Quoted 6 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureOn Mon, Nov 09, 2020 at 10:14:46AM +0000, Sudip Mukherjee
Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Hi Greg,
Quoted 2 lines · Greg Kroah-Hartman
On Sat, Nov 07, 2020 at 10:47:27PM +0000, Sudip Mukherjee
Quoted 27 lines · wrote:
Quoted 27 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
When
CONFIG_MXC_CLK_SCUis configured as 'm' the build fails as it is unable to finddevice_is_bound(). The error being:
ERROR: modpost: "device_is_bound"[
drivers/clk/imx/clk-imx-scu.ko]Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
undefined!
Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cellsbinding
support")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/base/dd.c bool device_is_bound(struct device · line 353
Quoted 6 lines
drivers/base/dd.c +0
-0@@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev){
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/base/dd.c bool device_is_bound(struct device · line 357
Quoted 4 lines
drivers/base/dd.c +1
-0return dev->p &&klist_node_attached (&dev->p->knode_driver); } +EXPORT_SYMBOL (device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other exports in thisfile.
Quoted 49 lines
Quoted 31 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, wait, no, don't call this, are you sure you are calling it in a race-free way? And what branch/tree is the above
commit in?
Quoted 26 lines
Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np); if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }
Quoted 5 lines
Quoted 2 lines
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
I tried to understand how to use devlink for this case by diving deep into the devlink code, however, it looked to me there're a few limitations on the current devlink usage.
Adding Saravana, who wrote that code to help explain it.
Quoted 3 lines
We can't create driver presence dependency link in consumer's probe function while the supplier driver is still not probed or even not created yet. (we're the later case that supplier device scu-pd may be created after scu-clk device).
Sounds like your DT is set up backwards?
Quoted 7 lines
The kernel doc
Documentation/driver-api/device_link.rstalso mentioned this limitation and the suggested solution is:
"The onus is thus on the consumer to check presence of the supplier after adding the link, and defer probing on non-presence."Then the question is , back again, , how to check the presense of other device driver if we can't use
device_is_bound()API in module?
Your driver should not care, as you can't get direct access to it, so don't try to ask the driver core about it as that is racy and not viable.
If your driver needs resources that it can not get at this point in time, just return from probe with a defer error. That way it will be called again after other drivers load.
Quoted 2 lines
The
dev_driver_string()seems be a quick and dirty solution for the this build break issue as the driver name is less possible to be changed and under control.
No, driver names are not ever guaranteed to stay the same and are not to be used for this at all, sorry.
Quoted 1 line
How would you suggest for current situation?
defer your probe like all other drivers in this situation do it? What makes this one driver so much different than the thousands of other ones we currently have?
thanks,
greg k-h
Quoted 131 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Wednesday, November 18, 2020 6:46 PMQuoted 34 lines · Aisheng Dong
Hi Greg,
Quoted 32 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:48 PMQuoted 17 lines · Aisheng Dong
Quoted 17 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 13 lines · Aisheng Dong
Quoted 13 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 9 lines · Aisheng Dong
Hi Greg,
Quoted 7 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureOn Mon, Nov 09, 2020 at 10:14:46AM +0000, Sudip Mukherjee
Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Hi Greg,
Quoted 3 lines · Greg Kroah-Hartman
On Sat, Nov 07, 2020 at 10:47:27PM +0000, Sudip
MukherjeeQuoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
When
CONFIG_MXC_CLK_SCUis configured as 'm' the
build fails as it is unable to finddevice_is_bound(). The errorbeing:
Quoted 85 lines
Quoted 85 lines
Quoted 26 lines
Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
ERROR: modpost: "
device_is_bound"[
drivers/clk/imx/clk-imx-scu.ko]Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
undefined!
Export the symbol so that the module finds it.
Fixes 77d8f3068c63 ("clk: imx: scu: add two cellsbinding
support")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
drivers/base/dd.c | 1 + 1 file changed, 1 insertion(+)Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/base/dd.c +0
-0@@ -353,6 +353,7 @@ bool device_is_bound(structdevice
*dev){
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
return dev->p &&
klist_node_attached(&dev->p->knode_driver);
}
+EXPORT_SYMBOL(device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other
exports in thisfile.
Quoted 50 lines
Quoted 32 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, wait, no, don't call this, are you sure you
are calling it in a race-free way? And what
branch/tree is the abovecommit in?
Quoted 27 lines
Quoted 26 lines
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np); if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }Quoted 5 lines
Quoted 2 lines
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
I tried to understand how to use devlink for this case by diving deep into the devlink code, however, it looked to me there're a few limitations on
the current devlink usage.
Quoted 8 lines
Adding Saravana, who wrote that code to help explain it.
Quoted 3 lines
We can't create driver presence dependency link in consumer's probe function while the supplier driver is still not probed or even not created yet. (we're the later case that supplier device scu-pd may be created after scu-clk
device).
Sounds like your DT is set up backwards?
Yes, the dts is like below:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/freescale/imx8qxp.dtsi?h=v5.10-rc4
scu {
compatible = "fsl,imx-scu";
mbox-names = "tx0",
"rx0",
"gip3";
mboxes = <&lsio_mu1 0 0
&lsio_mu1 1 0
&lsio_mu1 3 3>;
clk: clock-controller {
compatible = "fsl,imx8qxp-clk";
#clock-cells = <1>;
clocks = <&xtal32k &xtal24m>;
clock-names = "xtal_32KHz", "xtal_24Mhz";
};
pd: imx8qx-pd {
compatible = "fsl,imx8qxp-scu-pd";
#power-domain-cells = <1>;
};
...Clk and pd devices under scu node are propagated by scu driver in DT order. If moving pd node before clk node can also address this issue.
Quoted 9 lines
Quoted 8 lines
The kernel doc
Documentation/driver-api/device_link.rstalso mentioned this limitation and the suggested solution is:
"The onus is thus on the consumer to check presence of the supplier after adding the link, and defer probing on non-presence."Then the question is , back again, , how to check the presense of other device driver if we can't use
device_is_bound()API in module?
Quoted 7 lines
Your driver should not care, as you can't get direct access to it, so don't try to ask the driver core about it as that is racy and not viable.
If your driver needs resources that it can not get at this point in time, just return from probe with a defer error. That way it will be called again after other drivers load.
Referring to above dts snippet, you can see the problem here is that there're no power domain property in clock-controller node which cause the clock driver unable to use the Normal/standard way to acquire PD resources and return a EPROBE_DEFFER if failed like Other resources, e.g. irq, gpio and etc.
That's the main reason we use device_is_bound() in clock driver to check if PD driver has been probed.
And of_genpd_add_device() we used in scu clk driver does not support EPROBE_DEFER and in order to maintainer the backwards compatibility of imx_clk_scu_alloc_dev() API, We also can't return PROBE_DEFER. All those are special reasons which made things complicated and un-easy to address in standard way.
Maybe the simplest solution is justing move scu pd node above scu clk node which is also make Sense because it can save a huge number of defer probes.
Anyway, thanks for the suggestion and detailed, patient explanation. I could cook a patch to remove device_is_bound() checking code from clk driver and moving scu pd node in dt to address it if no strong objections.
Regards
Aisheng
Quoted 16 lines
Quoted 2 lines
The
dev_driver_string()seems be a quick and dirty solution for the this build break issue as the driver name is less possible to be changed andunder control.
No, driver names are not ever guaranteed to stay the same and are not to be used for this at all, sorry.
Quoted 1 line
How would you suggest for current situation?
defer your probe like all other drivers in this situation do it? What makes this one driver so much different than the thousands of other ones we currently have?
thanks,
greg k-h
Quoted 165 lines · Aisheng Dong
Quoted 132 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Wednesday, November 18, 2020 6:46 PMQuoted 34 lines · Aisheng Dong
Hi Greg,
Quoted 32 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:48 PMQuoted 17 lines · Aisheng Dong
Quoted 17 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 13 lines · Aisheng Dong
Quoted 13 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMQuoted 9 lines · Aisheng Dong
Hi Greg,
Quoted 7 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureOn Mon, Nov 09, 2020 at 10:14:46AM +0000, Sudip Mukherjee
Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Hi Greg,
Quoted 3 lines · Greg Kroah-Hartman
On Sat, Nov 07, 2020 at 10:47:27PM +0000, Sudip
MukherjeeQuoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
When CONFIG_MXC_CLK_SCU is configured as 'm' the
build fails as it is unable to find device_is_bound(). The errorbeing:
Quoted 85 lines
Quoted 85 lines
Quoted 26 lines
Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
ERROR: modpost: "device_is_bound"
[
drivers/clk/imx/clk-imx-scu.ko]Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
undefined!
Export the symbol so that the module finds it.
Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells
binding
support")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
drivers/base/dd.c | 1 +
1 file changed, 1 insertion(+)Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 148e81969e04..a796a57e5efb 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -353,6 +353,7 @@ bool device_is_bound(struct
device
*dev){
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
return dev->p &&
klist_node_attached(&dev->p->knode_driver);
}
+EXPORT_SYMBOL(device_is_bound);
EXPORT_SYMBOL_GPL()please, like all the other
exports in thisfile.
Quoted 50 lines
Quoted 32 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, wait, no, don't call this, are you sure you
are calling it in a race-free way? And what
branch/tree is the abovecommit in?
Quoted 27 lines
Quoted 26 lines
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should be fixed.Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many problems.
Quoted 5 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support defer probe.Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np); if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }Quoted 5 lines
Quoted 2 lines
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
I tried to understand how to use devlink for this case by diving deep into the devlink code, however, it looked to me there're a few limitations on
the current devlink usage.
Quoted 8 lines
Adding Saravana, who wrote that code to help explain it.
Quoted 3 lines
We can't create driver presence dependency link in consumer's probe function while the supplier driver is still not probed or even not created yet. (we're the later case that supplier device scu-pd may be created after scu-clk
device).
Sounds like your DT is set up backwards?
Yes, the dts is like below:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/freescale/imx8qxp.dtsi?h=v5.10-rc4scu { compatible = "fsl,imx-scu"; mbox-names = "tx0", "rx0", "gip3"; mboxes = <&lsio_mu1 0 0 &lsio_mu1 1 0 &lsio_mu1 3 3>; clk: clock-controller { compatible = "fsl,imx8qxp-clk"; #clock-cells = <1>; clocks = <&xtal32k &xtal24m>; clock-names = "xtal_32KHz", "xtal_24Mhz"; }; pd: imx8qx-pd { compatible = "fsl,imx8qxp-scu-pd"; #power-domain-cells = <1>; }; ...
Quoted 2 lines
Clk and pd devices under scu node are propagated by scu driver in DT order. If moving pd node before clk node can also address this issue.
I can bet the DT maintainers are going to NACK a DT node reordering. The ordering of DT nodes should not matter for correctness.
Quoted 13 lines
Quoted 13 lines
Quoted 9 lines
The kernel doc
Documentation/driver-api/device_link.rstalso mentioned this limitation and the suggested solution is:
"The onus is thus on the consumer to check presence of the supplier after adding the link, and defer probing on non-presence."Then the question is , back again, , how to check the presense of other device driver if we can't use
device_is_bound()API in module?Your driver should not care, as you can't get direct access to it, so don't try to ask the driver core about it as that is racy and not viable.
Quoted 8 lines
Quoted 4 lines
If your driver needs resources that it can not get at this point in time, just return from probe with a defer error. That way it will be called again after other drivers load.
Referring to above dts snippet, you can see the problem here is that there're no power domain property in clock-controller node which cause the clock driver unable to use the Normal/standard way to acquire PD resources and return a
EPROBE_DEFFERif failed like
_THIS_ is your main problem. If you add the power domain property,
Quoted 3 lines · your problem would be solved. Earlier in the thread you
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT for a single clock controller node.
But this just seems like an arbitrary position you are taking and then digging yourself into a hole.
Does the clock controller actually depend on the power domain? If it does, then list it in DT. If it doesn't and the real dependency is one of the consumer devices that consume the clock provided by this clock controller, then your clock controller should not be waiting/deferring probe on this power domain. Leave that to the actual device that depends on the power domain.
What are you even achieving by not listing the power domain in the DT node of the clock controller if you are then going to have the clock controller block on the power domain having probed?
Quoted 8 lines
Other resources, e.g. irq, gpio and etc.
That's the main reason we usedevice_is_bound()in clock driver to check if PD driver has been probed.And
of_genpd_add_device()we used in scu clk driver does not supportEPROBE_DEFERand in order to maintainer the backwards compatibility ofimx_clk_scu_alloc_dev()API, We also can't returnPROBE_DEFER. All those are special reasons which made things complicated and un-easy to address in standard way.
This seems to be talking about some out of tree code? So can't really help you without seeing the code. And I don't understand what backward compatibility you are trying to maintain within kernel code. That's not something we try to or need to do. Just fix up the users.
Quoted 2 lines
Maybe the simplest solution is justing move scu pd node above scu clk node which is also make Sense because it can save a huge number of defer probes.
This is 100% going to get rejected upstream. Even if you reorder the DT nodes, there's no guarantee that your power domain device would get probed before the clock driver.
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
-Saravana
Quoted 217 lines
From: Saravana Kannan <[email protected]>
Sent: Thursday, November 19, 2020 6:22 AMQuoted 19 lines · Aisheng Dong
Quoted 19 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Wednesday, November 18, 2020 6:46 PMQuoted 14 lines · Aisheng Dong
Hi Greg,
Quoted 12 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:48 PMQuoted 8 lines · Aisheng Dong
Quoted 8 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 8:05 PMQuoted 4 lines · Aisheng Dong
Quoted 4 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 7:41 PMOn Mon, Nov 09, 2020 at 10:57:05AM +0000, Aisheng Dong
Quoted 62 lines · wrote:
Quoted 62 lines
Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Hi Greg,
Quoted 8 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, November 9, 2020 6:37 PM
Subject: Re: [PATCH RESEND] driver core: exportdevice_is_bound()to fix build failureOn Mon, Nov 09, 2020 at 10:14:46AM +0000, Sudip Mukherjee
Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Hi Greg,
Quoted 1 line · Greg Kroah-Hartman
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
On Sat, Nov 07, 2020 at 10:47:27PM +0000, Sudip
MukherjeeQuoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
When CONFIG_MXC_CLK_SCU is configured as 'm'
the build fails as it is unable to find
device_is_bound(). The errorbeing:
Quoted 39 lines
Quoted 39 lines
Quoted 27 lines
Quoted 27 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
ERROR: modpost: "device_is_bound"
[
drivers/clk/imx/clk-imx-scu.ko]Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
undefined!
Export the symbol so that the module finds it.
Fixes: 77d8f3068c63 ("clk: imx: scu: add two
cells binding
support")
Signed-off-by: Sudip Mukherjee
<[email protected]>
---resending with the Fixes: tag.
drivers/base/dd.c | 1 +
1 file changed, 1 insertion(+)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
diff --git a/drivers/base/dd.c
b/drivers/base/dd.c index
148e81969e04..a796a57e5efb 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -353,6 +353,7 @@ bool
device_is_bound(struct device
*dev){
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
return dev->p &&
klist_node_attached(&dev->p->knode_driver);
}
+EXPORT_SYMBOL(device_is_bound);EXPORT_SYMBOL_GPL() please, like all the other
exports in thisfile.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Also, wait, no, don't call this, are you sure
you are calling it in a race-free way? And what
branch/tree is the aboveQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
commit in?
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
I have not checked fully but since it is being called from
probe()I assume the lock will be held at that time.
probe()should never call this function as it makes no sense at all at that point in time. The driver should befixed.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Would you suggest if any other API we can use to allow the driver to know whether another device has been probed?
There is none, sorry, as that just opens up way too many
problems.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number
(200+) of power domains for each device clock, we can't define them all in DTfor a single clock controller node.
Quoted 3 lines
That's why we wanted to use
device_is_bound()before to check if scu power domain is ready or not to support deferprobe.
Quoted 30 lines
Quoted 30 lines
Quoted 30 lines
Quoted 24 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Use the device link functionality for this type of thing, that is what it was created for.
Quoted 7 lines
Quoted 3 lines
Thanks for the suggestion. I will check it how to use. BTW, I wonder if
dev_driver_string()could be an optional solution which seems a more simple way?Also, how do you really know you even have a valid pointer to that other device structure? How are you getting access to that?
The rough idea is as follows. Not sure if those APIs are safe enough as there're many users In kernel.
Quoted 7 lines
pd_np=of_find_compatible_node(NULL, NULL, "fsl,scu-pd");pd_dev=of_find_device_by_node(pd_np); if (!pd_dev || !dev_driver_string(&pd_dev->dev) ||strcmp(dev_driver_string(&pd_dev->dev), "imx-scu-pd")) { of_node_put(pd_np); return -EPROBE_DEFER; }Quoted 2 lines
Ick, again, no, don't do that, you can not guarantee "names" of devices anywhere in the system, sorry.
I tried to understand how to use devlink for this case by diving deep into the devlink code, however, it looked to me there're a few limitations on
Quoted 6 lines
Quoted 6 lines
the current devlink usage.
Adding Saravana, who wrote that code to help explain it.
Quoted 2 lines
We can't create driver presence dependency link in consumer's probe function while the supplier driver is still not probed or even not
created yet.
Quoted 30 lines
Quoted 5 lines
Quoted 2 lines
(we're the later case that supplier device scu-pd may be created after scu-clk
device).
Sounds like your DT is set up backwards?
Yes, the dts is like below:
scu { compatible = "fsl,imx-scu"; mbox-names = "tx0", "rx0", "gip3"; mboxes = <&lsio_mu1 0 0 &lsio_mu1 1 0 &lsio_mu1 3 3>; clk: clock-controller { compatible = "fsl,imx8qxp-clk"; #clock-cells = <1>; clocks = <&xtal32k &xtal24m>; clock-names = "xtal_32KHz", "xtal_24Mhz"; }; pd: imx8qx-pd { compatible = "fsl,imx8qxp-scu-pd"; #power-domain-cells = <1>; }; ...Quoted 2 lines
Clk and pd devices under scu node are propagated by scu driver in DT order. If moving pd node before clk node can also address this issue.
I can bet the DT maintainers are going to NACK a DT node reordering. The ordering of DT nodes should not matter for correctness.
Quoted 18 lines
Quoted 10 lines
Quoted 9 lines
The kernel doc
Documentation/driver-api/device_link.rstalso mentioned this limitation and the suggested solution is:
"The onus is thus on the consumer to check presence of the supplier after adding the link, and defer probing on non-presence."Then the question is , back again, , how to check the presense of other device driver if we can't use
device_is_bound()API in module?Quoted 7 lines
Your driver should not care, as you can't get direct access to it, so don't try to ask the driver core about it as that is racy and not viable.
If your driver needs resources that it can not get at this point in time, just return from probe with a defer error. That way it will be called again after other drivers load.
Quoted 4 lines
Referring to above dts snippet, you can see the problem here is that there're no power domain property in clock-controller node which cause the clock driver unable to use the Normal/standard way to acquire PD resources and return a
EPROBE_DEFFERif failed like_THIS_ is your main problem. If you add the power domain property, your
Quoted 3 lines · problem would be solved. Earlier in the thread you
For imx scu driver in question, it has a special requirement that it depends on scu power domain driver. However, there're a huge number (200+) of power domains for each device clock, we can't define them all in DT
for a single clock controller node.
Quoted 8 lines
But this just seems like an arbitrary position you are taking and then digging yourself into a hole.
Does the clock controller actually depend on the power domain? If it does, then list it in DT. If it doesn't and the real dependency is one of the consumer devices that consume the clock provided by this clock controller, then your clock controller should not be waiting/deferring probe on this power domain. Leave that to the actual device that depends on the power domain.
It's not that case.
The clocks provided by clock provider depends on a big number of various power domains.
More strictly, the clock-controller node itself (clock protocol) does not depends on power domain. But the sub clocks created by clock protocol driver depends on each resource power domain.
See: imx_clk_scu_alloc_dev()
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/clk/imx/clk-scu.c
That's why we didn't list power domains in clock-controller node.
Quoted 13 lines
What are you even achieving by not listing the power domain in the DT node of the clock controller if you are then going to have the clock controller block on the power domain having probed?
Quoted 8 lines
Other resources, e.g. irq, gpio and etc.
That's the main reason we usedevice_is_bound()in clock driver to check if PD driver has been probed.And
of_genpd_add_device()we used in scu clk driver does not supportEPROBE_DEFERand in order to maintainer the backwards compatibility ofimx_clk_scu_alloc_dev()API, We also can't returnPROBE_DEFER. All those are special reasons which made things complicated and un-easy to
Quoted 6 lines
address in standard way.
This seems to be talking about some out of tree code? So can't really help you without seeing the code. And I don't understand what backward compatibility you are trying to maintain within kernel code. That's not something we try to or need to do. Just fix up the users.
Pls refer to above link for the code.
Quoted 9 lines
Quoted 3 lines
Maybe the simplest solution is justing move scu pd node above scu clk node which is also make Sense because it can save a huge number of defer
probes.
This is 100% going to get rejected upstream. Even if you reorder the DT nodes, there's no guarantee that your power domain device would get probed before the clock driver.
The point here is saving a huge number of defer probes.
We could find a way to ensure power domain driver get probed before clock.
Quoted 10 lines
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
Yes, I understand those are for normal cases. But our case is a bit different and we don't want imx_clk_scu() API return PROBE_DEFER which is unnecessary for a hundred of clocks. Even we want to defer probe, we prefer to defer in imx_clk_scu_init() rather than in imx_clk_scu().
Maybe the things can be simplified as a simple requirement:
How users can make Driver A (CLK) to be probed after Driver B (PD) without explicit firmware function dependency description (e.g. phandle in DT)?
As kernel core does not want to support it, then the left way may be change scu-pd driver Inicall level or provide a private callback to query the readiness.
Regards
Aisheng
Quoted 1 line
-Saravana
Greg Kroah-Hartman
maintainerQuoted 6 lines · Aisheng Dong
Quoted 6 lines
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
Quoted 8 lines
Quoted 4 lines
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
Yes, I understand those are for normal cases. But our case is a bit different and we don't want
imx_clk_scu()API returnPROBE_DEFERwhich is unnecessary for a hundred of clocks. Even we want to defer probe, we prefer to defer inimx_clk_scu_init()rather than inimx_clk_scu().
What is wrong with PROBE_DEFER, that is what it is there for.
Quoted 6 lines
Maybe the things can be simplified as a simple requirement:
How users can make Driver A (CLK) to be probed after Driver B (PD) without explicit firmware function dependency description (e.g. phandle in DT)?As kernel core does not want to support it, then the left way may be change scu-pd driver Inicall level or provide a private callback to query the readiness.
No, do not mess with that, as it totally breaks when things are built as a module.
Rely on the deferred probing, that is what it was designed for, and it should not take very long at all, and it keeps you from having to dig into the driver core in ways that no one else has to.
Please just fix up your DT file (sorry I didn't know ordering wouldn't solve this), and you should be fine.
thanks,
greg k-h
Quoted 15 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Thursday, November 19, 2020 9:10 PMQuoted 11 lines · Aisheng Dong
Quoted 10 lines
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
Quoted 8 lines
Quoted 3 lines
Yes, I understand those are for normal cases. But our case is a bit different and we don't want
imx_clk_scu()API returnPROBE_DEFERwhich is unnecessary for a hundred ofclocks.
Quoted 1 line
Even we want to defer probe, we prefer to defer in
imx_clk_scu_init()ratherthan in
imx_clk_scu().What is wrong with
PROBE_DEFER, that is what it is there for.
Yes, we can use PROBE_DEFER, just not want to defer in imx_clk_scu_init() when creating sub clock devices. Instead, we want to defer at the beginning of clock driver probe which can save tens of defer probes due to the same reasons that PD driver is not ready.
Quoted 4 lines
Quoted 4 lines
Maybe the things can be simplified as a simple requirement:
How users can make Driver A (CLK) to be probed after Driver B (PD) without explicit firmware function dependency description (e.g. phandle in
Quoted 8 lines
DT)?
Quoted 3 lines
As kernel core does not want to support it, then the left way may be change scu-pd driver Inicall level or provide a private callback to query the
readiness.
No, do not mess with that, as it totally breaks when things are built as a module.
Can't this be addressed by proper module dependency? E.g clock module depends on power domain module. Then clock driver can only be loaded after power domain.
Quoted 7 lines
Rely on the deferred probing, that is what it was designed for, and it should not take very long at all, and it keeps you from having to dig into the driver core in ways that no one else has to.
Please just fix up your DT file (sorry I didn't know ordering wouldn't solve this), and you should be fine.
Never mind and thank you for bringing me to the new features of fw_devlink which I believe is good and can help us a lot on boot optimization and driver probes. We may enable it in the future by default.
For the current problem, the difficulty is i don't know how to do it in standard way as we can't add power domains property in clock-controller node.
The reason is described here that clock-controller (SCU clock protocol) itself does not Depends on power domain.
https://www.spinics.net/lists/kernel/msg3742050.html
scu {
compatible = "fsl,imx-scu";
...
clk: clock-controller {
compatible = "fsl,imx8qxp-clk";
#clock-cells = <2>;
clocks = <&xtal32k &xtal24m>;
clock-names = "xtal_32KHz", "xtal_24Mhz";
};
pd: imx8qx-pd {
compatible = "fsl,imx8qxp-scu-pd", "fsl,scu-pd";
#power-domain-cells = <1>;
};
...
}Regards
Aisheng
Quoted 3 lines
thanks,
greg k-h
Greg Kroah-Hartman
maintainerQuoted 19 lines · Aisheng Dong
Quoted 19 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Thursday, November 19, 2020 9:10 PMQuoted 6 lines · Aisheng Dong
Quoted 6 lines
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
Quoted 8 lines
Quoted 4 lines
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
Yes, I understand those are for normal cases. But our case is a bit different and we don't want
imx_clk_scu()API returnPROBE_DEFERwhich is unnecessary for a hundred ofclocks.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Even we want to defer probe, we prefer to defer in
imx_clk_scu_init()ratherthan in
imx_clk_scu().What is wrong with
PROBE_DEFER, that is what it is there for.Yes, we can use
PROBE_DEFER, just not want to defer inimx_clk_scu_init()when creating sub clock devices. Instead, we want to defer at the beginning of clock driver probe which can save tens of defer probes due to the same reasons that PD driver is not ready.
There's nothing wrong with deferring that many times until your proper driver is loaded, what does it cost you to do so?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Maybe the things can be simplified as a simple requirement:
How users can make Driver A (CLK) to be probed after Driver B (PD) without explicit firmware function dependency description (e.g. phandle inDT)?
Quoted 3 lines
As kernel core does not want to support it, then the left way may be change scu-pd driver Inicall level or provide a private callback to query the
Quoted 7 lines
Quoted 4 lines
readiness.
No, do not mess with that, as it totally breaks when things are built as a module.
Can't this be addressed by proper module dependency? E.g clock module depends on power domain module. Then clock driver can only be loaded after power domain.
Sure, if you can do that, make your modules load properly by symbol dependency and all should be fine. Have you done that?
thanks,
greg k-h
Quoted 30 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Thursday, November 19, 2020 10:26 PMQuoted 26 lines · Aisheng Dong
Quoted 25 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Thursday, November 19, 2020 9:10 PMQuoted 11 lines · Aisheng Dong
Quoted 10 lines
Long story short, either
* Don't care about the power domain in your clock driver.
Or,
* List the power domain in the clock controller's DT node and then use the normal APIs to get the power domain. And defer like any other driver if you can't get the power domain.
Quoted 4 lines
Yes, I understand those are for normal cases. But our case is a bit different and we don't want
imx_clk_scu()API returnPROBE_DEFERwhich is unnecessary for a hundred ofclocks.
Quoted 2 lines
Even we want to defer probe, we prefer to defer in
imx_clk_scu_init()ratherthan in
imx_clk_scu().What is wrong with
PROBE_DEFER, that is what it is there for.
Quoted 7 lines
Quoted 3 lines
Yes, we can use
PROBE_DEFER, just not want to defer inimx_clk_scu_init()when creating sub clock devices. Instead, we want to defer at the beginning of clock driver probe which can save tens of deferprobes due to the same reasons that PD driver is not ready.
There's nothing wrong with deferring that many times until your proper driver is loaded, what does it cost you to do so?
One problem is that current imx8qxp-clk driver allows sub clocks register optionally fail. That's also the reason we don't want defer probe during register sub clocks.
static int imx8qxp_clk_probe(struct platform_device *pdev)
{
clks[IMX_LSIO_PWM0_CLK] = imx_clk_scu("pwm0_clk", IMX_SC_R_PWM_0, IMX_SC_PM_CLK_PER, clk_cells);
clks[IMX_LSIO_PWM1_CLK] = imx_clk_scu("pwm1_clk", IMX_SC_R_PWM_1, IMX_SC_PM_CLK_PER, clk_cells)
....
return of_clk_add_hw_provider(ccm_node, imx_scu_of_clk_src_get, imx_scu_clks);
}Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Maybe the things can be simplified as a simple requirement:
How users can make Driver A (CLK) to be probed after Driver B (PD) without explicit firmware function dependency description (e.g. phandle inQuoted 8 lines
Quoted 8 lines
DT)?
Quoted 4 lines
As kernel core does not want to support it, then the left way may be change scu-pd driver Inicall level or provide a private callback to query the
readiness.
No, do not mess with that, as it totally breaks when things are built as a
module.
Quoted 2 lines
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Can't this be addressed by proper module dependency? E.g clock module depends on power domain module. Then clock driver can only be loaded after
power domain.
Sure, if you can do that, make your modules load properly by symbol dependency and all should be fine. Have you done that?
Still no. I planned to do that in another separate patch The rough idea may be:
In PD driver, export an API like:
Bool imx_scu_pd_is_initilized(void);
In SCU clock driver:
If (!imx_scu_pd_is_initialized())
return -EPROBE_DEFER;
BTW I've already sent out a patch to remove the calling of device_is_bound() in order to fix the build break first.
https://patchwork.kernel.org/project/linux-clk/patch/[email protected]/
It's okay to remove it first as DT patch using this code still not merged in mainline.
Regards
Aisheng
Quoted 4 lines
thanks,
greg k-h