linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maximilian Luz <luzmaximilian@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] PCI: Run platform power transition on initial D0 entry
Date: Tue, 16 Mar 2021 15:10:04 +0100	[thread overview]
Message-ID: <821c10e8-ef19-4d2e-5ea2-a1964ef58d67@gmail.com> (raw)
In-Reply-To: <CAJZ5v0g+wkyzrD120yiyyBFjVO=LYS3j0WK1Fi-j+LS5fwgqZg@mail.gmail.com>

On 3/16/21 2:36 PM, Rafael J. Wysocki wrote:
> On Mon, Mar 15, 2021 at 7:28 PM Maximilian Luz <luzmaximilian@gmail.com> wrote:
>>
>> On 3/15/21 4:34 PM, Rafael J. Wysocki wrote:
>>> On Sun, Mar 14, 2021 at 1:06 AM Maximilian Luz <luzmaximilian@gmail.com> wrote:
>>>>
>>>> On some devices and platforms, the initial platform (e.g. ACPI) power
>>>> state is not in sync with the power state of the PCI device.
>>>>
>>>> This seems like it is, for all intents and purposes, an issue with the
>>>> device firmware (e.g. ACPI). On some devices, specifically Microsoft
>>>> Surface Books 2 and 3, we encounter ACPI code akin to the following
>>>> power resource, corresponding to a PCI device:
>>>>
>>>>       PowerResource (PRP5, 0x00, 0x0000)
>>>>       {
>>>>           // Initialized to zero, i.e. off. There is no logic for checking
>>>>           // the actual state dynamically.
>>>>           Name (_STA, Zero)
>>>>
>>>>           Method (_ON, 0, Serialized)
>>>>           {
>>>>               // ... code omitted ...
>>>>               _STA = One
>>>>           }
>>>>
>>>>           Method (_OFF, 0, Serialized)
>>>>           {
>>>>               // ... code omitted ...
>>>>               _STA = Zero
>>>>           }
>>>>       }
>>>>
>>>> This resource is initialized to 'off' and does not have any logic for
>>>> checking its actual state, i.e. the state of the corresponding PCI
>>>> device. The stored state of this resource can only be changed by running
>>>> the (platform/ACPI) power transition functions (i.e. _ON and _OFF).
>>>
>>> Well, there is _STA that returns "off" initially, so the OS should set
>>> the initial state of the device to D3cold and transition it into D0 as
>>> appropriate (i.e. starting with setting all of the power resources
>>> used by it to "on").
>>>
>>>> This means that, at boot, the PCI device power state is out of sync with
>>>> the power state of the corresponding ACPI resource.
>>>>
>>>> During initial bring-up of a PCI device, pci_enable_device_flags()
>>>> updates its PCI core state (from initially 'unknown') by reading from
>>>> its PCI_PM_CTRL register. It does, however, not check if the platform
>>>> (here ACPI) state is in sync with/valid for the actual device state and
>>>> needs updating.
>>>
>>> Well, that's inconsistent.
>>>
>>> Also, it is rather pointless to update the device's power state at
>>> this point, because nothing between this point and the later
>>> do_pci_enable_device() call in this function requires its
>>> current_state to be up to date AFAICS.
>>>
>>> Have you tried to drop the power state update from
>>> pci_enable_device_flags()?  [Note that we're talking about relatively
>>> old code here and it looks like that code is not necessary any more.]
>>
>> I had not tried this before, as I assumed the comment was still
>> relevant. I did test that now and it works! I can't detect any
>> regressions.
>>
>> Do you want to send this in or should I do that?
> 
> I'll post it, thanks!

Thank you!

Feel free to add my tested-by tag.

Regards,
Max

      reply	other threads:[~2021-03-16 14:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14  0:04 [PATCH v2] PCI: Run platform power transition on initial D0 entry Maximilian Luz
2021-03-15 15:34 ` Rafael J. Wysocki
2021-03-15 18:28   ` Maximilian Luz
2021-03-16 13:36     ` Rafael J. Wysocki
2021-03-16 14:10       ` Maximilian Luz [this message]

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=821c10e8-ef19-4d2e-5ea2-a1964ef58d67@gmail.com \
    --to=luzmaximilian@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /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).