Error and deferred probe fixes to Rockchip PM domain driver
Subsystems (3)
cover Error and deferred probe fixes to Rockchip PM domain driver
These issues were found after I upgraded a RK3528 board to v7.3 kernel. Here's a configuration that I used to reproduce both of these two problems[1].
Thanks for your time and review.
[1]: https://gist.github.com/ziyao233/a5ee8862d1baf21ad756cf4e959e14c3
Yao Zi (2):
pmdomain: rockchip: Only put clocks that have been successfully
obtained
pmdomain: rockchip: Don't log when of_clk_get() fails with
-EPROBE_DEFER
drivers/pmdomain/rockchip/pm-domains.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
Signature · 7 lines
2.56.0 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH 1/2 pmdomain: rockchip: Only put clocks that have been successfully obtained
Since pd->num_clks represents the number of clocks described in devicetree, invoking clk_bulk_put() with it will put invalid pointers when some clocks cannot be obtained, triggering a warning in CCF like,
WARNING: drivers/clk/clk.c:4844 at __clk_put+0xf8/0x12c, CPU#0: swapper/0/1
Call trace:
__clk_put+0xf8/0x12c (P)
clk_put+0x10/0x20
clk_bulk_put+0x38/0x60
rockchip_pm_add_one_domain+0x2b0/0x468
rockchip_pm_domain_probe+0xd4/0x2f0
platform_probe+0x80/0xac
...Invoke clk_bulk_put() with the counter used in the loop of obtaining clocks instead.
--- drivers/pmdomain/rockchip/pm-domains.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/rockchip/pm-domains.c +1 -1
@@ -931,7 +931,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, err_unprepare_clocks:clk_bulk_unprepare (pd->num_clks, pd->clks); err_put_clocks: -clk_bulk_put (pd->num_clks, pd->clks); +clk_bulk_put (i, pd->clks);return error; }
Signature · 7 lines
2.56.0 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH 2/2 pmdomain: rockchip: Don't log when of_clk_get() fails with -EPROBE_DEFER
In reply to Yao ZiCurrent error handling code considers -EPROBE_DEFER as hard errors, logs misleading dmesg like,
rockchip-pm-domain ff600000.power-management:power-controller: power-domain: failed to get clk at index 0: -517 rockchip-pm-domain ff600000.power-management:power-controller: failed to handle node power-domain: -517
Use dev_err_probe() at the callsite of of_clk_get(), and check for -EPROBE_DEFER in places where its return value could propagate to.
--- drivers/pmdomain/rockchip/pm-domains.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/pmdomain/rockchip/pm-domains.c +13 -9
@@ -851,9 +851,9 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, pd->clks[i].clk =of_clk_get (node, i);if (IS_ERR (pd->clks[i].clk)) { error =PTR_ERR (pd->clks[i].clk); -dev_err (pmu->dev, -"%pOFn: failed to get clk at index %d: %d\n" , - node, i, error); +dev_err_probe (pmu->dev, error, +"%pOFn: failed to get clk at index %d: %d\n" , + node, i, error); goto err_put_clocks; } }
@@ -1006,8 +1006,10 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, error =rockchip_pm_add_one_domain (pmu, np);if (error) { -dev_err (pmu->dev,"failed to handle node %pOFn: %d\n" , - np, error); +if (error != -EPROBE_DEFER ) +dev_err (pmu->dev, +"failed to handle node %pOFn: %d\n" , + np, error);return error; }
@@ -1102,15 +1104,17 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)for_each_available_child_of_node_scoped (np, node) { error =rockchip_pm_add_one_domain (pmu, node);if (error) { -dev_err (dev,"failed to handle node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle node %pOFn: %d\n" , + node, error); goto err_out; } error =rockchip_pm_add_subdomain (pmu, node);if (error <0 ) { -dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , + node, error); goto err_out; } }
Signature · 7 lines
2.56.0 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Re: [PATCH 2/2] pmdomain: rockchip: Don't log when of_clk_get() fails with -EPROBE_DEFER
Hello!
Please consider using --no-git-fallback with scripts/get_maintainer.pl --
I don't see what do I have to do with this patch (other than fixing another bug in this driver earlier).
Quoted 9 lines · Yao Zi
Current error handling code considers -EPROBE_DEFER as hard errors, logs misleading dmesg like,
rockchip-pm-domain ff600000.power-management:power-controller: power-domain: failed to get clk at index 0: -517 rockchip-pm-domain ff600000.power-management:power-controller: failed to handle node power-domain: -517
Use
dev_err_probe()at the callsite ofof_clk_get(),and check for -EPROBE_DEFER in places> where its return value could propagate to.
To where?
And I didn't understand why you couldn't just call dev_err_probe() everywhere --
the error code seems to always be propagated...
drivers/pmdomain/rockchip/pm-domains.c
Quoted 12 lines
Fixes 7c696693a4f5 ("soc: rockchip: power-domain: Add power domain driver")Fixes 6be05b5ec161 ("soc: rockchip: power-domain: add support for sub-power domains")Signed-off-by Yao Zi <[email protected]>--- drivers/pmdomain/rockchip/pm-domains.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/pmdomain/rockchip/pm-domains.c +0
-0
[...]> @@ -1006,8 +1006,10 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
drivers/pmdomain/rockchip/pm-domains.c static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, · line 1009
Quoted 6 lines
error = rockchip_pm_add_one_domain(pmu, np); if (error) {drivers/pmdomain/rockchip/pm-domains.c +1
-2-dev_err (pmu->dev,"failed to handle node %pOFn: %d\n" , - np, error); +if (error != -EPROBE_DEFER )
Why not just call dev_err_probe() instead?
Quoted 18 lines
drivers/pmdomain/rockchip/pm-domains.c +6
-2+dev_err (pmu->dev, +"failed to handle node %pOFn: %d\n" , + np, error);return error; }@@ -1102,15 +1104,17 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)for_each_available_child_of_node_scoped (np, node) { error =rockchip_pm_add_one_domain (pmu, node);if (error) { -dev_err (dev,"failed to handle node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle node %pOFn: %d\n" , + node, error); goto err_out; }
drivers/pmdomain/rockchip/pm-domains.c static int rockchip_pm_domain_probe(struct platform_device *pdev) · line 1120
Quoted 10 lines
drivers/pmdomain/rockchip/pm-domains.c +3
-2error =rockchip_pm_add_subdomain (pmu, node);if (error <0 ) { -dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , + node, error); goto err_out; } }
[...]
MBR, Sergey
Re: [PATCH 2/2] pmdomain: rockchip: Don't log when of_clk_get() fails with -EPROBE_DEFER
Quoted 5 lines · Sergey Shtylyov
Hello!
Please consider using --no-git-fallback with scripts/get_maintainer.pl --I don't see what do I have to do with this patch (other than fixing another bug in this driver earlier).
Thanks for the reminder, I usually enable it but forgot it this time, sorry for disturbing...
Quoted 5 lines · Yao Zi
Quoted 4 lines
Current error handling code considers -EPROBE_DEFER as hard errors, logs misleading dmesg like,
Quoted 8 lines
Quoted 6 lines
rockchip-pm-domain ff600000.power-management:power-controller: power-domain: failed to get clk at index 0: -517 rockchip-pm-domain ff600000.power-management:power-controller: failed to handle node power-domain: -517
Use
dev_err_probe()at the callsite ofof_clk_get(),and check for -EPROBE_DEFER in places> where its return value could propagate to.
To where?
rockchip_pm_add_one_domain, rockchip_pm_add_subdomain, and rockchip_pm_domain_probe. I think it's obvious in the diff and too detailed to the commit message, so didn't add them here.
Quoted 2 lines
And I didn't understand why you couldn't just call
dev_err_probe()everywhere --
the error code seems to always be propagated...
This was what I originally wanted to do, but dev_err_probe() sets the deferred probe reason, and if we call it several times, the earlier and more specific messagess ("failed to get clk at index %d") get overridden by the later and less descriptive ones ("failed to handle subdomain node %pOFn"), which I think would make it harder to debug.
Quoted 52 lines
drivers/pmdomain/rockchip/pm-domains.c
Quoted 12 lines
Fixes 7c696693a4f5 ("soc: rockchip: power-domain: Add power domain driver")Fixes 6be05b5ec161 ("soc: rockchip: power-domain: add support for sub-power domains")Signed-off-by Yao Zi <[email protected]>--- drivers/pmdomain/rockchip/pm-domains.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/pmdomain/rockchip/pm-domains.c +0
-0[...]> @@ -1006,8 +1006,10 @@ static int rockchip_pm_add_subdomain(struct
rockchip_pmu*pmu,drivers/pmdomain/rockchip/pm-domains.c static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, · line 1009
Quoted 6 lines
error = rockchip_pm_add_one_domain(pmu, np); if (error) {drivers/pmdomain/rockchip/pm-domains.c +1
-2-dev_err (pmu->dev,"failed to handle node %pOFn: %d\n" , - np, error); +if (error != -EPROBE_DEFER )Why not just call
dev_err_probe()instead?Quoted 28 lines
drivers/pmdomain/rockchip/pm-domains.c +9
-4+dev_err (pmu->dev, +"failed to handle node %pOFn: %d\n" , + np, error);return error; }@@ -1102,15 +1104,17 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)for_each_available_child_of_node_scoped (np, node) { error =rockchip_pm_add_one_domain (pmu, node);if (error) { -dev_err (dev,"failed to handle node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle node %pOFn: %d\n" , + node, error); goto err_out; } error =rockchip_pm_add_subdomain (pmu, node);if (error <0 ) { -dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , - node, error); +if (error != -EPROBE_DEFER ) +dev_err (dev,"failed to handle subdomain node %pOFn: %d\n" , + node, error); goto err_out; } }[...]
Quoted 2 lines
MBR, Sergey
Regards,
Yao Zi
Re: [PATCH 2/2] pmdomain: rockchip: Don't log when of_clk_get() fails with -EPROBE_DEFER
On 11/6/26 11:50 AM, Yao Zi wrote:
[...]
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Current error handling code considers -EPROBE_DEFER as hard errors, logs misleading dmesg like,
rockchip-pm-domain ff600000.power-management:power-controller: power-domain: failed to get clk at index 0: -517 rockchip-pm-domain ff600000.power-management:power-controller: failed to handle node power-domain: -517
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Use
dev_err_probe()at the callsite ofof_clk_get(), and check for -EPROBE_DEFER in places where its return value could propagate to.To where?
rockchip_pm_add_one_domain,rockchip_pm_add_subdomain, androckchip_pm_domain_probe. I think it's obvious in the diff and too detailed to the commit message, so didn't add them here.
Ah, I was too hasty and misread the patch, sorry about that!
Quoted 8 lines
Quoted 2 lines
And I didn't understand why you couldn't just call
dev_err_probe()everywhere --
the error code seems to always be propagated...This was what I originally wanted to do, but
dev_err_probe()sets the deferred probe reason, and if we call it several times, the earlier and more specific messagess ("failed to get clk at index %d") get overridden by the later and less descriptive ones ("failed to handle subdomain node %pOFn"), which I think would make it harder to debug.
Seeing it now, sorry again! :-)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Fixes 7c696693a4f5 ("soc: rockchip: power-domain: Add power domain driver")Fixes 6be05b5ec161 ("soc: rockchip: power-domain: add support for sub-power domains")Signed-off-by Yao Zi <[email protected]>
Not sure the patch qualifies for stable though...
[...]
MBR, Sergey
Quoted 15 lines · Yao Zi
These issues were found after I upgraded a RK3528 board to v7.3 kernel. Here's a configuration that I used to reproduce both of these two problems[1].
Thanks for your time and review.
[1]: https://gist.github.com/ziyao233/a5ee8862d1baf21ad756cf4e959e14c3
Yao Zi (2):
pmdomain: rockchip: Only put clocks that have been successfully
obtained
pmdomain: rockchip: Don't log whenof_clk_get()fails with
-EPROBE_DEFER
Quoted 6 lines
drivers/pmdomain/rockchip/pm-domains.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)--
2.56.0
Patch 1 applied for fixes and patch2 for next (by dropping fixes/stable tags), thanks!
Kind regards
Uffe