All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Kevin Hilman <khilman@baylibre.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: PM regression with commit 5de85b9d57ab PM runtime re-init in v4.5-rc1
Date: Wed, 3 Feb 2016 08:09:51 -0800	[thread overview]
Message-ID: <20160203160951.GF19432@atomide.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1602031034360.2041-100000@iolanthe.rowland.org>

* Alan Stern <stern@rowland.harvard.edu> [160203 07:46]:
> On Wed, 3 Feb 2016, Ulf Hansson wrote:
> 
> > > Let me summarize my understanding of this thread so far.
> > >
> > > It looks like the omap3 code initializes hardware in ->probe() and
> > > then it may return -EPROBE_DEFER due to some unmet dependencies.  In
> > > that case the hardware is not reset to the previous state and the
> > > runtime PM framework is left in the state that corresponds to the
> > > current hardware state.  Before we had pm_runtime_reinit(), everything
> > > worked as expected on the second ->probe() call, because things were
> > > in sync then.
> > 
> > Correct!

Well not quite correct. After failed probe PM runtime is set to reset
state while hardware is still enabled.

> > Before pm_runtime_reinit(), the failing probe case (-EPROBE_DEFER)
> > worked fine because the HW state and the runtime PM status was in
> > sync. The device was powered and the runtime PM status was RPM_ACTIVE.
> > 
> > >
> > > The introduction of pm_runtime_reinit() changed the situation and now
> > > effectively the hardware is required to be reset to the initial state
> > > if -EPROBE_DEFER is to be returned too.
> > 
> > Not correct. The hardware doesn't need a reset as it stays powered
> > after a failed probe.

It is really best to disable the hardware after a failed probe
like we do with pm_runtime_put_sync_(suspend)() and pm_runtime_disable().

This is because there may never be another probe attempt and we want
to have unclaimed devices shut off (or idled) for PM.

> > Instead, only the runtime PM status needs to be synchronized with the
> > HW state the next probe attempt.
>
> In other words, the probe routine assumes the actual state is the same
> as the PM status.  This may have been true before pm_runtime_reinit()
> came along, but it's not true now.
> 
> > In other words, when the PM domain's ->runtime_resume() callbacks gets
> > called due to a pm_runtime_get_sync() in the second probe attempt, it
> > may find that the HW is already powered and can return zero instead of
> > resetting it.

Certainly that should at least produce a warning in the hardware
specific implementation. It's a state mismatch between PM runtime
and the hardware specific implementation.

And as discussed, the problem does not exist as long as we understand
that we need to use pm_runtime_put_sync_suspend() if the driver has
set pm_runtime_use_autoidle(). Or else use the combination of
pm_runtime_dont_use_autoidle() and pm_runtime_put_sync().

> What's wrong with going ahead and resetting the hardware anyway?

Nothing, unless a state needs to be maintained for things like GPIO
pins power memory :)

Regards,

Tony

WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: PM regression with commit 5de85b9d57ab PM runtime re-init in v4.5-rc1
Date: Wed, 3 Feb 2016 08:09:51 -0800	[thread overview]
Message-ID: <20160203160951.GF19432@atomide.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1602031034360.2041-100000@iolanthe.rowland.org>

* Alan Stern <stern@rowland.harvard.edu> [160203 07:46]:
> On Wed, 3 Feb 2016, Ulf Hansson wrote:
> 
> > > Let me summarize my understanding of this thread so far.
> > >
> > > It looks like the omap3 code initializes hardware in ->probe() and
> > > then it may return -EPROBE_DEFER due to some unmet dependencies.  In
> > > that case the hardware is not reset to the previous state and the
> > > runtime PM framework is left in the state that corresponds to the
> > > current hardware state.  Before we had pm_runtime_reinit(), everything
> > > worked as expected on the second ->probe() call, because things were
> > > in sync then.
> > 
> > Correct!

Well not quite correct. After failed probe PM runtime is set to reset
state while hardware is still enabled.

> > Before pm_runtime_reinit(), the failing probe case (-EPROBE_DEFER)
> > worked fine because the HW state and the runtime PM status was in
> > sync. The device was powered and the runtime PM status was RPM_ACTIVE.
> > 
> > >
> > > The introduction of pm_runtime_reinit() changed the situation and now
> > > effectively the hardware is required to be reset to the initial state
> > > if -EPROBE_DEFER is to be returned too.
> > 
> > Not correct. The hardware doesn't need a reset as it stays powered
> > after a failed probe.

It is really best to disable the hardware after a failed probe
like we do with pm_runtime_put_sync_(suspend)() and pm_runtime_disable().

This is because there may never be another probe attempt and we want
to have unclaimed devices shut off (or idled) for PM.

> > Instead, only the runtime PM status needs to be synchronized with the
> > HW state the next probe attempt.
>
> In other words, the probe routine assumes the actual state is the same
> as the PM status.  This may have been true before pm_runtime_reinit()
> came along, but it's not true now.
> 
> > In other words, when the PM domain's ->runtime_resume() callbacks gets
> > called due to a pm_runtime_get_sync() in the second probe attempt, it
> > may find that the HW is already powered and can return zero instead of
> > resetting it.

