From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932863AbcBAORV (ORCPT ); Mon, 1 Feb 2016 09:17:21 -0500 Received: from mga03.intel.com ([134.134.136.65]:8209 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932597AbcBAORS (ORCPT ); Mon, 1 Feb 2016 09:17:18 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,380,1449561600"; d="scan'208";a="645170183" Message-ID: <1454336144.32507.15.camel@linux.intel.com> Subject: Re: [PATCH] PM: Avoid false-positive warnings in dev_pm_domain_set() From: Andy Shevchenko To: "Rafael J. Wysocki" , Linux PM list Cc: Linux Kernel Mailing List , Tomeu Vizoso , Ulf Hansson , Kevin Hilman Date: Mon, 01 Feb 2016 16:15:44 +0200 In-Reply-To: <80793506.EZRY3UmSeu@vostro.rjw.lan> References: <80793506.EZRY3UmSeu@vostro.rjw.lan> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.3-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2016-01-30 at 12:54 +0100, 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. Tested on Intel Braswell where modprobe -r sdhci-acpi caused a warning before this patch. Tested-by: Andy Shevchenko > > 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"); >   dev->pm_domain = pd; >   device_pm_check_callbacks(dev); > -- Andy Shevchenko Intel Finland Oy