Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp153212rdf; Mon, 20 Nov 2023 20:54:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq+IWbLgD74VpoT5o8Fd9kHgIFoMmU1Qg7GLtQVGIgo9ytOW6ChFUd/q8x5lNvQryG2rZd X-Received: by 2002:a05:6a20:f388:b0:188:c44:61d with SMTP id qr8-20020a056a20f38800b001880c44061dmr9150104pzb.62.1700542445182; Mon, 20 Nov 2023 20:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700542445; cv=none; d=google.com; s=arc-20160816; b=XYy+ipYCQOmeVPdI7piQJyzJyjTmPdsxw2XHspi3t82qloA5ZoAgm8UKyENR56BpCc ErvUhSjW1nxQGIwL36HA9PW9uLS+XxpJrrDVyF/Xfm5+3CRoQwyjalv0FGfvFIcGUSYu H4spgacfb6prUmArv7vq4MUcWEwn1sFWnK3M4x86mZZO9vk2ITM0SpQ7JQW5JMPnIpbj 9By3yKAX+7Cy6/RWWqH7y+A6zH2xIOXwIXzAYZ9AfQE53Gm3gj7K3Yw+zj4bx8oJNNU0 5VRfkh+5YLzJjbgu7wOYlOjPNKrKig4KeZmN7aEbEu3dArded8GxyoHcb4fJn5S5FO3t t0og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KBkXRng0WwkeqG3mC9E0rD7mpoQUAf8DyTenpNasvY8=; fh=Rw0c93a25kClpa9s0Gy8k11upHGLV/ljn91F/j5IslQ=; b=tJmp6UkqUzxTRz7coecMMBteB1Afy/viU9x3V5dZW4PFYo+dFBWzs4g+cONN2gInaA 6WiQL0kfqjkTkAvjysiO3Cu8jb92lLMMKWF3jHkMlvmL50FNMfA3Yzzm1nWtZ1u1RkEr Gxe2MNdsMI3DUO5dPSoraaG3vdGL2R50JaRxIIg4JsAr01PBIlD/mabLSTFN1HkHlfD/ yIddFdir9DTowzzETvweXOgJzXbdnkmYb+qUvoXqpygo0+Yjzw6XfvnSH6T9u/CEBaQc fbZTsF8C6eqgFJbmvsb1w1BhdojrEHmoZyrvBEDPXb9FvOaSegRFhA1ugWPjpJbt5K5V hlyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QGDAQCEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u4-20020a17090282c400b001cc47d6f4absi9311973plz.107.2023.11.20.20.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 20:54:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=QGDAQCEg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0BCAD805A892; Mon, 20 Nov 2023 20:53:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjKUExg (ORCPT + 99 others); Mon, 20 Nov 2023 23:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKUExf (ORCPT ); Mon, 20 Nov 2023 23:53:35 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A9BBD for ; Mon, 20 Nov 2023 20:53:31 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-41ea9c5e83cso224881cf.0 for ; Mon, 20 Nov 2023 20:53:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700542409; x=1701147209; 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=KBkXRng0WwkeqG3mC9E0rD7mpoQUAf8DyTenpNasvY8=; b=QGDAQCEgR5l9hFEqYkMeDmlIOlwa16rpRybBtCppGvHSktuhNGeLgBY/9hzoGejjCq tYw1Mq9/IhkJh0mArrVcPtwTggSDTQqosdCgrGt3dXsp1Vnm316/p9nCZSUpKpayEklZ wz3Jv7AcLA4V+X7VNUd4RZSLjbw5c9IpuL+Uk4Ff3JTS6T1M/FhH0dF5HPhyVMkcTRzR 3j3UE1Qo0IM4i+T4L2Cy2dCgahBVku7TbpQlwhxMXMuXPX8G8S93Wki4cwo5tWj86t2f o+kTYrqO+nhO5Qiq1JkNnrUka4TJCggBAlXzXBLIh8FojjH93PDefNroBQ/7HNgvB/N0 Ho4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700542409; x=1701147209; 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=KBkXRng0WwkeqG3mC9E0rD7mpoQUAf8DyTenpNasvY8=; b=OeIoGpDrmzc4zw5vCUotfMM7+aM5DI63dXZWXNnuuDOfu3uQUEsQlGbdyI0rQHI8i1 Dp4PxwdF9X15ZEC37HemM9z7bhslYPTXrPVxhqNgaA/I/zjzrbBI6KuTEbHvlxoNzZqP YXXN296p+oDnU0QVmH99uAzH2dqw3QwWAz+U4pOg3JaaP/S80fqjXvdL+E4utZI13M3j q06sOHBsP2ZQpXKx+YlaH+7713CJOeS+DnH0t9a0Iu8/plVqBq4sSNDkhezOm8hkMpyF i9MbipTJ7XYi0J4csDRMSd7KxNNixmprk84usDOzrIAE22S3WTb5/6b0Rd/PgZ8CbcGH nyXA== X-Gm-Message-State: AOJu0Yy+FOtMSh1oR0gIprjQkdUWMuX1oLk4wuyjvU9zGNPj9SpD6yNk BuP3aDw2l6pF3zixBz+CqFo4LbtBV2OlwM9iP6EIspv78KHZ8rbqHJMONg== X-Received: by 2002:a05:622a:6086:b0:41c:da19:f763 with SMTP id hf6-20020a05622a608600b0041cda19f763mr805230qtb.14.1700542408942; Mon, 20 Nov 2023 20:53:28 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Saravana Kannan Date: Mon, 20 Nov 2023 20:52:52 -0800 Message-ID: Subject: Re: Device links between providers and consumers To: Bartosz Golaszewski Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , LKML , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 20:53:48 -0800 (PST) Hi Bartosz, Adding LKML so that others are aware of what the issue is and it'll be easier when I get to my TODO patches and send them out. I'm hoping that's okay with you because we didn't discuss anything confidential here. On Mon, Nov 20, 2023 at 2:21=E2=80=AFPM Saravana Kannan wrote: > > On Mon, Nov 20, 2023 at 12:38=E2=80=AFPM Bartosz Golaszewski wrote: > > > > Hi Saravana, > > > > As I suspected, I couldn't observe the behavior you described during > > our discussion at the LPC event. I have a DT GPIO provider and a > > consumer referencing it by phandle. I'm unbinding the provider and the > > consumer keeps on living, if it tries to use the GPIO, then it will > > enter the regular code path in GPIO for checking if the provider is > > there or not. > > > > Could you point me in the right direction here? > > Thanks for trying it out! Based on the code it should unbind the > consumers. I haven't ever tried it myself (no need for it). I took a closer look to show you where the consumer unbind is supposed to be done, but in doing so I think I know what issue you are hitting. One of my TODO items for device links should fix your problem. The force unbinding of consumers when the supplier is unbound is supposed to happen here: device_driver_detach() -> device_release_driver_internal() -> __device_release_driver() -> device_links_unbind_consumers() -> for all "active" consumer -> device_release_driver_internal() However the problem is the "if (drv)" check in __device_release_driver(). This problem also exists for "class" device suppliers that don't have a drv. Fixing managed device links for "class" suppliers (and now, bus suppliers without drv) has been in my TODO list for a while. The gpio device is one of the cases of a "bus" device probing without a driver. A while ago, I implemented a gpio_bus_match() that'll probe the gpio device (so consumer probing isn't blocked) and I was trying to keep the boilerplate code minimalistic. So, for your test case, a quick test hack would be to implement an actual stub driver instead of using a stub bus match. That should fix your problem with the consumers not unbinding. I'll put up a proper fix sometime soon (hopefully over the holiday lulls). Btw, when we were talking in person at the LPC dinner, you were asking "what would you do if the supplier was an optional supplier but you forcefully unbound the consumer?" I have a nice answer now: After a force unbind, we need to add all these consumers to the deferred probe list and trigger another deferred probe attempt. If the supplier was optional, the consumer would probe again. This also has the nice property that the consumer doesn't advertise something to userspace that it can't deliver (because the supplier has gone missing) and it makes the error handling easier for drivers. They don't have to worry about suppliers vanishing in every part of their code. Once they get the supplier and probe successfully, they shouldn't have to worry about it vanishing underneath them. Cheers, Saravana > > Let's start with making sure the basic functionality is working in your c= ase. > > Can you check /sys/class/devlink to see if you see a folder with the > following name? > -- > > Once you find it, can you cat all the file contents and tell me what > it says before you unbind it? > > The "status" should be "available". And "sync_state_only" should be false= . > > Also, how are you unbinding the supplier? And does the board you are > playing with something that's upstream? Should we take this discussion > to LKML? > > -Saravana