[PATCH] pinctrl: rk805: fix ordering of gpio and pinctrl registration
Heiko Stuebner
heiko at sntech.de
Fri Oct 30 04:55:40 PDT 2026
From: Heiko Stuebner <heiko.stuebner at 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 at vger.kernel.org
Signed-off-by: Heiko Stuebner <heiko.stuebner at 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
More information about the Linux-rockchip
mailing list