Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp348302ybv; Wed, 19 Feb 2020 23:04:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwzmOoBWBv3pVcwbIj18R/Uqea71HG5km3ga9wENxPiXZ6o9tF28ePcudp+jojAGt31BjTr X-Received: by 2002:a9d:10d:: with SMTP id 13mr10296785otu.238.1582182258013; Wed, 19 Feb 2020 23:04:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582182258; cv=none; d=google.com; s=arc-20160816; b=dRcftrNcAzCVrW++c4ed0odfN/dDwS9YZp2+7Drv9smDG77EY6b8VAsF2R+1aFd4IH SEphDrHbx5+HLdAUitKN3ggWL5GS+oTQlIqJOJcGVRpOheokwavqf+vRTMqsULSP2zyV DP+R//DfHqkvxh+7RceUUJAXhqSmwmSn1K/V1JLEHN5K/zAflRdAu+qRbaR/EGROW1eg ltt7mXGq114uQ+WNXAdUhHUrua/VpTCkx+84ade48aIuCNAUi8TiiG2UJNyPin+a31gX F7wkIm/E+1Y9k5T+mNooZ6yxdgVYh2ktn6YDNPwiSk0/kIP8gLlhQxmiel8fcp/c/GA/ oTrw== 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=h5E2ab5bQfBEgY4U6KD2KRUgY16A0wGI5TupMQRDmn4=; b=yZ6VdE5SoZxHP6/PUsAd7W6+o3C6sFexXDi6zi8oQA3zYoyvHF9PNWChwvH3UWHHzp h3AwuZ3aid36N8d0rROzs7LTCBN9iZUKfHLswGcxHL2uQ4oqK/p7FpG9KY4xmdjNp1Eh qOw6hbMYKuAJAkfLoHFg/SYvwar5ebFP34MlkxSUqWAp83CoJP6vu5p3Gzg6X8utokMm tMtpq5Nl9uDmPJJmqV325sqRQpJ/h47+4qVVDB8xyyBg5NsZUdFbs5rTSHqbCAxUIhf9 57mWrGkDxsDnbQHhOa3m/PNXgIkDPSn2lksXdsmSyTLL3ktdwH52dfhOaX0cZo24avf2 ooCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nDmrtEDs; 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 g9si1275502otq.68.2020.02.19.23.04.05; Wed, 19 Feb 2020 23:04:17 -0800 (PST) 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=nDmrtEDs; 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 S1726669AbgBTHDi (ORCPT + 99 others); Thu, 20 Feb 2020 02:03:38 -0500 Received: from mail-ot1-f45.google.com ([209.85.210.45]:42153 "EHLO mail-ot1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbgBTHDi (ORCPT ); Thu, 20 Feb 2020 02:03:38 -0500 Received: by mail-ot1-f45.google.com with SMTP id 66so2704219otd.9 for ; Wed, 19 Feb 2020 23:03:38 -0800 (PST) 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=h5E2ab5bQfBEgY4U6KD2KRUgY16A0wGI5TupMQRDmn4=; b=nDmrtEDs9AWEGU6QOOeO1Pq0SISrC6XvGGGjJN6ubYHZ/pmgcmuDIeMFN35fghE5wl YrfGs+qfqFBTyfUjVMRMR184DSzmzTP6fPQc1yQgZ61pRem9TevWRsyTj4HE2W3Rk9km QCANrnmQgQ0TZFJlgIfxGYuFbjSJ76lLFbplEhE3PG/OeXjoS64xg2bIR2sEmclTLMG6 DOUPMmHCn6D4ALa78bgrhj9F4esIvn2Xm7kV3tOImV4Jl/rRdrzWk67T6TYUpmUJVo04 x31xSOKZR/Vealwahr44Ye0gcXJldAdN86zWM2HXoWNX/ZK8QcqVVC6p5MC2OyOLqEKn jX4w== 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=h5E2ab5bQfBEgY4U6KD2KRUgY16A0wGI5TupMQRDmn4=; b=Qt/ycvccbRJnr26HeMQUuoOovtIhRp3iDUZv/N4FJAepq13vCQ2YkqQLI4FJFzol2P Uit9c/+MUp3EO3H4mfw7ky3V61uxZTdhSif/JieMeB1rnBtN2GDyctFPasYy5peZa7lv IY8e1vJtQpcPc3f5szzCDm0mmY6rJ7zNHFrVcK4VC0IPhI3DIEzNvnX7GYsrpbZnUNsr v2mL+Tra+D8LIPpp1dGoxvjDlBPVrIwcIJthkmZa3PZ8A5AEB02xIzv+GgTiNJ61tbjH DjNkowd0bbgXB7/cmMeu6uat9FEciq5gMvX/DirQuPPAIa1PXttNl32A3ovZSEyZwnzn 67bQ== X-Gm-Message-State: APjAAAXFMf3jrdNjhXWdXilWPG88GV9OhNFyoDP1lT/O+WeVEaXVRL97 bjpWAKTHZesXWqfzqBxxL8m3eMrVdxh16eimga9Btw== X-Received: by 2002:a9d:6a85:: with SMTP id l5mr23603776otq.231.1582182217622; Wed, 19 Feb 2020 23:03:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Saravana Kannan Date: Wed, 19 Feb 2020 23:03:01 -0800 Message-ID: Subject: Re: Adding depends-on DT binding to break cyclic dependencies To: Rob Herring Cc: Mark Rutland , Greg Kroah-Hartman , Frank Rowand , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , 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 Fri, Aug 30, 2019 at 10:01 PM Saravana Kannan wrote: > > So we can take our time trying to solve this in a generic fashion (new > DT property/binding, edit_links(), letting devices probe, etc). In the > meantime, maybe we'll run into more cycle issues that'll give us a > better idea of which solution would be better as a generic solution. Mainly reviving an old thread to say this to Rob and Frank: Thanks for pushing back on "depends-on" and asking me to use the existing bindings instead. Saved a whole bunch of time when I actually tried to use of_devlink. Didn't have to add stupid "depends-on" for all the existing dependencies. But then I've also been meaning to send an RFC for this following, so rolling it into the same email. Thanks for also pushing back on all the earlier "meh" solutions for solving the cyclic dependency issue. I think I have a pretty good proposal now. While trying to solve the "dependencies of child nodes need to be proxied by the parents till the child devices are created" problem, I ended up having to add a "SYNC_STATE_ONLY" device link flag that treats those dependencies as "optional for probing". It also allows cycles (because it only affects sync state behavior). Also, dependencies of child nodes (whether they are actually devices or not) are always treated as "optional for probe" dependencies by of_devlink. So, how does this affect cyclic dependencies? Obviously, when two devices have cyclic dependencies, they don't have cyclic probe dependencies. Then they'd never probe even if of_devlink is not in the picture. At least one of the dependencies is only relevant for some "post-probe" functionality. So let's take a simple example: dev_a: device-a@xxxx { compatible = "fizzbuzz"; } dev_b: device-b@yyyy { compatible = "fizzbazz"; supplier-property-1 = <&dev_a>; supplier-property-2 = <&dev_c>; } dev_c: device-c@zzzz { compatible = "fizzfizz"; supplier-property-1 = <&dev_a>; supplier-property-3 = <&dev_b>; } Let's say dev_c only doesn't depend on dev_b for probing but needs it only for some functionality "foo" (Eg: thermal management, secure video playback, etc. Nothing OS specific). If the DT nodes are written as above, then there'll be a cycle with of_devlink and neither dev_b or dev_c will probe. However, if we can write dev_c DT as: dev_c: device-c@zzzz { compatible = "fizzfizz"; supplier-property-1 = <&dev_a>; foo { /* No compatible property */ supplier-property-2 = <&dev_b>; } } Then of_devlink will automatically treat dev_b as an optional requirement for dev_c. I think this is also nice from a DT perspective because it gives a clear representation of the dependency without really breaking or adding any DT rules. If you need some DT bindings only for a subset functionality, just list them under a child node with a meaningful name for that functionality. For this to work, the framework that supports "supplier-property-2" will have to add APIs to "get" the supplier by passing a DT node (instead of just struct device), but: 1) That is already supported by quite a few frameworks. 2) That shouldn't be too hard to add where necessary. And the driver needs to handle the child node explicitly (kinda obvious). Thoughts? Like the proposal? -Saravana