LinuxTV Patchwork [1/5] ACPI: Enable driver and firmware hints to control power at probe time

login
register
mail settings
Submitter Sakari Ailus
Date May 10, 2019, 10:09 a.m.
Message ID <20190510100930.14641-2-sakari.ailus@linux.intel.com>
Download mbox | patch
Permalink /patch/56098/
State New
Headers show

Comments

Sakari Ailus - May 10, 2019, 10:09 a.m.
Allow drivers and firmware tell ACPI that there's no need to power on a
device for probe. This requires both a hint from the firmware as well as
an indication from a driver to leave the device off.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/device_pm.c | 9 +++++++--
 include/linux/device.h   | 6 ++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Patch

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index b859d75eaf9f6..ca2409a30d26d 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -1225,7 +1225,9 @@  static void acpi_dev_pm_detach(struct device *dev, bool power_off)
 	if (adev && dev->pm_domain == &acpi_general_pm_domain) {
 		dev_pm_domain_set(dev, NULL);
 		acpi_remove_pm_notifier(adev);
-		if (power_off) {
+		if (power_off &&
+		    !(dev->driver->probe_powered_off &&
+		      device_property_present(dev, "avoid-power-probe"))) {
 			/*
 			 * If the device's PM QoS resume latency limit or flags
 			 * have been exposed to user space, they have to be
@@ -1273,7 +1275,10 @@  int acpi_dev_pm_attach(struct device *dev, bool power_on)
 
 	acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
 	dev_pm_domain_set(dev, &acpi_general_pm_domain);
-	if (power_on) {
+
+	if (power_on &&
+	    !(dev->driver->probe_powered_off &&
+	      device_property_present(dev, "avoid-power-probe"))) {
 		acpi_dev_pm_full_power(adev);
 		acpi_device_wakeup_disable(adev);
 	}
diff --git a/include/linux/device.h b/include/linux/device.h
index e85264fb66161..2a459fd5b954a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -245,6 +245,11 @@  enum probe_type {
  * @owner:	The module owner.
  * @mod_name:	Used for built-in modules.
  * @suppress_bind_attrs: Disables bind/unbind via sysfs.
+ * @probe_powered_off: The driver supports its probe function being called while
+ *		       the device is powered off, independently of the expected
+ *		       behaviour on combination of a given bus and firmware
+ *		       interface etc. The driver is responsible for powering the
+ *		       device on using runtime PM in such case.
  * @probe_type:	Type of the probe (synchronous or asynchronous) to use.
  * @of_match_table: The open firmware table.
  * @acpi_match_table: The ACPI match table.
@@ -282,6 +287,7 @@  struct device_driver {
 	const char		*mod_name;	/* used for built-in modules */
 
 	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
+	bool probe_powered_off;
 	enum probe_type probe_type;
 
 	const struct of_device_id	*of_match_table;

Privacy Policy