All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: rk805: fix ordering of gpio and pinctrl registration
@ 2026-10-30 11:55 ` Heiko Stuebner
  0 siblings, 0 replies; 4+ messages in thread
From: Heiko Stuebner @ 2026-10-30 11:55 UTC (permalink / raw)
  To: linusw; +Cc: heiko, chenjh, linux-gpio, linux-rockchip, Heiko Stuebner, stable

From: Heiko Stuebner <heiko.stuebner@cherry.de>

The call to gpiochip_add_pin_range() binds the gpio-chip and pinctrl
together. devm_gpiochip_add_data() sets up the devm action to tear it
down again - and this includes removing the pin-range.

As devm teardown is running in opposite order, when
pinctrl_remove_gpio_range() is reached from gpiochip_remove_pin_ranges()
that pin-controller is already gone, leading to something like:

[    9.703366] Unable to handle kernel paging request at virtual address dead000000000108
[...]
[    9.703553] [dead000000000108] address between user and kernel address ranges
[    9.703573] Internal error: Oops: 0000000096000044 [#1]  SMP
[...]
[   23.237380] Call trace:
[   23.240120]  pinctrl_remove_gpio_range+0x28/0x60 (P)
[   23.245687]  gpiochip_remove_pin_ranges+0x5c/0x8c
[   23.250955]  gpiochip_remove+0x144/0x1c0
[   23.255350]  devm_gpio_chip_release+0x10/0x1c
[   23.260239]  devm_action_release+0x14/0x20
[   23.264834]  devres_release_all+0xb0/0x120
[   23.269430]  device_unbind_cleanup+0x2c/0x84
[   23.274221]  device_release_driver_internal+0x1ec/0x224
[   23.280072]  device_release_driver+0x18/0x24
[   23.284862]  bus_remove_device+0xe4/0x19c
[   23.289359]  device_del+0x14c/0x40c
[   23.293273]  platform_device_del+0x28/0x94
[   23.297871]  platform_device_unregister+0x18/0x3c
[   23.303149]  mfd_remove_devices_fn+0x130/0x14c
[...]

Fix this by reordering gpio and pinctrl addition.

Fixes: ea479996c79b ("pinctrl: Add pinctrl driver for the RK805 PMIC")
Cc: stable@vger.kernel.org
Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
---
 drivers/pinctrl/pinctrl-rk805.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rk805.c b/drivers/pinctrl/pinctrl-rk805.c
index 22f576337faa..8e04da3ef0f3 100644
--- a/drivers/pinctrl/pinctrl-rk805.c
+++ b/drivers/pinctrl/pinctrl-rk805.c
@@ -663,13 +663,6 @@ static int rk805_pinctrl_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	/* Add gpio chip */
-	ret = devm_gpiochip_add_data(&pdev->dev, &pci->gpio_chip, pci);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "Couldn't add gpiochip\n");
-		return ret;
-	}
-
 	/* Add pinctrl */
 	pci->pctl = devm_pinctrl_register(&pdev->dev, &pci->pinctrl_desc, pci);
 	if (IS_ERR(pci->pctl)) {
@@ -677,6 +670,13 @@ static int rk805_pinctrl_probe(struct platform_device *pdev)
 		return PTR_ERR(pci->pctl);
 	}
 
+	/* Add gpio chip */
+	ret = devm_gpiochip_add_data(&pdev->dev, &pci->gpio_chip, pci);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Couldn't add gpiochip\n");
+		return ret;
+	}
+
 	/* Add pin range */
 	ret = gpiochip_add_pin_range(&pci->gpio_chip, dev_name(&pdev->dev),
 				     0, 0, pci->gpio_chip.ngpio);
-- 
2.47.3


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2026-10-30 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 11:55 [PATCH] pinctrl: rk805: fix ordering of gpio and pinctrl registration Heiko Stuebner
2026-10-30 11:55 ` Heiko Stuebner
2026-10-30 12:05 ` sashiko-bot
2026-10-30 17:16   ` Heiko Stuebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.