Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1322339 > unrolled thread

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

Started by"Rafael J. Wysocki" <rjw@rjwysocki.net>
First post2016-01-30 13:00 +0100
Last post2016-02-03 14:20 +0100
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-01-30 13:00 +0100
    Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-02-01 15:20 +0100
    Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() Ulf Hansson <ulf.hansson@linaro.org> - 2016-02-03 11:10 +0100
      Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() "Rafael J. Wysocki" <rafael@kernel.org> - 2016-02-03 13:10 +0100
        Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() Ulf Hansson <ulf.hansson@linaro.org> - 2016-02-03 14:20 +0100

#1322339 — [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set()

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2016-01-30 13:00 +0100
Subject[PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set()
Message-ID<qWCm5-28q-1@gated-at.bofh.it>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.

Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 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);

[toc] | [next] | [standalone]


#1323160

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2016-02-01 15:20 +0100
Message-ID<qXnuG-40K-29@gated-at.bofh.it>
In reply to#1322339
On Sat, 2016-01-30 at 12:54 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> 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@linux.intel.com>

> 
> Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  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@linux.intel.com>
Intel Finland Oy

[toc] | [prev] | [next] | [standalone]


#1325122

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-02-03 11:10 +0100
Message-ID<qY2xR-A6-27@gated-at.bofh.it>
In reply to#1322339
On 30 January 2016 at 12:54, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
>
> Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  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");

Perhaps this information then becomes a bit misleading, as it's okay
to clear the pointer, but not assign it to a valid PM domain.

>         dev->pm_domain = pd;
>         device_pm_check_callbacks(dev);
>

Otherwise, this looks good to me!

Kind regards
Uffe

[toc] | [prev] | [next] | [standalone]


#1325308

From"Rafael J. Wysocki" <rafael@kernel.org>
Date2016-02-03 13:10 +0100
Message-ID<qY4pY-1KZ-9@gated-at.bofh.it>
In reply to#1325122
On Wed, Feb 3, 2016 at 10:58 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On 30 January 2016 at 12:54, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> 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.
>>
>> Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> ---
>>  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");
>
> Perhaps this information then becomes a bit misleading, as it's okay
> to clear the pointer, but not assign it to a valid PM domain.

Well, this is a "you're doing a wrong thing" warning and it does say
what the wrong thing is.  Does it have to be more specific?  I don't
think so.

Thanks,
Rafael

[toc] | [prev] | [next] | [standalone]


#1325397

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-02-03 14:20 +0100
Message-ID<qY5vH-2qT-11@gated-at.bofh.it>
In reply to#1325308
On 3 February 2016 at 13:08, Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Wed, Feb 3, 2016 at 10:58 AM, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>> On 30 January 2016 at 12:54, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>
>>> 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.
>>>
>>> Fixes: 989561de9b51 (PM / Domains: add setter for dev.pm_domain)
>>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>> ---
>>>  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");
>>
>> Perhaps this information then becomes a bit misleading, as it's okay
>> to clear the pointer, but not assign it to a valid PM domain.
>
> Well, this is a "you're doing a wrong thing" warning and it does say
> what the wrong thing is.  Does it have to be more specific?  I don't
> think so.

Okay! I don't have a strong opinion.

Feel free to add:
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web