Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/3] drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive
@ 2026-11-03 13:33 Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 1/3] ARM: stm32: select HAVE_SHARED_GPIOS Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-11-03 13:33 UTC (permalink / raw)
  To: Russell King, Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-arm-kernel, linux-stm32, linux-kernel, linux-sunxi,
	dri-devel, linux-gpio, Bartosz Golaszewski

GPIOD_FLAGS_BIT_NONEXCLUSIVE is deprecated and I'm slowly working on
converting all users to using the shared GPIO proxy which automates the
sharing and allows drivers to not care about whether the pins are shared
(as they should). This series selects HAVE_SHARED_GPIOS for the two ARM
platforms that use this panel driver and then drops the non-exclusive
flag.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Bartosz Golaszewski (3):
      ARM: stm32: select HAVE_SHARED_GPIOS
      ARM: sunxi: select HAVE_SHARED_GPIOS
      drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE

 arch/arm/mach-stm32/Kconfig           | 1 +
 arch/arm/mach-sunxi/Kconfig           | 1 +
 drivers/gpu/drm/tiny/panel-mipi-dbi.c | 3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)
---
base-commit: 2637bdec0535a2044cd830eba9a79363651d9043
change-id: 20261103-panel-mipi-non-exclusive-gpios-bb27e91f31e1

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ARM: stm32: select HAVE_SHARED_GPIOS
  2026-11-03 13:33 [PATCH 0/3] drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive Bartosz Golaszewski
@ 2026-11-03 13:33 ` Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 2/3] ARM: sunxi: " Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
  2 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-11-03 13:33 UTC (permalink / raw)
  To: Russell King, Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-arm-kernel, linux-stm32, linux-kernel, linux-sunxi,
	dri-devel, linux-gpio, Bartosz Golaszewski

Enable automated management of shared GPIOs provided by the GPIO shared
proxy module for stm32 platforms.

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

diff --git a/arch/arm/mach-stm32/Kconfig b/arch/arm/mach-stm32/Kconfig
index 4ac3384e397aabd86e4843d6a6326cd22a2dd66e..ecb6b35610f4988b4fca3fa10defc260a149f7c1 100644
--- a/arch/arm/mach-stm32/Kconfig
+++ b/arch/arm/mach-stm32/Kconfig
@@ -9,6 +9,7 @@ menuconfig ARCH_STM32
 	select ARM_AMBA
 	select ARCH_HAS_RESET_CONTROLLER
 	select CLKSRC_STM32
+	select HAVE_SHARED_GPIOS
 	select PINCTRL
 	select RESET_CONTROLLER
 	select STM32_EXTI if ARM_SINGLE_ARMV7M

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ARM: sunxi: select HAVE_SHARED_GPIOS
  2026-11-03 13:33 [PATCH 0/3] drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 1/3] ARM: stm32: select HAVE_SHARED_GPIOS Bartosz Golaszewski
@ 2026-11-03 13:33 ` Bartosz Golaszewski
  2026-11-03 13:43   ` sashiko-bot
  2026-11-03 13:33 ` [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
  2 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-11-03 13:33 UTC (permalink / raw)
  To: Russell King, Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-arm-kernel, linux-stm32, linux-kernel, linux-sunxi,
	dri-devel, linux-gpio, Bartosz Golaszewski

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(+)

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

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
  2026-11-03 13:33 [PATCH 0/3] drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 1/3] ARM: stm32: select HAVE_SHARED_GPIOS Bartosz Golaszewski
  2026-11-03 13:33 ` [PATCH 2/3] ARM: sunxi: " Bartosz Golaszewski
@ 2026-11-03 13:33 ` Bartosz Golaszewski
  2026-11-03 13:42   ` sashiko-bot
  2 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-11-03 13:33 UTC (permalink / raw)
  To: Russell King, Maxime Coquelin, Alexandre Torgue, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-arm-kernel, linux-stm32, linux-kernel, linux-sunxi,
	dri-devel, linux-gpio, Bartosz Golaszewski

GPIOD_FLAGS_BIT_NONEXCLUSIVE is deprecated and will be removed. The
preferred way of sharing of GPIO pins is relying on the GPIO shared
proxy provided by GPIOLIB. There are only two users of this driver in
upstream DT sources and both now select HAVE_SHARED_GPIOS so we can
safely drop the non-exclusive acquisition of dc-gpios.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpu/drm/tiny/panel-mipi-dbi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tiny/panel-mipi-dbi.c b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
index 60cd65cae41d8d4f4f6e5fbc57d5d34058ca4d38..6f09b723cd7c352b0a1ea9f11a2e58052978cf0d 100644
--- a/drivers/gpu/drm/tiny/panel-mipi-dbi.c
+++ b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
@@ -418,8 +418,7 @@ static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
 	if (IS_ERR(dbi->reset))
 		return dev_err_probe(dev, PTR_ERR(dbi->reset), "Failed to get GPIO 'reset'\n");
 
-	/* Multiple panels can share the "dc" GPIO, but only if they are on the same SPI bus! */
-	dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
+	dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);
 	if (IS_ERR(dc))
 		return dev_err_probe(dev, PTR_ERR(dc), "Failed to get GPIO 'dc'\n");
 

-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
  2026-11-03 13:33 ` [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
@ 2026-11-03 13:42   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-03 13:42 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linux-sunxi, dri-devel, linux-gpio

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/panel-mipi-dbi: broken shared dc GPIO in panel_mipi_dbi_spi_probe()
--

commit 90b279985dbeced362ebac928f364d9afff9972e
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE

This commit removes the deprecated GPIOD_FLAGS_BIT_NONEXCLUSIVE flag when
requesting the dc GPIO in panel_mipi_dbi_spi_probe(), relying on the GPIOLIB
shared GPIO proxy instead.

> diff --git a/drivers/gpu/drm/tiny/panel-mipi-dbi.c b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> index 60cd65cae41d8..6f09b723cd7c3 100644
> --- a/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> +++ b/drivers/gpu/drm/tiny/panel-mipi-dbi.c
> @@ -418,8 +418,7 @@ static int panel_mipi_dbi_spi_probe(struct spi_device *spi)
>  	if (IS_ERR(dbi->reset))
>  		return dev_err_probe(dev, PTR_ERR(dbi->reset), "Failed to get GPIO 'reset'\n");
>  
> -	/* Multiple panels can share the "dc" GPIO, but only if they are on the same SPI bus! */
> -	dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
> +	dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);

