Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp816400ybl; Fri, 30 Aug 2019 07:36:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvgrV9kcAxEbYbmh1tvCtw1E8P3NbbS/Lap74tNXFJT9nE2ZRbFMWPV2PJO4FCHjjAPlwc X-Received: by 2002:a63:be0d:: with SMTP id l13mr13213001pgf.357.1567175781127; Fri, 30 Aug 2019 07:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567175781; cv=none; d=google.com; s=arc-20160816; b=Vy4UHwH2qLjMv08Wx3sYfzWdRl/cC3wr7T3j5x2RERGx9gXv5mnr8M6tiHRJqvCoTE MqZYjfYBm6FHEWdTzkpIJvaDfhQ0JSiik37hBXZsfd6CqUdKJs/b4lPFayTAEcGcxlNj Qho00c2LYWWJY6fNikMYV6DKI6wIpdeRASeOiZ58cGppv6YuiuidBbGqp9hgTPMHRQGn TjmIz6EyF23/I4+WKo5ZJgnOifnBT0bRvNGxSN7iNOB4rZcZxL/VU+1PWLt5DM3cvc16 a7uk+hhmaueciM70pASpNynY9XzARUL6Md+DJGHVFz9JO2I1b/B/0XCCQBxeOpgpWrW9 244A== 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=nNLPmaKMMB2N7l9R/H4ByTAR5mepW2jNCvoDSdRyy5U=; b=QsHqSY2/O2PkqvbBavEvT7QEx911sa/+ERmn6maSJIa80xf85esE7tgFjh17aD2BMo rcCZ1ilO83ih9Ns1JF+kqYs1MN+Ruos21iVq0DmMraodsSxxZy7kzfRVJ7bumdVREdKg zTwg9Xs9V1c/Mv/GATHaHc2QMxrg49YwtPhCugbAQ4Qo6m53y1Igpt9t+THNXlcUFgKB uWHLv41bTsGbYHHmbs0w5EhY2v5xLO//b7p0Zope8O+fw/gbdujyynsXElQJ7USyEKFL qDNr4579HqrsIOfzHJUgaUCPZvzAJ+30dNWj5MUFsRsqHDtAb1QthcKzkukRgjXcRuUe TmbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UmocibFq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m14si4673517pgv.97.2019.08.30.07.36.05; Fri, 30 Aug 2019 07:36:21 -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=@kernel.org header.s=default header.b=UmocibFq; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbfH3OfK (ORCPT + 99 others); Fri, 30 Aug 2019 10:35:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:59742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727883AbfH3OfK (ORCPT ); Fri, 30 Aug 2019 10:35:10 -0400 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 359862342A; Fri, 30 Aug 2019 14:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567175708; bh=nNLPmaKMMB2N7l9R/H4ByTAR5mepW2jNCvoDSdRyy5U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UmocibFq5CDI1wGQee6sVYNdf25UrDCs4hSY9FU+tOxZb3AEQWL8YDG16KppVIg0W rbOvOyRItwDjdCAG0iKF5cki73HBWoCZD9bQseeqvjAL06ie1jnuk8K6WfVKbj4Qac 4knN2qI+IGN110HniEEGcuH54ltiWAY4AaWhY7aQ= Received: by mail-qt1-f178.google.com with SMTP id n7so7807013qtb.6; Fri, 30 Aug 2019 07:35:08 -0700 (PDT) X-Gm-Message-State: APjAAAW91RJUT1gh64tdeoF6OPwrhJbWSn3mXph1cof2AOkxyQzB8RBm HME4wVcST7XxyqtwE8RdtZycFF7FvxrzNTdQxw== X-Received: by 2002:ac8:368a:: with SMTP id a10mr15705734qtc.143.1567175707306; Fri, 30 Aug 2019 07:35:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rob Herring Date: Fri, 30 Aug 2019 09:34:55 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Adding depends-on DT binding to break cyclic dependencies To: Saravana Kannan 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 Thu, Aug 29, 2019 at 11:58 PM Saravana Kannan wrote: > > On Thu, Aug 29, 2019 at 9:28 AM Rob Herring wrote: > > > > On Thu, Aug 22, 2019 at 1:55 AM Saravana Kannan wrote: > > > > > > Hi Rob, > > > > > > Frank, Greg and I got together during ELC and had an extensive and > > > very productive discussion about my "postboot supplier state cleanup" > > > patch series [1]. The three of us are on the same page now -- the > > > series as it stands is the direction we want to go in, with some minor > > > refactoring, documentation and naming changes. > > > > > > However, one of the things Frank is concerned about (and Greg and I > > > agree) in the current patch series is that the "cyclic dependency > > > breaking" logic has been pushed off to individual drivers using the > > > edit_links() callback. > > > > I would think the core can detect this condition. There's nothing > > device specific once you have the dependency tree. You still need to > > know what device needs to probe first and the drivers are going to > > have that knowledge anyways. So wouldn't it be enough to allow probe > > to proceed for devices in the loop. > > The problem is that device links don't allow creating a cyclic > dependency graph -- for good reasons. The last link in the cycle would > be rejected. I don't think trying to change device link to allow > cyclic links is the right direction to go in nor is it a can of worms > I want to open. > > So, we'll need some other way of tracking the loop and then allowing > only those devices in a loop to attempt probing even if their > suppliers haven't probed. And then if a device ends up being in more > than one loop, things could get even more complicated. And after one > of the devices in the loop probes, we still need to somehow figure out > the "bad" link and delete it so the last "good" link can be made > before all the suppliers have their sync_state() called (because the > "good" link hasn't been created yet). That all gets pretty messy. If > we are never going to accept any DT changes, then I'd rather go with > edit_links() and keep the complexity within the one off weird hardware > where there are cycles instead of over complicating the driver core. If it is so complex, then it should not be in DT. Things like describing clocks at the gate/mux/divider level turned out to be too complex to get right or complete, so we avoid that. > > Once 1 driver succeeds, then you > > can enforce the dependencies on the rest. > > > > > The concern being, there are going to be multiple device specific ad > > > hoc implementations to break a cyclic dependency. Also, if a device > > > can be part of a cyclic dependency, the driver for that device has to > > > check for specific system/products in which the device is part of a > > > cyclic dependency (because it might not always be part of a cycle), > > > and then potentially have cycle/product specific code to break the > > > cycle (since the cycle can be different on each system/product). > > > > > > One way to avoid all of the device/driver specific code and simplify > > > my patch series by a non-trivial amount would be by adding a > > > "depends-on" DT binding that can ONLY be used to break cycles. We can > > > document it as such and reject any attempts to use it for other > > > purposes. When a depends-on property is present in a device node, that > > > specific device's supplier list will be parsed ONLY from the > > > depends-on property and the other properties won't be parsed for > > > deriving dependency information for that device. > > > > Seems like only ignoring the dependencies with a cycle would be > > sufficient. > > No, we need to only ignore the "bad" dependency. We can't ignore all > the dependencies in the cycle because that would cause the suppliers > to clean up the hardware state before the consumers are ready. I misunderstood. I now see this is back to duplicating all the data that's already there which I've already said no to. > > For example, consider a clock controller which has 2 clock > > inputs from other clock controllers where one has a cycle and one > > doesn't. Also consider it has a regulator dependency. We only need to > > ignore the dependency for 1 of the clock inputs. The rest of the > > dependencies should be honored. > > Agreed. In this case, if the device used the depends-on property, > it'll have to list the 1 clock controller and the regulator. > > > > Frank, Greg and I like this usage model for a new depends-on DT > > > binding. Is this something you'd be willing to accept? > > > > To do the above, it needs to be inverted. > > I understand you are basically asking for a "does-not-depend-on" > property (like a black list). But I think a whitelist on the rare > occasions that we need to override would give more flexibility than a > blacklist. It'll also mean we don't have to check every supplier with > the entire black list each time. So if we have 10 dependencies and 1 to ignore, we're going to list the 9 dependencies? And if I want to know where the cycle is, I have to figure out which 1 of the 10 dependencies you omitted. Pick black or white list with what's going to be shortest in the common case. Also, when new dependencies are added to a node, we'd have to check that the dependency is added to 'depends-on' (or was it not on purpose). > > Convince me that cycles are really a problem anywhere besides clocks. > > I wouldn't be surprised at all if interconnects end up with cyclic > dependencies as support for more of them are added. Perhaps, though I'm doubtful the drivers for them could be both required at probe and built as modules. > > I'd be more comfortable with a clock specific property if we only need > > it for clocks and I'm having a hard time imagining cycles for other > > dependencies. > > I definitely don't want per-supplier type override. That's just making > things too complicated and adding too many DT properties if we need to > override more than clocks. I'm all for generic properties, but not if we only have hypothetical cases for anything beyond clocks. I know clocks are a somewhat common problem because it has come up before. I'm just asking for specific example that's not clocks. Part of the problem is we can't really police how a generic property is used. Maybe Linux is only using it for cycles, but then u-boot folks may think it works well for other reasons. Maybe a dtc check could mitigate that. Warn on any dependencies that are not a cycle. Actually, you could add a check for any cycles first and then we can see where all they exist. Rob