Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set()

From: Andy Shevchenko
Date: Mon Feb 01 2016 - 09:17:25 EST


On Sat, 2016-01-30 at 12:54 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
>
> There is a WARN_ON() in dev_pm_domain_set() that triggers on attempts
> to set the pm_domain pointer for devices with a driver bound.
>
> However, that WARN_ON() triggers on attempts to clear the pointer
> too and the test it uses is based on checking the device's
> p->knode_driver pointer which still is set when the device bus
> type's/driver's ->remove callback has been executed.ÂÂThis
> leads to false-positive warnings when bus type code calls
> dev_pm_domain_set() to clear the pm_domain pointer after
> invoking the driver's ->remove() callback.
>
> To avoid those false-positives, make dev_pm_domain_set() check
> if the pointer passed to it is NULL and skip the warning in
> that case.

Tested on Intel Braswell where modprobe -r sdhci-acpi caused a warning
before this patch.

Tested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

>
> Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
> Âdrivers/base/power/common.c |ÂÂÂÂ2 +-
> Â1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: linux-pm/drivers/base/power/common.c
> ===================================================================
> --- linux-pm.orig/drivers/base/power/common.c
> +++ linux-pm/drivers/base/power/common.c
> @@ -146,7 +146,7 @@ void dev_pm_domain_set(struct device *de
> Â if (dev->pm_domain == pd)
> Â return;
> Â
> - WARN(device_is_bound(dev),
> + WARN(pd && device_is_bound(dev),
> Â ÂÂÂÂÂ"PM domains can only be changed for unbound
> devices\n");
> Â dev->pm_domain = pd;
> Â device_pm_check_callbacks(dev);
>

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy