linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Peter Wang <peter.wang@mediatek.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Saravana Kannan <saravanak@google.com>
Subject: Re: [PATCH] PM: runtime: Fix supplier device management during consumer probe
Date: Fri, 1 Jul 2022 10:33:37 +0200	[thread overview]
Message-ID: <Yr6xYX1vyIS3pQiX@kroah.com> (raw)
In-Reply-To: <4748074.GXAFRqVoOG@kreacher>

On Thu, Jun 30, 2022 at 09:16:41PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Because pm_runtime_get_suppliers() bumps up the rpm_active counter
> of each device link to a supplier of the given device in addition
> to bumping up the supplier's PM-runtime usage counter, a runtime
> suspend of the consumer device may case the latter to go down to 0
> when pm_runtime_put_suppliers() is running on a remote CPU.  If that
> happens after pm_runtime_put_suppliers() has released power.lock for
> the consumer device, and a runtime resume of that device takes place
> immediately after it, before pm_runtime_put() is called for the
> supplier, that pm_runtime_put() call may cause the supplier to be
> suspended even though the consumer is active.
> 
> To prevent that from happening, modify pm_runtime_get_suppliers() to
> call pm_runtime_get_sync() for the given device's suppliers without
> touching the rpm_active counters of the involved device links
> Accordingly, modify pm_runtime_put_suppliers() to call pm_runtime_put()
> for the given device's suppliers without looking at the rpm_active
> counters of the device links at hand.  [This is analogous to what
> happened before commit 4c06c4e6cf63 ("driver core: Fix possible
> supplier PM-usage counter imbalance").]
> 
> Since pm_runtime_get_suppliers() sets supplier_preactivated for each
> device link where the supplier's PM-runtime usage counter has been
> incremented and pm_runtime_put_suppliers() calls pm_runtime_put() for
> the suppliers whose device links have supplier_preactivated set, the
> PM-runtime usage counter is balanced for each supplier and this is
> independent of the runtime suspend and resume of the consumer device.
> 
> However, in case a device link with DL_FLAG_PM_RUNTIME set is dropped
> during the consumer device probe, so pm_runtime_get_suppliers() bumps
> up the supplier's PM-runtime usage counter, but it cannot be dropped by
> pm_runtime_put_suppliers(), make device_link_release_fn() take care of
> that.
> 
> Fixes: 4c06c4e6cf63 ("driver core: Fix possible supplier PM-usage counter imbalance")
> Reported-by: Peter Wang <peter.wang@mediatek.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/base/core.c          |   10 ++++++++++
>  drivers/base/power/runtime.c |   14 +-------------
>  2 files changed, 11 insertions(+), 13 deletions(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

  reply	other threads:[~2022-07-01  8:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 19:16 [PATCH] PM: runtime: Fix supplier device management during consumer probe Rafael J. Wysocki
2022-07-01  8:33 ` Greg Kroah-Hartman [this message]
2022-07-01 10:36 ` Peter Wang

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=Yr6xYX1vyIS3pQiX@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=adrian.hunter@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peter.wang@mediatek.com \
    --cc=rjw@rjwysocki.net \
    --cc=saravanak@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).