Linux Power Management development
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Pin-yen Lin <treapking@chromium.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Saravana Kannan <saravanak@google.com>,
	Hsin-Te Yuan <yuanhsinte@chromium.org>,
	linux-pm@vger.kernel.org, Chen-Yu Tsai <wenst@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] PM: sleep: Don't wait for SYNC_STATE_ONLY device links
Date: Thu, 11 Sep 2025 14:28:51 +0200	[thread overview]
Message-ID: <2025091129-harmonics-clambake-6240@gregkh> (raw)
In-Reply-To: <20250911112058.3610201-2-treapking@chromium.org>

On Thu, Sep 11, 2025 at 07:16:03PM +0800, Pin-yen Lin wrote:
> Device links with DL_FLAG_SYNC_STATE_ONLY should not affect suspend
> and resume, and functions like device_reorder_to_tail() and
> device_link_add() doesn't try to reorder the consumers with such flag.
> 
> However, dpm_wait_for_consumers() and dpm_wait_for_suppliers() doesn't
> check this flag before triggering dpm_wait, leading to potential hang
> during suspend/resume.
> 
> This can be reproduced on MT8186 Corsola Chromebook with devicetree like:
> 
> usb-a-connector {
>         compatible = "usb-a-connector";
>         port {
>                 usb_a_con: endpoint {
>                         remote-endpoint = <&usb_hs>;
>                 };
>         };
> };
> 
> usb_host {
>         compatible = "mediatek,mt8186-xhci", "mediatek,mtk-xhci";
>         port {
>                 usb_hs: endpoint {
>                         remote-endpoint = <&usb_a_con>;
>                 };
>         };
> };
> 
> In this case, the two nodes form a cycle and a SYNC_STATE_ONLY devlink
> between usb_host (supplier) and usb-a-connector (consumer) is created.
> 
> Use device_link_flag_is_sync_state_only() to check this in
> dpm_wait_for_consumers() and dpm_wait_for_suppliers() to fix this.
> 
> Fixes: 05ef983e0d65a ("driver core: Add device link support for SYNC_STATE_ONLY flag")
> Signed-off-by: Pin-yen Lin <treapking@chromium.org>
> ---
> 
> Changes in v2:
> - Update commit message
> - Use device_link_flag_is_sync_state_only()
> 
>  drivers/base/power/main.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index 2ea6e05e6ec9..73a1916170ae 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -282,7 +282,8 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async)
>  	 * walking.
>  	 */
>  	list_for_each_entry_rcu_locked(link, &dev->links.suppliers, c_node)
> -		if (READ_ONCE(link->status) != DL_STATE_DORMANT)
> +		if (READ_ONCE(link->status) != DL_STATE_DORMANT &&
> +		    !device_link_flag_is_sync_state_only(link->flags))
>  			dpm_wait(link->supplier, async);
>  
>  	device_links_read_unlock(idx);
> @@ -339,7 +340,8 @@ static void dpm_wait_for_consumers(struct device *dev, bool async)
>  	 * unregistration).
>  	 */
>  	list_for_each_entry_rcu_locked(link, &dev->links.consumers, s_node)
> -		if (READ_ONCE(link->status) != DL_STATE_DORMANT)
> +		if (READ_ONCE(link->status) != DL_STATE_DORMANT &&
> +		    !device_link_flag_is_sync_state_only(link->flags))
>  			dpm_wait(link->consumer, async);
>  
>  	device_links_read_unlock(idx);

The way you use this new function does not require it to have been
exported to modules :(

thanks,

greg k-h

  reply	other threads:[~2025-09-11 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 11:16 [PATCH v2 1/2] driver core: Export device_link_flag_is_sync_state_only() Pin-yen Lin
2025-09-11 11:16 ` [PATCH v2 2/2] PM: sleep: Don't wait for SYNC_STATE_ONLY device links Pin-yen Lin
2025-09-11 12:28   ` Greg Kroah-Hartman [this message]
2025-09-11 12:49     ` Rafael J. Wysocki
2025-09-11 12:28 ` [PATCH v2 1/2] driver core: Export device_link_flag_is_sync_state_only() Greg Kroah-Hartman
2025-09-11 12:50 ` Rafael J. Wysocki

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=2025091129-harmonics-clambake-6240@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@google.com \
    --cc=treapking@chromium.org \
    --cc=wenst@chromium.org \
    --cc=yuanhsinte@chromium.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox