Skip to contentSkip to conversation

pinctrl: bcm2835: Fix gpio hogs and pin reinitialisation

PATCH In review Phil Elwell 7 participants 27 messages Dec 6, 2021 – Jan 4, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: bcm2835: Fix gpio hogs and pin reinitialisation

Tackle two problems with the pinctrl-bcm2835 driver and its Device Tree configuration:

1. The pinctrl-bcm2835 driver is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data).

2. Since [1], a "gpio-ranges" property is required in order for pins to be returned to inputs when freed. Note that without patch 1, the device never gets out of EPROBE_DEFER.

Note that the Fixes: tags are little more than hooks to hang the back-ports on - no blame is intended.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Changes in v2:
* Removed wrapping of Fixes: tags.
* Added Reviewed-by from Linus, who asks that Patch 2 be merged through the Broadcom/SoC tree.
* Corrected Nicolas's email address.

Phil Elwell (2):
pinctrl: bcm2835: Change init order for gpio hogs
ARM: dts: gpio-ranges property is now required

 arch/arm/boot/dts/bcm2711.dtsi        |  2 ++
 arch/arm/boot/dts/bcm283x.dtsi        |  2 ++
 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 29 +++++++++++++++------------
 3 files changed, 20 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 pinctrl: bcm2835: Change init order for gpio hogs

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")
---
 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 29 +++++++++++++++------------
 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +16 -13
index 2abcc6ce4eba3..b607d10e4cbd8 100644
@@ -1244,6 +1244,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 		raw_spin_lock_init(&pc->irq_lock[i]);
 	}
 
+	pc->pctl_desc = *pdata->pctl_desc;
+	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
+	if (IS_ERR(pc->pctl_dev)) {
+		gpiochip_remove(&pc->gpio_chip);
+		return PTR_ERR(pc->pctl_dev);
+	}
+
+	pc->gpio_range = *pdata->gpio_range;
+	pc->gpio_range.base = pc->gpio_chip.base;
+	pc->gpio_range.gc = &pc->gpio_chip;
+	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
+
 	girq = &pc->gpio_chip.irq;
 	girq->chip = &bcm2835_gpio_irq_chip;
 	girq->parent_handler = bcm2835_gpio_irq_handler;
@@ -1251,8 +1263,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 	girq->parents = devm_kcalloc(dev, BCM2835_NUM_IRQS,
 				     sizeof(*girq->parents),
 				     GFP_KERNEL);
