From patchwork Wed Sep 15 17:09: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: 12496957 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 D9E81C433EF for ; Wed, 15 Sep 2021 17:09:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFDA16127B for ; Wed, 15 Sep 2021 17:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbhIORLM (ORCPT ); Wed, 15 Sep 2021 13:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhIORLI (ORCPT ); Wed, 15 Sep 2021 13:11:08 -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 CA57BC061764 for ; Wed, 15 Sep 2021 10:09:49 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id j27-20020a05620a0a5b00b0042874883070so5583344qka.19 for ; Wed, 15 Sep 2021 10:09: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=SK0Awx6gBdtKUkOkh7F3holwbySWbAOSfl3fXGrSMFk=; b=j/6JMqqVwtPJr2PuYNwQ9wHyUtwghqpcHDRgXk+GpqAzIOKLLlEezdzFBuFFcvA3bk lFWUqD4frWgBGCCe5sqKyNW9RTDZkP5GBw+rmHvsu78Kqu3BZ9BFR6OLgKh0+OdBAZ77 LMXJdaaUkF5RaBueu/TL8CHaIDou4p6a4kLpK87FJW3yiy5bAuZylth0AtGOwEDzBt/0 RsnqKLvC7W7ZiPQ+7OPB8fpQxfbzYXS34akl0jznUoy+gFauKX3DjrXQQAYh5A7nD39E 0xtxj7UWDMDfs9lkdv7KBSW1SMh1Uy0qu+e3rf6A6rn9bVwdSYkvFNqs6oFWhtUj27rr KTzw== 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=SK0Awx6gBdtKUkOkh7F3holwbySWbAOSfl3fXGrSMFk=; b=BF1tiHqMGIOQBNheBQjtQqHB3HjkJibxQSO75GHfnnxerzXZGMEGJxGKXoSywzM6ry eHPsrNQMF8R6F/nTkbjDu/wOoPyaIGq1bKrZdEwBwgGR3cQxbs8Cib1/m490yDnChbfG YS8wjnIiXu93zBh6BhxB/R7wbH8LcMCbavFsh82DPQX/vErfyWDXaTR+3KKe5V2si6YS +wg0Fcya9mAT7YfU23S3Fkit/Lg6YCiCbYeZbCng5HU+yxrVsEis3Z/G/UX0L4RWBjCs PUEHH0CG1jAC9k46LkmTGOZXu1UwjJ+qzvYq/ZZYv9lJ3ISLsHW37JjPe0l7joVUAUXN 1QYA== X-Gm-Message-State: AOAM532I7TDhrQxPuBDe54O+xOViF9TwBUY3CT/zaJ+v+Ga4RQGdLhdU dE1JmvRc1QJKfpypZUWa+BjNs+Z29sNnlUc= X-Google-Smtp-Source: ABdhPJzpSB08zJBnLwbHl02W9xYuCHlr5gBvgb/tW3BrQDILrEXB073GvlAwzYRJ7nRDUowH61DjK//i7prT180= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a0c:aa01:: with SMTP id d1mr714696qvb.47.1631725789030; Wed, 15 Sep 2021 10:09:49 -0700 (PDT) Date: Wed, 15 Sep 2021 10:09:37 -0700 In-Reply-To: <20210915170940.617415-1-saravanak@google.com> Message-Id: <20210915170940.617415-2-saravanak@google.com> Mime-Version: 1.0 References: <20210915170940.617415-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v3 1/3] 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: Geert Uytterhoeven , Vladimir Oltean , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-acpi@vger.kernel.org, Marek Szyprowski 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 Tested-by: Marek Szyprowski --- 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 17:09: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: 12496959 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=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 BCD48C433EF for ; Wed, 15 Sep 2021 17:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A280260E90 for ; Wed, 15 Sep 2021 17:09:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbhIORLO (ORCPT ); Wed, 15 Sep 2021 13:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhIORLM (ORCPT ); Wed, 15 Sep 2021 13:11: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 0D4BBC061764 for ; Wed, 15 Sep 2021 10:09:53 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id b84-20020a253457000000b0059e6b730d45so4528921yba.6 for ; Wed, 15 Sep 2021 10:09:53 -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=2lJ0J4500ZYIhX1EYV/ZexmHeXs7PML1pzFGBHjPm2U=; b=nI3Ht9LVInk1Tm3cGHj65FkLZwg8om+aKaHWFC3J/iqkNimaavtGddierU0U/LNH2v 99P343QiRJrpY2aYxf2G+emGzD7pHJEz8hWTHXDkX//2G6QBCvR/DyVnepVITg44m05L QQgtoomCzoO9bxa5fEdFcGYLLg8oJKoferC6gSwkXg9mJInH2HADJScJbYBWP8LPre9k 0Vt4fQoAauE+bvxgXld+nvBTiQl2rdgsOfY9TT+/+54XCNsfE8J4ACkTV/cAJ3MOVbHf +vbj6S4wNwrHt84hDokzcoSzR2PqV4HgJGgITx86IIWI1fWASseP+bzk5LnH/THpXJ0i zhjQ== 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=2lJ0J4500ZYIhX1EYV/ZexmHeXs7PML1pzFGBHjPm2U=; b=Rsf2vp/yRSEwxe7bo2SLI9OxRw2CAPvcCIiDaVc9yEx5mYcyEPFX11PdvjFfYMvvN1 ljuaVDr6Lp0SYz8Iem3dwH9GPhMTjWi+vmqO5j1tQAjch2rTKreKQeBxtDpyFQVWM3Sx NhGG2eL2+pbE7N92O0UjID+oDL7PWIlbsQfE+LqZjokPqgCjDjLbDHyBxExemmWcys7P /CySiO7HeMllsMftMAy+p9i8I0Lfqo7/9bDgDNXvRIWH0C73hMKY60ybxLvP9F3QzU+b XxTzjkbd+RoFRsxu8Z/siCHzwCQGkysk9y/9j/1rlEU5jSOeIVAZdxQJczTxMyrkFZR6 kBeA== X-Gm-Message-State: AOAM532e8Xf4xAwuZUgcgXWj7li0bjY2I546PfjtEuCM/8PYH5SqlCsA HMIpuz94lSL/Hm8ySQ7KHigE1VdwGH3WkWQ= X-Google-Smtp-Source: ABdhPJzajoUWYGw9XTDVj89C0KnB5ylhkI12ge/OdvhJfcN8kj38fwKy6OfgQ4NxRDOpj1WyMWcSbTnO/1Dq35I= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a25:bacd:: with SMTP id a13mr1389689ybk.216.1631725792265; Wed, 15 Sep 2021 10:09:52 -0700 (PDT) Date: Wed, 15 Sep 2021 10:09:38 -0700 In-Reply-To: <20210915170940.617415-1-saravanak@google.com> Message-Id: <20210915170940.617415-3-saravanak@google.com> Mime-Version: 1.0 References: <20210915170940.617415-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v3 2/3] 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: 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/ Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by default""") 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 316df6027093..21d4cb5d3767 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1722,6 +1722,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 17:09:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 12496961 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 6F3DCC433EF for ; Wed, 15 Sep 2021 17:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5911F60E90 for ; Wed, 15 Sep 2021 17:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbhIORLT (ORCPT ); Wed, 15 Sep 2021 13:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbhIORLP (ORCPT ); Wed, 15 Sep 2021 13:11:15 -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 2A02EC061575 for ; Wed, 15 Sep 2021 10:09:56 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id f8-20020a2585480000b02905937897e3daso4584404ybn.2 for ; Wed, 15 Sep 2021 10:09:56 -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=0UkhiVR6DjX0Qd/nDHxWlOx6CU+wUejBFeHGRDPmxic=; b=rwiUknLhsfckyVtc9MYWfpdl3zUMcj5whM/wqIUzOr7o2qJxIqRU8JtfI8kmsp9RPC cDeUTCK6JiV3Lckp6PP2yElQNCgj9MAHv6Y060ht0erC5m5TM6cFAFlEGsIQTxpunqkJ TTmdqVt2BxbTrwpXoz2MK7WckyV25BgIsa/cOe8MbdW0TwswELSHN4loB6VRm1E3MoFH mv3X8AEDVvRNbr72GDMRLCGqivh2AfHr1AW2HFbuX7q88dvrmYlkdY6cCkbIIj/yfAj0 hRcDxevpYLN7SZ2ZsnVkE/qqQxQHCA/kXgRMDSoALiQci0e/P+iYgF8tV9TLT/684NE1 irrQ== 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=0UkhiVR6DjX0Qd/nDHxWlOx6CU+wUejBFeHGRDPmxic=; b=D59JzrD9/Q3D14nUO+Io05PQtu7RxCPJfQNfDbJamEkh8iyyaTCxPrCYCVEdWPJa5O TFori5QDv9eSdGEYY4/WFUlnmumZKGRAmyi+mk+Br5Q5KyhfhgWjghQaybh/r0siP9WT kTu73ioWfR9jdNktqRgTKFbyk5RJP0JzvwmVcqk1RARCOp5d8p9lOmAzCYIwCtO2NA/d EhoEzFYKSXIz60c491YlW5iPjoZLTif7Qe+jlLcUrUf9qd+6VG338xgcpaNwvaWGghUY rPT41PEMDcLdUoRzup94f5QVPOTs8JWxq9lXH7NdrxjSzRiUcggQFMcYuytlWnOCuEkZ lp5g== X-Gm-Message-State: AOAM5313NVpbhI3tX0rmEw5LHHQjgItuGG13ph53jwAPFrrJvhLrBho1 KkaioE7lEnwOBhMaWU0xxR2AjSo3ADrOpEg= X-Google-Smtp-Source: ABdhPJyvpC6BA5zyb82hUXBtYjxlMLYkjX2NtqbM8ENYqEoZl85lNNkglEar4E0dEbS7Amv0OoYKpo2c4nNcc14= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:16d1:ab0e:fc4a:b9b1]) (user=saravanak job=sendgmr) by 2002:a25:d387:: with SMTP id e129mr1258115ybf.239.1631725795385; Wed, 15 Sep 2021 10:09:55 -0700 (PDT) Date: Wed, 15 Sep 2021 10:09:39 -0700 In-Reply-To: <20210915170940.617415-1-saravanak@google.com> Message-Id: <20210915170940.617415-4-saravanak@google.com> Mime-Version: 1.0 References: <20210915170940.617415-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v3 3/3] 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: 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 Fixes: ea718c699055 ("Revert "Revert "driver core: Set fw_devlink=on by default""") 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);