Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2128818rbb; Tue, 27 Feb 2024 11:27:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWDDOE0DuL2MxDJugUcKLy+eg2Sa7iXi+V3ZCUIPejpebEfpjvfNLMCThHAiXh7qXCFm6A5MaQ26C8h6z6GaOKQErMXRcM3T6cUdAleXw== X-Google-Smtp-Source: AGHT+IECv3sM2p7ZXZ7HGT/EHY8iZRrQF8TMJNam5GwdpL9O3Vy8Ym/6BVwOAj8nnXaO74sReBwZ X-Received: by 2002:a17:906:79d7:b0:a43:1862:d7b with SMTP id m23-20020a17090679d700b00a4318620d7bmr5259433ejo.15.1709062048141; Tue, 27 Feb 2024 11:27:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709062048; cv=pass; d=google.com; s=arc-20160816; b=kLns6uJe+yYXhOu8bxCk4a8CxAROsY96mIYbkDgzruNXmPvnZykE7w1um9XH4/psjt qxR7habDrE4JionSj8X4UpVXnJI4vs3w4b83vXmnXTT0R38NNmEH9Ijp/OS3tRCJZIw7 6h6DSSaPYRMd3dNxljmvYaY9Mq5a4VXOn2VA0BzJLQYsifbhfgoYbYWtq3cKT3wqdp2G s8j9MUo61wnudsCo7hCuqR7NxOt+1EAKevSOznyn0ld2yc2b9AzlBjrb8LesMA+VkkPF dlqcvKxVwdmarYV2vTDk4wEwUtquETHk1BoedZ14aDC9Al7IfIJykeb/ARBSTmhhr04S GAlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=CZo+bB1dk8cpOA97BbHSLAQyCTqe94gEN503/zLlktA=; fh=uVYiDSkRPRI5F+OM7zi6nSZlKpRC3EZO6+zd48MLISI=; b=P/QiNA6TMSp1BZ+gjNSaPZGl7JMxY1DEEkaJ797Wg53E4s2b8BNnw24ewFyGcxWVY9 bD4hx49EfckmMPpLMM7ksrnuSitQIRhSmIGVczI06YeAvwnet8bSExFA6eVGp8QKIz73 /rO2stuHdMpYM+igi1lcQARqNomwwjcUTpetNcKc2XYEt77txnS6Hgh849FAPnFzh/y4 iAj7hSpryZYzMp97MGePYV/J+gB4uRyf3p9jGwN/b8sziwnjckd2DRIzXMblowKSZBTV UlmELT2pEQlun6vhU2rU27aTG7u16r1if0CGtJbewlOih3qxfLUhFDW3qgrwAcoBmm4e ql7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=fYp5rZ+f; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-83926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83926-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id jv1-20020a170907768100b00a3f2b83c813si936139ejc.628.2024.02.27.11.27.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 11:27:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=fYp5rZ+f; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-83926-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83926-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 86EBC1F2164B for ; Tue, 27 Feb 2024 19:27:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFB3551C5A; Tue, 27 Feb 2024 19:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="fYp5rZ+f" Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10FE951C39 for ; Tue, 27 Feb 2024 19:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709062039; cv=none; b=TfvHZU2i7it0aF8LRMyBmWcK/XQHNUkGvZWMUJCFar6eSKwlcN2ooeXbBUC6T7CqqPb1gZscmVZVnw10NBpSTmEAdvmgTjjROrYk/5lfzExKMplJwkV2xuXZnOvO71zcJFQnagRpg9wyVIbq/it007uNJfrq9xT3yQ6fFIHgW+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709062039; c=relaxed/simple; bh=HIKKzEVIfU4FOsnh3wR+y/aXx4vwP82xvrWjzqt/EUU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=c7m7zSAAlyhUf2l5QaD7Z61jbjxCc8M1KX6i2/qoFxjSkSZZ0kzKt+DHSgMXFwlJroO24COtQeeSOLbpssTtF3fkSpE0ZTkt1CxdWYuMeW9ygfNg/q0QiTG4WT9EWMfDTt/Q02QyCeL/MNKay4VMUfstXCJ0TIv7xONmkxbDCrk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=fYp5rZ+f; arc=none smtp.client-ip=209.85.221.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-4cb26623d0aso1169770e0c.1 for ; Tue, 27 Feb 2024 11:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1709062037; x=1709666837; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=CZo+bB1dk8cpOA97BbHSLAQyCTqe94gEN503/zLlktA=; b=fYp5rZ+fVw+uHT8xRt9OFYTFI6Vx5geo23hTpgTkzOcFMKxpm6g3pSyoCmwQlcsMID nCwIt9fOLikM676TCorWS/ubvRk2AnNpAkb85h0zxvPLtKD1Ww1uI541LG9gp42MIJw4 ONCtzXnINAKgeUcLArp27wIyA3AZzU4Gb4/HZFRUnUAB/NHBK0lZZZ8ojROxyOZ9R6K8 QQuOwsBImZxYPhT4miLymMwgvzInkRAZWns6Ic4b1eKe5Hf2VBL3biTvxsEzHqfjPucc 0EFbDh02w59aBbFDkZpsYpQtrLhIfKAiamq360YlenGoPCorbEfJ6Iif32cq4pIrXMFl 38Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709062037; x=1709666837; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CZo+bB1dk8cpOA97BbHSLAQyCTqe94gEN503/zLlktA=; b=GTKymDNnE/+yKeZVSM7KcqmvZW20TClU7Sekb39VzciN1z9Gwdud5O+mpIOpUcZ1N1 zK9JXVrZsE4HNBdcxsrb0CKRWYR7Lo1ivPnXSyOZM9QeYjMzshqIrcuIlntTNqNwBEE1 Adqo3js9Dq+3p8tz1RdGKdkzS3dMIuxIyIcQKYnUh7VYlRobneBt8kZwZu3UdMohje4l uqzMG7LOgOUXnR9UWWFbm7UmQ2h9rohn9FVMX4sRjPTkDN8x1yVLPS2NgS/Bu4vF8Q/O BYigJIQMUvpNH6tvzlnk7WFGpP8XPWWqbG6QFbJzxecsUkm5AJvkdktC5DuhodbGABJ+ SNXA== X-Forwarded-Encrypted: i=1; AJvYcCXuF43m5OPsfGnJMk7fHTo4aAO0p/bH69x70Paz6bPGUkE6eWP3SrEhN4fy/9xC4/m+nLMNrr+KeK5Dgj1r3o++sCLrEC+Ug5Fi+hhO X-Gm-Message-State: AOJu0Yzb/qGg96SkFT6eNBR3ipA6AP3HYoN+CAFi9pcHYVoVgXIRtDA6 psriTCXzYPU4rdzewoMcMdb1NW0FlquDFVLs2j08YBUXnKYOnl0fKL3kpwZSm3GKslVkk0sczQQ B5cdQk72JWLedLJt5GXnTyYLj8DC0qG+1pNwJfg== X-Received: by 2002:a1f:eb81:0:b0:4c9:44a0:84e6 with SMTP id j123-20020a1feb81000000b004c944a084e6mr7210453vkh.6.1709062036773; Tue, 27 Feb 2024 11:27:16 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240220111019.133697-1-herve.codina@bootlin.com> <20240220111019.133697-3-herve.codina@bootlin.com> <20240220142959.GA244726@rigel> <20240222005744.GA3603@rigel> <20240222010530.GA11949@rigel> <20240222123615.2cbada98@bootlin.com> In-Reply-To: From: Bartosz Golaszewski Date: Tue, 27 Feb 2024 20:27:05 +0100 Message-ID: Subject: Re: [PATCH 2/2] gpiolib: cdev: release IRQs when the gpio chip device is removed To: Saravana Kannan Cc: Herve Codina , Kent Gibson , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli , Thomas Petazzoni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Feb 23, 2024 at 12:51=E2=80=AFAM Saravana Kannan wrote: > [snip] > > > > > > > > If you unbind the "gpio0" device after the consumer requested the i= nterrupt, > > > > you'll get the same splat. And device links will not help you here = (on that > > > > note: Saravana: is there anything we could do about it? Have you ev= en > > > > considered making the irqchip subsystem use the driver model in any= way? Is it > > > > even feasible?). > > I did add support to irqchip to use the driver model. See > IRQCHIP_PLATFORM_DRIVER_BEGIN() and uses of it. So this makes sure > the probe ordering is correct. > > But when I added that support, there was some pushback on making the > modules removable[1]. But that's why you'll see that the > IRQCHIP_PLATFORM_DRIVER_BEGIN() macro set .suppress_bind_attrs =3D true. > > Do you have a way to unregister an interrupt controller in your > example? If so, how do you unregister it? It shouldn't be too hard to > extend those macros to add removal support. We could add a > IRQCHIP_MATCH2() that also takes in an exit() function op that gets > called on device unbind. > The provider in my example is a GPIO chip that registers its own IRQ domain. The domain is destroyed when the GPIO controller is unregistered but interrupts can be requested orthogonally to the GPIO subsystem and we don't have the knowledge about any interrupt users as the .to_irq() callback is never called. Let me know if anything can be done in this case. I used the gpio-sim testing module for it (instantiated over DT) but any such GPIO chip that is also an interrupt-controller would behave the same. > [1] - https://lore.kernel.org/lkml/86sghas7so.wl-maz@kernel.org/#t > > > > > > > > > I would prefer this to be fixed at a lower lever than the GPIOLIB c= haracter > > > > device. > > > > > > I think this use case is covered. > > > When the consumer device related to the consumer DT node is added, a > > > consumer/supplier relationship is created: > > > parse_interrupts() parses the 'interrups-extended' property > > > https://elixir.bootlin.com/linux/v6.8-rc1/source/drivers/of/propert= y.c#L1316 > > > and so, of_link_to_phandle() creates the consumer/supplier link. > > > https://elixir.bootlin.com/linux/v6.8-rc1/source/drivers/of/propert= y.c#L1316 > > > > > > We that link present, if the supplier is removed, the consumer is rem= oved > > > before. > > > The consumer should release the interrupt during its remove process (= i.e > > > explicit in its .remove() or explicit because of a devm_*() call). > > > > > > At least, it is my understanding. > > > > Well, then it doesn't work, because I literally just tried it before > > sending my previous email. > > For your gpio0 device, can you see why __device_release_driver() > doesn't end up calling device_links_unbind_consumers()? > It never gets into the while (device_links_busy(dev)) loop. > Also, can you look at > /sys/class/devlink/-- > folders and see what the status file says before you try to unbind the > gpio0 device? It should say "active". > It says "available". If you have some board supported upstream you could use for testing, I think I could prepare you a DT snippet for testing. Bart [snip]