* [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver
@ 2016-09-15 22:14 Heiko Stuebner
2016-09-15 22:14 ` [PATCH 1/2] soc: rockchip: power-domain: use pm_genpd_remove in error cleanup Heiko Stuebner
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heiko Stuebner @ 2016-09-15 22:14 UTC (permalink / raw)
To: linux-rockchip; +Cc: linux-kernel, tomeu.vizoso, wxt, rjw, Heiko Stuebner
A recent change to generic power-domains revealed that the rockchip
driver cannot safely fail it's probe. Also pm_genpd_init creates a
situation where a probe error leads to the generic power-domains
accessing already freed data.
The reason for us finding this issue (holes in power-domain lists), will
get fixed in the generic power-domains, but the fixes below will only
work after the newly added genpd-removal code got merged.
Therefore I hope to remember to send the two patches below as fix after
4.9-rc1.
Alternatively Rafael could include them into his branch directly.
Heiko Stuebner (1):
soc: rockchip: power-domain: use pm_genpd_remove in error cleanup
Tomeu Vizoso (1):
soc: rockchip: power-domain: Handle errors from
of_genpd_add_provider_onecell
drivers/soc/rockchip/pm_domains.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
--
2.8.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] soc: rockchip: power-domain: use pm_genpd_remove in error cleanup
2016-09-15 22:14 [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
@ 2016-09-15 22:14 ` Heiko Stuebner
2016-09-15 22:14 ` [PATCH 2/2] soc: rockchip: power-domain: Handle errors from of_genpd_add_provider_onecell Heiko Stuebner
2016-11-01 22:50 ` [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
2 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2016-09-15 22:14 UTC (permalink / raw)
To: linux-rockchip; +Cc: linux-kernel, tomeu.vizoso, wxt, rjw, Heiko Stuebner
The newly introduced pm_genpd_remove reverts the initialization done
by pm_genpd_init and is necessary in the error path of the rockchip
power-domain driver.
Without it the driver will in the error case cleanup the devm-allocated
structures including the elements referenced in the gpd_list thus making
deactivation of unused domains (and probably later genpd accesses as
well) fail by accessing invalid pointers.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/soc/rockchip/pm_domains.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
index 7acd151..241df213 100644
--- a/drivers/soc/rockchip/pm_domains.c
+++ b/drivers/soc/rockchip/pm_domains.c
@@ -445,7 +445,16 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd)
{
- int i;
+ int i, ret;
+
+ /*
+ * We're in the error cleanup already, so we only complain,
+ * but won't emit another error on top of the original one.
+ */
+ ret = pm_genpd_remove(&pd->genpd);
+ if (ret < 0)
+ dev_err(pd->pmu->dev, "failed to remove domain '%s' : %d - state may be inconsistent\n",
+ pd->genpd.name, ret);
for (i = 0; i < pd->num_clks; i++) {
clk_unprepare(pd->clks[i]);
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] soc: rockchip: power-domain: Handle errors from of_genpd_add_provider_onecell
2016-09-15 22:14 [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
2016-09-15 22:14 ` [PATCH 1/2] soc: rockchip: power-domain: use pm_genpd_remove in error cleanup Heiko Stuebner
@ 2016-09-15 22:14 ` Heiko Stuebner
2016-11-01 22:50 ` [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
2 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2016-09-15 22:14 UTC (permalink / raw)
To: linux-rockchip; +Cc: linux-kernel, tomeu.vizoso, wxt, rjw, Heiko Stuebner
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
It was a bit surprising that the device was reported to have probed just
fine, but the provider hadn't been registered.
So handle any errors when registering the provider and fail the probe
accordingly.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
unchanged from Tomeu's single-patch
drivers/soc/rockchip/pm_domains.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/rockchip/pm_domains.c b/drivers/soc/rockchip/pm_domains.c
index 241df213..2fd0c89 100644
--- a/drivers/soc/rockchip/pm_domains.c
+++ b/drivers/soc/rockchip/pm_domains.c
@@ -636,7 +636,11 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
goto err_out;
}
- of_genpd_add_provider_onecell(np, &pmu->genpd_data);
+ error = of_genpd_add_provider_onecell(np, &pmu->genpd_data);
+ if (error) {
+ dev_err(dev, "failed to add provider: %d\n", error);
+ goto err_out;
+ }
return 0;
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver
2016-09-15 22:14 [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
2016-09-15 22:14 ` [PATCH 1/2] soc: rockchip: power-domain: use pm_genpd_remove in error cleanup Heiko Stuebner
2016-09-15 22:14 ` [PATCH 2/2] soc: rockchip: power-domain: Handle errors from of_genpd_add_provider_onecell Heiko Stuebner
@ 2016-11-01 22:50 ` Heiko Stuebner
2 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2016-11-01 22:50 UTC (permalink / raw)
To: linux-rockchip; +Cc: linux-kernel, tomeu.vizoso, wxt, rjw
Am Freitag, 16. September 2016, 00:14:37 CET schrieb Heiko Stuebner:
> A recent change to generic power-domains revealed that the rockchip
> driver cannot safely fail it's probe. Also pm_genpd_init creates a
> situation where a probe error leads to the generic power-domains
> accessing already freed data.
>
> The reason for us finding this issue (holes in power-domain lists), will
> get fixed in the generic power-domains, but the fixes below will only
> work after the newly added genpd-removal code got merged.
>
>
> Therefore I hope to remember to send the two patches below as fix after
> 4.9-rc1.
>
> Alternatively Rafael could include them into his branch directly.
I've applied now both in a fixes branch for 4.9 and plan on sending it through
arm-soc later this week.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-01 22:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 22:14 [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
2016-09-15 22:14 ` [PATCH 1/2] soc: rockchip: power-domain: use pm_genpd_remove in error cleanup Heiko Stuebner
2016-09-15 22:14 ` [PATCH 2/2] soc: rockchip: power-domain: Handle errors from of_genpd_add_provider_onecell Heiko Stuebner
2016-11-01 22:50 ` [PATCH 0/2] soc: rockchip: fix probe error path in power-domain driver Heiko Stuebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).