Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp148284ybi; Tue, 2 Jul 2019 18:01:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzW9qUpNyPFAGCsrT8ude2d01XLolSRc0dR6zBAzfvUjWDAYBhSjdueXtDqHsTjccFUxM5G X-Received: by 2002:a63:2c87:: with SMTP id s129mr31024095pgs.1.1562115672519; Tue, 02 Jul 2019 18:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562115672; cv=none; d=google.com; s=arc-20160816; b=rN8TioLRyFoihwVxRNbi+PTI+4UWRs71fwre381WCn2B6mIQMolkv4kMTLNYQTfY17 5S8uEkK+pMILDezSJXqpZaOBlizMbq5LA+fQCooUL5vuyemn2+W3YbwIoM96bCKDDxju V4A0CKm8e+2aw8688TLbuUl8Ks++9pHvRrw38VdTNsQvYVBaky1EhhpGnLHDFtuIM+qq Yuzh7GE9kKiM5yp+7KhgsxKHz5eJT1qCv0DUCVv6HvccmRCllJn2uv1p6MRfkVdyCOFV 3XeJ0+zPR9T7jO0P9UnP5CM0XA0AHIzXKKYiTOvuVvbYtKPVuuBcfIxFLCzhR6T7RJev j1+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IScLyBXmZGGQsg6YA+cbexUtHiw0BDkrJFGTmkdmngg=; b=mSNTZP0J+H5kxzJj55d5xX9/taZF1CN1i69yv03+zFt+KyabtHi6pHwLNnRIFfdQX/ qyAseb39BCy45Cso5T4MWKl+iDoINrSCZ8iZg0EWE6HaWEnUoULf8C4H+myC6pgOPLif Bo49BcZU+uIqDo0w9R/xqMPoiAJEImy/Qd8EGocxXwiBQpw3JNrt5cQGQ2srgesBLLSR tWYpLR2llV4UQlFwvI5T8Qz1udqAM05WUuvAGAEcBSPlMSWshmkmpjTk3Zssom3zVMHM 5yDdqKb08RHyVHPdAWqrSTWKFNn+hYvgYBLESTBUCbXVaUmsf+KSLFFT4HNouN7luo5v TILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VMIxp3GS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si378603pgj.344.2019.07.02.18.00.57; Tue, 02 Jul 2019 18:01:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VMIxp3GS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727239AbfGCBAc (ORCPT + 99 others); Tue, 2 Jul 2019 21:00:32 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:38468 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726635AbfGCBAc (ORCPT ); Tue, 2 Jul 2019 21:00:32 -0400 Received: by mail-ot1-f68.google.com with SMTP id d17so528065oth.5 for ; Tue, 02 Jul 2019 18:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IScLyBXmZGGQsg6YA+cbexUtHiw0BDkrJFGTmkdmngg=; b=VMIxp3GShJJ/mN1EIIno9K4EiTWxB1WzC+kchDIN4KPW5q3pTD+fDKHqGZo9kBhNuy A7+lCno6kZdyolLkrhb5pvcMnYSutsIw4wvIkklE0lyBWKABdN76U+bxj69/D/SARfhO BHU7XxtoNJTW68uPJ9HQDugNLTeyhdhMvtwN8RQEnc15+Fzgq5LqCHzS/DTx9kzMWJPg PkIGWFt81cEswUIJkjjJJR+8RmCHQUC2NeYaACpLQOndB7z6Z/qUc7VxUeIk4UQd0hO6 aIxBMk2KZP857aor8fXbHLusNcpXMYEleDIfcL4xTvGWxqXWf3oNBdxasNX2v3ZhB4Rv /fGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IScLyBXmZGGQsg6YA+cbexUtHiw0BDkrJFGTmkdmngg=; b=c18mTZzK3ptUtpvC2xSxvbBUfi34CkMciHwX3RlKjuGI9hmIyKCRYPcs7OGWcX0hks G3rWrwgbC/jyyb+6ElPYdaLHdmga9QBuHHvJax3ANc4aksfhy70npBEGl3Yyo3v6yrWI 0D7vcoicUhg9gYmvNpLYaN1oGpjj9Bdj80OggvrtPhLBGHzQg3rJjvax8KfcrP+Bewc3 nqTt53dmPPXtGEfRtZ6CasxwD2yKZrmcpIcncUpdfqSVKHVrwuqdWLGXLnSx7iCvUk5n pMYdtoiacK/a8YCZd2yg51nwNLYma7EzQFJiaX+g2gwoqm4MKSFg9VL+6Lm7LEB5j+34 FAKQ== X-Gm-Message-State: APjAAAWW60snslVNbeLUEhIv6OmXcVIfFzgKjQPJejIgQfxPrvZUsP2U ogjEn3es9hb0dsIcCNjlxs2ems1q/5yC92MLQ0XuLQ== X-Received: by 2002:a9d:6d06:: with SMTP id o6mr22963590otp.225.1562115630968; Tue, 02 Jul 2019 18:00:30 -0700 (PDT) MIME-Version: 1.0 References: <20190702004811.136450-1-saravanak@google.com> <7900c670-5b3a-f950-dec9-70d98d94a84f@codeaurora.org> In-Reply-To: <7900c670-5b3a-f950-dec9-70d98d94a84f@codeaurora.org> From: Saravana Kannan Date: Tue, 2 Jul 2019 17:59:54 -0700 Message-ID: Subject: Re: [PATCH v3 0/4] Solve postboot supplier cleanup and optimize probe ordering To: David Collins Cc: Rob Herring , Mark Rutland , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , devicetree@vger.kernel.org, LKML , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 2, 2019 at 5:03 PM David Collins wrote: > > Hello Saravana, > > On 7/1/19 5:48 PM, Saravana Kannan wrote: > ... > > TODO: > > - For the case of consumer child sub-nodes being added by a parent > > device after late_initcall_sync we might be able to address that by > > recursively parsing all child nodes and adding all their suppliers as > > suppliers of the parent node too. The parent probe will add the > > children before its probe is completed and that will prevent the > > supplier's sync_state from being executed before the children are > > probed. > > > > But I'll write that part once I see how this series is received. > > I don't think that this scheme will work in all cases. It can also lead > to probing deadlock. > > Here is an example: > > Three DT devices (top level A with subnodes B and C): > /A > /A/B > /A/C > C is a consumer of B. > > When device A is created, a search of its subnodes will find the link from > C to B. Since device B hasn't been created yet, of_link_to_suppliers() > will fail and add A to the wait_for_suppliers list. This will cause the > probe of A to fail with -EPROBE_DEFER (thanks to the check in > device_links_check_suppliers()). As a result device B will not be created > and device A will never probe. > > You could try to resolve this situation by detecting the cycle and *not* > adding A to the wait_for_suppliers list. However, that would get us back > to the problem we had before. A would be allowed to probe which would > then result in devices being added for B and C. If the device for B is > added before C, then it would be allowed to immediately probe and > (assuming this all takes place after late_initcall_sync thanks to modules) > its sync_state() callback would be called since no consumer devices are > linked to B. > > Please note that to change this example from theoretical to practical, > replace "A" with apps_rsc, "B" with pmi8998-rpmh-regulators, and "C" with > pm8998-rpmh-regulators in [1]. Interesting use case. First, to clarify my TODO: I was initially thinking of the recursive "up-heritance" of suppliers from child to parent to handle cases where the supplier is a device from some other top level device (or its child). My thinking has evolved a bit on that. I think the parent needs to inherit only from it's immediate children and not its grandchildren (the child is responsible for handling grandchildren suppliers). I'll also have to make sure I don't try to create a link from a parent device to one of its child device nodes (should be easy to check). Anyway, going back to your case, for dependencies between child nodes of a parent, can't the parent just populate them in the right order? You can loop through the children and add them in multiple stages. I'll continue to think if I can come up with anything nicer on the drivers, but even if we can't come up with anything better, we can still make sync_state() work. Cheers, Saravana > > Take care, > David > > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/qcom/sdm845-mtp.dts?h=v5.2-rc7#n55 > > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project