All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Len Brown <lenb@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
	Abel Vesa <abel.vesa@linaro.org>,
	Alexander Stein <alexander.stein@ew.tq-group.com>,
	Tony Lindgren <tony@atomide.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	John Stultz <jstultz@google.com>,
	Doug Anderson <dianders@chromium.org>,
	Guenter Roeck <linux@roeck-us.net>,
	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
Subject: [PATCH v1 2/9] driver core: fw_devlink: Improve check for fwnode with no device/driver
Date: Tue,  9 Aug 2022 23:00:31 -0700	[thread overview]
Message-ID: <20220810060040.321697-3-saravanak@google.com> (raw)
In-Reply-To: <20220810060040.321697-1-saravanak@google.com>

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 <saravanak@google.com>
---
 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


  parent reply	other threads:[~2022-08-10  6:01 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  6:00 [PATCH v1 0/9] fw_devlink improvements Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 1/9] driver core: fw_devlink: Don't purge child fwnode's consumer links Saravana Kannan
2022-08-10  6:00 ` Saravana Kannan [this message]
2022-08-10  6:00 ` [PATCH v1 3/9] soc: renesas: Move away from using OF_POPULATED for fw_devlink Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 4/9] gpiolib: Clear the gpio_device's fwnode initialized flag before adding Saravana Kannan
2022-08-15  9:57   ` Bartosz Golaszewski
2022-08-10  6:00 ` [PATCH v1 5/9] driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 6/9] driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 7/9] driver core: fw_devlink: Consolidate device link flag computation Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 8/9] driver core: fw_devlink: Make cycle detection more robust Saravana Kannan
2022-08-10  6:00 ` [PATCH v1 9/9] of: property: Simplify of_link_to_phandle() Saravana Kannan
2022-08-12  9:47   ` Tony Lindgren
2022-08-13  0:37     ` Saravana Kannan
2022-08-15 10:31       ` Tony Lindgren
2022-08-15 21:00         ` Saravana Kannan
2022-08-12  9:49 ` [PATCH v1 0/9] fw_devlink improvements Tony Lindgren
2022-08-13  0:51   ` Saravana Kannan
2022-08-15 10:33     ` Tony Lindgren
2022-08-15 18:23       ` Saravana Kannan
2022-08-18  7:05         ` Tony Lindgren
2022-08-18 15:00           ` Greg Kroah-Hartman
2022-08-14  5:59 ` Saravana Kannan
2022-08-15 10:17   ` Naresh Kamboju
2022-08-15 11:01 ` Abel Vesa
2022-08-15 18:23   ` Saravana Kannan
2022-08-15 12:39 ` Alexander Stein
2022-08-15 19:17   ` Saravana Kannan
2022-08-15 20:56     ` Saravana Kannan
2022-08-16  7:17       ` Alexander Stein
2022-08-16 18:51         ` Saravana Kannan
2022-08-16  7:17     ` Alexander Stein
2022-08-15 13:52 ` Sudeep Holla
2022-08-17 13:01 ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220810060040.321697-3-saravanak@google.com \
    --to=saravanak@google.com \
    --cc=abel.vesa@linaro.org \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=djrscally@gmail.com \
    --cc=frowand.list@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jstultz@google.com \
    --cc=kernel-team@android.com \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=magnus.damm@gmail.com \
    --cc=rafael@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sudeep.holla@arm.com \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.