soc: imx: gpc: de-register power domains only if initialized
PATCH 1/1 soc: imx: gpc: de-register power domains only if initialized
If power domain information are missing in the device tree, no power domains get initialized. However, imx_gpc_remove tries to remove power domains always in the old DT binding case. Only remove power domains when imx_gpc_probe initialized them in first place.
--- drivers/soc/imx/gpc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/soc/imx/gpc.c +9 -1
@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)static int imx_gpc_remove (struct platform_device *pdev) { +struct device_node *pgc_node;int ret; + pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */ +if (!of_property_read_bool (pdev->dev.of_node,"#power-domain-cells" ) && + !pgc_node) +return 0 ; +/* * If the old DT binding is used the toplevel driver needs to * de-register the power domains */ -if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {of_genpd_del_provider (pdev->dev.of_node); ret =pm_genpd_remove (&imx_gpc_domains[GPC_PGC_DOMAIN_PU ].base);
Signature · 1 line
2.15.1
Quoted 18 lines · Stefan Agner
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>--- drivers/soc/imx/gpc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/soc/imx/gpc.c +0
-0
drivers/soc/imx/gpc.c static int imx_gpc_probe(struct platform_device *pdev) · line 472
Quoted 3 lines
drivers/soc/imx/gpc.c +0
-0@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)static int imx_gpc_remove (struct platform_device *pdev) {
What's the original purpose of imx_gpc_remove?
ARM power domain can't be removed.
And why current imx_gpc_remove only remove domains for old DT but not for new ones?
How about make it un-removable?
e.g.
drivers/soc/imx/gpc.c +6 -25
@@ -454,36 +454,17 @@ static int imx_gpc_probe(struct platform_device *pdev)return 0 ; } -static int imx_gpc_remove (struct platform_device *pdev) -{ -int ret; - -/* -* If the old DT binding is used the toplevel driver needs to -* de-register the power domains -*/ -if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { -of_genpd_del_provider (pdev->dev.of_node); - - ret =pm_genpd_remove (&imx_gpc_domains[GPC_PGC_DOMAIN_PU ].base); -if (ret) -return ret; -imx_pgc_put_clocks (&imx_gpc_domains[GPC_PGC_DOMAIN_PU ]); - - ret =pm_genpd_remove (&imx_gpc_domains[GPC_PGC_DOMAIN_ARM ].base); -if (ret) -return ret; - } - -return 0 ; -} -static struct platform_driver imx_gpc_driver = { .driver = { .name ="imx-gpc" , .of_match_table = imx_gpc_dt_ids, +/* +* We can't forcibly eject devices form power domain, +* so we can't really remove power domains once they +* were added. +*/ + .suppress_bind_attrs = true, }, .probe = imx_gpc_probe, - .remove = imx_gpc_remove, };builtin_platform_driver (imx_gpc_driver)
Regards
Dong Aisheng
Quoted 22 lines
drivers/soc/imx/gpc.c +9
-1+struct device_node *pgc_node;int ret; + pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */ +if (!of_property_read_bool (pdev->dev.of_node,"#power-domain-cells" ) && + !pgc_node) +return 0 ; +/* * If the old DT binding is used the toplevel driver needs to * de-register the power domains */ -if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {of_genpd_del_provider (pdev->dev.of_node); ret =pm_genpd_remove (&imx_gpc_domains[GPC_PGC_DOMAIN_PU ].base);Signature · 1 line
2.15.1
Am Montag, den 08.01.2018, 18:28 +0800 schrieb Dong Aisheng:
Quoted 15 lines · Stefan Agner
Quoted 14 lines
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPCdriver")
Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
?drivers/soc/imx/gpc.c | 10 +++++++++-
?1 file changed, 9 insertions(+), 1 deletion(-)
Quoted 12 lines
Quoted 9 lines
drivers/soc/imx/gpc.c +0
-0@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)?
?static intimx_gpc_remove(struct platform_device *pdev)?{What's the original purpose of
imx_gpc_remove?
ARM power domain can't be removed.
Why? As long as it stays powered on there is not reason why we wouldn't be able to remove the driver.
Quoted 2 lines
And why current
imx_gpc_removeonly remove domains for old DT but not for new ones?
With the new binding the power domains will be removed by the sub- drivers for the domains.
Quoted 2 lines
How about make it un-removable?
e.g.
I don't see why this would be a good idea. Once more device-dependency handling is in place we might need to unbind the power domains when the regulator driver for the domain is unbound. Do you intend to make them non-removable, too?
Regards,
Lucas
Quoted 82 lines
drivers/soc/imx/gpc.c +0
-0@@ -454,36 +454,17 @@ static int imx_gpc_probe(struct platform_device *pdev) ????????return 0; ?}?
drivers/soc/imx/gpc.c +0
-12-static int imx_gpc_remove (struct platform_device *pdev) -{ -???????int ret; - -???????/* -????????* If the old DT binding is used the toplevel driver needs to -????????* de-register the power domains -????????*/ -???????if (!of_get_child_by_name(pdev->dev.of_node, "pgc")) { -???????????????of_genpd_del_provider(pdev->dev.of_node); - -???????????????ret =
pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base); -???????????????if (ret)
-???????????????????????return ret; -???????????????imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU ]);
-
-???????????????ret =pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_ARM].base); -???????????????if (ret)
-???????????????????????return ret;
-???????}drivers/soc/imx/gpc.c +0
-4- -???????return 0; -} -?static struct
platform_driverimx_gpc_driver= { ????????.driver = {
????????????????.name = "imx-gpc", ????????????????.of_match_table =imx_gpc_dt_ids, +????????????????/*
+?????????????????* We can't forcibly eject devices form power domain,
+?????????????????* so we can't really remove power domains once they +?????????????????* were added.
+?????????????????*/
+????????????????.suppress_bind_attrs = true,
????????},
????????.probe =imx_gpc_probe,
-???????.remove =imx_gpc_remove,
?};
?builtin_platform_driver(imx_gpc_driver)Regards
Dong AishengQuoted 26 lines
drivers/soc/imx/gpc.c +1
-0+struct device_node *pgc_node;? int ret;
?drivers/soc/imx/gpc.c +3
-0+ pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */
drivers/soc/imx/gpc.c +1
-0+ if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") &&
drivers/soc/imx/gpc.c +3
-0+ ????!pgc_node) +return 0 ; +? /*
? ?* If the old DT binding is used the toplevel driver needs
to
? ?* de-register the power domains
? ?*/drivers/soc/imx/gpc.c +1
-1-if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {?
of_genpd_del_provider(pdev->dev.of_node);
?
? ret =pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base); --?
2.15.1
Quoted 29 lines · Lucas Stach
Am Montag, den 08.01.2018, 18:28 +0800 schrieb Dong Aisheng:
Quoted 15 lines · Stefan Agner
Quoted 14 lines
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPCdriver")
Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
?drivers/soc/imx/gpc.c | 10 +++++++++-
?1 file changed, 9 insertions(+), 1 deletion(-)Quoted 12 lines
Quoted 9 lines
drivers/soc/imx/gpc.c +0
-0@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)?
?static intimx_gpc_remove(struct platform_device *pdev)?{What's the original purpose of
imx_gpc_remove?
ARM power domain can't be removed.
Quoted 3 lines
Why? As long as it stays powered on there is not reason why we wouldn't be able to remove the driver.
Is it really safe to make assumptions of the hardware state when drivers get removed? At least some drivers disable the hardware on remove (e.g. i.MX SPI driver).
Quoted 6 lines
Quoted 2 lines
And why current
imx_gpc_removeonly remove domains for old DT but not for new ones?With the new binding the power domains will be removed by the sub- drivers for the domains.
Quoted 7 lines
Quoted 2 lines
How about make it un-removable?
e.g.I don't see why this would be a good idea. Once more device-dependency handling is in place we might need to unbind the power domains when the regulator driver for the domain is unbound. Do you intend to make them non-removable, too?
I think it would be preferable to keep the ability to remote the driver.
However, I noticed that even with this fix, with device trees which do use the power domains capabilities (e.g. i.MX6DL) it leads to a stack trace when using DEBUG_TEST_DRIVER_REMOVE=y, see:
https://marc.info/?l=linux-arm-kernel&m=151544599904423&w=4
--
Stefan
Quoted 86 lines
Regards,
LucasQuoted 82 lines
drivers/soc/imx/gpc.c +0
-0@@ -454,36 +454,17 @@ static int imx_gpc_probe(struct platform_device *pdev) ????????return 0; ?}?
drivers/soc/imx/gpc.c +0
-12-static int imx_gpc_remove (struct platform_device *pdev) -{ -???????int ret; - -???????/* -????????* If the old DT binding is used the toplevel driver needs to -????????* de-register the power domains -????????*/ -???????if (!of_get_child_by_name(pdev->dev.of_node, "pgc")) { -???????????????of_genpd_del_provider(pdev->dev.of_node); - -???????????????ret =
pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base); -???????????????if (ret)
-???????????????????????return ret; -???????????????imx_pgc_put_clocks(&imx_gpc_domains[GPC_PGC_DOMAIN_PU ]);
-
-???????????????ret =pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_ARM].base); -???????????????if (ret)
-???????????????????????return ret;
-???????}drivers/soc/imx/gpc.c +0
-4- -???????return 0; -} -?static struct
platform_driverimx_gpc_driver= { ????????.driver = {
????????????????.name = "imx-gpc", ????????????????.of_match_table =imx_gpc_dt_ids, +????????????????/*
+?????????????????* We can't forcibly eject devices form power domain,
+?????????????????* so we can't really remove power domains once they +?????????????????* were added.
+?????????????????*/
+????????????????.suppress_bind_attrs = true,
????????},
????????.probe =imx_gpc_probe,
-???????.remove =imx_gpc_remove,
?};
?builtin_platform_driver(imx_gpc_driver)Regards
Dong AishengQuoted 26 lines
drivers/soc/imx/gpc.c +1
-0+struct device_node *pgc_node;? int ret;
?drivers/soc/imx/gpc.c +3
-0+ pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */
drivers/soc/imx/gpc.c +1
-0+ if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") &&
drivers/soc/imx/gpc.c +3
-0+ ????!pgc_node) +return 0 ; +? /*
? ?* If the old DT binding is used the toplevel driver needs
to
? ?* de-register the power domains
? ?*/drivers/soc/imx/gpc.c +1
-1-if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {?
of_genpd_del_provider(pdev->dev.of_node);
?
? ret =pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base); --?
2.15.1
Am Montag, den 08.01.2018, 22:17 +0100 schrieb Stefan Agner:
Quoted 30 lines · Lucas Stach
Quoted 29 lines
Am Montag, den 08.01.2018, 18:28 +0800 schrieb Dong Aisheng:
Quoted 27 lines · Stefan Agner
Quoted 20 lines
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPCdriver")
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
?drivers/soc/imx/gpc.c | 10 +++++++++-
?1 file changed, 9 insertions(+), 1 deletion(-)drivers/soc/imx/gpc.c +0
-0@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)Quoted 3 lines
?
?static intimx_gpc_remove(struct platform_device *pdev)?{What's the original purpose of
imx_gpc_remove?
ARM power domain can't be removed.
Quoted 7 lines
Quoted 3 lines
Why? As long as it stays powered on there is not reason why we wouldn't be able to remove the driver.
Is it really safe to make assumptions of the hardware state when drivers get removed? At least some drivers disable the hardware on remove (e.g. i.MX SPI driver).
You are completely right that we should do something more sensible on remove. Like making sure the domain is powered on or (preferably for the non ARM domains) unbinding the consumers.
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
And why current
imx_gpc_removeonly remove domains for old DT but not for new ones?With the new binding the power domains will be removed by the sub- drivers for the domains.
Quoted 7 lines
Quoted 2 lines
How about make it un-removable?
e.g.I don't see why this would be a good idea. Once more device-dependency handling is in place we might need to unbind the power domains when the regulator driver for the domain is unbound. Do you intend to make them non-removable, too?
Quoted 6 lines
I think it would be preferable to keep the ability to remote the driver.
However, I noticed that even with this fix, with device trees which do use the power domains capabilities (e.g. i.MX6DL) it leads to a stack trace when using DEBUG_TEST_DRIVER_REMOVE=y, see:
https://marc.info/?l=linux-arm-kernel&m=151544599904423&w=4
Urgh. Yes, we should fix this. This is really missing a device dependency between the core GPC driver and the PM domain drivers. With this dependency in place we can make sure to unbind the domain driver before the core driver goes away.
Regards,
Lucas
Am Sonntag, den 07.01.2018, 14:49 +0100 schrieb Stefan Agner:
Quoted 10 lines
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPCdriver")
Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>
Quoted 36 lines
---
?drivers/soc/imx/gpc.c | 10 +++++++++-
?1 file changed, 9 insertions(+), 1 deletion(-)drivers/soc/imx/gpc.c +0
-0@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)?
?static intimx_gpc_remove(struct platform_device *pdev)?{drivers/soc/imx/gpc.c +1
-0+struct device_node *pgc_node;? int ret;
?drivers/soc/imx/gpc.c +3
-0+ pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */
drivers/soc/imx/gpc.c +1
-0+ if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells") &&
drivers/soc/imx/gpc.c +3
-0+ ????!pgc_node) +return 0 ; +? /*
? ?* If the old DT binding is used the toplevel driver needs
to
? ?* de-register the power domains
? ?*/drivers/soc/imx/gpc.c +1
-1-if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {?
of_genpd_del_provider(pdev->dev.of_node);
?
? ret =pm_genpd_remove(&imx_gpc_domains[GPC_PGC_DOMAIN_PU].base);
Quoted 5 lines · Stefan Agner
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.
Shawn, I think this patch can be merged. The discussion branches a bit off into a second problem, but this patch should be fine.
--
Stefan
Quoted 35 lines
Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>--- drivers/soc/imx/gpc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/soc/imx/gpc.c +9
-1@@ -470,13 +470,21 @@ static int imx_gpc_probe(struct platform_device *pdev)static int imx_gpc_remove (struct platform_device *pdev) { +struct device_node *pgc_node;int ret; + pgc_node =of_get_child_by_name (pdev->dev.of_node,"pgc" ); + +/* bail out if DT too old and doesn't provide the necessary info */ +if (!of_property_read_bool (pdev->dev.of_node,"#power-domain-cells" ) && + !pgc_node) +return 0 ; +/* * If the old DT binding is used the toplevel driver needs to * de-register the power domains */ -if (!of_get_child_by_name (pdev->dev.of_node,"pgc" )) { +if (!pgc_node) {of_genpd_del_provider (pdev->dev.of_node); ret =pm_genpd_remove (&imx_gpc_domains[GPC_PGC_DOMAIN_PU ].base);
Quoted 9 lines · Stefan Agner
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>
Shawn Guo
AppliedQuoted 9 lines · Stefan Agner
If power domain information are missing in the device tree, no power domains get initialized. However,
imx_gpc_removetries to remove power domains always in the old DT binding case. Only remove power domains whenimx_gpc_probeinitialized them in first place.Fixes 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")Cc Lucas Stach <[email protected]>Signed-off-by Stefan Agner <[email protected]>
Applied, thanks.