linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>,
	"Andreas K. Huettel" <andreas.huettel@ur.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH v1 2/2][RFT] ACPI: PM: Check states of power resources during initialization
Date: Fri, 15 Oct 2021 19:14:10 +0200	[thread overview]
Message-ID: <8835496.CDJkKcVGEf@kreacher> (raw)
In-Reply-To: <21226252.EfDdHjke4D@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

To avoid situations in which the actual states of certain ACPI power
resources are not known just because they have never been referenced
by any device configuration objects, check the initial states of all
power resources as soon as they are found in the ACPI namespace (and
fall back to turning them on if the state check fails).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

Andreas, please test this patch (on top of the [1/2]) and let me know
if it works for you.

Thanks!

---
 drivers/acpi/power.c |   30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

Index: linux-pm/drivers/acpi/power.c
===================================================================
--- linux-pm.orig/drivers/acpi/power.c
+++ linux-pm/drivers/acpi/power.c
@@ -923,6 +919,7 @@ struct acpi_device *acpi_add_power_resou
 	union acpi_object acpi_object;
 	struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
 	acpi_status status;
+	u8 state_dummy;
 	int result;
 
 	acpi_bus_get_device(handle, &device);
@@ -951,6 +948,10 @@ struct acpi_device *acpi_add_power_resou
 	resource->order = acpi_object.power_resource.resource_order;
 	resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN;
 
+	/* Get the initial state or just flip it on if that fails. */
+	if (acpi_power_get_state(resource, &state_dummy))
+		__acpi_power_on(resource);
+
 	pr_info("%s [%s]\n", acpi_device_name(device), acpi_device_bid(device));
 
 	device->flags.match_driver = true;




  parent reply	other threads:[~2021-10-15 17:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 17:11 [PATCH v1 0/2] ACPI: PM: Fix up turning off unused power resources Rafael J. Wysocki
2021-10-15 17:12 ` [PATCH v1 1/2] ACPI: PM: Do not turn off power resources in unknown state Rafael J. Wysocki
2021-10-15 17:14 ` Rafael J. Wysocki [this message]
2021-10-18 10:40   ` [EXT] [PATCH v1 2/2][RFT] ACPI: PM: Check states of power resources during initialization Andreas K. Huettel
2021-10-19 10:59     ` Rafael J. Wysocki

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=8835496.CDJkKcVGEf@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=andreas.huettel@ur.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.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).