Skip to contentSkip to conversation

pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()

PATCH In review Tony Lindgren 5 participants 5 messages Mar 30, 2017 – Apr 6, 2017

Subsystems (6)
lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

PATCH 1/1 pinctrl: core: Fix pinctrl_register_and_init() with pinctrl_enable()

Recent pinctrl changes to allow dynamic allocation of pins exposed one more issue with the pinctrl pins claimed early by the controller itself. This caused a regression for IMX6 pinctrl hogs.

Before enabling the pin controller driver we need to wait until it has been properly initialized, then claim the hogs, and only then enable it.

To fix the regression, split the code into pinctrl_claim_hogs() and pinctrl_enable(). And then let's require that pinctrl_enable() is always called by the pin controller driver when ready after calling pinctrl_register_and_init().

Depends-on: 950b0d91dc10 ("pinctrl: core: Fix regression caused by delayed work for hogs")

Fixes df61b366af26 ("pinctrl: core: Use delayed work for hogs")
Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for

managing groups")

Cc Fabio Estevam <[email protected]>
Cc Gary Bisson <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Nishanth Menon <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefan Agner <[email protected]>

---

Apologies with all the accidental delays getting this regression fixed. Here's a better version of the fix I attempted earlier that now just adds pinctrl_enable().

Some testing is needed for sure, can you guys please review and test? I've tested with my pinctrl hogs case, but I've and I've only compile tested for imx and sh.

---
 Documentation/pinctrl.txt               |  8 ++-
 drivers/pinctrl/core.c                  | 97 +++++++++++++++++++++------------
 drivers/pinctrl/freescale/pinctrl-imx.c |  2 +-
 drivers/pinctrl/pinctrl-single.c        |  2 +-
 drivers/pinctrl/sh-pfc/pinctrl.c        | 11 +++-
 drivers/pinctrl/ti/pinctrl-ti-iodelay.c |  2 +
 include/linux/pinctrl/pinctrl.h         |  3 +-
 7 files changed, 83 insertions(+), 42 deletions(-)
Documentation/pinctrl.txt +7 -1
@@ -77,9 +77,15 @@ static struct pinctrl_desc foo_desc = {
 
 int __init foo_probe(void)
 {
+	int error;
+
 	struct pinctrl_dev *pctl;
 
-	return pinctrl_register_and_init(&foo_desc, <PARENT>, NULL, &pctl);
+	error = pinctrl_register_and_init(&foo_desc, <PARENT>, NULL, &pctl);
+	if (error)
+		return error;
+
+	return pinctrl_enable(pctl);
 }
 
 To enable the pinctrl subsystem and the subgroups for PINMUX and PINCONF and
drivers/pinctrl/core.c +61 -36

136 lines not on this page · raw message

drivers/pinctrl/freescale/pinctrl-imx.c +1 -1
@@ -790,7 +790,7 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 
 	dev_info(&pdev->dev, "initialized IMX pinctrl driver\n");
 
-	return 0;
+	return pinctrl_enable(ipctl->pctl);
 
 free:
 	imx_free_resources(ipctl);
drivers/pinctrl/pinctrl-single.c +1 -1
@@ -1781,7 +1781,7 @@ static int pcs_probe(struct platform_device *pdev)
 	dev_info(pcs->dev, "%i pins at pa %p size %u\n",
 		 pcs->desc.npins, pcs->base, pcs->size);
 
-	return 0;
+	return pinctrl_enable(pcs->pctl);
 
 free:
 	pcs_free_resources(pcs);
drivers/pinctrl/sh-pfc/pinctrl.c +9 -2
@@ -816,6 +816,13 @@ int sh_pfc_register_pinctrl(struct sh_pfc *pfc)
 	pmx->pctl_desc.pins = pmx->pins;
 	pmx->pctl_desc.npins = pfc->info->nr_pins;
 
-	return devm_pinctrl_register_and_init(pfc->dev, &pmx->pctl_desc, pmx,
-					      &pmx->pctl);
+	ret = devm_pinctrl_register_and_init(pfc->dev, &pmx->pctl_desc, pmx,
+					     &pmx->pctl);
+	if (ret) {
+		dev_err(pfc->dev, "could not register: %i\n", ret);
+
+		return ret;
+	}
+
+	return pinctrl_enable(pmx->pctl);
 }
drivers/pinctrl/ti/pinctrl-ti-iodelay.c +2 -0
@@ -893,6 +893,8 @@ static int ti_iodelay_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, iod);
 
+	return pinctrl_enable(iod->pctl);
+
 exit_out:
 	of_node_put(np);
 	return ret;
include/linux/pinctrl/pinctrl.h +2 -1
@@ -145,8 +145,9 @@ struct pinctrl_desc {
 extern int pinctrl_register_and_init(struct pinctrl_desc *pctldesc,
 				     struct device *dev, void *driver_data,
 				     struct pinctrl_dev **pctldev);
+extern int pinctrl_enable(struct pinctrl_dev *pctldev);
 
-/* Please use pinctrl_register_and_init() instead */
+/* Please use pinctrl_register_and_init() and pinctrl_enable() instead */
 extern struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
 				struct device *dev, void *driver_data);
 
