From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396AbcBCMIS (ORCPT ); Wed, 3 Feb 2016 07:08:18 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:35286 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751952AbcBCMIQ (ORCPT ); Wed, 3 Feb 2016 07:08:16 -0500 MIME-Version: 1.0 In-Reply-To: References: <80793506.EZRY3UmSeu@vostro.rjw.lan> Date: Wed, 3 Feb 2016 13:08:14 +0100 X-Google-Sender-Auth: OxobxvzlYYVFkF6KOF8mzoUwluA Message-ID: Subject: Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() From: "Rafael J. Wysocki" To: Ulf Hansson Cc: "Rafael J. Wysocki" , Linux PM list , Linux Kernel Mailing List , Andy Shevchenko , Tomeu Vizoso , Kevin Hilman Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 3, 2016 at 10:58 AM, Ulf Hansson wrote: > On 30 January 2016 at 12:54, Rafael J. Wysocki wrote: >> From: Rafael J. Wysocki >> >> 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 >> --- >> 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