From patchwork Wed Feb 26 16:30:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 3726081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BB4EF9F35F for ; Wed, 26 Feb 2014 16:30:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDC19201BA for ; Wed, 26 Feb 2014 16:30:45 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E080320103 for ; Wed, 26 Feb 2014 16:30:44 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIhNW-0004bV-R1; Wed, 26 Feb 2014 16:30:38 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIhNU-0005z0-CG; Wed, 26 Feb 2014 16:30:36 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIhNR-0005xQ-Nx for linux-arm-kernel@lists.infradead.org; Wed, 26 Feb 2014 16:30:34 +0000 Received: by mail-pa0-f52.google.com with SMTP id fb1so1182042pad.25 for ; Wed, 26 Feb 2014 08:30:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:message-id :user-agent:mime-version:content-type; bh=V7xx8l4YtqjrZ3Qnmo2qUfYfIADVyLoA8lPLw936TgA=; b=fF6TNurQIDNHGUARheFfe0RP/waRTCrNWRfEikCqXF3o8NU5YlrQyQfU4uFinxq92z ZhdYEtj/uI2boTiqefHzDtcpt9X2mqWYIfTNypm+hADt/SJ+n3ItpPukde8/GPd7GMPy Tyo/uiYFqTCwHC9ya3SgFb2bPJ31EzFWoKVvgfsnwBIfBo6yGexsAI8aEnewq70NfeWD sXI/drzdHSm/naH2QqprljR25QaGq7l5SHltCXwQtFp0rLgglQA5x7MfaJTEhzCSw4se K2YaOGSKVfNDYfID6BD+3OL6sFMSGCm/a9aC/TNG/XFl2b4OFankKfkozY0bG2aPXfzG P2tA== X-Gm-Message-State: ALoCoQk7bvGEeo3kC74n13op2Ga4oJj3CM6b/kuqk8VeGZXuIHYxAmxycKn/e8lneApuq7Qw6iM/ X-Received: by 10.68.242.68 with SMTP id wo4mr8030300pbc.32.1393432211019; Wed, 26 Feb 2014 08:30:11 -0800 (PST) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPSA id cz3sm4855164pbc.9.2014.02.26.08.30.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Feb 2014 08:30:10 -0800 (PST) From: Kevin Hilman To: Ulf Hansson Subject: Re: [PATCH 0/8] PM / Sleep / Runtime: Fixup some driver's system suspend References: <1392910280-12891-1-git-send-email-ulf.hansson@linaro.org> Date: Wed, 26 Feb 2014 08:30:07 -0800 Message-ID: <7htxblx2eo.fsf@paris.lan> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140226_113033_925965_F6CA969E X-CRM114-Status: GOOD ( 16.31 ) X-Spam-Score: 0.5 (/) Cc: Len Brown , Russell King , linux-pm@vger.kernel.org, Linus Walleij , Wolfram Sang , "Rafael J. Wysocki" , Mark Brown , Alan Stern , Pavel Machek , linux-arm-kernel@lists.infradead.org, Alessandro Rubini X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ulf Hansson writes: > Patch 1 -> 2: > These patches provides two new runtime PM helper functions which intend to be > used from system suspend/resume callbacks, to make sure devices are put into low > power state during system suspend and brought back to full power at system > resume. > > The prerequisite is to have all levels of a device's runtime PM callbacks to be > defined through the SET_PM_RUNTIME_PM_OPS macro, which means these are available > for CONFIG_PM. > > By using the new runtime PM helper functions especially the two scenarios below > will be addressed. > > 1) The PM core prevents .runtime_suspend callbacks from being invoked during > system suspend. That means even for a runtime PM centric subsystem and driver, > the device needs to be put into low power state from a system suspend callback. > Otherwise it may very well be left in full power state (runtime resumed) while > the system is suspended. By using the new helper functions, we make sure to walk > the hierarchy of a device's power domain, subsystem and driver. I thought it was the case that runtime PM was only disabled during the 'late' phase now. Isn't that enough to allow runtime callbacks in the normal suspend/resume hooks now? /me looks. oh, wait. Ee still have the _get_noresume() in device_prepare(). hmm Either way, I'm not not a big fan of new functions. Personally, I think subsystems/busses/pm_domains should be able to opt out of the PM core behavior that blocks runtime PM transitions during system suspend. Something like the (untested) hack below. That way, we could avoid the need for new helper functions. Kevin diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1b41fca3d65a..e0770009ba8e 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -832,7 +832,8 @@ static void device_complete(struct device *dev, pm_message_t state) device_unlock(dev); - pm_runtime_put(dev); + if (dev->power.block_rpm_during_suspend) + pm_runtime_put(dev); } /** @@ -1318,7 +1319,8 @@ static int device_prepare(struct device *dev, pm_message_t state) * block runtime suspend here, during the prepare phase, and allow * it again during the complete phase. */ - pm_runtime_get_noresume(dev); + if (dev->power.block_rpm_during_suspend) + pm_runtime_get_noresume(dev); device_lock(dev); @@ -1350,7 +1352,7 @@ static int device_prepare(struct device *dev, pm_message_t state) device_unlock(dev); - if (error) + if (error && dev->power.block_rpm_during_suspend) pm_runtime_put(dev); return error; diff --git a/include/linux/pm.h b/include/linux/pm.h index 8c6583a53a06..692cd543b71d 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -551,6 +551,7 @@ struct dev_pm_info { struct wakeup_source *wakeup; bool wakeup_path:1; bool syscore:1; + unsigned int block_rpm_during_suspend:1; #else unsigned int should_wakeup:1; #endif