[Severity: High]
Can gpio-shared-proxy work for a shared MIPI DBI D/C line across multiple
panels on the same SPI bus?

Unlike a shared reset or enable pin, the D/C GPIO in MIPI DBI Type C Option 3
is a bus control signal (0 for commands, 1 for parameters and pixel data)
multiplexed under spi_bus_lock(). In drivers/gpu/drm/drm_mipi_dbi.c,
mipi_dbi_typec3_command() leaves dbi->dc asserted at 1 after transferring
command parameters or pixel data:

drivers/gpu/drm/drm_mipi_dbi.c:mipi_dbi_typec3_command() {
	...
	spi_bus_lock(spi->controller);
	gpiod_set_value_cansleep(dbi->dc, 0);
	speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1);
	ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, &cmd, 1);
	spi_bus_unlock(spi->controller);
	if (ret || !num)
		return ret;

	...
	spi_bus_lock(spi->controller);
	gpiod_set_value_cansleep(dbi->dc, 1);
	speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num);
	ret = mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num);
	spi_bus_unlock(spi->controller);

	return ret;
}

When panel_mipi_dbi_spi_probe() requests dc with GPIOD_OUT_LOW,
shared_desc->def_val is 0. Once panel A sends a command with parameters and
sets dbi->dc to 1, gpio_shared_proxy_set_unlocked() sets panel A's
proxy->voted_change = true and increments shared_desc->votecnt to 1. Because
mipi_dbi_typec3_command() returns with dbi->dc still at 1, panel A retains its
vote after releasing spi_bus_lock().

When panel B on the same SPI bus then calls gpiod_set_value_cansleep(dbi->dc, 0)
in mipi_dbi_typec3_command() or mipi_dbi_typec3_command_read() to send a
command byte, gpio_shared_proxy_set_unlocked() checks whether any other proxy
still holds a vote for 1:

drivers/gpio/gpio-shared-proxy.c:gpio_shared_proxy_set_unlocked() {
	...
	/* Desired value is the default. */
	if (!proxy->voted_change) {
		if (!shared_desc->votecnt)
			ret = gpiod_set_value_cansleep(desc, shared_desc->def_val);
		goto out;
	}

	/* We previously voted for change. */
	if (shared_desc->votecnt == 1) {
		/* This is the last remaining vote for change, set value to default. */
		ret = gpiod_set_value_cansleep(desc, shared_desc->def_val);
		if (ret)
			goto out;
	}
	...
}

Because panel A's vote keeps shared_desc->votecnt >= 1, gpio-shared-proxy will
not drive the physical D/C GPIO back to 0 when panel B requests 0, leaving the
physical D/C line stuck high in data mode during panel B's command transfers
(and vice versa once panel B also sets dc to 1).

Also, the two in-tree DT users mentioned in the commit message only define a
single panel each and do not share dc-gpios, whereas DRM_PANEL_MIPI_DBI itself
does not select HAVE_SHARED_GPIOS and can be used on any platform or via DT
overlays where shared dc-gpios configurations (added in commits 3a63ef6e4b9e
and 8cc8ccbaa5d8) would now either fail probe with -EBUSY or fail to toggle
the physical D/C line.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-panel-mipi-non-exclusive-gpios-v1-0-aa862c1d71e3@oss.qualcomm.com?part=3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] ARM: sunxi: select HAVE_SHARED_GPIOS
  2026-11-03 13:33 ` [PATCH 2/3] ARM: sunxi: " Bartosz Golaszewski
@ 2026-11-03 13:43   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-03 13:43 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linux-sunxi, dri-devel, linux-gpio

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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103-panel-mipi-non-exclusive-gpios-v1-0-aa862c1d71e3@oss.qualcomm.com?part=2

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-03 13:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 13:33 [PATCH 0/3] drm/panel-mipi-dbi: stop requesting GPIOs explicitly as non-exclusive Bartosz Golaszewski
2026-11-03 13:33 ` [PATCH 1/3] ARM: stm32: select HAVE_SHARED_GPIOS Bartosz Golaszewski
2026-11-03 13:33 ` [PATCH 2/3] ARM: sunxi: " Bartosz Golaszewski
2026-11-03 13:43   ` sashiko-bot
2026-11-03 13:33 ` [PATCH 3/3] drm/panel-mipi-dbi: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
2026-11-03 13:42   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox