All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Saravana Kannan <saravanak@google.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Marc Zyngier <maz@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>,
	kernel-team@android.com, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 13/17] driver core: Use device's fwnode to check if it is waiting for suppliers
Date: Mon, 27 Jun 2022 14:42:29 +0300	[thread overview]
Message-ID: <YrmXpcU1NTYW6T/n@linaro.org> (raw)
In-Reply-To: <20201121020232.908850-14-saravanak@google.com>

On 20-11-20 18:02:28, Saravana Kannan wrote:
> To check if a device is still waiting for its supplier devices to be
> added, we used to check if the devices is in a global
> waiting_for_suppliers list. Since the global list will be deleted in
> subsequent patches, this patch stops using this check.
>
> Instead, this patch uses a more device specific check. It checks if the
> device's fwnode has any fwnode links that haven't been converted to
> device links yet.
>
> Signed-off-by: Saravana Kannan <saravanak@google.com>
> ---
>  drivers/base/core.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 395dece1c83a..1873cecb0cc4 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock);
>  static LIST_HEAD(deferred_sync);
>  static unsigned int defer_sync_state_count = 1;
>  static DEFINE_MUTEX(fwnode_link_lock);
> +static bool fw_devlink_is_permissive(void);
>
>  /**
>   * fwnode_link_add - Create a link between two fwnode_handles.
> @@ -995,13 +996,13 @@ int device_links_check_suppliers(struct device *dev)
>  	 * Device waiting for supplier to become available is not allowed to
>  	 * probe.
>  	 */
> -	mutex_lock(&wfs_lock);
> -	if (!list_empty(&dev->links.needs_suppliers) &&
> -	    dev->links.need_for_probe) {
> -		mutex_unlock(&wfs_lock);
> +	mutex_lock(&fwnode_link_lock);
> +	if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
> +	    !fw_devlink_is_permissive()) {
> +		mutex_unlock(&fwnode_link_lock);

Hi Saravana,

First of, sorry for going back to this.

There is a scenario where this check will not work and probably should
work. It goes like this:

A clock controller is not allowed to probe because it uses a clock from a child device of a
consumer, like so:

	dispcc: clock-controller@af00000 {
        	clocks = <&dsi0_phy 0>;
	};

	mdss: mdss@ae00000 {
		clocks = <&dispcc DISP_CC_MDSS_MDP_CLK>;

		dsi0_phy: dsi-phy@ae94400 {
        		clocks = <&dispcc DISP_CC_MDSS_AHB_CLK>,
		};
	};

This is a real scenario actually, but I stripped it down to the essentials.

So, the dsi0_phy will be "device_add'ed" (through of_platform_populate) by the mdss probe.
The mdss will probe defer waiting for the DISP_CC_MDSS_MDP_CLK, while
the dispcc will probe defer waiting for the dsi0_phy (supplier).

Basically, this 'supplier availability check' does not work when a supplier might
be populated by a consumer of the device that is currently trying to probe.


Abel


>  		return -EPROBE_DEFER;
>  	}
> -	mutex_unlock(&wfs_lock);
> +	mutex_unlock(&fwnode_link_lock);
>
>  	device_links_write_lock();
>
> @@ -1167,10 +1168,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev,
>  	bool val;
>
>  	device_lock(dev);
> -	mutex_lock(&wfs_lock);
> -	val = !list_empty(&dev->links.needs_suppliers)
> -	      && dev->links.need_for_probe;
> -	mutex_unlock(&wfs_lock);
> +	val = !list_empty(&dev->fwnode->suppliers);
>  	device_unlock(dev);
>  	return sysfs_emit(buf, "%u\n", val);
>  }
> @@ -2202,7 +2200,7 @@ static int device_add_attrs(struct device *dev)
>  			goto err_remove_dev_groups;
>  	}
>
> -	if (fw_devlink_flags && !fw_devlink_is_permissive()) {
> +	if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) {
>  		error = device_create_file(dev, &dev_attr_waiting_for_supplier);
>  		if (error)
>  			goto err_remove_dev_online;
> --
> 2.29.2.454.gaff20da3a2-goog
>
>

  reply	other threads:[~2022-06-27 11:50 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21  2:02 [PATCH v2 00/17] Refactor fw_devlink to significantly improve boot time Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 01/17] Revert "driver core: Avoid deferred probe due to fw_devlink_pause/resume()" Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 02/17] Revert "driver core: Rename dev_links_info.defer_sync to defer_hook" Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 03/17] Revert "driver core: Don't do deferred probe in parallel with kernel_init thread" Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 04/17] Revert "driver core: Remove check in driver_deferred_probe_force_trigger()" Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 05/17] Revert "of: platform: Batch fwnode parsing when adding all top level devices" Saravana Kannan
2020-12-07 22:18   ` Rob Herring
2020-11-21  2:02 ` [PATCH v2 06/17] Revert "driver core: fw_devlink: Add support for batching fwnode parsing" Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 07/17] driver core: Add fwnode_init() Saravana Kannan
2020-12-06  7:26   ` Leon Romanovsky
2020-12-07 19:25     ` Saravana Kannan
2020-12-07 19:53       ` Leon Romanovsky
2020-12-07 20:36         ` Saravana Kannan
2020-12-08  6:34           ` Leon Romanovsky
2020-12-07 22:20   ` Rob Herring
2020-11-21  2:02 ` [PATCH v2 08/17] driver core: Add fwnode link support Saravana Kannan
2020-12-06  7:48   ` Leon Romanovsky
2020-12-07 19:25     ` Saravana Kannan
2020-12-07 19:56       ` Leon Romanovsky
2020-12-07 22:21   ` Rob Herring
2020-11-21  2:02 ` [PATCH v2 09/17] driver core: Allow only unprobed consumers for SYNC_STATE_ONLY device links Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 10/17] device property: Add fwnode_is_ancestor_of() and fwnode_get_next_parent_dev() Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 11/17] driver core: Redefine the meaning of fwnode_operations.add_links() Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 12/17] driver core: Add fw_devlink_parse_fwtree() Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 13/17] driver core: Use device's fwnode to check if it is waiting for suppliers Saravana Kannan
2022-06-27 11:42   ` Abel Vesa [this message]
2022-06-27 22:30     ` Saravana Kannan
2022-06-28 15:24       ` Abel Vesa
2022-06-28 15:44         ` Abel Vesa
2022-06-28 15:55       ` Abel Vesa
2022-06-28 18:09         ` Saravana Kannan
2023-01-05 14:47           ` Dmitry Baryshkov
2020-11-21  2:02 ` [PATCH v2 14/17] of: property: Update implementation of add_links() to create fwnode links Saravana Kannan
2020-12-07 22:37   ` Rob Herring
2020-11-21  2:02 ` [PATCH v2 15/17] efi: " Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 16/17] driver core: Refactor fw_devlink feature Saravana Kannan
2020-11-23 16:00   ` [driver core] 95f755a4ef: will-it-scale.per_process_ops 2.2% improvement kernel test robot
2020-12-11 14:11   ` [PATCH v2 16/17] driver core: Refactor fw_devlink feature Qian Cai
2020-12-11 14:11     ` Qian Cai
2020-12-11 16:34     ` Robin Murphy
2020-12-11 16:34       ` Robin Murphy
2020-12-11 17:51       ` Saravana Kannan
2020-12-11 17:51         ` Saravana Kannan
2020-12-11 18:03         ` Marc Zyngier
2020-12-11 18:03           ` Marc Zyngier
2020-12-11 18:20           ` Saravana Kannan
2020-12-11 18:20             ` Saravana Kannan
2020-12-11 19:07             ` Marc Zyngier
2020-12-11 19:07               ` Marc Zyngier
2020-12-11 22:29               ` Saravana Kannan
2020-12-11 22:29                 ` Saravana Kannan
2020-12-29  3:34   ` Michael Walle
2021-01-05 19:00     ` Saravana Kannan
2021-01-05 21:03       ` Michael Walle
2021-01-06 23:29         ` Saravana Kannan
2020-11-21  2:02 ` [PATCH v2 17/17] driver core: Delete pointless parameter in fwnode_operations.add_links Saravana Kannan
2020-12-07 22:38   ` Rob Herring
2020-11-24  8:29 ` [PATCH v2 00/17] Refactor fw_devlink to significantly improve boot time Tomi Valkeinen
2020-11-24 17:25   ` Saravana Kannan
2020-12-03 19:05   ` Saravana Kannan
2020-12-09 18:16 ` Greg Kroah-Hartman
2020-12-09 20:24   ` Saravana Kannan
2020-12-10  9:26     ` Greg Kroah-Hartman

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=YrmXpcU1NTYW6T/n@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=ardb@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=grygorii.strashko@ti.com \
    --cc=kernel-team@android.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=saravanak@google.com \
    --cc=tglx@linutronix.de \
    --cc=tomi.valkeinen@ti.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.