Received: by 2002:a17:90a:37a3:0:0:0:0 with SMTP id v32csp3531728pjb; Mon, 1 Jul 2019 20:42:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvh1CeWibWzXLcUE7zei/Y1zm7A/1nqAw3HXm5NR26DOOSOkoQUajUbRriqMy+zCsQxyzJ X-Received: by 2002:a65:640a:: with SMTP id a10mr19328046pgv.338.1562038927411; Mon, 01 Jul 2019 20:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562038927; cv=none; d=google.com; s=arc-20160816; b=WbvyhTzuDQj3v2kSMwEunEE8fZybEFFxXnEOgWPkfLpoC89rPQyGL7llNC+BwG3InE 9o4nQy4ykl77FRCC3uij5CmcbpjCx9bF7eJ95eSOeqFCWKSaMrLMvh0Tq9h8W0p05vsG /4CGwybb0Ux0znZMo5y3aIrEtVLsXrI2id1RzGql/DoaP4u+heoBaMdje8TY+3pb7Ik4 ONEb03Q58/mlFG83EETLM+JXtXsVv6mcyaV7SAkUBtSyrmXLlzyRazEBbodtLMzbj3cB cPvQqDkDVR4JCHzQbASn/OdQv56khzeNck1AByjhpxh87cMkxxS+RbRvKRA8RN2HPODs lYYQ== 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=AwFMvNlDZyc812vrg+bp/ViMSNpSgttyG5YsRP7U/zs=; b=lUHsCqG8NuIoSSx4u/v3nLqRyYEcJjtZziYpDqjlHfOT9QwCsvz/uktLVKkQuBGLNy /+s76EQHbhwd9HJA5QtxNYvSlQADe7XGcNsFzmSouagdoqbPo6SC5CnkMaXoh/MOY79i ksfrJ/uYS/Wn7cI+L1gAvA2YZPBxi+UVznUGIAa1Mu+BvCYkvOfmfFpc5HAhYjmQBW/B +d5LCcZ3uy+TmIchL9iRzknvbd/DkbRmVDckpCJGxUq5MktBih26yZ7ab7Osa62G2Q+V F+mtpfEspqji/YyzoJCnGx8CpYZod9OVAGW1+ozmbGwNi3aT7T+gBOEnNb3bmMhg8ewj 0WPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mfYKBa3F; 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 z2si10650819pgp.191.2019.07.01.20.41.52; Mon, 01 Jul 2019 20:42:07 -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=mfYKBa3F; 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 S1726967AbfGBDl1 (ORCPT + 99 others); Mon, 1 Jul 2019 23:41:27 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46603 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbfGBDl1 (ORCPT ); Mon, 1 Jul 2019 23:41:27 -0400 Received: by mail-ot1-f65.google.com with SMTP id z23so15721701ote.13 for ; Mon, 01 Jul 2019 20:41:26 -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=AwFMvNlDZyc812vrg+bp/ViMSNpSgttyG5YsRP7U/zs=; b=mfYKBa3Fe+hxUiDN022gH0lEGTEMq3JXVnwiUnLyW6FqMu7SRaHkzGumur2mcma+i3 p0RofUHDm3aCF+7v7SRVceN74CHTceHz7LgkcmbYg3hmSireatVhaTiKBHNk3muKza5C KNIrfHTCeFuL07S2xdESCkaeQy+DDBVXD6UKvHj0rGw+yrt9Wjyn7eaKZHjDPQg7ykr1 iNxuu/kAR/Fxr9Agl85nh5t39bo4SpthylP2XjKGz+CJtH6wO1d1iSAg1kbMyMRfOQ9C zkeKZi0gxjbXGgYU7a9ZhKjmWxzPuggcWw2JJp7MkXF9s4pj00IbtYMJsu5LjNMMpl59 mEqQ== 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=AwFMvNlDZyc812vrg+bp/ViMSNpSgttyG5YsRP7U/zs=; b=ebIeDDsSMiXxmShffvDdPteYQhzAEMOMTpMfKhEzyShg9nlKT23vZnnLD/0FrN0vd9 musGEfYhBPSm1+MUcZRtAZysvZWJvRANDzcEepwalZpHnttcVu8pGkQBrg56bALTuMJ7 X31w2+q10AzZ6NA7xE0ikfAPmS/5Q3T7442p2aryCFJUU9DtZLH94KAazukQeCXqEDOX yDFD0ZcQm02uaprLDBO6Cxbb+pSDICSMZy+3zmAS7DfCfsVxQE9IFJGE0q/Pypm6kxoy M9ACiEw+As40THFDih9KVQ3TS/pyOe7i+xDhPBku45kTnTpLJm+skKWgCn7RzpasyfS6 uNCg== X-Gm-Message-State: APjAAAWrjAjImV7EFpP2kQ0J02iuDZprWLvkMSqrnUIaLhAHx8w6hS9g bSz3jxv/e+lci4DbSOSuw0bruRuCfPJJcydGaeDS0w== X-Received: by 2002:a05:6830:160c:: with SMTP id g12mr24058948otr.231.1562038886315; Mon, 01 Jul 2019 20:41:26 -0700 (PDT) MIME-Version: 1.0 References: <20190702004811.136450-1-saravanak@google.com> <20190702004811.136450-5-saravanak@google.com> In-Reply-To: From: Saravana Kannan Date: Mon, 1 Jul 2019 20:40:50 -0700 Message-ID: Subject: Re: [PATCH v3 4/4] driver core: Add edit_links() callback for drivers To: Rob Herring Cc: Mark Rutland , Greg Kroah-Hartman , "Rafael J. Wysocki" , Frank Rowand , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , David Collins , 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 Mon, Jul 1, 2019 at 6:46 PM Rob Herring wrote: > > On Mon, Jul 1, 2019 at 6:48 PM Saravana Kannan wrote: > > > > The driver core/bus adding dependencies by default makes sure that > > suppliers don't sync the hardware state with software state before all the > > consumers have their drivers loaded (if they are modules) and are probed. > > > > However, when the bus incorrectly adds dependencies that it shouldn't have > > added, the devices might never probe. > > > > For example, if device-C is a consumer of device-S and they have phandles > > to each other in DT, the following could happen: > > > > 1. Device-S get added first. > > 2. The bus add_links() callback will (incorrectly) try to link it as > > a consumer of device-C. > > 3. Since device-C isn't present, device-S will be put in > > "waiting-for-supplier" list. > > 4. Device-C gets added next. > > 5. All devices in "waiting-for-supplier" list are retried for linking. > > 6. Device-S gets linked as consumer to Device-C. > > 7. The bus add_links() callback will (correctly) try to link it as > > a consumer of device-S. > > 8. This isn't allowed because it would create a cyclic device links. > > > > So neither devices will get probed since the supplier is dependent on a > > consumer that'll never probe (because it can't get resources from the > > supplier). > > > > Without this patch, things stay in this broken state. However, with this > > patch, the execution will continue like this: > > > > 9. Device-C's driver is loaded. > > 10. Device-C's driver removes Device-S as a consumer of Device-C. > > 11. Device-C's driver adds Device-C as a consumer of Device-S. > > 12. Device-S probes. > > 13. Device-S sync_state() isn't called because Device-C hasn't probed yet. > > 14. Device-C probes. > > 15. Device-S's sync_state() callback is called. > > We already have some DT unittests around platform devices. It would be > nice to extend them to demonstrate this problem. Could be a follow-up > patch though. > > In the case a driver hasn't been updated, couldn't the driver core > just remove all the links of C to S and S to C so that progress can be > made and we retain the status quo of what we have today? The problem is knowing which of those links to delete and when. If a link between S and C fails, how do we know and keep track of which of the other 100 links in the system are causing a cycle? It can get unwieldy real quick. We could delete all the links to fall back to status quo, but how do we tell at what point in time we can delete them all? > That would > lessen the chances of breaking platforms and reduce the immediate need > to fix them. Which is why I think we need to have a commandline/config option to turn this series on. Keep in mind that once this patch is merged, the API for the supplier drivers would be the same whether the feature is enabled or not. They just fallback to status quo behavior (do their stuff in late_initcall_sync() like they do today). This patch series has a huge impact on the behavior and I don't think there's a sound reason to force it on everyone right away. This is something that needs incremental changes to bring in more and more platforms/drivers into the new scheme. At a minimum Qualcomm seems pretty interested in using this to solve their "when do I change/turn off this clock/interconnect after boot?" question. -Saravana