Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6725081rwb; Tue, 9 Aug 2022 23:14:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR7MNb4RlXjZls/V+eYwONbn4W38vCG3dfQW9Cli/CkdOBvnqXi3tkStmHQzLYUTtF8/S6J9 X-Received: by 2002:a05:6402:2684:b0:43d:9964:d2a0 with SMTP id w4-20020a056402268400b0043d9964d2a0mr24994016edd.250.1660112069626; Tue, 09 Aug 2022 23:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660112069; cv=none; d=google.com; s=arc-20160816; b=jx8zvNb/f6ZCHbabg7SQjCpBO/KTXJv1WclT5DLY21gAAg5yET4iGNhLQDzcwHAWW3 dXNlfIMdSJ/H9wreYkGx4kd3+1LOambFl5eZscIQjaTE3GTy/eJaGxhJJljgndaBpiOy ry76ERSsxCtR8nWHneT2TVdSdFoNZD+nNRd7Iuphj2ZKnkGFFCrjkk+9SBnrDCUKRBVh 50akloueCrphAoo1282+sOLcmGMNnAo7QnWft2bmPzYVR448wtKeajz9pWFDLi64hTHG k4/rHosflAS2HhUhxPzbA7YyvJCtaH69C0rqmgC4xJYpCYdq4UwkflcsXdjCgM0NqMOP LKLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=4jRmKhAnaVbGZ2PreR5yx2mRFJMw6J4dpUJKDGI8VVo=; b=vnUp/BfIgDZk3jwlSou69Kd+Yu4O/OpVQ0bKlUsByS6ubfrRAPNDr8Kv8KLK9p/dp/ VQHN0qFGo8eBpRbev9KRzYT48FBUGIcLn+WcoP3+jR/eCgLt1gNXV0RDhIU6PeT6Argv Ern1MkH9/jElRe6dIFj7TRQ08OyPkTS3mO+5Mc529iw7eX5LNKZMqYzzZCy3gXblctcU /TRC/Q4Zh1x7nReaZZoK8H1Xj9tGeayn3a+KKyk6ey0Q+zKwCARZ2Z44Z80QqDohQwka yWrAvlNkOz+AoVOFHVzZLe/tgiQ27qTqtLXDTxBFelzWQyWOAu32+lFHlnH8fRvcQXSo VCgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OxT4Afmf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a056402430e00b0043ca09be179si11423297edc.545.2022.08.09.23.14.04; Tue, 09 Aug 2022 23:14:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OxT4Afmf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231255AbiHJGBb (ORCPT + 99 others); Wed, 10 Aug 2022 02:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbiHJGAy (ORCPT ); Wed, 10 Aug 2022 02:00:54 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE2525FF for ; Tue, 9 Aug 2022 23:00:53 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31f46b4759bso118251187b3.0 for ; Tue, 09 Aug 2022 23:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=4jRmKhAnaVbGZ2PreR5yx2mRFJMw6J4dpUJKDGI8VVo=; b=OxT4AfmfLdEyfSQy0e92Efv0g+qYB6QYUz9bkXmQdeby668KcDAmVDJ7bOyUq7V0F2 QALyFz4wMMi53j3QRCAb8qA9F+kZ1RKov1W6yjvk3SKS5E1/4yAukI31vXSaR+iB3oH4 km0WTV6SkAwda2RS0hxEubyt9id8QjSpq7NCkQLS8tmgOqv78QQNaHTuxCkqp8rBkGOH fcESgAQOAIZcbW5as7agp9686kHQSepZw1hJrV0JV73xCs8a7LY61agm1fKZt383OK3W 84tW+occS8vIst00z0DYIJCMd4j9nmKVCYBFqM+yy8FYxe+FfwkJaFWeg01XxWaXlojV Zmrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=4jRmKhAnaVbGZ2PreR5yx2mRFJMw6J4dpUJKDGI8VVo=; b=UWMqC/FqwPSZskYxi6QYxIp02WQsNJ9XJsuDSHPm57UZ1p5sI0kvuTDjXnoePp9No1 lrmOZeFdiGpOuuW25pUOXLYAjJI2ENYwO3F6JErD7i9JaB8PvaH/2d4nBiyiZVGXSAOG 9hAoavfvMCuqJc9MHGy0QG2ds8xYAkhlCiTosf/9dnHIxWm4ZOSVd3BMmUm4jv7rIhh3 8POQzFYU2u5XnrEnwrwVccLLXwEx58/Tr33qyaT+yuV5E6GF9Dky01e2QJxPMZGMuCob Yn70zR8VncgDn5jqxeXTIHzccfdIF35fjifNS2pEefONaxWq00fhT4H/vEB7yPsMk/Pm 5TLQ== X-Gm-Message-State: ACgBeo0FltrDdKYSYUww4Cl3jh4a48I+ygkE7uuWjqMTg8lXruY6C7gS LLplCYhAkifhDnzuiumEIOuI+N1ELzQciA0= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:f21:76ca:766f:e0ab]) (user=saravanak job=sendgmr) by 2002:a05:6902:108c:b0:67b:bc33:ef01 with SMTP id v12-20020a056902108c00b0067bbc33ef01mr15758584ybu.251.1660111253153; Tue, 09 Aug 2022 23:00:53 -0700 (PDT) Date: Tue, 9 Aug 2022 23:00:31 -0700 In-Reply-To: <20220810060040.321697-1-saravanak@google.com> Message-Id: <20220810060040.321697-3-saravanak@google.com> Mime-Version: 1.0 References: <20220810060040.321697-1-saravanak@google.com> X-Mailer: git-send-email 2.37.1.559.g78731f0fdb-goog Subject: [PATCH v1 2/9] driver core: fw_devlink: Improve check for fwnode with no device/driver From: Saravana Kannan To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Linus Walleij , Bartosz Golaszewski , Rob Herring , Frank Rowand , Geert Uytterhoeven , Magnus Damm , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Len Brown Cc: Saravana Kannan , Abel Vesa , Alexander Stein , Tony Lindgren , Sudeep Holla , Geert Uytterhoeven , John Stultz , Doug Anderson , Guenter Roeck , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-acpi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fw_devlink shouldn't defer the probe of a device to wait on a supplier that'll never have a struct device or will never be probed by a driver. We currently check if a supplier falls into this category, but don't check its ancestors. We need to check the ancestors too because if the ancestor will never probe, then the supplier will never probe either. Signed-off-by: Saravana Kannan --- drivers/base/core.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 6f575c2a24ad..8ec2236b1f9c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1866,6 +1866,35 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup) return ret; } +static bool fwnode_init_without_drv(struct fwnode_handle *fwnode) +{ + struct device *dev; + bool ret; + + if (!(fwnode->flags & FWNODE_FLAG_INITIALIZED)) + return false; + + dev = get_dev_from_fwnode(fwnode); + ret = !dev || dev->links.status == DL_DEV_NO_DRIVER; + put_device(dev); + + return ret; +} + +static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *parent; + + fwnode_for_each_parent_node(fwnode, parent) { + if (fwnode_init_without_drv(parent)) { + fwnode_handle_put(parent); + return true; + } + } + + return false; +} + /** * fw_devlink_create_devlink - Create a device link from a consumer to fwnode * @con: consumer device for the device link @@ -1943,9 +1972,16 @@ static int fw_devlink_create_devlink(struct device *con, goto out; } - /* Supplier that's already initialized without a struct device. */ - if (sup_handle->flags & FWNODE_FLAG_INITIALIZED) + /* + * Supplier or supplier's ancestor already initialized without a struct + * device or being probed by a driver. + */ + if (fwnode_init_without_drv(sup_handle) || + fwnode_ancestor_init_without_drv(sup_handle)) { + dev_dbg(con, "Not linking %pfwP - Might never probe\n", + sup_handle); return -EINVAL; + } /* * DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports -- 2.37.1.559.g78731f0fdb-goog