Message ID | 20240220133950.138452-1-herve.codina@bootlin.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp406200dyc; Tue, 20 Feb 2024 05:42:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6xUYkwFsL4VSQmG2ZI0uj2aXi4hBM7T33VKXoIqtV8a2mXmMdozZLnd9DXMecOFIeNjJazf8aKhTqQCk7D1oR7kunxg== X-Google-Smtp-Source: AGHT+IE+k++gaPECKHcqaz8ahhH/XTPz2HDmP0Z0xZGLmtLllrRG7lORqm+cq7XdJj1eyZR0SvaL X-Received: by 2002:a05:6a21:9209:b0:19e:bc6b:e1ae with SMTP id tl9-20020a056a21920900b0019ebc6be1aemr19223361pzb.54.1708436567912; Tue, 20 Feb 2024 05:42:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708436567; cv=pass; d=google.com; s=arc-20160816; b=gcX4HJS4UaTZVmSjhK0mBMJcscgMPcdlYGbhz9e2RkyYxI90YWWyGAbP9eSDYgMpJF 1YptEcPpbQfXHo4I5OCmQLyqoZLZCyyDCQANJ5MswAlA+ka0eG8ivqZ2kjEzAxViL2MQ L9YiLhVYcW5tM64n+ktTwc3Bkk0DMNc3tNoRcUof28uthMC+goywkfLnFLPbyq+FYfHN 29muya+n1ROi/AEixPtZMcwhZvmaVRGNsQE9qHbForwI1OW0h8JZycXIqeit4/8amAcw FLeX+w6RTCRnEuToHQjAjUdFyzar8eOWnpJg9C3a9Ul4sq/Bp/T9/Hax7DH8k1Omb76Z Dh/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=JR5bxG1GSyiF5ERk11qYZtMLEqsuYC3EasEln4G35iQ=; fh=QafpXXBPN+evVxhvNLO0vOTmFz/JzXhK29Onx49STnY=; b=ArPzeMLq9xxAWYHoW90ViHhJ2PgrbobLvbaUtXEcuarLEDi5jqIz1rSzwNtfS1vK8W UebJqnNx4wNAuHGOY6E2uD1Kfx26esZBXn8nUYn4YeqcI9N8oPPI77ke49Pu/ptXTHyj wCkYCbn5NILvxiVE0VKn0UMI9jlIiIT4llCf9zeQVDEDbWMCUF6FY3s5gSWpCukvB7s4 KMF2w94+I7jhQ1M84necG+/KZ+ZV2yzLnGR0PKI5n57wIgt/bfUDlf4gNrtG+S7fv4/I +ozh6rClCf3uI/dKJwaJfUfQItA250c1DfQak/HjTBpce3AJubHL3+6xvwoUfaN2i8j6 NRTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D0wVH8Zx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u7-20020a655c07000000b005dc0b3095b3si6161903pgr.283.2024.02.20.05.42.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:42:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D0wVH8Zx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73083-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 10416B2249E for <ouuuleilei@gmail.com>; Tue, 20 Feb 2024 13:40:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75A466A8B4; Tue, 20 Feb 2024 13:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="D0wVH8Zx" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DE384C60; Tue, 20 Feb 2024 13:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708436399; cv=none; b=sT6n54azLk5rQuURgA8PyR1VIW8iRE//RDEMoIAEfV55s4I/Vlsfs3zouF/2gS+kx9Ia3+3lGpBnRYvKAzjSK+SRBUhxnUb6R1YLpwjMmr4u/Falqj2uIo2nG1bxlAAe3QsZB5V4ltTKyHqlR4hlnUurIVcSAem22FJgWhjj8Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708436399; c=relaxed/simple; bh=maUOB1I/kGF7pxO+VAjAEbO4lZcaywIU34qr1xonNlU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=l0IMDBQv6nIZbI1FIpsSp2FQyVf80i4yQHkfMroHCz3lAmrfin4viRvoxSuiPTuJ/P7e+boJQf9r7NlNy+UUP+QQHrO0TjFh59AqIOEybXjEVEjRDiTQwvBhzwpCi99oMvrKvkBxfk6S0un534QnX0S1wHrsNbiluwmj7j2EEdM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=D0wVH8Zx; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPA id D42FF20004; Tue, 20 Feb 2024 13:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708436395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JR5bxG1GSyiF5ERk11qYZtMLEqsuYC3EasEln4G35iQ=; b=D0wVH8ZxwoErTe+VqwqvA29q5zZjYHP66v8cKgfbdKh70MIQBuqFMtf1xTc9Bcyf9i+wT5 vFvkzyHA8FdGvsppHWxBjlVYwDEFbOvEV/Ew3H68t4aVwwVbECf0uGX/c1RrMkGId8aL3U YNkEkee0IPomt0KwmWaPdTPign4o/Ds85GxDvmAW88LTWiWY8Ye1UJHyR2GEsJ+S034PjA +1dIqXA5f3yKos+E54FvA5r/DSe9XV3msVL2TiqAqFNfK8K3KAm9eH1bmHjZAN/3uq0b7u ZcQCZ0FPn9DermON9GYt9tW+fjnKm0G1bkoTrzUPc6w4UnNdNvyW8wWK0RuHIA== From: Herve Codina <herve.codina@bootlin.com> To: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <brgl@bgdev.pl>, Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org> Cc: Saravana Kannan <saravanak@google.com>, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Luca Ceresoli <luca.ceresoli@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Herve Codina <herve.codina@bootlin.com> Subject: [PATCH RESEND 0/2] leds: gpio: Add devlink between the leds-gpio device and the gpio used. Date: Tue, 20 Feb 2024 14:39:47 +0100 Message-ID: <20240220133950.138452-1-herve.codina@bootlin.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791416136069786247 X-GMAIL-MSGID: 1791425582463704314 |
Series |
leds: gpio: Add devlink between the leds-gpio device and the gpio used.
|
|
Message
Herve Codina
Feb. 20, 2024, 1:39 p.m. UTC
Hi, Note: Resent this series with Saravana added in Cc. When a gpio used by the leds-gpio device is removed, the leds-gpio device continues to use this gpio. Also, when the gpio is back, the leds-gpio still uses the old removed gpio. A consumer/supplier relationship is missing between the leds-gpio device (consumer) and the gpio used (supplier). This series adds an addionnal devlink between this two device. With this link when the gpio is removed, the leds-gpio device is also removed. Best regards, Hervé Codina Herve Codina (2): gpiolib: Introduce gpiod_device_add_link() leds: gpio: Add devlinks between the gpio consumed and the gpio leds device drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ drivers/leds/leds-gpio.c | 15 +++++++++++++++ include/linux/gpio/consumer.h | 5 +++++ 3 files changed, 52 insertions(+)
Comments
On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > Hi, > > Note: Resent this series with Saravana added in Cc. > > When a gpio used by the leds-gpio device is removed, the leds-gpio > device continues to use this gpio. Also, when the gpio is back, the > leds-gpio still uses the old removed gpio. > > A consumer/supplier relationship is missing between the leds-gpio device > (consumer) and the gpio used (supplier). > > This series adds an addionnal devlink between this two device. > With this link when the gpio is removed, the leds-gpio device is also > removed. > > Best regards, > Hervé Codina > > Herve Codina (2): > gpiolib: Introduce gpiod_device_add_link() > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > device > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > include/linux/gpio/consumer.h | 5 +++++ > 3 files changed, 52 insertions(+) > > -- > 2.43.0 > Can you add some more context here in the form of DT snippets that lead to this being needed? Bartosz
On Tue, 20 Feb 2024 15:19:57 +0100 Bartosz Golaszewski <brgl@bgdev.pl> wrote: > On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > Hi, > > > > Note: Resent this series with Saravana added in Cc. > > > > When a gpio used by the leds-gpio device is removed, the leds-gpio > > device continues to use this gpio. Also, when the gpio is back, the > > leds-gpio still uses the old removed gpio. > > > > A consumer/supplier relationship is missing between the leds-gpio device > > (consumer) and the gpio used (supplier). > > > > This series adds an addionnal devlink between this two device. > > With this link when the gpio is removed, the leds-gpio device is also > > removed. > > > > Best regards, > > Hervé Codina > > > > Herve Codina (2): > > gpiolib: Introduce gpiod_device_add_link() > > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > > device > > > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > > include/linux/gpio/consumer.h | 5 +++++ > > 3 files changed, 52 insertions(+) > > > > -- > > 2.43.0 > > > > Can you add some more context here in the form of DT snippets that > lead to this being needed? / { leds-dock { compatible = "gpio-leds"; led-5 { label = "dock:alarm:red"; gpios = <&tca6424_dock_2 12 GPIO_ACTIVE_HIGH>; }; led-6 { label = "dock:alarm:yellow"; gpios = <&tca6424_dock_2 13 GPIO_ACTIVE_HIGH>; }; led-7 { label = "dock:alarm:blue"; gpios = <&tca6424_dock_2 14 GPIO_ACTIVE_HIGH>; }; }; ... i2c5 { ... tca6424_dock_2: gpio@23 { compatible = "ti,tca6424"; reg = <0x23>; gpio-controller; #gpio-cells = <2>; interrupt-parent = <&tca6424_dock_1>; interrupts = <23 IRQ_TYPE_EDGE_FALLING>; interrupt-controller; #interrupt-cells = <2>; vcc-supply = <®_dock_ctrl_3v3>; }; tca6424_dock_1: gpio@22 { compatible = "ti,tca6424"; reg = <0x22>; gpio-controller; #gpio-cells = <2>; interrupt-parent = <&gpio4>; interrupts = <1 IRQ_TYPE_EDGE_FALLING>; interrupt-controller; #interrupt-cells = <2>; vcc-supply = <®_dock_ctrl_3v3>; }; }; }; Also, had the exact same issue if I use a SoC gpio chip instead of an i2c gpio expander. Best regards, Hervé
On Tue, Feb 20, 2024 at 3:53 PM Herve Codina <herve.codina@bootlin.com> wrote: > > On Tue, 20 Feb 2024 15:19:57 +0100 > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > Hi, > > > > > > Note: Resent this series with Saravana added in Cc. > > > > > > When a gpio used by the leds-gpio device is removed, the leds-gpio > > > device continues to use this gpio. Also, when the gpio is back, the > > > leds-gpio still uses the old removed gpio. > > > > > > A consumer/supplier relationship is missing between the leds-gpio device > > > (consumer) and the gpio used (supplier). > > > > > > This series adds an addionnal devlink between this two device. > > > With this link when the gpio is removed, the leds-gpio device is also > > > removed. > > > > > > Best regards, > > > Hervé Codina > > > > > > Herve Codina (2): > > > gpiolib: Introduce gpiod_device_add_link() > > > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > > > device > > > > > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > > > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > > > include/linux/gpio/consumer.h | 5 +++++ > > > 3 files changed, 52 insertions(+) > > > > > > -- > > > 2.43.0 > > > > > > > Can you add some more context here in the form of DT snippets that > > lead to this being needed? > > / { > leds-dock { > compatible = "gpio-leds"; > > led-5 { > label = "dock:alarm:red"; > gpios = <&tca6424_dock_2 12 GPIO_ACTIVE_HIGH>; > }; Do I understand correctly that the devlink is created between "led-5" and "tca6424_dock_2" but actually should also be created between "leds-dock" and "tca6424_dock_2"? Bartosz > > led-6 { > label = "dock:alarm:yellow"; > gpios = <&tca6424_dock_2 13 GPIO_ACTIVE_HIGH>; > }; > > led-7 { > label = "dock:alarm:blue"; > gpios = <&tca6424_dock_2 14 GPIO_ACTIVE_HIGH>; > }; > }; > > ... > i2c5 { > ... > tca6424_dock_2: gpio@23 { > compatible = "ti,tca6424"; > reg = <0x23>; > gpio-controller; > #gpio-cells = <2>; > interrupt-parent = <&tca6424_dock_1>; > interrupts = <23 IRQ_TYPE_EDGE_FALLING>; > interrupt-controller; > #interrupt-cells = <2>; > vcc-supply = <®_dock_ctrl_3v3>; > }; > tca6424_dock_1: gpio@22 { > compatible = "ti,tca6424"; > reg = <0x22>; > gpio-controller; > #gpio-cells = <2>; > interrupt-parent = <&gpio4>; > interrupts = <1 IRQ_TYPE_EDGE_FALLING>; > interrupt-controller; > #interrupt-cells = <2>; > vcc-supply = <®_dock_ctrl_3v3>; > }; > }; > }; > > Also, had the exact same issue if I use a SoC gpio chip instead of an > i2c gpio expander. > > Best regards, > Hervé
Hi Bartosz, On Tue, 20 Feb 2024 16:30:11 +0100 Bartosz Golaszewski <brgl@bgdev.pl> wrote: > On Tue, Feb 20, 2024 at 3:53 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > On Tue, 20 Feb 2024 15:19:57 +0100 > > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > > > On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > > > Hi, > > > > > > > > Note: Resent this series with Saravana added in Cc. > > > > > > > > When a gpio used by the leds-gpio device is removed, the leds-gpio > > > > device continues to use this gpio. Also, when the gpio is back, the > > > > leds-gpio still uses the old removed gpio. > > > > > > > > A consumer/supplier relationship is missing between the leds-gpio device > > > > (consumer) and the gpio used (supplier). > > > > > > > > This series adds an addionnal devlink between this two device. > > > > With this link when the gpio is removed, the leds-gpio device is also > > > > removed. > > > > > > > > Best regards, > > > > Hervé Codina > > > > > > > > Herve Codina (2): > > > > gpiolib: Introduce gpiod_device_add_link() > > > > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > > > > device > > > > > > > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > > > > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > > > > include/linux/gpio/consumer.h | 5 +++++ > > > > 3 files changed, 52 insertions(+) > > > > > > > > -- > > > > 2.43.0 > > > > > > > > > > Can you add some more context here in the form of DT snippets that > > > lead to this being needed? > > > > / { > > leds-dock { > > compatible = "gpio-leds"; > > > > led-5 { > > label = "dock:alarm:red"; > > gpios = <&tca6424_dock_2 12 GPIO_ACTIVE_HIGH>; > > }; > > Do I understand correctly that the devlink is created between "led-5" > and "tca6424_dock_2" but actually should also be created between > "leds-dock" and "tca6424_dock_2"? > Yes, that's my understanding too. Best regards, Hervé
On Tue, Feb 20, 2024 at 7:47 AM Herve Codina <herve.codina@bootlin.com> wrote: > > Hi Bartosz, > > On Tue, 20 Feb 2024 16:30:11 +0100 > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > On Tue, Feb 20, 2024 at 3:53 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > On Tue, 20 Feb 2024 15:19:57 +0100 > > > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > > > > > On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > > > > > Hi, > > > > > > > > > > Note: Resent this series with Saravana added in Cc. > > > > > > > > > > When a gpio used by the leds-gpio device is removed, the leds-gpio > > > > > device continues to use this gpio. Also, when the gpio is back, the > > > > > leds-gpio still uses the old removed gpio. > > > > > > > > > > A consumer/supplier relationship is missing between the leds-gpio device > > > > > (consumer) and the gpio used (supplier). > > > > > > > > > > This series adds an addionnal devlink between this two device. > > > > > With this link when the gpio is removed, the leds-gpio device is also > > > > > removed. > > > > > > > > > > Best regards, > > > > > Hervé Codina > > > > > > > > > > Herve Codina (2): > > > > > gpiolib: Introduce gpiod_device_add_link() > > > > > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > > > > > device > > > > > > > > > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > > > > > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > > > > > include/linux/gpio/consumer.h | 5 +++++ > > > > > 3 files changed, 52 insertions(+) > > > > > > > > > > -- > > > > > 2.43.0 > > > > > > > > > > > > > Can you add some more context here in the form of DT snippets that > > > > lead to this being needed? > > > > > > / { > > > leds-dock { > > > compatible = "gpio-leds"; > > > > > > led-5 { > > > label = "dock:alarm:red"; > > > gpios = <&tca6424_dock_2 12 GPIO_ACTIVE_HIGH>; > > > }; > > > > Do I understand correctly that the devlink is created between "led-5" > > and "tca6424_dock_2" but actually should also be created between > > "leds-dock" and "tca6424_dock_2"? > > > > Yes, that's my understanding too. I'm replying here instead of the RESEND because here's where the context and example are provided. I quickly poked into the gpio-leds driver. Please correct me if I'm misunderstanding anything. It looks like led-5 will be added as a class device. But the dev->fwnode is not set before it's added because it uses device_create_with_groups(). So, fw_devlink doesn't create a link between led-5 and tca6424_dock_2 unless tca6424_dock_2 is added after led-5. Which coincidentally seems to be the case here. Might want to explicitly create the device in gpio-leds driver. The issue you are trying to fix is a generic issue that I'd like to fix in a generic fashion. It's one of my TODOs which I've mentioned before in conferences/emails to LKML: device links framework has a bunch of gaps when it comes to class devices. I've been thinking about it for a while, but it needs a lot more work and testing. I'll roll in this case when I deal with it in a generic fashion. But here's the general idea of things that need to be addressed: 1. "Managed" device links allow having a class device as a supplier, but that'll mean the consumer will never probe. 2. What if a class device is a consumer and the supplier isn't ready. What does it mean for the class device to be added? Is it available for use? Probably not. Can we do something here that'll be useful for the class implementation? 3. What if the supplier and consumer are class devices, when does the consumer class device become "available" (do we check the suppliers of the supplier?)? 4. What happens if the supplier of a class device gets removed? Do we notify the class so it can do the right thing? Do we force unbind the first ancestor that's on a bus? (your case). 5. What if a supplier class device is removed, should we unbind the consumer (if it's a bus device)? I'm currently working on a patch to break dependency cycles. Once that's in, the next TODO item I work on is going to be this or clock framework sync_state() support. So, I'd recommend waiting this out if it's not urgent. Heh, here's my commit on my local repo from a year ago when I touched on this and realised the scope of the work. commit 7dcaad52e569209104408f3e472fde4ef8cd5585 (class-devlinks-v1) Author: Saravana Kannan <saravanak@google.com> Date: Mon Feb 13 13:40:43 2023 -0800 add class support to device links Thanks, Saravana
Hi Saravana, On Tue, 20 Feb 2024 19:28:17 -0800 Saravana Kannan <saravanak@google.com> wrote: > On Tue, Feb 20, 2024 at 7:47 AM Herve Codina <herve.codina@bootlin.com> wrote: > > > > Hi Bartosz, > > > > On Tue, 20 Feb 2024 16:30:11 +0100 > > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > > > On Tue, Feb 20, 2024 at 3:53 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > > > On Tue, 20 Feb 2024 15:19:57 +0100 > > > > Bartosz Golaszewski <brgl@bgdev.pl> wrote: > > > > > > > > > On Tue, Feb 20, 2024 at 2:39 PM Herve Codina <herve.codina@bootlin.com> wrote: > > > > > > > > > > > > Hi, > > > > > > > > > > > > Note: Resent this series with Saravana added in Cc. > > > > > > > > > > > > When a gpio used by the leds-gpio device is removed, the leds-gpio > > > > > > device continues to use this gpio. Also, when the gpio is back, the > > > > > > leds-gpio still uses the old removed gpio. > > > > > > > > > > > > A consumer/supplier relationship is missing between the leds-gpio device > > > > > > (consumer) and the gpio used (supplier). > > > > > > > > > > > > This series adds an addionnal devlink between this two device. > > > > > > With this link when the gpio is removed, the leds-gpio device is also > > > > > > removed. > > > > > > > > > > > > Best regards, > > > > > > Hervé Codina > > > > > > > > > > > > Herve Codina (2): > > > > > > gpiolib: Introduce gpiod_device_add_link() > > > > > > leds: gpio: Add devlinks between the gpio consumed and the gpio leds > > > > > > device > > > > > > > > > > > > drivers/gpio/gpiolib.c | 32 ++++++++++++++++++++++++++++++++ > > > > > > drivers/leds/leds-gpio.c | 15 +++++++++++++++ > > > > > > include/linux/gpio/consumer.h | 5 +++++ > > > > > > 3 files changed, 52 insertions(+) > > > > > > > > > > > > -- > > > > > > 2.43.0 > > > > > > > > > > > > > > > > Can you add some more context here in the form of DT snippets that > > > > > lead to this being needed? > > > > > > > > / { > > > > leds-dock { > > > > compatible = "gpio-leds"; > > > > > > > > led-5 { > > > > label = "dock:alarm:red"; > > > > gpios = <&tca6424_dock_2 12 GPIO_ACTIVE_HIGH>; > > > > }; > > > > > > Do I understand correctly that the devlink is created between "led-5" > > > and "tca6424_dock_2" but actually should also be created between > > > "leds-dock" and "tca6424_dock_2"? > > > > > > > Yes, that's my understanding too. > > I'm replying here instead of the RESEND because here's where the > context and example are provided. > > I quickly poked into the gpio-leds driver. Please correct me if I'm > misunderstanding anything. > > It looks like led-5 will be added as a class device. But the > dev->fwnode is not set before it's added because it uses > device_create_with_groups(). So, fw_devlink doesn't create a link > between led-5 and tca6424_dock_2 unless tca6424_dock_2 is added after > led-5. Which coincidentally seems to be the case here. Might want to > explicitly create the device in gpio-leds driver. > > The issue you are trying to fix is a generic issue that I'd like to > fix in a generic fashion. It's one of my TODOs which I've mentioned > before in conferences/emails to LKML: device links framework has a > bunch of gaps when it comes to class devices. I've been thinking about > it for a while, but it needs a lot more work and testing. I'll roll in > this case when I deal with it in a generic fashion. But here's the > general idea of things that need to be addressed: > > 1. "Managed" device links allow having a class device as a supplier, > but that'll mean the consumer will never probe. > 2. What if a class device is a consumer and the supplier isn't ready. > What does it mean for the class device to be added? Is it available > for use? Probably not. Can we do something here that'll be useful for > the class implementation? > 3. What if the supplier and consumer are class devices, when does the > consumer class device become "available" (do we check the suppliers of > the supplier?)? > 4. What happens if the supplier of a class device gets removed? Do we > notify the class so it can do the right thing? Do we force unbind the > first ancestor that's on a bus? (your case). > 5. What if a supplier class device is removed, should we unbind the > consumer (if it's a bus device)? > > I'm currently working on a patch to break dependency cycles. Once > that's in, the next TODO item I work on is going to be this or clock > framework sync_state() support. > > So, I'd recommend waiting this out if it's not urgent. > > Heh, here's my commit on my local repo from a year ago when I touched > on this and realised the scope of the work. > > commit 7dcaad52e569209104408f3e472fde4ef8cd5585 (class-devlinks-v1) > Author: Saravana Kannan <saravanak@google.com> > Date: Mon Feb 13 13:40:43 2023 -0800 > > add class support to device links > Well, on one side we have this current patch that fixes the current issue in the gpio-led use case. On the other side, I have a commit hash from your local repo which is one year old and some more work is needed on it. Maybe my patch is not fully correct but it fixes the issue. Do you have any idea about when your work on that topic will be available? Best regards, Hervé