linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	youling257@gmail.com,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH] ACPI / PM: Do not infer power-state if there are no D0 power-resources
Date: Thu, 4 Jun 2020 13:22:43 +0200	[thread overview]
Message-ID: <CAJZ5v0g7rhiWs0ZeGGS5OoSMH7DiVT1D-EUgX5HFXYkcvXcm2Q@mail.gmail.com> (raw)
In-Reply-To: <20200603194659.185757-1-hdegoede@redhat.com>

On Wed, Jun 3, 2020 at 9:47 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Some devices do not have a power-resource-list for D0, but do have a
> power-resource-lists for e.g. D3 (_PR3).

This looks like a bug in the firmware.

It is hard to imagine a design in which some power resources only need
to be "on" in the D3hot power state of a device and not in D0 (which
is implied by the lack of _PR0 and the presence of _PR3).

So when the device goes from D0 to D3hot, we are expected to turn some
power resources "on"?  What sense does this make?

I'm guessing that this only works at all, because we only use D0 and
D3cold with the affected devices and _PS0 simply turns the power
resource(s) in question on.

> On these devices the "if (device->power.flags.power_resources)" check
> in acpi_device_get_power() succeeds because of the presence of the _PR3
> resources, so the code used to try and infer the power-state.
>
> In this case since there is no power-resource-list for D0, we can never
> infer that the device is in D0 even though it very well might be in D0.
> This results in the code inferring that the device is in D3HOT and on
> the first suspend acpi_device_set_power() skips calling _PS3 for the
> device because it thinks the device is already in D3.
>
> An example of a family of devices which are affected by this are
> Bay Trail based devices. The ACPI device for the XHCI controller on
> these devices does not have a _PR0 method, but it does have a _PR3
> method. The problem described above causes the XHCI controller's _PS3
> method not getting called on the first suspend of the device, which
> causes these devices to not reach the S0i3 power-state during suspend.
>
> Since we cannot infer if the device is in D0 or not when there is no
> power-resource-list for D0, the best thing to do is to change
> acpi_power_get_inferred_state() to return ACPI_STATE_UNKNOWN in this
> case.
>
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205057
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/acpi/power.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
> index fe1e7bc91a5e..db54393a077b 100644
> --- a/drivers/acpi/power.c
> +++ b/drivers/acpi/power.c
> @@ -807,6 +807,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
>         if (!device || !state)
>                 return -EINVAL;
>
> +       /*
> +        * Some devices do not have a power-resource-list for D0, but do
> +        * have a power-resource-lists for e.g. D3 so we do end up here.
> +        * In this case we can never infer that the device is in D0 even
> +        * though it might very well be in D0, so return ACPI_STATE_UNKNOWN.
> +        */
> +       if (list_empty(&device->power.states[ACPI_STATE_D0].resources)) {
> +               *state = ACPI_STATE_UNKNOWN;
> +               return 0;
> +       }

Well, this makes things work on the particular affected platform, but
that seems to be just by accident, because _PS0 does something special
on it.

IMO this needs to be addressed elsewhere and in a different way.

Namely, it looks like if _PR0 is not present (or its return package is
empty), but _PR3 is present, we should use the _PR3 list of power
resources for D0 as well as for D3hot.

Let me cut a patch for that.

Thanks!

  reply	other threads:[~2020-06-04 11:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03 19:46 [PATCH] ACPI / PM: Do not infer power-state if there are no D0 power-resources Hans de Goede
2020-06-04 11:22 ` Rafael J. Wysocki [this message]
2020-06-04 12:15   ` Hans de Goede
2020-06-04 14:42     ` Rafael J. Wysocki
2020-06-04 17:22     ` [PATCH] ACPI: PM: Avoid using power resources if there are none for D0 Rafael J. Wysocki
2020-06-06 15:45       ` Hans de Goede

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=CAJZ5v0g7rhiWs0ZeGGS5OoSMH7DiVT1D-EUgX5HFXYkcvXcm2Q@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=youling257@gmail.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 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).