Skip to contentSkip to conversation

gpio: vf610: switch to dynamic allocat GPIO base

PATCH In review [email protected] 5 participants 13 messages May 6, 2023 – Aug 28, 2023

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

PATCH 1/2 gpio: vf610: switch to dynamic allocat GPIO base

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

---
 drivers/gpio/gpio-vf610.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-vf610.c +1 -2
index d3f3a69d4907..70e16cef7738 100644
@@ -259,7 +259,6 @@ static void vf610_gpio_disable_clk(void *data)
 static int vf610_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = dev->of_node;
 	struct vf610_gpio_port *port;
 	struct gpio_chip *gc;
 	struct gpio_irq_chip *girq;
@@ -319,7 +318,7 @@ static int vf610_gpio_probe(struct platform_device *pdev)
 	gc->parent = dev;
 	gc->label = dev_name(dev);
 	gc->ngpio = VF610_GPIO_PER_PORT;
-	gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT;
+	gc->base = -1;
 
 	gc->request = gpiochip_generic_request;
 	gc->free = gpiochip_generic_free;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 gpio: mxc: switch to dynamic allocat GPIO base

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

---
 drivers/gpio/gpio-mxc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +1 -2
index 9d0cec4b82a3..abc129a88a62 100644
@@ -462,8 +462,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	port->gc.request = gpiochip_generic_request;
 	port->gc.free = gpiochip_generic_free;
 	port->gc.to_irq = mxc_gpio_to_irq;
-	port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
-					     pdev->id * 32;
+	port->gc.base = -1;
 
 	err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
 	if (err)
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 10 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

Yours,
Linus Walleij

author
#3 lore raw

RE: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 16 lines

-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: 2023年5月6日 21:06
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 6 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

Quoted 6 lines
Quoted 4 lines
[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

Hi Linus and Bartosz,

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

Best Regards
Haibo Chen

Quoted 3 lines

Yours,
Linus Walleij

#4 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 4 lines · Bough Chen

Hi Linus and Bartosz,

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

As pointed out by Bartosz you cannot just mechanically switch the base to -1.

You also need to convince us that this doesn't break any systems, and if it does, fix them so they don't break before submitting this patch.

Yours,
Linus Walleij

#5 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Hi Linus,

Am Montag, 21. August 2023, 09:25:54 CEST schrieb Linus Walleij:

Quoted 1 line

On Mon, Aug 21, 2023 at 4:47 AM Bough Chen <[email protected]> wrote:> > Hi

Linus and Bartosz,

Quoted 9 lines
Quoted 3 lines

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

As pointed out by Bartosz you cannot just mechanically switch the base to -1.

You also need to convince us that this doesn't break any systems, and if it does, fix them so they don't break before submitting this patch.

I think it's hard to tell if something breaks, this driver is used in a lot of boards. AFAIR some people are relying on the assumption of fixed order. Using dynamic allocation this not ensured. A possible fix is to use aliases [1].

Best regards,
Alexander

[1] https://lore.kernel.org/lkml/[email protected]/T/#u

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
Acked-by
#6 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 10 lines · Alexander Stein

Am Montag, 21. August 2023, 09:25:54 CEST schrieb Linus Walleij:

Quoted 1 line

On Mon, Aug 21, 2023 at 4:47 AM Bough Chen <[email protected]> wrote:> > Hi

Linus and Bartosz,

Quoted 7 lines
Quoted 3 lines

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

As pointed out by Bartosz you cannot just mechanically switch the base to -1.

Quoted 6 lines
Quoted 2 lines

You also need to convince us that this doesn't break any systems, and if it does, fix them so they don't break before submitting this patch.

I think it's hard to tell if something breaks, this driver is used in a lot of boards. AFAIR some people are relying on the assumption of fixed order. Using dynamic allocation this not ensured. A possible fix is to use aliases [1].

Hm I might have been to grumpy!

It looks like any boardfiles using gpio-mxc have been eliminated so this driver is now only used in device tree-boots? Right?

Then I feel a lot better about it.

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Quoted 25 lines · Linus Walleij
Quoted 10 lines · Alexander Stein

Am Montag, 21. August 2023, 09:25:54 CEST schrieb Linus Walleij:

Quoted 1 line

On Mon, Aug 21, 2023 at 4:47 AM Bough Chen <[email protected]> wrote:> > Hi

Linus and Bartosz,

Quoted 7 lines
Quoted 3 lines

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

As pointed out by Bartosz you cannot just mechanically switch the base to -1.

Quoted 6 lines
Quoted 2 lines

You also need to convince us that this doesn't break any systems, and if it does, fix them so they don't break before submitting this patch.

I think it's hard to tell if something breaks, this driver is used in a lot of boards. AFAIR some people are relying on the assumption of fixed order. Using dynamic allocation this not ensured. A possible fix is to use aliases [1].

Hm I might have been to grumpy!

It looks like any boardfiles using gpio-mxc have been eliminated so this driver is now only used in device tree-boots? Right?

Quoted 6 lines

Then I feel a lot better about it.

Yours,
Linus Walleij

I will not be queueing it for v6.6 as merge window opens in a week, I want to give it more time in next and see if anyone complains so it'll make it for v6.7.

Bart

#8 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

Hello,

Cc += i.MX maintainers as this file isn't matched by the MAINTAINERS entry.

Quoted 28 lines · Bartosz Golaszewski
Quoted 27 lines · Linus Walleij
Quoted 10 lines · Alexander Stein

Am Montag, 21. August 2023, 09:25:54 CEST schrieb Linus Walleij:

Quoted 1 line

On Mon, Aug 21, 2023 at 4:47 AM Bough Chen <[email protected]> wrote:> > Hi

Linus and Bartosz,

Quoted 7 lines
Quoted 3 lines

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

As pointed out by Bartosz you cannot just mechanically switch the base to -1.

Quoted 6 lines
Quoted 2 lines

You also need to convince us that this doesn't break any systems, and if it does, fix them so they don't break before submitting this patch.

I think it's hard to tell if something breaks, this driver is used in a lot of boards. AFAIR some people are relying on the assumption of fixed order. Using dynamic allocation this not ensured. A possible fix is to use aliases [1].

Hm I might have been to grumpy!

It looks like any boardfiles using gpio-mxc have been eliminated so this driver is now only used in device tree-boots? Right?

Then I feel a lot better about it.

Quoted 8 lines
Quoted 4 lines

Yours,
Linus Walleij

I will not be queueing it for v6.6 as merge window opens in a week, I want to give it more time in next and see if anyone complains so it'll make it for v6.7.

IMO, this should not be merged. I would hate to do a kernel update and see the kernel toggle some unrelated GPIO, because probe order changes. This will eventually happen to somebody and if they're unlucky, it will break something.

For systems, where the order was never fixed, I agree it's on them, but for i.MX, it has been fixed since inception AFAIK and I fail to see what strong reason there is to justify breaking their setups in such a manner.

Yes, the sysfs interface will eventually go away and fixed numbering with it but that has been announced long in advance and when that happens, updated systems with legacy scripts will cease to do GPIO until fixed and not essentially toggling GPIOs at random.

Thanks,
Ahmad

Quoted 2 lines

Bart

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#9 lore raw

Re: [PATCH 2/2] gpio: mxc: switch to dynamic allocat GPIO base

In reply to [email protected]
Quoted 30 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

---
 drivers/gpio/gpio-mxc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +1 -3
index 9d0cec4b82a3..abc129a88a62 100644
@@ -462,8 +462,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
        port->gc.request = gpiochip_generic_request;
        port->gc.free = gpiochip_generic_free;
        port->gc.to_irq = mxc_gpio_to_irq;
-       port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
-                                            pdev->id * 32;
+       port->gc.base = -1;
 
        err = devm_gpiochip_add_data(&pdev->dev, &port->gc, port);
        if (err)
--
Quoted 2 lines

2.34.1

This is not the first time we're seeing someone submit this fix[1].

Unfortunately it's been brought to our attention that this breaks existing user-space scripts that rely on fixed GPIO numbering in sysfs.

Bart

[1] https://lore.kernel.org/lkml/CACRpkdYV3mHNYvBg1nf+12Q2XZH_g4iTrA2YB1SVQ=ROriRRgg@mail.gmail.com/T/

Reviewed-by on v1 1/2
#10 lore raw
In reply to [email protected]
Quoted 10 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

Yours,
Linus Walleij

author
#11 lore raw
Quoted 16 lines

-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: 2023年5月6日 21:05
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] gpio: vf610: switch to dynamic allocat GPIO base

Quoted 6 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

Quoted 6 lines
Quoted 4 lines
[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

Hi Linus and Bartosz,

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

Best Regards
Haibo Chen

Quoted 3 lines

Yours,
Linus Walleij

#12 lore raw
Quoted 20 lines · Bough Chen
Quoted 20 lines

-----Original Message-----
From: Linus Walleij <[email protected]>
Sent: 2023年5月6日 21:05
To: Bough Chen <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; dl-linux-imx <[email protected]>; [email protected]
Subject: Re: [PATCH 1/2] gpio: vf610: switch to dynamic allocat GPIO base

Quoted 9 lines · On Sat, May 6, 2023 at 10:56 AM <[email protected]> wrote:

From: Haibo Chen <[email protected]>

gpiolib want to get completely rid of static gpiobase allocation, so switch to dynamic allocat GPIO base, also can avoid warning message:

[    1.529974] gpio gpiochip0: Static allocation of GPIO base

is deprecated, use dynamic allocation.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Hi Linus and Bartosz,

For this patch, still not in the main trunk (Linux 6.5-rc7) and linux-next(next-20230818). Can you help apply or any comment?

I think I didn't apply it because the first patch in this series was controversial with known user-space breakages. Now applied.

Bart