-	if (!girq->parents)
+	if (!girq->parents) {
+		pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
 		return -ENOMEM;
+	}
 
 	if (is_7211) {
 		pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
@@ -1307,21 +1321,10 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 	err = gpiochip_add_data(&pc->gpio_chip, pc);
 	if (err) {
 		dev_err(dev, "could not add GPIO chip\n");
+		pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
 		return err;
 	}
 
-	pc->pctl_desc = *pdata->pctl_desc;
-	pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
-	if (IS_ERR(pc->pctl_dev)) {
-		gpiochip_remove(&pc->gpio_chip);
-		return PTR_ERR(pc->pctl_dev);
-	}
-
-	pc->gpio_range = *pdata->gpio_range;
-	pc->gpio_range.base = pc->gpio_chip.base;
-	pc->gpio_range.gc = &pc->gpio_chip;
-	pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
-
 	return 0;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 9 lines · Phil Elwell

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Quoted 8 lines

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")
Signature · 1 line
Florian
#3 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

In reply to Phil Elwell
Quoted 9 lines · Phil Elwell

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Quoted 8 lines

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 14 lines · Phil Elwell
Quoted 13 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

Quoted 6 lines
Quoted 5 lines

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

After reverting this change everything is back to normal.

Best regards

Quoted 8 lines

Yours,
Linus Walleij

_______________________________________________
linux-rpi-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

#5 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 20 lines · Stefan Wahren

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 19 lines · Phil Elwell
Quoted 18 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")
Quoted 8 lines
Quoted 1 line

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

After reverting this change everything is back to normal.

And this patch has already been applied to the stable 5.15 and 5.10 branches as well, FWIW.

Signature · 1 line
Florian
#6 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

In reply to Stefan Wahren
Quoted 20 lines · Stefan Wahren

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 19 lines · Phil Elwell
Quoted 18 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")
Quoted 8 lines
Quoted 1 line

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

After reverting this change everything is back to normal.

Oh what a mess. OK I reverted the fix.

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 23 lines · Linus Walleij
Quoted 22 lines · Stefan Wahren

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 20 lines · Phil Elwell
Quoted 10 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Quoted 8 lines

Change the initialisation sequence to register the pinctrl driver first.

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Quoted 9 lines
Quoted 6 lines

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

After reverting this change everything is back to normal.

Oh what a mess. OK I reverted the fix.

I happened to debug this regression as well: The issue of the patch seems to be that it initializes gpio_range.base with -1, because gpio_chip.base is not yet set at this point. Maybe that can be achieved differently, to please all cases.

Jan

#8 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Hi Jan,

Am 02.01.22 um 12:02 schrieb Jan Kiszka:

Quoted 28 lines · Linus Walleij
Quoted 27 lines · Stefan Wahren
Quoted 26 lines

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 14 lines · Phil Elwell
Quoted 13 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

Quoted 6 lines
Quoted 5 lines

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

After reverting this change everything is back to normal.

Oh what a mess. OK I reverted the fix.

I happened to debug this regression as well: The issue of the patch seems to be that it initializes gpio_range.base with -1, because gpio_chip.base is not yet set at this point. Maybe that can be achieved differently, to please all cases.

thanks for the hint.

I tried to reproduce the original issue with the gpio hog by adding one to the RPi Zero W. Here are my test results of this series based on Linux 5.16:

1. - Patch 1 & 2 not applied: boot hangs caused by gpio hog
2. - Patch 1 applied, Patch 2 not applied: boot hangs caused by gpio hog
3. - Patch 1 not applied, Patch 2 applied: boot hangs caused by gpio hog
4. - Patch 1 & 2 applied: boot ok, LEDs okay, hog okay

So both patches must be applied at the same time. In general this is done via immutable branch. But this requires caution while backporting.

Best regards

Quoted 2 lines

Jan

#9 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 45 lines · Stefan Wahren

Hi Jan,

Am 02.01.22 um 12:02 schrieb Jan Kiszka:

Quoted 28 lines · Linus Walleij
Quoted 27 lines · Stefan Wahren
Quoted 26 lines

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 14 lines · Phil Elwell
Quoted 13 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

Quoted 6 lines
Quoted 5 lines

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

After reverting this change everything is back to normal.

Oh what a mess. OK I reverted the fix.

I happened to debug this regression as well: The issue of the patch seems to be that it initializes gpio_range.base with -1, because gpio_chip.base is not yet set at this point. Maybe that can be achieved differently, to please all cases.

thanks for the hint.

I tried to reproduce the original issue with the gpio hog by adding one to the RPi Zero W. Here are my test results of this series based on Linux 5.16:

Quoted 8 lines

1. - Patch 1 & 2 not applied: boot hangs caused by gpio hog
2. - Patch 1 applied, Patch 2 not applied: boot hangs caused by gpio hog
3. - Patch 1 not applied, Patch 2 applied: boot hangs caused by gpio hog
4. - Patch 1 & 2 applied: boot ok, LEDs okay, hog okay

So both patches must be applied at the same time. In general this is done via immutable branch. But this requires caution while backporting.

Indeed - upstream and stable are missing patch 2, and that fixes the issue as well. Too bad that this series was split during merge.

Jan

#10 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 51 lines · Jan Kiszka
Quoted 50 lines · Stefan Wahren

Hi Jan,

Am 02.01.22 um 12:02 schrieb Jan Kiszka:

Quoted 28 lines · Linus Walleij
Quoted 27 lines · Stefan Wahren
Quoted 26 lines

Am 10.12.21 um 00:24 schrieb Linus Walleij:

Quoted 14 lines · Phil Elwell
Quoted 13 lines

...and gpio-ranges

pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover.

Change the initialisation sequence to register the pinctrl driver first.

Quoted 6 lines
Quoted 5 lines

This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs.

Fixes 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip")

This patch (1/2) applied for fixes.

Unfortunately this change breaks all GPIO LEDs at least on the Raspberry Pi 3 Plus (Linux 5.16-rc7, multi_v7_defconfig). The ACT LED for instance stays in the last state instead of the configured heartbeat behavior. Also there are no GPIO LEDs in /sys/class/leds/ directory.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

After reverting this change everything is back to normal.

Oh what a mess. OK I reverted the fix.

I happened to debug this regression as well: The issue of the patch seems to be that it initializes gpio_range.base with -1, because gpio_chip.base is not yet set at this point. Maybe that can be achieved differently, to please all cases.

thanks for the hint.

I tried to reproduce the original issue with the gpio hog by adding one to the RPi Zero W. Here are my test results of this series based on Linux 5.16:

1. - Patch 1 & 2 not applied: boot hangs caused by gpio hog
2. - Patch 1 applied, Patch 2 not applied: boot hangs caused by gpio hog
3. - Patch 1 not applied, Patch 2 applied: boot hangs caused by gpio hog
4. - Patch 1 & 2 applied: boot ok, LEDs okay, hog okay

Quoted 7 lines
Quoted 3 lines

So both patches must be applied at the same time. In general this is done via immutable branch. But this requires caution while backporting.

Indeed - upstream and stable are missing patch 2, and that fixes the issue as well. Too bad that this series was split during merge.

But, in fact, this series was misordered then, suggesting that patch 1 was independent of patch 2, but it actually depended on patch 2 to avoid even temporary regressions.

Jan

#11 lore raw

Re: [PATCH v2 1/2] pinctrl: bcm2835: Change init order for gpio hogs

Quoted 3 lines · Jan Kiszka

But, in fact, this series was misordered then, suggesting that patch 1 was independent of patch 2, but it actually depended on patch 2 to avoid even temporary regressions.

I picked patch 2/2 out of my tree and sent it off to the SoC tree that applies DTS fixes.

Let's see if they manage to get it to Torvalds before the merge window.

Yours,
Linus Walleij

#12 lore raw

PATCH v2 2/2 ARM: dts: gpio-ranges property is now required

In reply to Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")
---
 arch/arm/boot/dts/bcm2711.dtsi | 2 ++
 arch/arm/boot/dts/bcm283x.dtsi | 2 ++
 2 files changed, 4 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +2 -0
index 9e01dbca4a011..dff18fc9a9065 100644
@@ -582,6 +582,8 @@ &gpio {
 		     <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>,
 		     <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
 
+	gpio-ranges = <&gpio 0 0 58>;
+
 	gpclk0_gpio49: gpclk0_gpio49 {
 		pin-gpclk {
 			pins = "gpio49";
arch/arm/boot/dts/bcm283x.dtsi +2 -0
index a3e06b6809476..c113661a6668f 100644
@@ -126,6 +126,8 @@ gpio: gpio@7e200000 {
 			interrupt-controller;
 			#interrupt-cells = <2>;
 
+			gpio-ranges = <&gpio 0 0 54>;
+
 			/* Defines common pin muxing groups
 			 *
 			 * While each pin can have its mux selected
Signature · 1 line
2.25.1
Reviewed-by on v2 2/2
#13 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 9 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Please funnel this patch through the SoC tree.

Yours,
Linus Walleij

#14 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 9 lines · Linus Walleij
Quoted 7 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Quoted 6 lines
Quoted 2 lines
Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Please funnel this patch through the SoC tree.

This one was definitively going to go via ARM SoC in the absence of any explicit routing, did you mean that patch #1 should also be routed via ARM SoC?

Signature · 1 line
Florian
#15 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

On Mon, Dec 6, 2021 at 6:25 PM Florian Fainelli <[email protected]> wrote:
[Me]

Quoted 5 lines
Quoted 1 line

Please funnel this patch through the SoC tree.

This one was definitively going to go via ARM SoC in the absence of any explicit routing, did you mean that patch #1 should also be routed via ARM SoC?

No just over-clarifying.
I will merge patch #1 after some review slack.

Yours,
Linus Walleij

#16 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

In reply to Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 7 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Quoted 6 lines
Quoted 2 lines
Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Please funnel this patch through the SoC tree.

Applied for fixes.

Thanks,
Nicolas

#17 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

In reply to Phil Elwell

Hi Phil,

Quoted 9 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

This patch breaks today's linux-next (next-20211214) on RPi3 and RPi4. Either there is something missing or wrong here. Booting stops after following messages (on RPi4):

[    3.186786] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.234513] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.276703] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    3.287191] pinctrl-bcm2835 fe200000.gpio

Quoted 23 lines
---
  arch/arm/boot/dts/bcm2711.dtsi | 2 ++
  arch/arm/boot/dts/bcm283x.dtsi | 2 ++
  2 files changed, 4 insertions(+)
arch/arm/boot/dts/bcm2711.dtsi +2 -0
index 9e01dbca4a011..dff18fc9a9065 100644
@@ -582,6 +582,8 @@ &gpio {
  		     <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>,
  		     <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>;
 
+	gpio-ranges = <&gpio 0 0 58>;
+
  	gpclk0_gpio49: gpclk0_gpio49 {
  		pin-gpclk {
  			pins = "gpio49";
arch/arm/boot/dts/bcm283x.dtsi +0 -0
index a3e06b6809476..c113661a6668f 100644

arch/arm/boot/dts/bcm283x.dtsi gpio: gpio@7e200000 { · line 133

Quoted 8 lines
arch/arm/boot/dts/bcm283x.dtsi +2 -0
@@ -126,6 +126,8 @@ gpio: gpio@7e200000 {
  			interrupt-controller;
  			#interrupt-cells = <2>;
 
+			gpio-ranges = <&gpio 0 0 54>;
+
  			/* Defines common pin muxing groups
  			 *
  			 * While each pin can have its mux selected

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#18 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Hi Marek,

Quoted 17 lines · Marek Szyprowski

Hi Phil,

Quoted 9 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

This patch breaks today's linux-next (next-20211214) on RPi3 and RPi4. Either there is something missing or wrong here. Booting stops after following messages (on RPi4):

Quoted 5 lines

[    3.186786] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.234513] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.276703] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    3.287191] pinctrl-bcm2835 fe200000.gpio

This patch is part of a two-patch set, the cover note for which says:

2. Since [1], a "gpio-ranges" property is required in order for pins to be returned to inputs when freed. Note that without patch 1, the device never gets out of EPROBE_DEFER.

It looks as though patch 2 has been merged without/before patch 1 ("pinctrl: bcm2835: Change init order for gpio hogs").

Phil

#19 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 27 lines · Phil Elwell

Hi Marek,

Quoted 18 lines · Marek Szyprowski

Hi Phil,

Quoted 10 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without

pin-ranges")

This patch breaks today's linux-next (next-20211214) on RPi3 and RPi4. Either there is something missing or wrong here. Booting stops after following messages (on RPi4):

Quoted 5 lines

[    3.186786] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.234513] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.276703] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    3.287191] pinctrl-bcm2835 fe200000.gpio

Quoted 8 lines

This patch is part of a two-patch set, the cover note for which says:

    2. Since [1], a "gpio-ranges" property is required in order for pins to be returned to inputs when freed. Note that without patch 1, the device never gets out of EPROBE_DEFER.

It looks as though patch 2 has been merged without/before patch 1 ("pinctrl: bcm2835: Change init order for gpio hogs").

Yes, the hope was that there would be no such breakage, I suppose we will have to work out a plan to address that and coordinate both changes landing in at the same time.

I will work with Arnd to back out the Device Tree changes, sorry about that.

Signature · 1 line
Florian
#20 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Florian,

Quoted 34 lines · Florian Fainelli
Quoted 33 lines · Phil Elwell

Hi Marek,

Quoted 18 lines · Marek Szyprowski

Hi Phil,

Quoted 10 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without

pin-ranges")

This patch breaks today's linux-next (next-20211214) on RPi3 and RPi4. Either there is something missing or wrong here. Booting stops after following messages (on RPi4):

Quoted 5 lines

[    3.186786] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.234513] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.276703] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    3.287191] pinctrl-bcm2835 fe200000.gpio

This patch is part of a two-patch set, the cover note for which says:

    2. Since [1], a "gpio-ranges" property is required in order for pins to be returned to inputs when freed. Note that without patch 1, the device never gets out of EPROBE_DEFER.

Quoted 8 lines
Quoted 2 lines

It looks as though patch 2 has been merged without/before patch 1 ("pinctrl: bcm2835: Change init order for gpio hogs").

Yes, the hope was that there would be no such breakage, I suppose we will have to work out a plan to address that and coordinate both changes landing in at the same time.

I will work with Arnd to back out the Device Tree changes, sorry about that.

This is linux-next, so I can back out the DT change myself. Sorry for the breakage.

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

Regards,
Nicolas

#21 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 44 lines · nicolas saenz julienne

Florian,

Quoted 41 lines · Florian Fainelli
Quoted 27 lines · Phil Elwell

Hi Marek,

Quoted 18 lines · Marek Szyprowski

Hi Phil,

Quoted 10 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without

pin-ranges")

This patch breaks today's linux-next (next-20211214) on RPi3 and RPi4. Either there is something missing or wrong here. Booting stops after following messages (on RPi4):

Quoted 5 lines

[    3.186786] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.234513] pinctrl-bcm2835 fe200000.gpio: could not add GPIO chip [    3.276703] mmc0: SDHCI controller on fe340000.mmc [fe340000.mmc] using ADMA
[    3.287191] pinctrl-bcm2835 fe200000.gpio

Quoted 8 lines

This patch is part of a two-patch set, the cover note for which says:

    2. Since [1], a "gpio-ranges" property is required in order for pins to be returned to inputs when freed. Note that without patch 1, the device never gets out of EPROBE_DEFER.

It looks as though patch 2 has been merged without/before patch 1 ("pinctrl: bcm2835: Change init order for gpio hogs").

Yes, the hope was that there would be no such breakage, I suppose we will have to work out a plan to address that and coordinate both changes landing in at the same time.

Quoted 7 lines
Quoted 1 line

I will work with Arnd to back out the Device Tree changes, sorry about that.

This is linux-next, so I can back out the DT change myself. Sorry for the breakage.

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

That would definitively work, Linus, are you comfortable with doing that? I will reply to the patch with an Acked-by if that helps.

Signature · 1 line
Florian
#22 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 7 lines · Florian Fainelli
Quoted 2 lines · nicolas saenz julienne

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

That would definitively work, Linus, are you comfortable with doing that? I will reply to the patch with an Acked-by if that helps.

Do you want me to merge this patch (2/2) into the pinctrl tree, where patch (1/2) is already merged?

Sorry just a bit confused.

Yours,
Linus Walleij

#23 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 11 lines · Linus Walleij
Quoted 7 lines · Florian Fainelli
Quoted 2 lines · nicolas saenz julienne

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

That would definitively work, Linus, are you comfortable with doing that? I will reply to the patch with an Acked-by if that helps.

Do you want me to merge this patch (2/2) into the pinctrl tree, where patch (1/2) is already merged?

Yes please merge patch 2 into the pinctrl tree where patch 1 is already applied. Thanks!

Signature · 1 line
Florian
#24 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 7 lines · Florian Fainelli
Quoted 6 lines · Linus Walleij
Quoted 5 lines · Florian Fainelli
Quoted 2 lines · nicolas saenz julienne

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

That would definitively work, Linus, are you comfortable with doing that? I will reply to the patch with an Acked-by if that helps.

Do you want me to merge this patch (2/2) into the pinctrl tree, where patch (1/2) is already merged?

Yes please merge patch 2 into the pinctrl tree where patch 1 is already applied. Thanks!

OK! Patch applied!

Yours,
Linus Walleij

#25 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

Quoted 11 lines · Linus Walleij
Quoted 10 lines · Florian Fainelli
Quoted 9 lines · Linus Walleij
Quoted 7 lines · Florian Fainelli
Quoted 2 lines · nicolas saenz julienne

As for channeling the path, would it make sense for linusw to take it alonside GPIO fix?

That would definitively work, Linus, are you comfortable with doing that? I will reply to the patch with an Acked-by if that helps.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Do you want me to merge this patch (2/2) into the pinctrl tree, where patch (1/2) is already merged?

Yes please merge patch 2 into the pinctrl tree where patch 1 is already applied. Thanks!

OK! Patch applied!

Thanks!

Acked-by on v2 2/2
#26 lore raw

Re: [PATCH v2 2/2] ARM: dts: gpio-ranges property is now required

In reply to Phil Elwell
Quoted 9 lines · Phil Elwell

Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices.

[1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")

Fixes 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges")
Signature · 1 line
Florian