From patchwork Wed Sep 15 08:11:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495697 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 4D247C43219 for ; Wed, 15 Sep 2021 08:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33F3C6112D for ; Wed, 15 Sep 2021 08:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237095AbhIOINX (ORCPT ); Wed, 15 Sep 2021 04:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237042AbhIOINM (ORCPT ); Wed, 15 Sep 2021 04:13:12 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDA9C0613EF for ; Wed, 15 Sep 2021 01:11:46 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id s204-20020a252cd5000000b005a16e62ee63so2577764ybs.12 for ; Wed, 15 Sep 2021 01:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WuAb6MBtSzivvvxQ/9C3pYrE2NS/OY1FoVAPECcMVH8=; b=K9Yt53VW22oqgQL+/rMGeYCH6nAlDx+0sOi3uZ6egzz66Ue1dohvyJJVcpfqKb9MYT juYS7Kyo38+lI7/M1iZ0Z4LP1zO/geJkWdmbjD+VW46+r72EWzdWXBBjv6lwUPpwVOLJ RKWsGAW/YqC9HI2ozQ1evL2equN9q9opQg87fjJ1w12AJHd3SeeNoSWY3xTcAF3iCPc3 7dMTUMxxWAs0XGTMOqf7mzVoy4VO8rAgkUmbhH7W4fbEoBAz+uanJZUcidlE8FgcVkQh F1Ce0/hd6ycGUBSU+woVOxO9EyU6qcaYuMYcMbN0CeJ4TKjsBOuHQ6WAbs15fhFdbdLx phAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WuAb6MBtSzivvvxQ/9C3pYrE2NS/OY1FoVAPECcMVH8=; b=AyOaJyRwVBaoKkK2Xe5DuFUguqxzK7cLE6fr+fEYGZ6nF+8kuljwnghcCJs+5At8vv 0f6J9Rka/Ldt/C04I5GOHLlHqmzxzpKaVfLmoI9jBULxTTuXv55qoB1jrkFEQ2CRwzz8 BWY604BloJlJ5jdOA6/Hooin80QZiKzuQTt8GwR4r/Ly5ImFTERg7LXsVYfblsDl4I4r wxIaGRnV4tT7lewBltKKBM1KiM4FPH4lt2Y/dnWL2v1h2szg0lrAQEYZPglqehq3+Kkj PLUrBOKRcFySoJImJQIh8adtqcVc0+c9UwnRQBvgGqtKwPToyEh6zqXcN9RsIB17wNtm LyXA== X-Gm-Message-State: AOAM532zVCFD2cT9vzRHjHpGMcniEeEdcMoNgH9ovphkVNaytr2pgi+3 4fR/xyDA1ha+Y3Pw3xWuC4bFVfl30I63f/k= X-Google-Smtp-Source: ABdhPJzpQv0MpGydkOw27weKviy+9CiEfXH7nqPp8EFl39Q7uzmFnDgg1XrIHMmEKRbkXD/TsDULRd1KM9blN14= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a25:1b89:: with SMTP id b131mr4526177ybb.40.1631693506005; Wed, 15 Sep 2021 01:11:46 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:33 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-2-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 1/6] driver core: fw_devlink: Improve handling of cyclic dependencies From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 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 { /* From patchwork Wed Sep 15 08:11:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495699 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 97E86C433EF for ; Wed, 15 Sep 2021 08:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82880610FF for ; Wed, 15 Sep 2021 08:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237150AbhIOIN2 (ORCPT ); Wed, 15 Sep 2021 04:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231720AbhIOINN (ORCPT ); Wed, 15 Sep 2021 04:13:13 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E16FC061766 for ; Wed, 15 Sep 2021 01:11:49 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id l11-20020a056902072b00b005a776eefb28so2654649ybt.5 for ; Wed, 15 Sep 2021 01:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SwVyaP/Ht2PwaBMDQzWc9eJHDBQpCz2nALAmbECEhpQ=; b=QUGoVBusTu4hW55kbQfAHy0Gpz3kYuimJYcUOODn8J0I/7DZkCM14Y/XV93nl4aYCP +ezA6KRcvEAcmEmCHGF5DK4VQuHzoqloHRAExFyo7XQX8VWVQZZuMgxbs6GCErGm2xMo 3WhdO6zOo0cDPPeM9+uOMVq6rJzF5I1bMsuh9A+hQ9dQKjLGrEjVGGh3qZ4jo2NavqpK fEWQGL9qQYSigSa3YT6nkRZJis7DRUE0zbaV3jtu3YQv4UgL/fPifi3K+lWZrkLDAE9V 0VrtY5L3be1fgKiq/HYPxZl3N1zuyBS1+avTDv8T5P89lhU3OE4fk6lyCuhow3EQ4a24 yK+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SwVyaP/Ht2PwaBMDQzWc9eJHDBQpCz2nALAmbECEhpQ=; b=lShuSWmm8vcpBxlsK0fvtOsYV72WsV7G/ughd8Se3ZMJRaJuEytTaEbxXcrIEoAL4j 3ThIiCeObZOeBofLfkQXcM/93Z9tWcQ6HrsPmQWh3Gjb3a3AEukMVCe3o18Rv8cljSKS beHqZjBefKDlZkAPV3HFL/C8cjOSALaXU+m7uB1qZoir1jevqk6LnzIQS1WTdrCuWvuF xfPx4P6sI2EVgam+tkKS/o7LT9xXho3YQ4YLE6/Rd8iaiS4QRLs0466aPufI3Es9Y3gO rigjAZfqXqug1XS1vAwL1+wz1EU9Lc3tMKq9SVydkvo/LmbQBge/w8P4RYZS7t9SoEPW VizQ== X-Gm-Message-State: AOAM530/QN38dy/x1mX2yO1j/lRREei87isvMLZx+v2I7Behw0hvCNdQ 94jMGroa+L67194MnbSBVR+eMwz3Gp0RoPA= X-Google-Smtp-Source: ABdhPJzEE5Yr1jFgjYuau+gaFxStrLfBehac0EkhE77LIzIh9w6hvW01QzSMoNh14iJf8H76Z5XogrY3/gaGBTI= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a25:6d83:: with SMTP id i125mr4550266ybc.298.1631693508682; Wed, 15 Sep 2021 01:11:48 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:34 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-3-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 2/6] driver core: Set deferred probe reason when deferred by driver core From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the driver core defers the probe of a device, set the deferred probe reason so that it's easier to debug. The deferred probe reason is available in debugfs under devices_deferred. Signed-off-by: Saravana Kannan Reviewed-by: Geert Uytterhoeven --- drivers/base/core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 316df6027093..ca6c61a2e2e9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -975,6 +975,7 @@ int device_links_check_suppliers(struct device *dev) { struct device_link *link; int ret = 0; + struct fwnode_handle *sup_fw; /* * Device waiting for supplier to become available is not allowed to @@ -983,10 +984,11 @@ int device_links_check_suppliers(struct device *dev) mutex_lock(&fwnode_link_lock); if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) && !fw_devlink_is_permissive()) { - dev_dbg(dev, "probe deferral - wait for supplier %pfwP\n", - list_first_entry(&dev->fwnode->suppliers, - struct fwnode_link, - c_hook)->supplier); + sup_fw = list_first_entry(&dev->fwnode->suppliers, + struct fwnode_link, + c_hook)->supplier; + dev_err_probe(dev, -EPROBE_DEFER, "wait for supplier %pfwP\n", + sup_fw); mutex_unlock(&fwnode_link_lock); return -EPROBE_DEFER; } @@ -1001,8 +1003,9 @@ int device_links_check_suppliers(struct device *dev) if (link->status != DL_STATE_AVAILABLE && !(link->flags & DL_FLAG_SYNC_STATE_ONLY)) { device_links_missing_supplier(dev); - dev_dbg(dev, "probe deferral - supplier %s not ready\n", - dev_name(link->supplier)); + dev_err_probe(dev, -EPROBE_DEFER, + "supplier %s not ready\n", + dev_name(link->supplier)); ret = -EPROBE_DEFER; break; } From patchwork Wed Sep 15 08:11:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495701 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 03006C433F5 for ; Wed, 15 Sep 2021 08:12:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFCE8610D1 for ; Wed, 15 Sep 2021 08:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237127AbhIOINi (ORCPT ); Wed, 15 Sep 2021 04:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231610AbhIOINP (ORCPT ); Wed, 15 Sep 2021 04:13:15 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78319C0613CF for ; Wed, 15 Sep 2021 01:11:52 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id b15-20020a05622a020f00b0029e28300d94so1792669qtx.16 for ; Wed, 15 Sep 2021 01:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tE5kGBxc9PR5MYieHfGicxhFgO1boA1xk2XZYsANqZE=; b=KN5josXRk6vEJRYv7Y1XeBMkRQ8IZkeHu44xya1+5GcI4HNGbxj/PzNhRJv03Gm7gz vwZ+eUszHx3DpNx65e2e5tZwGBh4E735USu8tG5dL74IvqQS7GCR28Zet9kaZOkKGvfO 1YhaL/yYj9lv4TJfaP0O95HgWwVHMxevZNv5+x9HkCTw8gLypeb4HuL1IHfm3jfS4XTH kgoGDssnvd/dlvR7WgNGENS05/uC5nXpQCEZw/0JIG5MksUhDetVqUVN7J3YRjO+aXuD xrMHTI1av5a7LngEXrGJW1Q3kTesixXypTyLae2F+0L6oZw4+JAiS73jCRIQsnHE+vJg obag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tE5kGBxc9PR5MYieHfGicxhFgO1boA1xk2XZYsANqZE=; b=zAM/2f2bXvJoFiKQLv023i+2zyahLUPxgk9iphnSqQTHpPEsbqQNeHpeQ3/LqFIzeJ Y92SmV+8JWi3GfUij+L5ve9ego6tufXYL3ArZPwFl8Mu5jSOwFivkGiFyouVioqbMcZs SlTrsZozyoGA5v3JzsPW0r08DvXp7/1Ra9XaYuuT8GCTR4EhhwPcp6uqeeQERPwCXQFF aUqo3Y6jBHOZcENP5tO144+DZBAMTJ1gPCllvu+qKEZzNgGY9g4HAyR+rxOWyVDe2xqG yj5PJYBF908PAwFONwCDecwt+r4qe8RnyyXx6r4rKykEltIwr7AFIZnq6Y52CPEAdgVD Zi4Q== X-Gm-Message-State: AOAM531DHmROaK2E7kDZBJvTR5ZuLvxvr0QBN9qtgABoT5eMqfVkrxQ9 4EhmFgEYUgsWka56BeT7szaxvuI1T0vzwbk= X-Google-Smtp-Source: ABdhPJymuo/nGsFPIwVrp7CZBqqkEkLsixu4nf/KlVnpN+10WWdFz1i21Iee5Xghf2MWQiCPsNtZaWmaSD1VQvY= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a0c:fca2:: with SMTP id h2mr9492302qvq.5.1631693511580; Wed, 15 Sep 2021 01:11:51 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:35 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-4-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 3/6] driver core: Create __fwnode_link_del() helper function From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Geert Uytterhoeven Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The same code is repeated in multiple locations. Create a helper function for it. Signed-off-by: Saravana Kannan Reviewed-by: Geert Uytterhoeven --- drivers/base/core.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index ca6c61a2e2e9..5e7faad4e083 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -101,6 +101,19 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) return ret; } +/** + * __fwnode_link_del - Delete a link between two fwnode_handles. + * @link: the fwnode_link to be deleted + * + * The fwnode_link_lock needs to be held when this function is called. + */ +static void __fwnode_link_del(struct fwnode_link *link) +{ + list_del(&link->s_hook); + list_del(&link->c_hook); + kfree(link); +} + /** * fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle. * @fwnode: fwnode whose supplier links need to be deleted @@ -112,11 +125,8 @@ static void fwnode_links_purge_suppliers(struct fwnode_handle *fwnode) struct fwnode_link *link, *tmp; mutex_lock(&fwnode_link_lock); - list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) { - list_del(&link->s_hook); - list_del(&link->c_hook); - kfree(link); - } + list_for_each_entry_safe(link, tmp, &fwnode->suppliers, c_hook) + __fwnode_link_del(link); mutex_unlock(&fwnode_link_lock); } @@ -131,11 +141,8 @@ static void fwnode_links_purge_consumers(struct fwnode_handle *fwnode) struct fwnode_link *link, *tmp; mutex_lock(&fwnode_link_lock); - list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) { - list_del(&link->s_hook); - list_del(&link->c_hook); - kfree(link); - } + list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook) + __fwnode_link_del(link); mutex_unlock(&fwnode_link_lock); } @@ -1868,9 +1875,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev) if (!own_link || ret == -EAGAIN) continue; - list_del(&link->s_hook); - list_del(&link->c_hook); - kfree(link); + __fwnode_link_del(link); } } @@ -1922,9 +1927,7 @@ static void __fw_devlink_link_to_suppliers(struct device *dev, if (!own_link || ret == -EAGAIN) continue; - list_del(&link->s_hook); - list_del(&link->c_hook); - kfree(link); + __fwnode_link_del(link); /* If no device link was created, nothing more to do. */ if (ret) From patchwork Wed Sep 15 08:11:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495703 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 74AAEC433FE for ; Wed, 15 Sep 2021 08:12:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA35610FF for ; Wed, 15 Sep 2021 08:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237241AbhIOINm (ORCPT ); Wed, 15 Sep 2021 04:13:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237071AbhIOINT (ORCPT ); Wed, 15 Sep 2021 04:13:19 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC49C0613DE for ; Wed, 15 Sep 2021 01:11:54 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id h186-20020a3785c3000000b00425f37f792aso2477466qkd.22 for ; Wed, 15 Sep 2021 01:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cajmSKnfvpV4C51UK3Pjlq0PRtDcgxs8IXvmV4F1Bco=; b=MIYh+lurVtarZ7crdmPcrieMH8EZz98B67CS2pRpH+bw+nIifY+/74UZXzCrFVmvG7 5JNVXmSzUYMT6PjI6EPXSUDNQWJ0WtDfUXOTV574KiQakHURApKafcz71OkdVKsfbYES cGTYLboAdCqfpDw4psp0OfGRrZdivXKhQR05iQ0bEBla+cLfZ8Lun5wq2S79odkUsf82 Ft1meJUUQbSwLBZsoe3vZdLzB1wwu6jtfH6CZvyWrohKZv3afrvUIe6eG7+LQQkv1p0C Rb466pXXNvNvL7w9bCjzEvxuIC/e+NPOqYO0ymBiCbYLNQvQXpENU1zwOp5sl88UQ6Cd 5XtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cajmSKnfvpV4C51UK3Pjlq0PRtDcgxs8IXvmV4F1Bco=; b=WLsrq0oMQUr9ARlV8mYgqcL+IyJ7ZQuS7CmgmPlH8gS7hT72PUXk0k/4TahhbLtinJ y0KmQbx92Ibjngrd7O4w1Pbe04mJlcKRUbUvpNG0Nw6O0IQpcLvKXXU8bCXQY3M0yMcW IrBvbjrhgqmWXxPduffANpKEv0pcf3//iBY2bL3eml4i6c4Dl/nRXYSs56vPymiEVKab uQQIHcpOAWBIaXJzSZFWk05Jdpg+2M0YdoCA8++UMIYFZniDuBHp40ZTLbg4SUbK60kI mx+bYoe5s+ZJWTSRq1jtvbocZEpgYd9YgXGuMhjh4hFVXAq5mfoUS95Rwev4fSlB1fA6 E22A== X-Gm-Message-State: AOAM533y4M+0RfB2yo81q1LvPo9l+rAUcWsGSzqfKQOGoO2owOCtxf20 6oG78x3hfaXInN5WI6wFw12PVfDwi/hyeV4= X-Google-Smtp-Source: ABdhPJw1MLQHUnPoE+xMUea0zwhQNWiEbbrDkOr6kvJJOLYN+b9okqykFfE3JvdOltc9UL2WPu1eY+Y4pt4ZAjk= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a0c:ab01:: with SMTP id h1mr9553038qvb.0.1631693514157; Wed, 15 Sep 2021 01:11:54 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:36 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-5-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 4/6] driver core: Add debug logs when fwnode links are added/deleted From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Geert Uytterhoeven Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This will help with debugging fw_devlink issues. Signed-off-by: Saravana Kannan Reviewed-by: Geert Uytterhoeven --- drivers/base/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 5e7faad4e083..f06e8e2dc69b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -95,6 +95,8 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) list_add(&link->s_hook, &sup->consumers); list_add(&link->c_hook, &con->suppliers); + pr_debug("%pfwP Linked as a fwnode consumer to %pfwP\n", + con, sup); out: mutex_unlock(&fwnode_link_lock); @@ -109,6 +111,8 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup) */ static void __fwnode_link_del(struct fwnode_link *link) { + pr_debug("%pfwP Dropping the fwnode link to %pfwP\n", + link->consumer, link->supplier); list_del(&link->s_hook); list_del(&link->c_hook); kfree(link); From patchwork Wed Sep 15 08:11:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495705 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 F1FFAC4332F for ; Wed, 15 Sep 2021 08:12:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF531608FB for ; Wed, 15 Sep 2021 08:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237293AbhIOINs (ORCPT ); Wed, 15 Sep 2021 04:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236837AbhIOINU (ORCPT ); Wed, 15 Sep 2021 04:13:20 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4BBBC0613E4 for ; Wed, 15 Sep 2021 01:11:57 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id k15-20020a25240f000000b0059efafc5a58so2607340ybk.11 for ; Wed, 15 Sep 2021 01:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XikR/WOyJ2plSXMfR/Ef32dJfmo7/8orGj4hh35u364=; b=TuHTGT5MNcDdeMBfWhtm4T/pyh3m+EAo8jpD6ijC3MxuXQlqpvD80rQJf52X5NiEs7 FjEDDkXki6rhLTfnJeJEbHdg5+XEVSPO+XEFq6kW87922I0XxniRk9eGw1n6wCmSp1rN j6G0QceBDMDZzsW9fWpuWhEToW062Udv9V+RL2NFPmDCYwWb1J4UF7H2+acTk4U2y49P FaqOPkiX4kQ+Gg4MJUxoBvoihMaJKUx9Wd8d0jlpACi7By0kUVM+ObbAOwi4RBLAqo7x LW41dQN59e1nvGG/34DjLju2N+Rn345HadSQW+6SXqG+Kt5l5P++sWACZZw71Dj5s8Gi I/Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XikR/WOyJ2plSXMfR/Ef32dJfmo7/8orGj4hh35u364=; b=Dfad1M2k1EZ6M8hyE1r5/HMUaLeiqL7NR8037qows4cy+WuWvMZ90sry5ulzVNhc3y mXS+QbO8p3ByN8WPFNBxN22Frjk/j8Ffyl7s8SAOVxcNg/cMaCWQo06IfYn3kgydfdcI Bwx3OsLdIJuI5PIdO1cEfKZYHL3hheDTYn/8sJgrZ8DT8S3Xomf/Ew4jBsOfD5PKpZrp XMC27rjBjBvx6FrOXjKQIz1jsR+6M7dFSaxYWGwvpAyBW/abBNEZUffGuszngmKlwnjU Dh903WG7Xq4HIkf+cn7e19CjjkfipP3ArZRMn3HH2ASZEVU0S1jdFmhHesGNybAExtkK ghRg== X-Gm-Message-State: AOAM533XwXkkApUj+7SwbqQMbRKhH2+A2+ihNnVOyHqDgHpoPsXUp4J9 BG+pc4rYfnu6LTiZuzsTCi897xR9KvuWdXM= X-Google-Smtp-Source: ABdhPJy5AxcNM2TqizAS8drKUPgZ4XQI+j5Lt62BcdTxiW35unksixbmoua3iA7KZ+GXHA9w8WG4ySlrigtnNDE= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a25:cac3:: with SMTP id a186mr4869148ybg.370.1631693517036; Wed, 15 Sep 2021 01:11:57 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:37 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-6-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 5/6] driver core: fw_devlink: Add support for FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If a parent device is also a supplier to a child device, fw_devlink=on by design delays the probe() of the child device until the probe() of the parent finishes successfully. However, some drivers of such parent devices (where parent is also a supplier) expect the child device to finish probing successfully as soon as they are added using device_add() and before the probe() of the parent device has completed successfully. One example of such a case is discussed in the link mentioned below. Add a flag to make fw_devlink=on not enforce these supplier-consumer relationships, so these drivers can continue working. Link: https://lore.kernel.org/netdev/CAGETcx_uj0V4DChME-gy5HGKTYnxLBX=TH2rag29f_p=UcG+Tg@mail.gmail.com/ Signed-off-by: Saravana Kannan --- drivers/base/core.c | 19 +++++++++++++++++++ include/linux/fwnode.h | 11 ++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index f06e8e2dc69b..15986cc2fe5e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1736,6 +1736,25 @@ static int fw_devlink_create_devlink(struct device *con, struct device *sup_dev; int ret = 0; + /* + * In some cases, a device P might also be a supplier to its child node + * C. However, this would defer the probe of C until the probe of P + * completes successfully. This is perfectly fine in the device driver + * model. device_add() doesn't guarantee probe completion of the device + * by the time it returns. + * + * However, there are a few drivers that assume C will finish probing + * as soon as it's added and before P finishes probing. So, we provide + * a flag to let fw_devlink know not to delay the probe of C until the + * probe of P completes successfully. + * + * When such a flag is set, we can't create device links where P is the + * supplier of C as that would delay the probe of C. + */ + if (sup_handle->flags & FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD && + fwnode_is_ancestor_of(sup_handle, con->fwnode)) + return -EINVAL; + sup_dev = get_dev_from_fwnode(sup_handle); if (sup_dev) { /* diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 59828516ebaf..9f4ad719bfe3 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -22,10 +22,15 @@ struct device; * LINKS_ADDED: The fwnode has already be parsed to add fwnode links. * NOT_DEVICE: The fwnode will never be populated as a struct device. * INITIALIZED: The hardware corresponding to fwnode has been initialized. + * NEEDS_CHILD_BOUND_ON_ADD: For this fwnode/device to probe successfully, its + * driver needs its child devices to be bound with + * their respective drivers as soon as they are + * added. */ -#define FWNODE_FLAG_LINKS_ADDED BIT(0) -#define FWNODE_FLAG_NOT_DEVICE BIT(1) -#define FWNODE_FLAG_INITIALIZED BIT(2) +#define FWNODE_FLAG_LINKS_ADDED BIT(0) +#define FWNODE_FLAG_NOT_DEVICE BIT(1) +#define FWNODE_FLAG_INITIALIZED BIT(2) +#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3) struct fwnode_handle { struct fwnode_handle *secondary; From patchwork Wed Sep 15 08:11:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12495707 X-Patchwork-Delegate: kuba@kernel.org 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=-26.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 981DFC433EF for ; Wed, 15 Sep 2021 08:12:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CA2A6112D for ; Wed, 15 Sep 2021 08:12:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237328AbhIOINt (ORCPT ); Wed, 15 Sep 2021 04:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237065AbhIOINV (ORCPT ); Wed, 15 Sep 2021 04:13:21 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754E8C0613E0 for ; Wed, 15 Sep 2021 01:12:00 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id y185-20020a3764c20000b02903d2c78226ceso2590485qkb.6 for ; Wed, 15 Sep 2021 01:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=RwmF1eG4qjehbM/6vPHudaKlp5QMZAj0EjDeZYR+hmQ=; b=lisrCW1FhYgFf8tDVaJoILHzDIzWOAS5LqcKP0JGtTYPEKmraA3n3o4QQJNAhwl4/4 TKKR9DPQyLJ+kZ+nQVA5aF0oHoCDT1mORXCa+VYPIIXBaK53fZDs3wSXIpuCpM4HtEHd b/iAKZelL/EgjCvxZmEGTurk1lK6922v21LbUJ7JxgYlexfobGlx8iZtIOyAVx9pyLqc QoK/xekl9Y57N7unuQldMOQfk+G87n32xwKcmHW32zh2RgOIGp313Kq5TsYpXT1+rwvt 2+9hEwDzGoaW2+9sGVLIWufrkLfBncwA57Rvmmv5Nfz9ops1bM9sDFOdfaWw3keCzCk/ ZRgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=RwmF1eG4qjehbM/6vPHudaKlp5QMZAj0EjDeZYR+hmQ=; b=1aOAY0yo/lXWs7f+Oz287tLmfxz8J2qVMW0oYFf37ocESNSlItDwqk6LPdppzqXbV/ D53ZH7dZCKZXP7CiwoOLO26/EItffzBnjh15wkKri9AlkRg4FPRAvMPadc/2paipS0pU ACdzarJlvPBIqOp9e83pUfEQx4/Bij4Fkh/A4HG3lzVyA7OdI8P8kra1Wk7o1/iLjS6T 77ZzX2k2+TS1S6tNP3UQWF0NIasZNpPBuHRmVkLfKszYpik9kqUOJddBqKTM+XABXBuY ML6tE7OSdGJvT9Ax6s71DGRTKuNORn0GuDeMyyiRLXfV2PYBxePn/VuOcWUX36v99gHl mYog== X-Gm-Message-State: AOAM5329XTnXF49LVJwTo1hIvlgtU2jN7plGTWi6s3Cxb3qlSaBTluuS CoD6Bk6ycuTQNnJAJ6mNXQmeTndWszPxUy4= X-Google-Smtp-Source: ABdhPJzcVHO3Ms5A0jhHL8HrSgC/BPW06xlc2sD9lu2NhNaF2NYgAvjFpvJKh45oFc+yH+l3aOMriFQ5YfmnYCc= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a0c:d6cd:: with SMTP id l13mr9444170qvi.24.1631693519655; Wed, 15 Sep 2021 01:11:59 -0700 (PDT) Date: Wed, 15 Sep 2021 01:11:38 -0700 In-Reply-To: <20210915081139.480263-1-saravanak@google.com> Message-Id: <20210915081139.480263-7-saravanak@google.com> Mime-Version: 1.0 References: <20210915081139.480263-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v2 6/6] net: mdiobus: Set FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD for mdiobus parents From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Len Brown , Saravana Kannan Cc: John Stultz , Marek Szyprowski , Rob Herring , Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are many instances of PHYs that depend on a switch to supply a resource (Eg: interrupts). Switches also expects the PHYs to be probed by their specific drivers as soon as they are added. If that doesn't happen, then the switch would force the use of generic PHY drivers for the PHY even if the PHY might have specific driver available. fw_devlink=on by design can cause delayed probes of PHY. To avoid, this we need to set the FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD for the switch's fwnode before the PHYs are added. The most generic way to do this is to set this flag for the parent of MDIO busses which is typically the switch. For more context: https://lore.kernel.org/lkml/YTll0i6Rz3WAAYzs@lunn.ch/#t Suggested-by: Andrew Lunn Signed-off-by: Saravana Kannan --- drivers/net/phy/mdio_bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 53f034fc2ef7..ee8313a4ac71 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -525,6 +525,10 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) NULL == bus->read || NULL == bus->write) return -EINVAL; + if (bus->parent && bus->parent->of_node) + bus->parent->of_node->fwnode.flags |= + FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD; + BUG_ON(bus->state != MDIOBUS_ALLOCATED && bus->state != MDIOBUS_UNREGISTERED);