From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Tomeu Vizoso <tomeu.vizoso@collabora.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
bilhuang@nvidia.com
Subject: Re: [PATCH] driver core: Ensure proper suspend/resume ordering
Date: Thu, 10 Sep 2015 13:58:37 +0300 [thread overview]
Message-ID: <55F1625D.9090209@ti.com> (raw)
In-Reply-To: <1441880343-30852-1-git-send-email-thierry.reding@gmail.com>
On 09/10/2015 01:19 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Deferred probe can lead to strange situations where a device that is a
> dependency for others will be moved to the end of the dpm_list. At the
> same time the dependers may not be moved because at the time they will
> be probed the dependee may already have been successfully reprobed and
> they will not have to defer the probe themselves.
>
> One example where this happens is the Jetson TK1 board (Tegra124). The
> gpio-keys driver exposes the power key of the board as an input device
> that can also be used as a wakeup source. Commit 17cdddf0fb68 ("ARM:
> tegra: Add gpio-ranges property") results in the gpio-tegra driver
> deferring probe because one of its dependencies, the pinctrl-tegra
> driver, has not successfully completed probing. Currently the deferred
> probe code will move the corresponding gpio-tegra device to the end of
> the dpm_list, but by the time the gpio-keys device, depending on the
> gpio-tegra device, is probed, gpio-tegra has already been reprobed, so
> the gpio-keys device is not moved to the end of dpm_list itself. As a
> result, the suspend ordering becomes pinctrl-tegra -> gpio-keys ->
> gpio-tegra. That's problematic because the gpio-keys driver requests
> the power key to be a wakeup source. However, the programming of the
> wakeup interrupt registers happens in the gpio-tegra driver's suspend
> callback, which is now called before that of the gpio-keys driver. The
> result is that the wrong values are programmed and leaves the system
> unable to be resumed using the power key.
>
> To fix this situation, always move devices to the end of the dpm_list
> before probing them. Technically this should only be done for devices
> that have been successfully probed, but that won't work for recursive
> probing of devices (think an I2C master that instantiates children in
> its ->probe()). Effectively the dpm_list will end up ordered the same
> way that devices were probed, hence taking care of dependencies.
Second try :), first one was here:
"[RFC 1/1] driver core: re-order dpm_list after a succussful probe"
https://lkml.org/lkml/2014/12/12/324
and it was unsuccessful exactly because dpm_list was reordered after probe()
and not before, i think.
I'll try to test it.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Note that this commit is kind of the PM equivalent of 52cdbdd49853
> ("driver core: correct device's shutdown order) and that we have two
> lists that are essentially the same (dpm_list and devices_kset). I'm
> wondering if it would be worth looking into getting rid of one of
> them? I don't see any reason why the ordering for shutdown and
> suspend/resume should be different, and having a single list would
> help keep this in sync.
Yep. I've tried to remove one of those lists while working on shutdown issue.
I've tried to drop dmp_list, but my try was unsuccessful, because I was not
able to find simple way to handle device's dynamic creation/removal during
suspend/resume :(.
Also note, dmp_list's presence depends on Kconfig options.
>
> drivers/base/dd.c | 33 +++++++++++++++++++++++----------
> 1 file changed, 23 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index be0eb4639128..56291b11049b 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -88,16 +88,6 @@ static void deferred_probe_work_func(struct work_struct *work)
> */
> mutex_unlock(&deferred_probe_mutex);
>
> - /*
> - * Force the device to the end of the dpm_list since
> - * the PM code assumes that the order we add things to
> - * the list is a good order for suspend but deferred
> - * probe makes that very unsafe.
> - */
> - device_pm_lock();
> - device_pm_move_last(dev);
> - device_pm_unlock();
> -
> dev_dbg(dev, "Retrying from deferred list\n");
> bus_probe_device(dev);
>
> @@ -312,6 +302,29 @@ static int really_probe(struct device *dev, struct device_driver *drv)
> */
> devices_kset_move_last(dev);
>
> + /*
> + * Force the device to the end of the dpm_list since the PM code
> + * assumes that the order we add things to the list is a good order
> + * for suspend but deferred probe makes that very unsafe.
> + *
> + * Deferred probe can also cause situations in which a device that is
> + * a dependency for others gets moved further down the dpm_list as a
> + * result of probe deferral. In that case the dependee will end up
> + * getting suspended before any of its dependers.
> + *
> + * To ensure proper ordering of suspend/resume, move every device that
> + * is being probed to the end of the dpm_list. Note that technically
> + * only successfully probed devices need to be moved, but that breaks
> + * for recursively added devices because they would end up in the list
> + * in reverse of the desired order, so we simply do it unconditionally
> + * for all devices before they are being probed. In the worst case the
> + * list will be reordered a couple more times than necessary, which
> + * should be an insignificant amount of work.
> + */
> + device_pm_lock();
> + device_pm_move_last(dev);
> + device_pm_unlock();
> +
> if (dev->bus->probe) {
> ret = dev->bus->probe(dev);
> if (ret)
>
--
regards,
-grygorii
WARNING: multiple messages have this Message-ID (diff)
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Tomeu Vizoso <tomeu.vizoso@collabora.com>,
<linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<bilhuang@nvidia.com>
Subject: Re: [PATCH] driver core: Ensure proper suspend/resume ordering
Date: Thu, 10 Sep 2015 13:58:37 +0300 [thread overview]
Message-ID: <55F1625D.9090209@ti.com> (raw)
In-Reply-To: <1441880343-30852-1-git-send-email-thierry.reding@gmail.com>
On 09/10/2015 01:19 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Deferred probe can lead to strange situations where a device that is a
> dependency for others will be moved to the end of the dpm_list. At the
> same time the dependers may not be moved because at the time they will
> be probed the dependee may already have been successfully reprobed and
> they will not have to defer the probe themselves.
>
> One example where this happens is the Jetson TK1 board (Tegra124). The
> gpio-keys driver exposes the power key of the board as an input device
> that can also be used as a wakeup source. Commit 17cdddf0fb68 ("ARM:
> tegra: Add gpio-ranges property") results in the gpio-tegra driver
> deferring probe because one of its dependencies, the pinctrl-tegra
> driver, has not successfully completed probing. Currently the deferred
> probe code will move the corresponding gpio-tegra device to the end of
> the dpm_list, but by the time the gpio-keys device, depending on the
> gpio-tegra device, is probed, gpio-tegra has already been reprobed, so
> the gpio-keys device is not moved to the end of dpm_list itself. As a
> result, the suspend ordering becomes pinctrl-tegra -> gpio-keys ->
> gpio-tegra. That's problematic because the gpio-keys driver requests
> the power key to be a wakeup source. However, the programming of the
> wakeup interrupt registers happens in the gpio-tegra driver's suspend
> callback, which is now called before that of the gpio-keys driver. The
> result is that the wrong values are programmed and leaves the system
> unable to be resumed using the power key.
>
> To fix this situation, always move devices to the end of the dpm_list
> before probing them. Technically this should only be done for devices
> that have been successfully probed, but that won't work for recursive
> probing of devices (think an I2C master that instantiates children in
> its ->probe()). Effectively the dpm_list will end up ordered the same
> way that devices were probed, hence taking care of dependencies.
Second try :), first one was here:
"[RFC 1/1] driver core: re-order dpm_list after a succussful probe"
https://lkml.org/lkml/2014/12/12/324
and it was unsuccessful exactly because dpm_list was reordered after probe()
and not before, i think.
I'll try to test it.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> Note that this commit is kind of the PM equivalent of 52cdbdd49853
> ("driver core: correct device's shutdown order) and that we have two
> lists that are essentially the same (dpm_list and devices_kset). I'm
> wondering if it would be worth looking into getting rid of one of
> them? I don't see any reason why the ordering for shutdown and
> suspend/resume should be different, and having a single list would
> help keep this in sync.
Yep. I've tried to remove one of those lists while working on shutdown issue.
I've tried to drop dmp_list, but my try was unsuccessful, because I was not
able to find simple way to handle device's dynamic creation/removal during
suspend/resume :(.
Also note, dmp_list's presence depends on Kconfig options.
>
> drivers/base/dd.c | 33 +++++++++++++++++++++++----------
> 1 file changed, 23 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index be0eb4639128..56291b11049b 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -88,16 +88,6 @@ static void deferred_probe_work_func(struct work_struct *work)
> */
> mutex_unlock(&deferred_probe_mutex);
>
> - /*
> - * Force the device to the end of the dpm_list since
> - * the PM code assumes that the order we add things to
> - * the list is a good order for suspend but deferred
> - * probe makes that very unsafe.
> - */
> - device_pm_lock();
> - device_pm_move_last(dev);
> - device_pm_unlock();
> -
> dev_dbg(dev, "Retrying from deferred list\n");
> bus_probe_device(dev);
>
> @@ -312,6 +302,29 @@ static int really_probe(struct device *dev, struct device_driver *drv)
> */
> devices_kset_move_last(dev);
>
> + /*
> + * Force the device to the end of the dpm_list since the PM code
> + * assumes that the order we add things to the list is a good order
> + * for suspend but deferred probe makes that very unsafe.
> + *
> + * Deferred probe can also cause situations in which a device that is
> + * a dependency for others gets moved further down the dpm_list as a
> + * result of probe deferral. In that case the dependee will end up
> + * getting suspended before any of its dependers.
> + *
> + * To ensure proper ordering of suspend/resume, move every device that
> + * is being probed to the end of the dpm_list. Note that technically
> + * only successfully probed devices need to be moved, but that breaks
> + * for recursively added devices because they would end up in the list
> + * in reverse of the desired order, so we simply do it unconditionally
> + * for all devices before they are being probed. In the worst case the
> + * list will be reordered a couple more times than necessary, which
> + * should be an insignificant amount of work.
> + */
> + device_pm_lock();
> + device_pm_move_last(dev);
> + device_pm_unlock();
> +
> if (dev->bus->probe) {
> ret = dev->bus->probe(dev);
> if (ret)
>
--
regards,
-grygorii
next prev parent reply other threads:[~2015-09-10 10:58 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 10:19 [PATCH] driver core: Ensure proper suspend/resume ordering Thierry Reding
2015-09-10 10:58 ` Grygorii Strashko [this message]
2015-09-10 10:58 ` Grygorii Strashko
2015-09-10 22:08 ` Rafael J. Wysocki
2015-09-11 12:03 ` Thierry Reding
2015-09-11 19:01 ` Alan Stern
2015-09-11 19:01 ` Alan Stern
2015-09-11 22:28 ` Rafael J. Wysocki
2015-09-12 17:40 ` Alan Stern
2015-09-12 17:40 ` Alan Stern
2015-09-15 0:40 ` Rafael J. Wysocki
2015-09-15 14:23 ` Alan Stern
2015-09-16 1:04 ` Rafael J. Wysocki
2015-09-16 13:39 ` Grygorii Strashko
2015-09-16 13:39 ` Grygorii Strashko
2015-09-16 19:27 ` Alan Stern
2015-09-16 19:27 ` Alan Stern
2015-09-17 0:07 ` Rafael J. Wysocki
2015-09-17 15:48 ` Grygorii Strashko
2015-09-17 15:48 ` Grygorii Strashko
2015-09-17 23:59 ` Rafael J. Wysocki
2015-09-18 0:03 ` Rafael J. Wysocki
2015-10-01 18:14 ` Grygorii Strashko
2015-09-15 16:10 ` Thierry Reding
2015-09-15 19:18 ` Alan Stern
2015-09-15 19:18 ` Alan Stern
2015-09-16 1:28 ` Rafael J. Wysocki
2015-09-16 13:38 ` Grygorii Strashko
2015-09-16 13:38 ` Grygorii Strashko
2015-09-16 16:58 ` Alan Stern
2015-09-16 16:58 ` Alan Stern
2015-09-16 17:08 ` Alan Stern
2015-09-16 17:08 ` Alan Stern
2015-09-16 13:16 ` Thierry Reding
2015-09-16 19:22 ` Alan Stern
2015-09-16 19:22 ` Alan Stern
2015-09-17 0:27 ` Rafael J. Wysocki
2015-09-17 2:04 ` Rafael J. Wysocki
2015-09-17 17:02 ` Alan Stern
2015-09-17 18:43 ` Rafael J. Wysocki
2015-09-17 21:06 ` Alan Stern
2015-09-18 0:13 ` Rafael J. Wysocki
2015-09-18 15:55 ` Thierry Reding
2015-09-18 23:07 ` Rafael J. Wysocki
2015-09-21 8:51 ` Thierry Reding
2015-09-21 14:34 ` Alan Stern
2015-09-22 0:26 ` Rafael J. Wysocki
2015-09-22 1:22 ` Alan Stern
2015-09-22 0:39 ` Rafael J. Wysocki
2015-09-17 5:40 ` Tomeu Vizoso
2015-09-17 18:15 ` Rafael J. Wysocki
2015-09-17 19:21 ` Alan Stern
2015-09-11 22:38 ` Rafael J. Wysocki
2015-09-15 15:53 ` Thierry Reding
2015-09-16 1:18 ` Rafael J. Wysocki
2015-09-16 13:38 ` Grygorii Strashko
2015-09-16 13:38 ` Grygorii Strashko
2015-09-17 0:55 ` Rafael J. Wysocki
2015-09-11 14:05 ` Alan Stern
2015-09-11 14:05 ` Alan Stern
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=55F1625D.9090209@ti.com \
--to=grygorii.strashko@ti.com \
--cc=bilhuang@nvidia.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=thierry.reding@gmail.com \
--cc=tomeu.vizoso@collabora.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.