The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] pinctrl: rockchip: Check the error of the pmu syscon lookup
@ 2026-12-01 11:33 Anton Protopopov
  2026-12-01 12:13 ` Heiko Stübner
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Protopopov @ 2026-12-01 11:33 UTC (permalink / raw)
  To: Linus Walleij, Heiko Stuebner, Ye Zhang, linux-gpio,
	linux-arm-kernel, linux-rockchip, linux-kernel
  Cc: Anton Protopopov, Bjorn Helgaas

The syscon_regmap_lookup_by_phandle_optional() function returns NULL
only when the property is missing (-ENODEV). On other errors it
returns an error pointer. Before commit dbd2317d7b9f ("pinctrl:
rockchip: Add rk3506 pinctrl support") the probe returned the error
of the "rockchip,pmu" lookup. Now it stores the error pointer in
info->regmap_pmu. The pin configuration code then uses an error
pointer as a regmap, which leads to an oops.

The lookup may fail with a correct device tree too: it returns
-EPROBE_DEFER when the hwspinlock of the syscon or the driver which
registers its regmap is not probed yet. Return the error from the
probe, so that it is retried.

Fixes: dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support")
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
---

It's one of three related changes, but for different trees.
See https://lore.kernel.org/linux-pci/20261127101915.1348807-1-a.s.protopopov@gmail.com/

This is based on the for-next branch of
git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
and applies to its fixes branch too.

 drivers/pinctrl/pinctrl-rockchip.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index cad602fa41ae..76e6ce2d52bc 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -5022,6 +5022,9 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
 
 	/* try to find the optional reference to the pmu syscon */
 	info->regmap_pmu = syscon_regmap_lookup_by_phandle_optional(np, "rockchip,pmu");
+	if (IS_ERR(info->regmap_pmu))
+		return dev_err_probe(dev, PTR_ERR(info->regmap_pmu),
+				     "failed to look up pmu syscon\n");
 
 	if (ctrl->type == RK3308) {
 		ret = rk3308_soc_data_init(info);

base-commit: 948b743d6ce070e3d6a31806b8aab4f151e69178

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: rockchip: Check the error of the pmu syscon lookup
  2026-12-01 11:33 [PATCH] pinctrl: rockchip: Check the error of the pmu syscon lookup Anton Protopopov
@ 2026-12-01 12:13 ` Heiko Stübner
  0 siblings, 0 replies; 2+ messages in thread
From: Heiko Stübner @ 2026-12-01 12:13 UTC (permalink / raw)
  To: Linus Walleij, Ye Zhang, linux-gpio, linux-arm-kernel,
	linux-rockchip, linux-kernel, Anton Protopopov
  Cc: Anton Protopopov, Bjorn Helgaas

Am Dienstag, 1. Dezember 2026, 12:33:49 Mitteleuropäische Normalzeit schrieb Anton Protopopov:
> The syscon_regmap_lookup_by_phandle_optional() function returns NULL
> only when the property is missing (-ENODEV). On other errors it
> returns an error pointer. Before commit dbd2317d7b9f ("pinctrl:
> rockchip: Add rk3506 pinctrl support") the probe returned the error
> of the "rockchip,pmu" lookup. Now it stores the error pointer in
> info->regmap_pmu. The pin configuration code then uses an error
> pointer as a regmap, which leads to an oops.
> 
> The lookup may fail with a correct device tree too: it returns
> -EPROBE_DEFER when the hwspinlock of the syscon or the driver which
> registers its regmap is not probed yet. Return the error from the
> probe, so that it is retried.
> 
> Fixes: dbd2317d7b9f ("pinctrl: rockchip: Add rk3506 pinctrl support")
> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>

Looked up the behaviour of syscon_regmap_lookup_by_phandle_optional(),
so for the change itself:

Reviewed-by: Heiko Stuebner <heiko@sntech.de>


(had a bit of fun, remembering that the 2nd syscon handling was removed
by commit 9884c330dd80 ("pinctrl: rockchip: Fix RK3506 pinctrl support") )

Thanks
Heiko



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 11:33 [PATCH] pinctrl: rockchip: Check the error of the pmu syscon lookup Anton Protopopov
2026-12-01 12:13 ` Heiko Stübner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox