[2/3] ARM: sunxi: select HAVE_SHARED_GPIOS

Message ID 20261103-panel-mipi-non-exclusive-gpios-v1-2-aa862c1d71e3@oss.qualcomm.com (mailing list archive)
State New
Headers
Series drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive |

Commit Message

Bartosz Golaszewski Nov. 3, 2026, 1:33 p.m. UTC
Enable automated management of shared GPIOs provided by the GPIO shared
proxy module for sunxi platforms.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 arch/arm/mach-sunxi/Kconfig | 1 +
 1 file changed, 1 insertion(+)
  

Comments

sashiko-bot@kernel.org Nov. 3, 2026, 1:43 p.m. UTC | #1
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ARM: sunxi: HAVE_SHARED_GPIOS ignores 3-cell sunxi SoC GPIO bindings
--

commit 08b8c5df755142dacaed1d91af688663b9db7e82
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

ARM: sunxi: select HAVE_SHARED_GPIOS

This commit selects HAVE_SHARED_GPIOS for ARCH_SUNXI to enable automated
management of shared GPIOs via the GPIO shared proxy module on sunxi
platforms.

> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index e015f2497111a..b62e8518e2704 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -5,6 +5,7 @@ menuconfig ARCH_SUNXI
>  	select ARCH_HAS_RESET_CONTROLLER
>  	select CLKSRC_MMIO
>  	select GPIOLIB
> +	select HAVE_SHARED_GPIOS

[Severity: Medium]
Does selecting HAVE_SHARED_GPIOS here actually work for Allwinner sunxi SoC
GPIO controllers?

Allwinner sunxi pinctrl/GPIO controllers (&pio and &r_pio) use 3-cell GPIO
specifiers (#gpio-cells = <3>: bank, pin, flags), as translated in
drivers/pinctrl/sunxi/pinctrl-sunxi.c:sunxi_pinctrl_gpio_of_xlate():

static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
				const struct of_phandle_args *gpiospec,
				u32 *flags)
{
	int pin, base;

	base = PINS_PER_BANK * gpiospec->args[0];
	pin = base + gpiospec->args[1];

For example, in arch/arm/boot/dts/allwinner/sunxi-libretech-all-h3-cc.dtsi,
reg_vcc1v2 and reg_vdd_cpux share a GPIO using a 3-cell specifier:

	gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */

However, during boot, gpio_shared_of_scan() -> gpio_shared_of_traverse() in
drivers/gpio/gpiolib-shared.c skips any GPIO specifier that does not have
exactly 2 cells:

	if (args.args_count != 2)
		continue;

Additionally, struct gpio_shared_entry only records a single cell in
entry->offset, and gpiochip_setup_shared() in drivers/gpio/gpiolib-shared.c
hardcodes a 2-cell specifier with only args[0] populated when invoking
gc->of_xlate():

	gpiospec.np = to_of_node(entry->fwnode);
	gpiospec.args_count = 2;
	gpiospec.args[0] = entry->offset;

	ret = gc->of_xlate(gc, &gpiospec, NULL);

Wouldn't this cause gpiolib-shared to ignore all shared sunxi SoC GPIOs in
device tree, so any consumer relying on HAVE_SHARED_GPIOS rather than
GPIOD_FLAGS_BIT_NONEXCLUSIVE fails with -EBUSY?
  
Bartosz Golaszewski Nov. 5, 2026, 8:35 a.m. UTC | #2
On Tue, Nov 03, 2026 at 01:43:13PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] ARM: sunxi: HAVE_SHARED_GPIOS ignores 3-cell sunxi SoC GPIO bindings
> --
> 
> commit 08b8c5df755142dacaed1d91af688663b9db7e82
> Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> 
> ARM: sunxi: select HAVE_SHARED_GPIOS
> 
> This commit selects HAVE_SHARED_GPIOS for ARCH_SUNXI to enable automated
> management of shared GPIOs via the GPIO shared proxy module on sunxi
> platforms.
> 
> > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > index e015f2497111a..b62e8518e2704 100644
> > --- a/arch/arm/mach-sunxi/Kconfig
> > +++ b/arch/arm/mach-sunxi/Kconfig
> > @@ -5,6 +5,7 @@ menuconfig ARCH_SUNXI
> >  	select ARCH_HAS_RESET_CONTROLLER
> >  	select CLKSRC_MMIO
> >  	select GPIOLIB
> > +	select HAVE_SHARED_GPIOS
> 
> [Severity: Medium]
> Does selecting HAVE_SHARED_GPIOS here actually work for Allwinner sunxi SoC
> GPIO controllers?
> 
> Allwinner sunxi pinctrl/GPIO controllers (&pio and &r_pio) use 3-cell GPIO
> specifiers (#gpio-cells = <3>: bank, pin, flags), as translated in
> drivers/pinctrl/sunxi/pinctrl-sunxi.c:sunxi_pinctrl_gpio_of_xlate():
>

Right, shared GPIOs need support for 3-cell bindings first. Let's drop
this for now.

Bart
  

Patch

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index e015f2497111a42133ddd4e7ddd172eda06d90ba..b62e8518e270459444e7d4ee382ef753c368dd51 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -5,6 +5,7 @@  menuconfig ARCH_SUNXI
 	select ARCH_HAS_RESET_CONTROLLER
 	select CLKSRC_MMIO
 	select GPIOLIB
+	select HAVE_SHARED_GPIOS
 	select PINCTRL
 	select PM_OPP
 	select SUN4I_TIMER