All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Wu <peter@lekensteyn.nl>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Dave Airlie <airlied@redhat.com>
Subject: Re: [PATCH 1/2] PCI: Add a helper to check Power Resource Requirements _PR3 existence
Date: Tue, 27 Aug 2019 23:39:51 +0100	[thread overview]
Message-ID: <20190827223951.GA27744@al> (raw)
In-Reply-To: <20190827221321.GA9987@google.com>

On Tue, Aug 27, 2019 at 05:13:21PM -0500, Bjorn Helgaas wrote:
> [+cc Peter, Mika, Dave]
> 
> https://lore.kernel.org/r/20190827134756.10807-1-kai.heng.feng@canonical.com
> 
> On Wed, Aug 28, 2019 at 12:58:28AM +0800, Kai-Heng Feng wrote:
> > at 23:25, Takashi Iwai <tiwai@suse.de> wrote:
> > > On Tue, 27 Aug 2019 15:47:55 +0200,
> > > Kai-Heng Feng wrote:
> > > > A driver may want to know the existence of _PR3, to choose different
> > > > runtime suspend behavior. A user will be add in next patch.
> > > > 
> > > > This is mostly the same as nouveau_pr3_present().
> > > 
> > > Then it'd be nice to clean up the nouveau part, too?
> > 
> > nouveau_pr3_present() may call pci_d3cold_disable(), and my intention is to
> > only check the presence of _PR3 (i.e. a dGPU) without touching anything.
> 
> It looks like Peter added that code with 279cf3f23870
> ("drm/nouveau/acpi: use DSM if bridge does not support D3cold").
> 
> I don't understand the larger picture, but it is somewhat surprising
> that nouveau_pr3_present() *looks* like a simple predicate with no
> side-effects, but in fact it disables the use of D3cold in some cases.

The reason for disabling _PR3 from that point on is because mixing the
ACPI firmware code that uses power resources (_PR3) with the legacy
_DSM/_PS0/_PS3 methods to manage power states could break as that
combination is unlikely to be supported nor tested by firmware authors.

If a user sets /sys/bus/pci/devices/.../d3cold_allowed to 0, then the
pci_d3cold_disable call ensures that this action is remembered and
prevents power resources from being used again.

For example, compare this power resource _OFF code:
https://github.com/Lekensteyn/acpi-stuff/blob/b55f6bdb/dsl/Clevo_P651RA/ssdt3.dsl#L454-L471

with this legacy _PS0/_PS3 code:
https://github.com/Lekensteyn/acpi-stuff/blob/b55f6bdb/dsl/Clevo_P651RA/ssdt7.dsl#L113-L142

The power resource code checks the "MSD3" variable to check whether a
transition to OFF is required while the legacy _PS3 checks "DGPS". The
sequence PG00._OFF followed by _DSM (to to change "OPCE") and _PS3 might
trigger some device-specific code twice and could lead to lockups
(infinite loops polling for power state) or worse. I am not sure if I
have ever tested this scenario however.

> If the disable were moved to the caller, Kai-Heng's new interface
> could be used both places.

Moving the pci_d3cold_disable call to the caller looks reasonable to me.
After the first patch gets merged, nouveau could use something like:

    *has_pr3 = pci_pr3_present(pdev);
    if (*has_pr3 && !pdev->bridge_d3) {
        /*
         * ...
         */
        pci_d3cold_disable(pdev);
        *has_pr3 = false;
    }


For the 1/2 patch,
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-- 
Kind regards,
Peter Wu
https://lekensteyn.nl

  reply	other threads:[~2019-08-27 22:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 13:47 [PATCH 1/2] PCI: Add a helper to check Power Resource Requirements _PR3 existence Kai-Heng Feng
2019-08-27 13:47 ` [PATCH 2/2] ALSA: hda: Allow HDA to be runtime suspended when dGPU is not bound Kai-Heng Feng
2019-08-27 14:50   ` Kai-Heng Feng
2019-08-27 15:24   ` Takashi Iwai
2019-08-27 15:24     ` Takashi Iwai
2019-08-27 22:31   ` Bjorn Helgaas
2019-08-28  8:25     ` Kai-Heng Feng
2019-08-28 18:01   ` [PATCH v2 " Kai-Heng Feng
2019-09-05 21:35     ` [alsa-devel] " Bjorn Helgaas
2019-09-05 21:35       ` Bjorn Helgaas
2019-09-17  9:36       ` [alsa-devel] " Kai-Heng Feng
2019-09-17  9:36         ` Kai-Heng Feng
2019-09-18 12:42     ` [alsa-devel] [PATCH v3 2/2] ALSA: hda: Allow HDA to be runtime suspended when dGPU is not bound to a driver Kai-Heng Feng
2019-09-18 12:42       ` Kai-Heng Feng
2019-08-27 15:25 ` [PATCH 1/2] PCI: Add a helper to check Power Resource Requirements _PR3 existence Takashi Iwai
2019-08-27 15:25   ` Takashi Iwai
2019-08-27 16:58   ` Kai-Heng Feng
2019-08-27 22:13     ` Bjorn Helgaas
2019-08-27 22:39       ` Peter Wu [this message]
2019-09-09 11:41 ` [alsa-devel] " Bjorn Helgaas
2019-09-09 11:41   ` Bjorn Helgaas
2019-09-20 11:23   ` [alsa-devel] " Kai-Heng Feng
2019-09-20 11:23     ` Kai-Heng Feng
2019-09-20 13:26     ` [alsa-devel] " Bjorn Helgaas
2019-09-20 13:26       ` Bjorn Helgaas

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=20190827223951.GA27744@al \
    --to=peter@lekensteyn.nl \
    --cc=airlied@redhat.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=helgaas@kernel.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=tiwai@suse.de \
    /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.