PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain
Subsystems (4)
PATCH v2 1/1 PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain
When a device is probed, the function dev_pm_domain_attach() is called to see if there is a power-domain that is associated with the device and needs to be turned on. If dev_pm_domain_attach() does not return -EPROBE_DEFER then the device will be probed.
For devices using genpd, dev_pm_domain_attach() will call genpd_dev_pm_attach(). If genpd_dev_pm_attach() does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, if genpd_dev_pm_attach() does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore, genpd_dev_pm_attach() does not check the error code returned by pm_genpd_poweron() to see if the power-domain was turned on successfully.
Fix this by checking the return code from pm_genpd_poweron() and returning -EPROBE_DEFER from genpd_dev_pm_attach on failure, if there is a power-domain associated with the device.
---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.
drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/base/power/domain.c +9 -5
@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or +* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {
@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ; }dev_dbg (dev,"adding to PM domain %s\n" , pd->name);
@@ -2002,14 +2005,15 @@ int genpd_dev_pm_attach(struct device *dev)dev_err (dev,"failed to add to PM domain %s: %d" , pd->name, ret);of_node_put (dev->of_node); - return ret; + goto out; } dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; -pm_genpd_poweron (pd); + ret =pm_genpd_poweron (pd); -return 0 ; +out: +return ret ? -EPROBE_DEFER :0 ; }EXPORT_SYMBOL_GPL (genpd_dev_pm_attach);#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
Signature · 1 line
2.1.4
Rafael J. Wysocki
AppliedQuoted 15 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifgenpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.
Quoted 7 lines
Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>
Queued up for 4.3, thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Hi Jon,
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 9 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, if
Your patch description doesn't say this behavior was changed...
Quoted 25 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0
drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or
... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;
And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
Thanks!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 11 lines · Geert Uytterhoeven
Hi Jon,
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.
Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.
... does the above not state the behaviour was changed?
Quoted 38 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
Quoted 7 lines
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable PM_GENERIC_DOMAINS in the config in that case?
Quoted 8 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Cheers Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Hi Jon,
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.
Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?
Because it may be enabled for another platform in multi-platform kernels.
Quoted 6 lines
Quoted 6 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Quoted 7 lines
Quoted 2 lines
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 99 lines · Geert Uytterhoeven
Hi Jon,
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 6 lines
Quoted 6 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Quoted 7 lines
Quoted 2 lines
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Well, should I drop the patch, then?
Rafael
Quoted 100 lines · Rafael J. Wysocki
Quoted 99 lines · Geert Uytterhoeven
Hi Jon,
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 13 lines
Quoted 8 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 6 lines
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Well, should I drop the patch, then?
Although I respect Geert's opinion, I am still not convinced that we should drop this because of the scenario that Geert is describing.
IMO, the scenario would only impact early development and usually you may need to hack the kernel a bit to get things up a running initially anyway. Furthermore, I don't think that the kernel should make any assumptions about what a bootloader may or may not do.
I think that it is best for the kernel to behave as we would want in a production environment and that is if the device has associated power-domains then we should defer the probe until the gpd provider is available.
Cheers
Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Quoted 117 lines · Jon Hunter
Quoted 100 lines · Rafael J. Wysocki
Quoted 99 lines · Geert Uytterhoeven
Hi Jon,
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 13 lines
Quoted 8 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 6 lines
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Well, should I drop the patch, then?
Although I respect Geert's opinion, I am still not convinced that we should drop this because of the scenario that Geert is describing.
IMO, the scenario would only impact early development and usually you may need to hack the kernel a bit to get things up a running initially anyway. Furthermore, I don't think that the kernel should make any assumptions about what a bootloader may or may not do.
Quoted 4 lines
I think that it is best for the kernel to behave as we would want in a production environment and that is if the device has associated power-domains then we should defer the probe until the gpd provider is available.
Furthermore, without this change, it means I need to ensure that the gpd provider(s) is always probed before any device that is dependent upon that provider (ie. faff with initcalls). Otherwise a device can be probed before the provider and potentially crash/hang the system when accessing the hardware. That's the real problem I am trying to solve here. Sorry if that was not clear.
Cheers
Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Hi Jon,
Quoted 100 lines · Jon Hunter
Quoted 99 lines · Jon Hunter
Quoted 98 lines · Rafael J. Wysocki
Quoted 97 lines · Geert Uytterhoeven
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 13 lines
Quoted 8 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Well, should I drop the patch, then?
No, I wouldn't drop the whole patch.
Quoted 13 lines
Quoted 8 lines
Although I respect Geert's opinion, I am still not convinced that we should drop this because of the scenario that Geert is describing.
IMO, the scenario would only impact early development and usually you may need to hack the kernel a bit to get things up a running initially anyway. Furthermore, I don't think that the kernel should make any assumptions about what a bootloader may or may not do.
Quoted 4 lines
I think that it is best for the kernel to behave as we would want in a production environment and that is if the device has associated power-domains then we should defer the probe until the gpd provider is available.
Quoted 6 lines
Furthermore, without this change, it means I need to ensure that the gpd provider(s) is always probed before any device that is dependent upon that provider (ie. faff with initcalls). Otherwise a device can be probed before the provider and potentially crash/hang the system when accessing the hardware. That's the real problem I am trying to solve here. Sorry if that was not clear.
I had already realized your probe order issue before.
On Renesas SoCs, we have to initialize the PM Domain very early, as even critical infrastructure can be part of a power or clock domain. And as these days most critical infrastructure is initialized from some OF_DECLARE() variant (which doesn't support retry on EPROBE_DEFER!), we don't have much of a choice...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 132 lines · Geert Uytterhoeven
Hi Jon,
Quoted 100 lines · Jon Hunter
Quoted 99 lines · Jon Hunter
Quoted 98 lines · Rafael J. Wysocki
Quoted 97 lines · Geert Uytterhoeven
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 13 lines
Quoted 8 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
Well, should I drop the patch, then?
No, I wouldn't drop the whole patch.
Quoted 13 lines
Quoted 8 lines
Although I respect Geert's opinion, I am still not convinced that we should drop this because of the scenario that Geert is describing.
IMO, the scenario would only impact early development and usually you may need to hack the kernel a bit to get things up a running initially anyway. Furthermore, I don't think that the kernel should make any assumptions about what a bootloader may or may not do.
Quoted 4 lines
I think that it is best for the kernel to behave as we would want in a production environment and that is if the device has associated power-domains then we should defer the probe until the gpd provider is available.
Quoted 6 lines
Furthermore, without this change, it means I need to ensure that the gpd provider(s) is always probed before any device that is dependent upon that provider (ie. faff with initcalls). Otherwise a device can be probed before the provider and potentially crash/hang the system when accessing the hardware. That's the real problem I am trying to solve here. Sorry if that was not clear.
Quoted 7 lines
I had already realized your probe order issue before.
On Renesas SoCs, we have to initialize the PM Domain very early, as even critical infrastructure can be part of a power or clock domain. And as these days most critical infrastructure is initialized from some
OF_DECLARE()variant (which doesn't support retry onEPROBE_DEFER!), we don't have much of a choice...
So from an SoC power-domain perspective I can think of at least 4 types/classes ...
1. Always-on (never turns off)
2. CPU domain
3. Core domain(s) (must be on for memory accesses and CPUs to operate)
4. Peripheral domains (various power-domains for various devices)
For tegra, certain power-domains, particularly those in the peripheral space, are dependent on the regulator framework and we cannot make any assumptions about them. Don't get me wrong the "core" and "cpu" domains are also dependent on regulators as well for things like frequency scaling and low-power modes. However, we know that the "core" and "cpu" has to be on otherwise we would not be running.
These peripheral domains cannot be registered early because they need the regulator framework. So I don't think OF_DECLARE() will work for all devices.
It still sounds to me that the nodes should be disabled/removed from the dtb. Having a dynamic way to do this would be useful, I can see.
Cheers
Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Hi Jon,
On Thu, Aug 6, 2015 at 11:26 AM, Jon Hunter <[email protected]> wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
[...]
Quoted 2 lines
It still sounds to me that the nodes should be disabled/removed from the dtb. Having a dynamic way to do this would be useful, I can see.
I had a quick look, and it already seem to exist..
Hence on platforms not implementing power controllers yet, the early platform code could do:
struct device_node *np;
for_each_node_with_property(dn, "power-domains")
of_remove_property(np, "power-domains");Haven't tested that yet, though...
Heck, even the core power domain code could do that, if CONFIG_PM_GENERIC_DOMAINS=n ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 23 lines · Geert Uytterhoeven
Hi Jon,
On Thu, Aug 6, 2015 at 11:26 AM, Jon Hunter <[email protected]> wrote:
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
[...]
Quoted 2 lines
It still sounds to me that the nodes should be disabled/removed from the dtb. Having a dynamic way to do this would be useful, I can see.
I had a quick look, and it already seem to exist..
Hence on platforms not implementing power controllers yet, the early platform code could do:
Quoted 5 lines
struct device_node *np; for_each_node_with_property(dn, "power-domains") of_remove_property(np, "power-domains");Haven't tested that yet, though...
Yes that could be an option, however, it would mean doing this type of thing for various types of nodes. You mentioned dma was another case.
Quoted 2 lines
Heck, even the core power domain code could do that, if
CONFIG_PM_GENERIC_DOMAINS=n;-)
Yes that's true. Hopefully it would WARN too ;-)
Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Quoted 7 lines · Jon Hunter
Quoted 7 lines
Quoted 2 lines
It still sounds to me that the nodes should be disabled/removed from the dtb. Having a dynamic way to do this would be useful, I can see.
I had a quick look, and it already seem to exist..
Hence on platforms not implementing power controllers yet, the early platform code could do:
Quoted 8 lines
Quoted 5 lines
struct device_node *np; for_each_node_with_property(dn, "power-domains") of_remove_property(np, "power-domains");Haven't tested that yet, though...
Yes that could be an option, however, it would mean doing this type of thing for various types of nodes. You mentioned dma was another case.
DMA is different, as many drivers can fall back to PIO if the DMA engine driver is mssing (not implemented/not enabled/module not loaded).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
Quoted 99 lines · Geert Uytterhoeven
Hi Jon,
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 6 lines
Quoted 6 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Quoted 7 lines
Quoted 2 lines
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
I understand the desire to have the device-tree completely populated even before the drivers are in place. However, may be that is not practical.
Seems to me that we need to be able to remove particular nodes. I know that the u-boot fdt command can remove nodes. It would be nice if we could do this at compile time via the dts file (assuming that the dtsi file specifies the device nodes with the dma/power-domain nodes). In other words, have a keyword like "remove-property = dmas" that could be appended to a device node in the dts file. Just a thought.
Cheers Jon
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Hi Jon,
Quoted 106 lines · Jon Hunter
Quoted 97 lines · Geert Uytterhoeven
Quoted 74 lines · Jon Hunter
Quoted 9 lines · Geert Uytterhoeven
Now this ended up in pm/linux-next, I gave it a try, also with a special test case.
Quoted 5 lines · Jon Hunter
When a device is probed, the function
dev_pm_domain_attach()is called to see if there is a power-domain that is associated with the device and needs to be turned on. Ifdev_pm_domain_attach()does not return -EPROBE_DEFER then the device will be probed.Quoted 6 lines
Quoted 4 lines
For devices using genpd,
dev_pm_domain_attach()will callgenpd_dev_pm_attach(). Ifgenpd_dev_pm_attach()does not find a power domain associated with the device then it returns an error code not equal to -EPROBE_DEFER to allow the device to be probed. However, ifYour patch description doesn't say this behavior was changed...
Sorry if this was not clear, but ...
Quoted 9 lines
Quoted 9 lines
genpd_dev_pm_attach()does find a power-domain that is associated with the device, then it does not return -EPROBE_DEFER on failure and hence the device will still be probed. Furthermore,genpd_dev_pm_attach()does not check the error code returned bypm_genpd_poweron()to see if the power-domain was turned on successfully.Fix this by checking the return code from
pm_genpd_poweron()and returning -EPROBE_DEFER fromgenpd_dev_pm_attachon failure, if there is a power-domain associated with the device.... does the above not state the behaviour was changed?
Quoted 43 lines
Quoted 15 lines
Signed-off-by Jon Hunter <[email protected]>Acked-by Ulf Hansson <[email protected]>Acked-by Kevin Hilman <[email protected]>---
V2 changes:
- Updated description per Kevin's feedback and added Kevin's ACK.drivers/base/power/domain.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/base/power/domain.c +0
-0drivers/base/power/domain.c static void genpd_dev_pm_sync(struct device *dev) · line 1951
Quoted 6 lines
drivers/base/power/domain.c +2
-1@@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)* Both generic and legacy Samsung-specific DT bindings are supported to keep * backwards compatibility with existing DTBs. * -* Returns 0 on successfully attached PM domain or negative error code. +* Returns 0 on successfully attached PM domain or negative error code. Note +* that if a power-domain exists for the device, but it cannot be found or ... but here it does.
drivers/base/power/domain.c int genpd_dev_pm_attach(struct device *dev) · line 1990
Quoted 11 lines
drivers/base/power/domain.c +3
-1+* turned on, then return -EPROBE_DEFER to ensure that the device is not +* probed and to re-try again later. */ int genpd_dev_pm_attach (struct device *dev) {@@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)dev_dbg (dev,"%s() failed to find PM domain: %ld\n" , __func__,PTR_ERR (pd));of_node_put (dev->of_node); -return PTR_ERR (pd); +return -EPROBE_DEFER ;And it really does.
This causes a regression for platforms where:
1. DT describes the hardware power domains, and
2. The boot loader or reset state has enabled all power domains, and
3. Linux doesn't have a driver for the power controller yet.Quoted 5 lines
Quoted 2 lines
Before, devices for which the PM domain couldn't be found just probed and worked, Now, these devices don't probe anymore, and the kernel fails to boot.
I see. Sounds like a chicken or the egg scenario. Why not just disable
PM_GENERIC_DOMAINSin the config in that case?Because it may be enabled for another platform in multi-platform kernels.
Quoted 6 lines
Quoted 6 lines
Note that I only managed to trigger this by explicitly disabling my power controller driver (the platforms I'm interested in already have power controller drivers). But I think it will hamper bring-up of new boards, as you can no longer write a "perfect and stable" .dts first, and implement kernel support incrementally.
Quoted 7 lines
Quoted 2 lines
Hence I think it's worthwhile to revert just this hunk. If you agree, I can send a patch.
But what about the case where we do have device that does have a power controller driver? Don't we want to defer in case it has not been probed yet? I am concerned we could try to probe a device before the power controller has been probed.
Quoted 4 lines
That's indeed an issue.
There's a similar problem with "dmas" properties and the (non)presence of the DMA controller.
I understand the desire to have the device-tree completely populated even before the drivers are in place. However, may be that is not practical.
Quoted 6 lines
Seems to me that we need to be able to remove particular nodes. I know that the u-boot fdt command can remove nodes. It would be nice if we could do this at compile time via the dts file (assuming that the dtsi file specifies the device nodes with the dma/power-domain nodes). In other words, have a keyword like "remove-property = dmas" that could be appended to a device node in the dts file. Just a thought.
Whether the DMA controller is available or not depends on kernel config. A distro kernel may lack support for the DMA controller, or has it as a loadable module.
Hence U-boot cannot know, and should not remove "dmas" properties.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds