[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-11 Thread Ulf Hansson
[...]

>> >
>> > Hi Rafael, Alan and Ulf,
>> >
>> > do you have any suggestion about this? I don't really understand why
>> > the device is detached from the domain on shutdown.

Sorry for the delay.

I fully agree with you Rafael, it shouldn't be detached. It's a bug.

>>
>> I am running linux-next and this commit causes the same problem for me
>> on a mx6 after running a 'reboot' command:
>>
>> Requesting system reboot
>> [   15.058782] [ cut here ]
>> [   15.063459] WARNING: CPU: 3 PID: 1122 at
>> drivers/base/power/common.c:150 dev_pm_domain_set+0x4c/0x58()
>> [   15.072838] PM domains can only be changed for unbound devices
>> [   15.078735] Modules linked in:
>> [   15.081849] CPU: 3 PID: 1122 Comm: init Not tainted
>> 4.4.0-rc8-next-20160111-dirty #207
>> [   15.089826] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
>> [   15.096375] Backtrace:
>> [   15.098941] [] (dump_backtrace) from []
>> (show_stack+0x18/0x1c)
>> [   15.106532]  r6:0096 r5: r4: r3:
>> [   15.112390] [] (show_stack) from []
>> (dump_stack+0x88/0xa4)
>> [   15.119708] [] (dump_stack) from []
>> (warn_slowpath_common+0x80/0xbc)
>> [   15.127860]  r5:c03da810 r4:ee63bd68
>> [   15.131533] [] (warn_slowpath_common) from []
>> (warn_slowpath_fmt+0x38/0x40)
>> [   15.140292]  r8:eea01db0 r7:c0b0f87c r6:eea01d80 r5: r4:ef181410
>> [   15.147165] [] (warn_slowpath_fmt) from []
>> (dev_pm_domain_set+0x4c/0x58)
>> [   15.155661]  r3:c0b0f7f0 r2:c09e82dc
>> [   15.159373] [] (dev_pm_domain_set) from []
>> (genpd_free_dev_data+0x20/0x50)
>> [   15.168065]  r5:ef1814a0 r4:ef181410
>> [   15.171737] [] (genpd_free_dev_data) from []
>> (pm_genpd_remove_device+0xb4/0xe0)
>> [   15.180842]  r6:ef181410 r5:eea01d80 r4:c0b0f7f0 r3:
>> [   15.186644] [] (pm_genpd_remove_device) from []
>> (genpd_dev_pm_detach+0x30/0xac)
>> [   15.195743]  r8:c0b0f7f0 r7:c1379734 r6:0001 r5:c0b209c4
>> r4:ef181410 r3:
>> [   15.203694] [] (genpd_dev_pm_detach) from []
>> (dev_pm_domain_detach+0x28/0x2c)
>> [   15.212621]  r10:ef181444 r8:c0b6f560 r7:c1379734 r6:ef181410
>> r5:ef173c10 r4:ef181410
>> [   15.220683] [] (dev_pm_domain_detach) from []
>> (platform_drv_shutdown+0x34/0x38)
>> [   15.229817] [] (platform_drv_shutdown) from []
>> (device_shutdown+0x3c/0x194)
>
> OK, so does the appended patch help?
>
> Rafael
>
> ---
> From: Rafael J. Wysocki 
> Subject: [PATCH] platform: Do not detach from PM domains on shutdown
>
> Shutdown is carried out when the driver is still bound to the
> device, so it is incorrect to detach it from a PM domain (if any)
> at this point.
>
> Signed-off-by: Rafael J. Wysocki 

Acked-by: Ulf Hansson 

> ---
>  drivers/base/platform.c |1 -
>  1 file changed, 1 deletion(-)
>
> Index: linux-pm/drivers/base/platform.c
> ===
> --- linux-pm.orig/drivers/base/platform.c
> +++ linux-pm/drivers/base/platform.c
> @@ -577,7 +577,6 @@ static void platform_drv_shutdown(struct
>
> if (drv->shutdown)
> drv->shutdown(dev);
> -   dev_pm_domain_detach(_dev, true);
>  }
>
>  /**
>


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-11 Thread Rafael J. Wysocki
On Monday, January 11, 2016 12:35:28 PM Fabio Estevam wrote:
> On Thu, Jan 7, 2016 at 12:47 PM, Tomeu Vizoso
>  wrote:
> > On 10 November 2015 at 10:33, Daniel Kurtz  wrote:
> > [snip]
> >>
> >> The problem appears to be that:
> >>   * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
> >> drv->probe(); thus, it calls dev_pm_domain_attach() while the device
> >> is unbound.
> >>
> >>  * However, for a platform_device, the reboot path calls
> >> device_shutdown(), but not __device_release_driver():
> >> device_shutdown()
> >>   dev->driver->shutdown => platform_drv_shutdown()
> >> dev_pm_domain_detach()
> >>dev->pm_domain->detach() => genpd_dev_pm_detach()
> >>  pm_genpd_remove_device()
> >> dev_pm_domain_set(dev, NULL);
> >>
> >> So, for a platform_device in a genpd power domain with .shutdown
> >> installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
> >> the device is still bound, which triggers the WARN().
> >
> > Hi Rafael, Alan and Ulf,
> >
> > do you have any suggestion about this? I don't really understand why
> > the device is detached from the domain on shutdown.
> 
> I am running linux-next and this commit causes the same problem for me
> on a mx6 after running a 'reboot' command:
> 
> Requesting system reboot
> [   15.058782] [ cut here ]
> [   15.063459] WARNING: CPU: 3 PID: 1122 at
> drivers/base/power/common.c:150 dev_pm_domain_set+0x4c/0x58()
> [   15.072838] PM domains can only be changed for unbound devices
> [   15.078735] Modules linked in:
> [   15.081849] CPU: 3 PID: 1122 Comm: init Not tainted
> 4.4.0-rc8-next-20160111-dirty #207
> [   15.089826] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
> [   15.096375] Backtrace:
> [   15.098941] [] (dump_backtrace) from []
> (show_stack+0x18/0x1c)
> [   15.106532]  r6:0096 r5: r4: r3:
> [   15.112390] [] (show_stack) from []
> (dump_stack+0x88/0xa4)
> [   15.119708] [] (dump_stack) from []
> (warn_slowpath_common+0x80/0xbc)
> [   15.127860]  r5:c03da810 r4:ee63bd68
> [   15.131533] [] (warn_slowpath_common) from []
> (warn_slowpath_fmt+0x38/0x40)
> [   15.140292]  r8:eea01db0 r7:c0b0f87c r6:eea01d80 r5: r4:ef181410
> [   15.147165] [] (warn_slowpath_fmt) from []
> (dev_pm_domain_set+0x4c/0x58)
> [   15.155661]  r3:c0b0f7f0 r2:c09e82dc
> [   15.159373] [] (dev_pm_domain_set) from []
> (genpd_free_dev_data+0x20/0x50)
> [   15.168065]  r5:ef1814a0 r4:ef181410
> [   15.171737] [] (genpd_free_dev_data) from []
> (pm_genpd_remove_device+0xb4/0xe0)
> [   15.180842]  r6:ef181410 r5:eea01d80 r4:c0b0f7f0 r3:
> [   15.186644] [] (pm_genpd_remove_device) from []
> (genpd_dev_pm_detach+0x30/0xac)
> [   15.195743]  r8:c0b0f7f0 r7:c1379734 r6:0001 r5:c0b209c4
> r4:ef181410 r3:
> [   15.203694] [] (genpd_dev_pm_detach) from []
> (dev_pm_domain_detach+0x28/0x2c)
> [   15.212621]  r10:ef181444 r8:c0b6f560 r7:c1379734 r6:ef181410
> r5:ef173c10 r4:ef181410
> [   15.220683] [] (dev_pm_domain_detach) from []
> (platform_drv_shutdown+0x34/0x38)
> [   15.229817] [] (platform_drv_shutdown) from []
> (device_shutdown+0x3c/0x194)

OK, so does the appended patch help?

Rafael

---
From: Rafael J. Wysocki 
Subject: [PATCH] platform: Do not detach from PM domains on shutdown

Shutdown is carried out when the driver is still bound to the
device, so it is incorrect to detach it from a PM domain (if any)
at this point.

Signed-off-by: Rafael J. Wysocki 
---
 drivers/base/platform.c |1 -
 1 file changed, 1 deletion(-)

Index: linux-pm/drivers/base/platform.c
===
--- linux-pm.orig/drivers/base/platform.c
+++ linux-pm/drivers/base/platform.c
@@ -577,7 +577,6 @@ static void platform_drv_shutdown(struct

if (drv->shutdown)
drv->shutdown(dev);
-   dev_pm_domain_detach(_dev, true);
 }

 /**



[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-11 Thread Fabio Estevam
On Mon, Jan 11, 2016 at 12:45 PM, Rafael J. Wysocki  
wrote:

> OK, so does the appended patch help?

Yes, thanks. I do not see the warnings after 'reboot' with your patch applied:

Tested-by: Fabio Estevam 


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-11 Thread Fabio Estevam
On Thu, Jan 7, 2016 at 12:47 PM, Tomeu Vizoso
 wrote:
> On 10 November 2015 at 10:33, Daniel Kurtz  wrote:
> [snip]
>>
>> The problem appears to be that:
>>   * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
>> drv->probe(); thus, it calls dev_pm_domain_attach() while the device
>> is unbound.
>>
>>  * However, for a platform_device, the reboot path calls
>> device_shutdown(), but not __device_release_driver():
>> device_shutdown()
>>   dev->driver->shutdown => platform_drv_shutdown()
>> dev_pm_domain_detach()
>>dev->pm_domain->detach() => genpd_dev_pm_detach()
>>  pm_genpd_remove_device()
>> dev_pm_domain_set(dev, NULL);
>>
>> So, for a platform_device in a genpd power domain with .shutdown
>> installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
>> the device is still bound, which triggers the WARN().
>
> Hi Rafael, Alan and Ulf,
>
> do you have any suggestion about this? I don't really understand why
> the device is detached from the domain on shutdown.

I am running linux-next and this commit causes the same problem for me
on a mx6 after running a 'reboot' command:

Requesting system reboot
[   15.058782] [ cut here ]
[   15.063459] WARNING: CPU: 3 PID: 1122 at
drivers/base/power/common.c:150 dev_pm_domain_set+0x4c/0x58()
[   15.072838] PM domains can only be changed for unbound devices
[   15.078735] Modules linked in:
[   15.081849] CPU: 3 PID: 1122 Comm: init Not tainted
4.4.0-rc8-next-20160111-dirty #207
[   15.089826] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[   15.096375] Backtrace:
[   15.098941] [] (dump_backtrace) from []
(show_stack+0x18/0x1c)
[   15.106532]  r6:0096 r5: r4: r3:
[   15.112390] [] (show_stack) from []
(dump_stack+0x88/0xa4)
[   15.119708] [] (dump_stack) from []
(warn_slowpath_common+0x80/0xbc)
[   15.127860]  r5:c03da810 r4:ee63bd68
[   15.131533] [] (warn_slowpath_common) from []
(warn_slowpath_fmt+0x38/0x40)
[   15.140292]  r8:eea01db0 r7:c0b0f87c r6:eea01d80 r5: r4:ef181410
[   15.147165] [] (warn_slowpath_fmt) from []
(dev_pm_domain_set+0x4c/0x58)
[   15.155661]  r3:c0b0f7f0 r2:c09e82dc
[   15.159373] [] (dev_pm_domain_set) from []
(genpd_free_dev_data+0x20/0x50)
[   15.168065]  r5:ef1814a0 r4:ef181410
[   15.171737] [] (genpd_free_dev_data) from []
(pm_genpd_remove_device+0xb4/0xe0)
[   15.180842]  r6:ef181410 r5:eea01d80 r4:c0b0f7f0 r3:
[   15.186644] [] (pm_genpd_remove_device) from []
(genpd_dev_pm_detach+0x30/0xac)
[   15.195743]  r8:c0b0f7f0 r7:c1379734 r6:0001 r5:c0b209c4
r4:ef181410 r3:
[   15.203694] [] (genpd_dev_pm_detach) from []
(dev_pm_domain_detach+0x28/0x2c)
[   15.212621]  r10:ef181444 r8:c0b6f560 r7:c1379734 r6:ef181410
r5:ef173c10 r4:ef181410
[   15.220683] [] (dev_pm_domain_detach) from []
(platform_drv_shutdown+0x34/0x38)
[   15.229817] [] (platform_drv_shutdown) from []
(device_shutdown+0x3c/0x194)
[   15.238579]  r4:ef18141c r3:c03d3e6c
[   15.242259] [] (device_shutdown) from []
(kernel_restart_prepare+0x34/0x40)
[   15.251021]  r10: r8:c0010044 r7: r6:c0b120cc
r5:4321fedc r4:
[   15.259065] [] (kernel_restart_prepare) from []
(kernel_restart+0x14/0x58)
[   15.267760] [] (kernel_restart) from []
(SyS_reboot+0x18c/0x1e4)
[   15.275526]  r4:01234567 r3:01234567
[   15.279242] [] (SyS_reboot) from []
(ret_fast_syscall+0x0/0x1c)
[   15.286920]  r7:0058 r6: r5: r4:
[   15.292754] ---[ end trace 3b419d3cbb367a11 ]---


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-08 Thread Rafael J. Wysocki
On Thursday, January 07, 2016 03:47:01 PM Tomeu Vizoso wrote:
> On 10 November 2015 at 10:33, Daniel Kurtz  wrote:
> [snip]
> >
> > The problem appears to be that:
> >   * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
> > drv->probe(); thus, it calls dev_pm_domain_attach() while the device
> > is unbound.
> >
> >  * However, for a platform_device, the reboot path calls
> > device_shutdown(), but not __device_release_driver():
> > device_shutdown()
> >   dev->driver->shutdown => platform_drv_shutdown()
> > dev_pm_domain_detach()
> >dev->pm_domain->detach() => genpd_dev_pm_detach()
> >  pm_genpd_remove_device()
> > dev_pm_domain_set(dev, NULL);
> >
> > So, for a platform_device in a genpd power domain with .shutdown
> > installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
> > the device is still bound, which triggers the WARN().
> 
> Hi Rafael, Alan and Ulf,
> 
> do you have any suggestion about this? I don't really understand why
> the device is detached from the domain on shutdown.

Well, this looks like a bug to me.

Thanks,
Rafael



[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2016-01-07 Thread Tomeu Vizoso
On 10 November 2015 at 10:33, Daniel Kurtz  wrote:
[snip]
>
> The problem appears to be that:
>   * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
> drv->probe(); thus, it calls dev_pm_domain_attach() while the device
> is unbound.
>
>  * However, for a platform_device, the reboot path calls
> device_shutdown(), but not __device_release_driver():
> device_shutdown()
>   dev->driver->shutdown => platform_drv_shutdown()
> dev_pm_domain_detach()
>dev->pm_domain->detach() => genpd_dev_pm_detach()
>  pm_genpd_remove_device()
> dev_pm_domain_set(dev, NULL);
>
> So, for a platform_device in a genpd power domain with .shutdown
> installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
> the device is still bound, which triggers the WARN().

Hi Rafael, Alan and Ulf,

do you have any suggestion about this? I don't really understand why
the device is detached from the domain on shutdown.

Thanks,

Tomeu

> Thanks,
> -Dan
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2015-11-10 Thread Daniel Kurtz
Hi Tomeu,

On Tue, Oct 27, 2015 at 10:38 PM, Tomeu Vizoso
 wrote:
> Adds a function that sets the pointer to dev_pm_domain in struct device
> and that warns if the device has already finished probing. The reason
> why we want to enforce that is because in the general case that can
> cause problems and also that we can simplify code quite a bit if we can
> always assume that.
>
> This patch also changes all current code that directly sets the
> dev.pm_domain pointer.
>
> Signed-off-by: Tomeu Vizoso 
> Reviewed-by: Ulf Hansson 
> ---

[snip...]

> diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c
> index f32b802b98f4..a70f8a5cdfd7 100644
> --- a/drivers/base/power/common.c
> +++ b/drivers/base/power/common.c
> @@ -128,3 +128,24 @@ void dev_pm_domain_detach(struct device *dev, bool 
> power_off)
> dev->pm_domain->detach(dev, power_off);
>  }
>  EXPORT_SYMBOL_GPL(dev_pm_domain_detach);
> +
> +/**
> + * dev_pm_domain_set - Set PM domain of a device.
> + * @dev: Device whose PM domain is to be set.
> + * @pd: PM domain to be set, or NULL.
> + *
> + * Sets the PM domain the device belongs to. The PM domain of a device needs
> + * to be set before its probe finishes (it's bound to a driver).
> + *
> + * This function must be called with the device lock held.
> + */
> +void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
> +{
> +   if (dev->pm_domain == pd)
> +   return;
> +
> +   WARN(device_is_bound(dev),
> +"PM domains can only be changed for unbound devices\n");
> +   dev->pm_domain = pd;
> +}

When testing this patch, I have a platform driver with a device in a
genpd that hits this WARN() during shutdown with a backtrace like:

[  930.476714] [ cut here ]
[  930.481323] WARNING: CPU: 3 PID: 10110 at
drivers/base/power/common.c:154 dev_pm_domain_set+0x50/0x60()
[  930.494605] PM domains can only be changed for unbound devices
[  930.541047] Call trace:
[  930.543470] [] dump_backtrace+0x0/0x140
[  930.548820] [] show_stack+0x1c/0x28
[  930.553826] [] dump_stack+0x74/0x94
[  930.558831] [] warn_slowpath_common+0x90/0xb8
[  930.564698] [] warn_slowpath_fmt+0x84/0xac
[  930.570305] [] dev_pm_domain_set+0x4c/0x60
[  930.575913] [] pm_genpd_remove_device+0xc4/0x174
[  930.582038] [] genpd_dev_pm_detach+0x7c/0xd4
[  930.587818] [] dev_pm_domain_detach+0x34/0x44
[  930.593685] [] platform_drv_shutdown+0x30/0x40
[  930.599639] [] device_shutdown+0x12c/0x184
[  930.605247] [] kernel_restart_prepare+0x38/0x44
[  930.611285] [] kernel_restart+0x1c/0x68
[  930.616634] [] SyS_reboot+0x1b4/0x210
[  930.621810] ---[ end trace 0551d0a7afcd5f6f ]---

The problem appears to be that:
  * On boot, platform_drv_probe() calls dev_pm_domain_attach() before
drv->probe(); thus, it calls dev_pm_domain_attach() while the device
is unbound.

 * However, for a platform_device, the reboot path calls
device_shutdown(), but not __device_release_driver():
device_shutdown()
  dev->driver->shutdown => platform_drv_shutdown()
dev_pm_domain_detach()
   dev->pm_domain->detach() => genpd_dev_pm_detach()
 pm_genpd_remove_device()
dev_pm_domain_set(dev, NULL);

So, for a platform_device in a genpd power domain with .shutdown
installed, platform_drv_shutdown() calls dev_pm_domain_detach() while
the device is still bound, which triggers the WARN().

Thanks,
-Dan


[PATCH v11 2/4] PM / Domains: add setter for dev.pm_domain

2015-10-27 Thread Tomeu Vizoso
Adds a function that sets the pointer to dev_pm_domain in struct device
and that warns if the device has already finished probing. The reason
why we want to enforce that is because in the general case that can
cause problems and also that we can simplify code quite a bit if we can
always assume that.

This patch also changes all current code that directly sets the
dev.pm_domain pointer.

Signed-off-by: Tomeu Vizoso 
Reviewed-by: Ulf Hansson 
---

Changes in v11:
- Move calls to dev_pm_domain_set() out from &dev->power.lock as that
  isn't needed for dev->pm_domain.

Changes in v9:
- Add docs noting the need for the device lock to be held before calling
  dev_pm_domain_set()

Changes in v8:
- Add dev_pm_domain_set() and update code to use it

 arch/arm/mach-omap2/omap_device.c |  7 ---
 drivers/acpi/acpi_lpss.c  |  5 +++--
 drivers/acpi/device_pm.c  |  5 +++--
 drivers/base/power/clock_ops.c|  5 +++--
 drivers/base/power/common.c   | 21 +
 drivers/base/power/domain.c   |  6 --
 drivers/gpu/vga/vga_switcheroo.c  | 10 +-
 drivers/misc/mei/pci-me.c |  5 +++--
 drivers/misc/mei/pci-txe.c|  5 +++--
 include/linux/pm_domain.h |  3 +++
 10 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c 
b/arch/arm/mach-omap2/omap_device.c
index 4cb8fd9f741f..204101d11632 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -168,7 +169,7 @@ static int omap_device_build_from_dt(struct platform_device 
*pdev)
r->name = dev_name(&pdev->dev);
}

-   pdev->dev.pm_domain = &omap_device_pm_domain;
+   dev_pm_domain_set(&pdev->dev, &omap_device_pm_domain);

if (device_active) {
omap_device_enable(pdev);
@@ -180,7 +181,7 @@ odbfd_exit1:
 odbfd_exit:
/* if data/we are at fault.. load up a fail handler */
if (ret)
-   pdev->dev.pm_domain = &omap_device_fail_pm_domain;
+   dev_pm_domain_set(&pdev->dev, &omap_device_fail_pm_domain);

return ret;
 }
@@ -701,7 +702,7 @@ int omap_device_register(struct platform_device *pdev)
 {
pr_debug("omap_device: %s: registering\n", pdev->name);

-   pdev->dev.pm_domain = &omap_device_pm_domain;
+   dev_pm_domain_set(&pdev->dev, &omap_device_pm_domain);
return platform_device_add(pdev);
 }

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index f51bd0d0bc17..cc6e1abc69b3 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 

@@ -706,7 +707,7 @@ static int acpi_lpss_platform_notify(struct notifier_block 
*nb,

switch (action) {
case BUS_NOTIFY_ADD_DEVICE:
-   pdev->dev.pm_domain = &acpi_lpss_pm_domain;
+   dev_pm_domain_set(&pdev->dev, &acpi_lpss_pm_domain);
if (pdata->dev_desc->flags & LPSS_LTR)
return sysfs_create_group(&pdev->dev.kobj,
  &lpss_attr_group);
@@ -714,7 +715,7 @@ static int acpi_lpss_platform_notify(struct notifier_block 
*nb,
case BUS_NOTIFY_DEL_DEVICE:
if (pdata->dev_desc->flags & LPSS_LTR)
sysfs_remove_group(&pdev->dev.kobj, &lpss_attr_group);
-   pdev->dev.pm_domain = NULL;
+   dev_pm_domain_set(&pdev->dev, NULL);
break;
default:
break;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 4806b7f856c4..8c5955bf9bbf 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 

 #include "internal.h"
@@ -1076,7 +1077,7 @@ static void acpi_dev_pm_detach(struct device *dev, bool 
power_off)
struct acpi_device *adev = ACPI_COMPANION(dev);

if (adev && dev->pm_domain == &acpi_general_pm_domain) {
-   dev->pm_domain = NULL;
+   dev_pm_domain_set(dev, NULL);
acpi_remove_pm_notifier(adev);
if (power_off) {
/*
@@ -1128,7 +1129,7 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
return -EBUSY;

acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
-   dev->pm_domain = &acpi_general_pm_domain;
+   dev_pm_domain_set(dev, &acpi_general_pm_domain);
if (power_on) {
acpi_dev_pm_full_power(adev);
acpi_device_wakeup(adev, ACPI_STATE_S0, false);
diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index 652b5a367c1f..e80fda6c03a9 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#in