Certainly that should at least produce a warning in the hardware
specific implementation. It's a state mismatch between PM runtime
and the hardware specific implementation.

And as discussed, the problem does not exist as long as we understand
that we need to use pm_runtime_put_sync_suspend() if the driver has
set pm_runtime_use_autoidle(). Or else use the combination of
pm_runtime_dont_use_autoidle() and pm_runtime_put_sync().

> What's wrong with going ahead and resetting the hardware anyway?

Nothing, unless a state needs to be maintained for things like GPIO
pins power memory :)

Regards,

Tony

  reply	other threads:[~2016-02-03 16:09 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26 22:48 PM regression with commit 5de85b9d57ab PM runtime re-init in v4.5-rc1 Tony Lindgren
2016-01-26 22:48 ` Tony Lindgren
2016-01-26 22:50 ` Tony Lindgren
2016-01-26 22:50   ` Tony Lindgren
2016-01-26 23:14 ` Rafael J. Wysocki
2016-01-26 23:14   ` Rafael J. Wysocki
2016-01-26 23:22   ` Tony Lindgren
2016-01-26 23:22     ` Tony Lindgren
2016-01-26 23:37     ` Rafael J. Wysocki
2016-01-26 23:37       ` Rafael J. Wysocki
2016-01-26 23:52       ` Tony Lindgren
2016-01-26 23:52         ` Tony Lindgren
2016-01-27  7:54         ` Rafael J. Wysocki
2016-01-27  7:54           ` Rafael J. Wysocki
2016-01-27  8:17           ` Ulf Hansson
2016-01-27  8:17             ` Ulf Hansson
2016-01-27 15:19             ` Tony Lindgren
2016-01-27 15:19               ` Tony Lindgren
2016-01-27 22:51             ` Rafael J. Wysocki
2016-01-27 22:51               ` Rafael J. Wysocki
2016-01-28 14:29         ` Ulf Hansson
2016-01-28 14:29           ` Ulf Hansson
2016-01-28 16:58           ` Tony Lindgren
2016-01-28 16:58             ` Tony Lindgren
2016-02-01 16:44             ` Ulf Hansson
2016-02-01 16:44               ` Ulf Hansson
2016-02-01 18:11               ` Tony Lindgren
2016-02-01 18:11                 ` Tony Lindgren
2016-02-01 22:06                 ` Tony Lindgren
2016-02-01 22:06                   ` Tony Lindgren
2016-02-01 22:17                   ` Rafael J. Wysocki
2016-02-01 22:17                     ` Rafael J. Wysocki
2016-02-01 22:29                     ` Tony Lindgren
2016-02-01 22:29                       ` Tony Lindgren
2016-02-01 23:10                       ` Rafael J. Wysocki
2016-02-01 23:10                         ` Rafael J. Wysocki
2016-02-01 23:28                         ` Tony Lindgren
2016-02-01 23:28                           ` Tony Lindgren
2016-02-01 23:44                           ` Tony Lindgren
2016-02-01 23:44                             ` Tony Lindgren
2016-02-01 23:49                           ` Alan Stern
2016-02-01 23:49                             ` Alan Stern
2016-02-02  3:05                             ` Tony Lindgren
2016-02-02  3:05                               ` Tony Lindgren
2016-02-02 10:07                               ` Ulf Hansson
2016-02-02 10:07                                 ` Ulf Hansson
2016-02-02 10:42                                 ` Ulf Hansson
2016-02-02 10:42                                   ` Ulf Hansson
2016-02-02 16:23                                   ` Alan Stern
2016-02-02 16:23                                     ` Alan Stern
2016-02-02 16:35                                   ` Tony Lindgren
2016-02-02 16:35                                     ` Tony Lindgren
2016-02-02 20:47                                     ` Ulf Hansson
2016-02-02 20:47                                       ` Ulf Hansson
2016-02-02 23:41                                       ` Tony Lindgren
2016-02-02 23:41                                         ` Tony Lindgren
2016-02-03 10:23                                         ` Ulf Hansson
2016-02-03 10:23                                           ` Ulf Hansson
2016-02-03 10:25                                           ` Ulf Hansson
2016-02-03 10:25                                             ` Ulf Hansson
2016-02-03 12:18                                             ` Rafael J. Wysocki
2016-02-03 12:18                                               ` Rafael J. Wysocki
2016-02-03 14:58                                               ` Ulf Hansson
2016-02-03 14:58                                                 ` Ulf Hansson
2016-02-03 15:45                                                 ` Alan Stern
2016-02-03 15:45                                                   ` Alan Stern
2016-02-03 16:09                                                   ` Tony Lindgren [this message]
2016-02-03 16:09                                                     ` Tony Lindgren
2016-02-03 16:24                                                     ` Ulf Hansson
2016-02-03 16:24                                                       ` Ulf Hansson
2016-02-03 17:01                                                       ` Tony Lindgren
2016-02-03 17:01                                                         ` Tony Lindgren
2016-02-03 17:16                                                       ` Rafael J. Wysocki
2016-02-03 17:16                                                         ` Rafael J. Wysocki
2016-02-03 16:27                                           ` Tony Lindgren
2016-02-03 16:27                                             ` Tony Lindgren
2016-02-03 18:02                                             ` Ulf Hansson
2016-02-03 18:02                                               ` Ulf Hansson
2016-02-03 18:28                                               ` Tony Lindgren
2016-02-03 18:28                                                 ` Tony Lindgren
2016-02-03 18:37                                                 ` Ulf Hansson
2016-02-03 18:37                                                   ` Ulf Hansson
2016-02-03 18:45                                                   ` Tony Lindgren
2016-02-03 18:45                                                     ` Tony Lindgren
2016-02-03 21:51                                                     ` Tony Lindgren
2016-02-03 21:51                                                       ` Tony Lindgren
2016-02-02 16:15                                 ` Alan Stern
2016-02-02 16:15                                   ` Alan Stern
2016-02-02 16:49                                   ` Tony Lindgren
2016-02-02 16:49                                     ` Tony Lindgren
2016-02-02 18:05                                     ` Tony Lindgren
2016-02-02 18:05                                       ` Tony Lindgren
2016-02-02 18:43                                       ` Alan Stern
2016-02-02 18:43                                         ` Alan Stern
2016-02-02 18:54                                         ` Tony Lindgren
2016-02-02 18:54                                           ` Tony Lindgren
2016-02-02 19:16                                           ` Alan Stern
2016-02-02 19:16                                             ` Alan Stern
2016-02-02 21:03                                             ` Tony Lindgren
2016-02-02 21:03                                               ` Tony Lindgren
2016-02-02 21:45                                               ` Alan Stern
2016-02-02 21:45                                                 ` Alan Stern
2016-02-02 23:46                                                 ` Tony Lindgren
2016-02-02 23:46                                                   ` Tony Lindgren
2016-02-03 13:06                                                   ` Rafael J. Wysocki
2016-02-03 13:06                                                     ` Rafael J. Wysocki
2016-02-03 16:36                                                     ` Tony Lindgren
2016-02-03 16:36                                                       ` Tony Lindgren
2016-02-03 15:48                                                   ` Alan Stern
2016-02-03 15:48                                                     ` Alan Stern
2016-02-03 16:37                                                     ` Tony Lindgren
2016-02-03 16:37                                                       ` Tony Lindgren
2016-02-03 17:18                                                   ` Rafael J. Wysocki
2016-02-03 17:18                                                     ` Rafael J. Wysocki
2016-02-03 17:22                                                     ` Tony Lindgren
2016-02-03 17:22                                                       ` Tony Lindgren
2016-02-03 17:27                                                       ` Rafael J. Wysocki
2016-02-03 17:27                                                         ` Rafael J. Wysocki
2016-02-04 10:20                                                     ` Ulf Hansson
2016-02-04 10:20                                                       ` Ulf Hansson
2016-02-04 16:04                                                       ` Alan Stern
2016-02-04 16:04                                                         ` Alan Stern
2016-02-04 17:20                                                         ` Tony Lindgren
2016-02-04 17:20                                                           ` Tony Lindgren
2016-02-04 21:11                                                         ` Ulf Hansson
2016-02-04 21:11                                                           ` Ulf Hansson
2016-02-04 22:09                                                           ` Alan Stern
2016-02-04 22:09                                                             ` Alan Stern
2016-02-04 22:34                                                             ` Ulf Hansson
2016-02-04 22:34                                                               ` Ulf Hansson
2016-02-05  1:08                                                               ` Tony Lindgren
2016-02-05  1:08                                                                 ` Tony Lindgren
2016-02-05  6:54                                                                 ` Ulf Hansson
2016-02-05  6:54                                                                   ` Ulf Hansson
2016-02-05 19:10                                                                   ` Tony Lindgren
2016-02-05 19:10                                                                     ` Tony Lindgren
2016-02-02 18:47                                       ` Tony Lindgren
2016-02-02 18:47                                         ` Tony Lindgren
2016-02-02 20:24                                   ` Ulf Hansson
2016-02-02 20:24                                     ` Ulf Hansson
2016-02-02 21:24                                     ` Alan Stern
2016-02-02 21:24                                       ` Alan Stern
2016-02-02 21:39                                     ` Tony Lindgren
2016-02-02 21:39                                       ` Tony Lindgren
2016-02-03 13:03                                       ` Rafael J. Wysocki
2016-02-03 13:03                                         ` Rafael J. Wysocki
2016-02-03 16:49                                         ` Tony Lindgren
2016-02-03 16:49                                           ` Tony Lindgren

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=20160203160951.GF19432@atomide.com \
    --to=tony@atomide.com \
    --cc=khilman@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=ulf.hansson@linaro.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 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.