Skip to contentSkip to conversation

drivers: core: Detach device from power domain on shutdown

PATCH In review Furquan Shaikh 5 participants 13 messages Dec 1, 2020 – Feb 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: core: Detach device from power domain on shutdown

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +3 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
 			dev->driver->shutdown(dev);
 		}
 
+		dev_pm_domain_detach(dev, true);
+
 		device_unlock(dev);
 		if (parent)
 			device_unlock(parent);
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
#1 lore raw
Quoted 43 lines · Furquan Shaikh

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +3 -1
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                        dev->driver->shutdown(dev);
                }
 
+               dev_pm_domain_detach(dev, true);
+
                device_unlock(dev);
                if (parent)
                        device_unlock(parent);
--
Quoted 2 lines

2.29.2.454.gaff20da3a2-goog

Hello,

Gentle ping. Just checking if there are any comments.

Thanks,
Furquan

#2 lore raw
Quoted 49 lines · Furquan Shaikh
Quoted 43 lines · Furquan Shaikh

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +3 -1
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                        dev->driver->shutdown(dev);
                }
 
+               dev_pm_domain_detach(dev, true);
+
                device_unlock(dev);
                if (parent)
                        device_unlock(parent);
--
Quoted 2 lines

2.29.2.454.gaff20da3a2-goog

Hello,

Quoted 1 line

Gentle ping. Just checking if there are any comments.

I'll wait for Rafael to ack this before taking it...

thanks,

greg k-h

#3 lore raw
Quoted 51 lines · Greg Kroah-Hartman
Quoted 49 lines · Furquan Shaikh
Quoted 43 lines · Furquan Shaikh

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +3 -1
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                        dev->driver->shutdown(dev);
                }
 
+               dev_pm_domain_detach(dev, true);
+
                device_unlock(dev);
                if (parent)
                        device_unlock(parent);
--
Quoted 2 lines

2.29.2.454.gaff20da3a2-goog

Hello,

Quoted 3 lines
Quoted 1 line

Gentle ping. Just checking if there are any comments.

I'll wait for Rafael to ack this before taking it...

Done.

Cheers!

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Furquan Shaikh
Quoted 9 lines · Furquan Shaikh

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

Quoted 8 lines

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

Quoted 28 lines
---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +3 -1
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                        dev->driver->shutdown(dev);
                }
 
+               dev_pm_domain_detach(dev, true);
+
                device_unlock(dev);
                if (parent)
                        device_unlock(parent);
--

2.29.2.454.gaff20da3a2-goog

#5 lore raw
In reply to Furquan Shaikh

02.12.2020 00:30, Furquan Shaikh пишет:

Quoted 34 lines

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +1 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>

drivers/base/core.c void device_shutdown(void) · line 4065

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
 			dev->driver->shutdown(dev);
 		}
 
+		dev_pm_domain_detach(dev, true);
+
 		device_unlock(dev);
 		if (parent)
 			device_unlock(parent);

This patch broke system shutdown on NVIDIA Tegra using today's linux-next because power domain can't be turned off until device drivers handed control over device resets to the power domain of Power Management controller on Tegra. This patch introduced the wrong behaviour, apparently it should be made specific to ACPI only.

Please fix, thanks in advance.

#6 lore raw
Quoted 51 lines · Dmitry Osipenko

02.12.2020 00:30, Furquan Shaikh пишет:

Quoted 34 lines

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +1 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>

drivers/base/core.c void device_shutdown(void) · line 4065

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                      dev->driver->shutdown(dev);
              }
 
+             dev_pm_domain_detach(dev, true);
+
              device_unlock(dev);
              if (parent)
                      device_unlock(parent);

This patch broke system shutdown on NVIDIA Tegra using today's linux-next because power domain can't be turned off until device drivers handed control over device resets to the power domain of Power Management controller on Tegra. This patch introduced the wrong behaviour, apparently it should be made specific to ACPI only.

Quoted 1 line

Please fix, thanks in advance.

OK, so Greg please drop it.

#7 lore raw
Quoted 52 lines · Rafael J. Wysocki
Quoted 51 lines · Dmitry Osipenko

02.12.2020 00:30, Furquan Shaikh пишет:

Quoted 34 lines

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +1 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>

drivers/base/core.c void device_shutdown(void) · line 4065

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                      dev->driver->shutdown(dev);
              }
 
+             dev_pm_domain_detach(dev, true);
+
              device_unlock(dev);
              if (parent)
                      device_unlock(parent);

This patch broke system shutdown on NVIDIA Tegra using today's linux-next because power domain can't be turned off until device drivers handed control over device resets to the power domain of Power Management controller on Tegra. This patch introduced the wrong behaviour, apparently it should be made specific to ACPI only.

Quoted 3 lines
Quoted 1 line

Please fix, thanks in advance.

OK, so Greg please drop it.

Now reverted, thanks.

greg k-h

#8 lore raw
Quoted 54 lines · Greg Kroah-Hartman
Quoted 52 lines · Rafael J. Wysocki
Quoted 51 lines · Dmitry Osipenko

02.12.2020 00:30, Furquan Shaikh пишет:

Quoted 34 lines

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +1 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>

drivers/base/core.c void device_shutdown(void) · line 4065

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                      dev->driver->shutdown(dev);
              }
 
+             dev_pm_domain_detach(dev, true);
+
              device_unlock(dev);
              if (parent)
                      device_unlock(parent);

This patch broke system shutdown on NVIDIA Tegra using today's linux-next because power domain can't be turned off until device drivers handed control over device resets to the power domain of Power Management controller on Tegra. This patch introduced the wrong behaviour, apparently it should be made specific to ACPI only.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Please fix, thanks in advance.

Sorry about the breakage. I am working on an alternate solution that Rafael suggested.

Quoted 4 lines
Quoted 2 lines

OK, so Greg please drop it.

Now reverted, thanks.

Thanks Greg!

Quoted 2 lines

greg k-h

#9 lore raw

13.01.2021 04:22, Furquan Shaikh пишет:

Quoted 62 lines
Quoted 54 lines · Greg Kroah-Hartman
Quoted 52 lines · Rafael J. Wysocki
Quoted 51 lines · Dmitry Osipenko

02.12.2020 00:30, Furquan Shaikh пишет:

Quoted 34 lines

When the system is powered off or rebooted, devices are not detached from their PM domain. This results in ACPI PM not being invoked and hence PowerResouce _OFF method not being invoked for any of the devices. Because the ACPI power resources are not turned off in case of poweroff and reboot, it violates the power sequencing requirements which impacts the reliability of the devices over the lifetime of the platform. This is currently observed on all Chromebooks using ACPI.

In order to solve the above problem, this change detaches a device from its PM domain whenever it is shutdown. This action is basically analogous to ->remove() from driver model perspective. Detaching the device from its PM domain ensures that the ACPI PM gets a chance to turn off the power resources for the device thus complying with its power sequencing requirements.

---
 drivers/base/core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/core.c +1 -0
index d661ada1518f..5823f1d719e1 100644
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/genhd.h>
 #include <linux/mutex.h>
+#include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
 #include <linux/netdevice.h>
 #include <linux/sched/signal.h>

drivers/base/core.c void device_shutdown(void) · line 4065

Quoted 8 lines
drivers/base/core.c +2 -0
@@ -4057,6 +4058,8 @@ void device_shutdown(void)
                      dev->driver->shutdown(dev);
              }
 
+             dev_pm_domain_detach(dev, true);
+
              device_unlock(dev);
              if (parent)
                      device_unlock(parent);

This patch broke system shutdown on NVIDIA Tegra using today's linux-next because power domain can't be turned off until device drivers handed control over device resets to the power domain of Power Management controller on Tegra. This patch introduced the wrong behaviour, apparently it should be made specific to ACPI only.

Quoted 1 line
Quoted 1 line
Quoted 1 line

Please fix, thanks in advance.

Sorry about the breakage. I am working on an alternate solution that Rafael suggested.

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

OK, so Greg please drop it.

Now reverted, thanks.

Thanks Greg!

Thank you all for addressing this problem!

#11 lore raw
Quoted 8 lines · Kai-Heng Feng

Hi Furquan,

On Wed, Jan 13, 2021 at 10:31 PM Dmitry Osipenko <[email protected]> wrote:
[snipped]

Quoted 1 line

Thank you all for addressing this problem!

Are you still working on the alternate solution?

Yes, it is in my pipeline, but I have been distracted because of some other high priority tasks. I plan to push something for review in ~3-4 weeks.

Quoted 5 lines

This patch can
address S5 power consumption issue for some laptops:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935

Kai-Heng

#12 lore raw
Quoted 8 lines · Furquan Shaikh
Quoted 5 lines · Kai-Heng Feng

Hi Furquan,

On Wed, Jan 13, 2021 at 10:31 PM Dmitry Osipenko <[email protected]> wrote:
[snipped]

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thank you all for addressing this problem!

Are you still working on the alternate solution?

Yes, it is in my pipeline, but I have been distracted because of some other high priority tasks. I plan to push something for review in ~3-4 weeks.

Please Cc me in the revised patch.
Thanks for your work.

Kai-Heng

Quoted 6 lines
Quoted 6 lines

This patch can
address S5 power consumption issue for some laptops:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1912935

Kai-Heng