mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* fw_devlink: consumers are not linked again when a gpiochip is re-added
@ 2026-11-25 11:07 Adrian Ambrozewicz
  0 siblings, 0 replies; only message in thread
From: Adrian Ambrozewicz @ 2026-11-25 11:07 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Rob Herring, Linus Walleij, Bartosz Golaszewski, Lee Jones,
	Pavel Machek, Herve Codina, driver-core, devicetree, linux-gpio,
	linux-leds, linux-kernel

Hi Saravana,

When a gpiochip is removed and added again for the same DT node, its
consumers do not follow it. We hit it with a USB GPIO expander in DT
(emulated so far). gpio-sim shows it on v7.3-rc7 (arm64 QEMU virt):

  gpio-sim {
  	compatible = "gpio-simulator";
  	sim: bank0 {
  		gpio-controller;
  		#gpio-cells = <2>;
  		ngpios = <16>;
  		gpio-sim,label = "sim-bank0";
  	};
  };
  leds {
  	compatible = "gpio-leds";
  	power_led { gpios = <&sim 2 GPIO_ACTIVE_LOW>; };
  	fault_led { gpios = <&sim 6 GPIO_ACTIVE_HIGH>; };
  	uid_led { gpios = <&sim 9 GPIO_ACTIVE_HIGH>; };
  };
  regulator-own {
  	compatible = "regulator-fixed";
  	regulator-name = "own_node_consumer";
  	gpio = <&sim 4 GPIO_ACTIVE_HIGH>;
  	regulator-min-microvolt = <1800000>;
  	regulator-max-microvolt = <1800000>;
  	enable-active-high;
  	regulator-always-on;
  	regulator-boot-on;
  };

  # echo gpio-sim > /sys/bus/platform/drivers/gpio-sim/unbind
  # echo gpio-sim > /sys/bus/platform/drivers/gpio-sim/bind

regulator-own has a managed link to the gpiochip. It is unbound with
gpio-sim and not probed again: nothing re-queues it, and its fwnode link
went with the first device link (drivers/base/core.c:2331, :2373).

leds has no device link to the gpiochip even before the unbind. From the
code, references in child nodes get SYNC_STATE_ONLY links (:2221), which
are dropped when leds binds (:1440). It stays bound and holds no line on
the new chip. Each new link is refused because leds has probed
(:851-859):

  leds-gpio leds: Failed to create device link (0x180) with supplier gpiochip2 for /leds/uid_led

The leds half does not need the device to go: with the same consumers on
QEMU virt's PL061 GPIO controller and only its driver rebound,
regulator-own is probed again, but leds holds no line on the new
gpiochip. From the code, an I2C expander on a rebound I2C controller
hits both halves.

Herve reported the leds case in 2024 and you called it a generic gap for
class devices [1]; in August you offered to write class device support
for device links [2]. The regulator case matches your 2023 suggestion
[3], though from the code a re-queued consumer would have no device link
afterwards. I found no later series for either.

Is the class device series still planned, and would it cover a gpiochip
that is removed and added again? Herve's leds-gpio link, ported to
v7.3-rc7, only gets leds unbound when the GPIO goes; nothing probes it
again when the chip returns. Would that be acceptable meanwhile? I can
test either with this reproducer.

[1] https://lore.kernel.org/all/CAGETcx_=g1dCH=YMUkc7VquUmLs=bNZMspUxH+V49uhcV0Bx2w@mail.gmail.com/
[2] https://lore.kernel.org/all/CACRMN=fEPoyEk1oi4QRMX0whMEF=xQv=kkd62bueKTKWtxDedA@mail.gmail.com/
[3] https://lore.kernel.org/all/CAGETcx_fXa6Zt_gkTQKw8Wt11EmSt8ZQ6TxKi5P+5ii3EvwsdA@mail.gmail.com/

Thanks,
Adrian

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-25 11:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 11:07 fw_devlink: consumers are not linked again when a gpiochip is re-added Adrian Ambrozewicz

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

all inboxes | Powered by JetHome®