Patch "pinctrl: bcm2835: Change init order for gpio hogs" has been added to the 5.4-stable tree

gregkh at linuxfoundation.org gregkh at linuxfoundation.org
Thu Jan 27 08:01:49 PST 2022


This is a note to let you know that I've just added the patch titled

    pinctrl: bcm2835: Change init order for gpio hogs

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.


>From foo at baz Thu Jan 27 04:40:37 PM CET 2022
From: Florian Fainelli <f.fainelli at gmail.com>
Date: Tue, 25 Jan 2022 11:42:21 -0800
Subject: pinctrl: bcm2835: Change init order for gpio hogs
To: stable at vger.kernel.org
Cc: Phil Elwell <phil at raspberrypi.com>, Florian Fainelli <f.fainelli at gmail.com>, Linus Walleij <linus.walleij at linaro.org>, Rob Herring <robh+dt at kernel.org>, Mark Rutland <mark.rutland at arm.com>, Ray Jui <rjui at broadcom.com>, Scott Branden <sbranden at broadcom.com>, bcm-kernel-feedback-list at broadcom.com (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Eric Anholt <eric at anholt.net>, Stefan Wahren <wahrenst at gmx.net>, Nicolas Saenz Julienne <nsaenz at kernel.org>, devicetree at vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel at vger.kernel.org (open list), linux-gpio at vger.kernel.org (open list:PIN CONTROL SUBSYSTEM), linux-rpi-kernel at lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel at lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE)
Message-ID: <20220125194222.12783-7-f.fainelli at gmail.com>

From: Phil Elwell <phil at raspberrypi.com>

commit 266423e60ea1b953fcc0cd97f3dad85857e434d1 upstream

...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")
Signed-off-by: Phil Elwell <phil at raspberrypi.com>
Reviewed-by: Florian Fainelli <f.fainelli at gmail.com>
Link: https://lore.kernel.org/r/20211206092237.4105895-2-phil@raspberrypi.com
Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/pinctrl/bcm/pinctrl-bcm2835.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -1241,6 +1241,18 @@ static int bcm2835_pinctrl_probe(struct
 		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;
@@ -1248,8 +1260,10 @@ static int bcm2835_pinctrl_probe(struct
 	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,
@@ -1300,21 +1314,10 @@ static int bcm2835_pinctrl_probe(struct
 	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;
 }
 


Patches currently in stable-queue which might be from f.fainelli at gmail.com are

queue-5.4/pinctrl-bcm2835-drop-unused-define.patch
queue-5.4/arm-dts-gpio-ranges-property-is-now-required.patch
queue-5.4/pinctrl-bcm2835-add-support-for-wake-up-interrupts.patch
queue-5.4/pinctrl-bcm2835-change-init-order-for-gpio-hogs.patch
queue-5.4/pinctrl-bcm2835-refactor-platform-data.patch
queue-5.4/pinctrl-bcm2835-match-bcm7211-compatible-string.patch
queue-5.4/pinctrl-bcm2835-add-support-for-all-gpios-on-bcm2711.patch



More information about the linux-arm-kernel mailing list