Signature · 1 line
2.12.1
Tested-by on v1 1/1
#1 lore raw

Hi Tony,

Quoted 17 lines · Tony Lindgren

Recent pinctrl changes to allow dynamic allocation of pins exposed one more issue with the pinctrl pins claimed early by the controller itself. This caused a regression for IMX6 pinctrl hogs.

Before enabling the pin controller driver we need to wait until it has been properly initialized, then claim the hogs, and only then enable it.

To fix the regression, split the code into pinctrl_claim_hogs() and pinctrl_enable(). And then let's require that pinctrl_enable() is always called by the pin controller driver when ready after calling pinctrl_register_and_init().

Depends-on: 950b0d91dc10 ("pinctrl: core: Fix regression caused by delayed work for hogs")

Fixes df61b366af26 ("pinctrl: core: Use delayed work for hogs")
Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for

managing groups")

Quoted 11 lines
Cc Fabio Estevam <[email protected]>
Cc Gary Bisson <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Nishanth Menon <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefan Agner <[email protected]>

The display on r8a7740-armadillo800eva still works, so the GPIO hog needed for that is OK.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Tested-by
#2 lore raw

Tony, All,

Quoted 33 lines · Geert Uytterhoeven

Hi Tony,

Quoted 17 lines · Tony Lindgren

Recent pinctrl changes to allow dynamic allocation of pins exposed one more issue with the pinctrl pins claimed early by the controller itself. This caused a regression for IMX6 pinctrl hogs.

Before enabling the pin controller driver we need to wait until it has been properly initialized, then claim the hogs, and only then enable it.

To fix the regression, split the code into pinctrl_claim_hogs() and pinctrl_enable(). And then let's require that pinctrl_enable() is always called by the pin controller driver when ready after calling pinctrl_register_and_init().

Depends-on: 950b0d91dc10 ("pinctrl: core: Fix regression caused by delayed work for hogs")

Fixes df61b366af26 ("pinctrl: core: Use delayed work for hogs")
Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for

managing groups")

Quoted 11 lines
Cc Fabio Estevam <[email protected]>
Cc Gary Bisson <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Nishanth Menon <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefan Agner <[email protected]>
Quoted 4 lines

The display on r8a7740-armadillo800eva still works, so the GPIO hog needed for that is OK.

For imx, tested on a Nitrogen6x platform:

Before the patch:

# dmesg | grep iomux
[    0.096672] imx6q-pinctrl 20e0000.iomuxc: unable to find group for
node hoggrp
[    0.097215] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver

After the patch:

# dmesg | grep iomux
[    0.097505] imx6q-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver

Also, checking the pinctrl of the hog pins in sysfs proved to be correct.

Regards,
Gary

maintainer Tested-by on v1 1/1
#3 lore raw
In reply to Tony Lindgren

Hi Tony,

Quoted 17 lines · Tony Lindgren

Recent pinctrl changes to allow dynamic allocation of pins exposed one more issue with the pinctrl pins claimed early by the controller itself. This caused a regression for IMX6 pinctrl hogs.

Before enabling the pin controller driver we need to wait until it has been properly initialized, then claim the hogs, and only then enable it.

To fix the regression, split the code into pinctrl_claim_hogs() and pinctrl_enable(). And then let's require that pinctrl_enable() is always called by the pin controller driver when ready after calling pinctrl_register_and_init().

Depends-on: 950b0d91dc10 ("pinctrl: core: Fix regression caused by delayed work for hogs")

Fixes df61b366af26 ("pinctrl: core: Use delayed work for hogs")
Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for

managing groups")

Quoted 11 lines
Cc Fabio Estevam <[email protected]>
Cc Gary Bisson <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Nishanth Menon <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefan Agner <[email protected]>

Your patch fixes the pinctrl hog issue on a imx53-qsb board, thanks:

#4 lore raw
In reply to Tony Lindgren
Quoted 17 lines · Tony Lindgren

Recent pinctrl changes to allow dynamic allocation of pins exposed one more issue with the pinctrl pins claimed early by the controller itself. This caused a regression for IMX6 pinctrl hogs.

Before enabling the pin controller driver we need to wait until it has been properly initialized, then claim the hogs, and only then enable it.

To fix the regression, split the code into pinctrl_claim_hogs() and pinctrl_enable(). And then let's require that pinctrl_enable() is always called by the pin controller driver when ready after calling pinctrl_register_and_init().

Depends-on: 950b0d91dc10 ("pinctrl: core: Fix regression caused by delayed work for hogs")

Fixes df61b366af26 ("pinctrl: core: Use delayed work for hogs")
Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for

managing groups")

Quoted 11 lines
Cc Fabio Estevam <[email protected]>
Cc Gary Bisson <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Haojian Zhuang <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Mika Westerberg <[email protected]>
Cc Nishanth Menon <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefan Agner <[email protected]>

Patch applied for fixes with the test tags,
sorry for slowness.

Yours,
Linus Walleij