From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 080B3C433F5 for ; Tue, 14 Sep 2021 06:16:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D23D56044F for ; Tue, 14 Sep 2021 06:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240050AbhINGSL (ORCPT ); Tue, 14 Sep 2021 02:18:11 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:43921 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239600AbhINGSJ (ORCPT ); Tue, 14 Sep 2021 02:18:09 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20210914061651euoutp024bbb90b625dfec1a790adfdcc1bed542~km7_DA8eN0904509045euoutp02W for ; Tue, 14 Sep 2021 06:16:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20210914061651euoutp024bbb90b625dfec1a790adfdcc1bed542~km7_DA8eN0904509045euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1631600211; bh=sJ896bsTZuWbJZQuipKgY7jqTRqWY4opH73RzQpVHts=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=cngnM9XRXtEMimi5PWNF3TAOJr8g+E/QT/pd3rhGggEgAvnHVzOko3yUu4J+MdsbI kZC4RhOKdfQBrEIewq2imt437XG31wjX3WfZQ5APOh4/QbhMhBEEdvJxkd5Ohh8yvh KrFxeKMoj95EAT9JfCb7LImsXQtXiZzTY5ivkpVA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210914061651eucas1p130b23ce3f853fb0f75d3099eaa4e0489~km79y8uZd1713217132eucas1p1C; Tue, 14 Sep 2021 06:16:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 56.E4.45756.35E30416; Tue, 14 Sep 2021 07:16:51 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210914061650eucas1p2d432b97038c76ee9778ee7678cbfd841~km79FdOLS3083730837eucas1p2G; Tue, 14 Sep 2021 06:16:50 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210914061650eusmtrp1a28088e7d11743320886713aa17ce89d~km79EuVjP1049310493eusmtrp1w; Tue, 14 Sep 2021 06:16:50 +0000 (GMT) X-AuditID: cbfec7f2-7d5ff7000002b2bc-2f-61403e53fab9 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D5.EF.31287.25E30416; Tue, 14 Sep 2021 07:16:50 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210914061650eusmtip206166440f8aee732d2482ce16a42807d~km78aB3wy2697426974eusmtip2Y; Tue, 14 Sep 2021 06:16:50 +0000 (GMT) Subject: Re: [PATCH v1 1/5] driver core: fw_devlink: Improve handling of cyclic dependencies To: Saravana Kannan , Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: John Stultz , Rob Herring , Geert Uytterhoeven , Andrew Lunn , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org From: Marek Szyprowski Message-ID: <7756112c-0378-f48b-ef5a-aafc994dc662@samsung.com> Date: Tue, 14 Sep 2021 08:16:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210914043928.4066136-2-saravanak@google.com> Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAKsWRmVeSWpSXmKPExsWy7djP87rBdg6JBp2zZCzO3z3EbPHs1l4m i+bF69kszvzWtdixXcTi8q45bBYbNn9nspj7ZSqzReveI+wWXYf+sjlweWzbvY3VY+esu+we CzaVemxa1cnmcefaHjaPQ4c7GD32z13D7rFzx2cmj8+b5AI4o7hsUlJzMstSi/TtErgy/kw+ zlTwX7Li+sQJjA2Mf0W6GDk5JARMJJrvLmTpYuTiEBJYwShxb99URgjnC6PEzznHmUCqhAQ+ M0rMWK4O03Fj0lpmiKLljBITLnexQTgfGSUu3F/CClIlLBAncW/9B7C5IgJtjBIP9/0Ec5gF vjJKfLi4nhGkik3AUKLrLUg7JwevgJ3E0u3fWEBsFgFViT/bbrKD2KICyRLT/jYxQ9QISpyc +QSshlPARuLn96tgNcwC8hLb385hhrDFJW49mc8EskxCoJ9TYvv6tUwQh7tIvL41D8oWlnh1 fAs7hC0jcXpyDwtEQzPQqefWskM4PYwSl5tmMEJUWUvcOfcL6FQOoBWaEut36UOEHSXOrJnI BBKWEOCTuPFWEOIIPolJ26YzQ4R5JTrahCCq1SRmHV8Ht/bghUvMExiVZiF5bRaSd2YheWcW wt4FjCyrGMVTS4tz01OLDfNSy/WKE3OLS/PS9ZLzczcxAhPZ6X/HP+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/Zz8w7Gea8+6h1iZOJgPMQowcGsJMK77Y1tohBvSmJlVWpRfnxRaU5q8SFGU6B/JjJL iSbnA5NHXkm8oZmBqaGJmaWBqaWZsZI479a5a+KFBNITS1KzU1MLUotg+pg4OKUamCYuFZn7 um2q5nMW/5ork91Ve42mOX61FJh8NChrD/v63bsYlq4pvVy7Qq8uPPmr6bdeibwVzm9N4hJE f8+4s6+27EXc7y/XHn+ZoT/P8Lqgol/r5dmtP7fYP0p+NuWKxo1Drww0nolOv3bQunyD34uN Xo2q+e9uL9JM3SXckOJesMZsnkXmks6z/Nv7DOcZcGp/WuD4Mv6i0fbrDW0fAvgS2q2rxR6y bVLxeRX75XUD3+LnmQmTaoW+pupqOkc0Wh3PVX+17WvV1tfbq/UamG4KCDnwrEydt9Sp4VxK Y9tU/SW9k/6m1HI77zl04H6Ck9+0Gu+KEwVnPhaU37cvqoyqlHQzW2096WhCfMnNbUosxRmJ hlrMRcWJAAeCf89mAwAA X-CMS-MailID: 20210914061650eucas1p2d432b97038c76ee9778ee7678cbfd841 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20210914043943eucas1p134f89c3399fb2bb6a5f24ea5b6119188 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210914043943eucas1p134f89c3399fb2bb6a5f24ea5b6119188 References: <20210914043928.4066136-1-saravanak@google.com> <20210914043928.4066136-2-saravanak@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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