Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp457973pxb; Tue, 14 Sep 2021 01:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlOhU5mCFDvaEITiIDOEPdjfM53zAXqNi8U9zBG3RMFnmwmbTWpEx+UvwcbFaoNWVQDbBl X-Received: by 2002:a6b:e50e:: with SMTP id y14mr12359965ioc.54.1631606912076; Tue, 14 Sep 2021 01:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631606912; cv=none; d=google.com; s=arc-20160816; b=TLl//KVcaesDPfCS0CyEXEbm3SQ3hSo98Ci9bqPMRPk1OZGzfSHvhlZGoWCdyTjAGp lutlqiK8ch4EN1f5ssQJilzyyaKJRwwQ83Sbl1LWt/t28KWxUnLsVhOZKc6ki2dsj81f h6v4Je4emvq2WjfT8UpavvfYjeML7gXyeqUssxlOssgrIUem0057n/b8iYqF9oqo7VyB k15mpxL4pQZf9yrjS+yeopPTo2Pl4EfNzoxUTogNGzSYwjI18UeicAeHUSeTWEAQ3Mp2 gwRrNMDYkLto54eoy93ToOWI3GpbojriNC8S/95MfIp3h2F5cJOEyH5gEHy1xiNltAED MTYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3QeCcLNaALY3aZOJPHqqh+5theWDaLEd6ZFO9u6rK4E=; b=wsUG/dqkb2jtWopVQyth7Lz0E7K8SsoOoQNppFkDfqBEUGQYbgvD6/yB1NHHUkCTgf IjH8YT7huRNFOOrEmQ3AJCCtbgRRGU1ffweSy8f/zDFwztJU06cPYbZ0gSWNi0vWQTJL 9wg3mxHObYY8nYYhaHvVzmT2k/cdOhfwxwEcITDTVbMiJPd9ZIrNKZ040VEJ7NiXs4Sh f0C0l+Sucdxqusi5T+wdwQUi8K6Oj9bAzA1uczev0V6CnM99+HKrcmf56vjvrDosPKRC zds/qnhV2YBE6kn9oDPxVlJ9hFobRDqXZIcBycFvw3yxyL1/pG/IVh2gnKLkDRgHzXMm BtBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ieZQQ5JX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id c32si9281853jaa.44.2021.09.14.01.08.20; Tue, 14 Sep 2021 01:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ieZQQ5JX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231300AbhINIHL (ORCPT + 99 others); Tue, 14 Sep 2021 04:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbhINIE0 (ORCPT ); Tue, 14 Sep 2021 04:04:26 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3281C061764 for ; Tue, 14 Sep 2021 01:02:29 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id z18so26311729ybg.8 for ; Tue, 14 Sep 2021 01:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3QeCcLNaALY3aZOJPHqqh+5theWDaLEd6ZFO9u6rK4E=; b=ieZQQ5JXNF2rTqt3gnyiKMb+FaXBAk21U9UkssNg7OlvQ9D9mgnLndndsiPejRpKVx FZvhadB+k5ZoswJg4EDEshjhDPYC6UIAFFEWapFclhoK8lPprHFO/XrSbHHYkGRnaHrD cDRD0bbPbcTGSv0Em0xMmZsBwnvywC7jWDfFgs9OozJ8BhJRRb89VS+2hnTiR5P5pVWI 5+lRTFMpl94r7NMSkxLvoVJ2SwL8vXnhu9AyFYx3SZb/l4PI15gK6rAqWLOPjJ7v//+9 PsfYozTfnzfIoV1G8DkMRxCVS/283J4hPvZLbNTbGVcBRRTQ5EJ5tYy+p39GpP3qPK0I HXMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3QeCcLNaALY3aZOJPHqqh+5theWDaLEd6ZFO9u6rK4E=; b=I0rqR+CYE6sWbDtA7bMJhsQkHIMdptpzU9CZSETbB+vdlpy9cVA+AeUj7ogs0vkDC4 OrcywilGoRucnsXclz5kKOap6IYUfB7V0zdI3Xf9CYwcuF2c37aBP3/cFlBpqf3b3hDE pct8gxcD7BtUN0+VOj6ARdXWc4bYhjAHgdFo6S6OiRuPgFRnM+0vtfmlzuuiRSpJTC1k YeR+V+au4dgxMx5Lfsbu65kU9uZ/Qs1BnvaeQhpRurUXvBZVfGv7h5N08Rnl4W+zBAW0 hwhUazG7Pw02HGLoR4FbrnqAmcpkki6ozxSRawiJzpg240LG06gF0IlvMh+Mij1+FucF bvJg== X-Gm-Message-State: AOAM530xcvkwtv73ppbUT99aTYb/WUzGk3XCHEHvU0wcyRN9TvCQ0D5u H3C3djyq8mMYxnUxCKCWmo4J2HP3owhCuR8NZlJuhQ== X-Received: by 2002:a25:21c5:: with SMTP id h188mr19316340ybh.23.1631606548762; Tue, 14 Sep 2021 01:02:28 -0700 (PDT) MIME-Version: 1.0 References: <20210914043928.4066136-1-saravanak@google.com> <20210914043928.4066136-2-saravanak@google.com> <7756112c-0378-f48b-ef5a-aafc994dc662@samsung.com> In-Reply-To: <7756112c-0378-f48b-ef5a-aafc994dc662@samsung.com> From: Saravana Kannan Date: Tue, 14 Sep 2021 01:01:52 -0700 Message-ID: Subject: Re: [PATCH v1 1/5] driver core: fw_devlink: Improve handling of cyclic dependencies To: Marek Szyprowski Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , John Stultz , Rob Herring , Geert Uytterhoeven , Andrew Lunn , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 13, 2021 at 11:16 PM Marek Szyprowski wrote: > > On 14.09.2021 06:39, Saravana Kannan wrote: > > When we have a dependency of the form: > > > > Device-A -> Device-C > > Device-B > > > > Device-C -> Device-B > > > > Where, > > * Indentation denotes "child of" parent in previous line. > > * X -> Y denotes X is consumer of Y based on firmware (Eg: DT). > > > > We have cyclic dependency: device-A -> device-C -> device-B -> device-A > > > > fw_devlink current treats device-C -> device-B dependency as an invalid > > dependency and doesn't enforce it but leaves the rest of the > > dependencies as is. > > > > While the current behavior is necessary, it is not sufficient if the > > false dependency in this example is actually device-A -> device-C. When > > this is the case, device-C will correctly probe defer waiting for > > device-B to be added, but device-A will be incorrectly probe deferred by > > fw_devlink waiting on device-C to probe successfully. Due to this, none > > of the devices in the cycle will end up probing. > > > > To fix this, we need to go relax all the dependencies in the cycle like > > we already do in the other instances where fw_devlink detects cycles. > > A real world example of this was reported[1] and analyzed[2]. > > > > [1] - https://lore.kernel.org/lkml/0a2c4106-7f48-2bb5-048e-8c001a7c3fda@samsung.com/ > > [2] - https://lore.kernel.org/lkml/CAGETcx8peaew90SWiux=TyvuGgvTQOmO4BFALz7aj0Za5QdNFQ@mail.gmail.com/ > > Fixes: f9aa460672c9 ("driver core: Refactor fw_devlink feature") > > Reported-by: Marek Szyprowski > Tested-by: Marek Szyprowski Thanks! -Saravana > > Signed-off-by: Saravana Kannan > > --- > > drivers/base/core.c | 17 ++++++++++++----- > > 1 file changed, 12 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > index e65dd803a453..316df6027093 100644 > > --- a/drivers/base/core.c > > +++ b/drivers/base/core.c > > @@ -1772,14 +1772,21 @@ static int fw_devlink_create_devlink(struct device *con, > > * be broken by applying logic. Check for these types of cycles and > > * break them so that devices in the cycle probe properly. > > * > > - * If the supplier's parent is dependent on the consumer, then > > - * the consumer-supplier dependency is a false dependency. So, > > - * treat it as an invalid link. > > + * If the supplier's parent is dependent on the consumer, then the > > + * consumer and supplier have a cyclic dependency. Since fw_devlink > > + * can't tell which of the inferred dependencies are incorrect, don't > > + * enforce probe ordering between any of the devices in this cyclic > > + * dependency. Do this by relaxing all the fw_devlink device links in > > + * this cycle and by treating the fwnode link between the consumer and > > + * the supplier as an invalid dependency. > > */ > > sup_dev = fwnode_get_next_parent_dev(sup_handle); > > if (sup_dev && device_is_dependent(con, sup_dev)) { > > - dev_dbg(con, "Not linking to %pfwP - False link\n", > > - sup_handle); > > + dev_info(con, "Fixing up cyclic dependency with %pfwP (%s)\n", > > + sup_handle, dev_name(sup_dev)); > > + device_links_write_lock(); > > + fw_devlink_relax_cycle(con, sup_dev); > > + device_links_write_unlock(); > > ret = -EINVAL; > > } else { > > /* > > Best regards > -- > Marek Szyprowski, PhD > Samsung R&D Institute Poland >