From patchwork Mon Feb 1 22:06:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 8183921 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9229F9FC36 for ; Mon, 1 Feb 2016 22:07:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AEB5C20375 for ; Mon, 1 Feb 2016 22:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 257E12039C for ; Mon, 1 Feb 2016 22:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932248AbcBAWHD (ORCPT ); Mon, 1 Feb 2016 17:07:03 -0500 Received: from muru.com ([72.249.23.125]:59356 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753815AbcBAWHB (ORCPT ); Mon, 1 Feb 2016 17:07:01 -0500 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 9DA21802C; Mon, 1 Feb 2016 22:07:59 +0000 (UTC) Date: Mon, 1 Feb 2016 14:06:58 -0800 From: Tony Lindgren To: Ulf Hansson Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Kevin Hilman , "linux-pm@vger.kernel.org" , Linux OMAP Mailing List , "linux-arm-kernel@lists.infradead.org" Subject: Re: PM regression with commit 5de85b9d57ab PM runtime re-init in v4.5-rc1 Message-ID: <20160201220657.GO19432@atomide.com> References: <20160126224804.GB19432@atomide.com> <20160126232212.GE19432@atomide.com> <20160126235222.GF19432@atomide.com> <20160128165810.GA19432@atomide.com> <20160201181135.GL19432@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160201181135.GL19432@atomide.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 * Tony Lindgren [160201 10:12]: > * Ulf Hansson [160201 08:45]: > > On 28 January 2016 at 17:58, Tony Lindgren wrote: > > > > > > The MMC hardware will not get idled properly any longer blocking any > > > deeper idle states. > > > > > >> Did the driver not probe successfully the second try? If so, what happened. > > > > > > It probes fine after a -EPROBE_DEFER on the vmmc i2c regulator. > > > But the PM runtime usecounts are wrong. > > > > Okay. How did you verify this? > > Well that was just based on what I see in the dmesg: > > omap_device: omap_device_enable() called from invalid state 1 So we're now missing the idling of hardare after -EPROBE_DEFER.. Does the following patch work for you guys? Regards, Tony 8< ----------------------------- From: Tony Lindgren Date: Mon, 1 Feb 2016 13:40:46 -0800 Subject: [PATCH] PM / runtime: Fix PM runtime reinit Commit 5de85b9d57ab ("PM / runtime: Re-init runtime PM states at probe error and driver unbind") added calls to reinit the PM runtime. This however broke things for idling the hardware at least if the driver probing has pm_runtime_set_autosuspend_delay() and -EPROBE_DEFER happens. Fix the problem by adding a check for configured autosuspend if RPM_ACTIVE is set. Then reset the autosuspend, and suspend the device to make sure the hardware gets idled. Let's also cut down one level of nestedness and remove a negative test by returning early if pm_runtime_enabled(dev) as there is currently nothing for us to do in that case. Fixes: 5de85b9d57ab ("PM / runtime: Re-init runtime PM states at probe error and driver unbind") Signed-off-by: Tony Lindgren --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1419,17 +1419,25 @@ void pm_runtime_init(struct device *dev) */ void pm_runtime_reinit(struct device *dev) { - if (!pm_runtime_enabled(dev)) { - if (dev->power.runtime_status == RPM_ACTIVE) + if (pm_runtime_enabled(dev)) + return; + + if (dev->power.runtime_status == RPM_ACTIVE) { + if (dev->power.use_autosuspend) { + __pm_runtime_use_autosuspend(dev, false); + pm_runtime_suspend(dev); + } else { pm_runtime_set_suspended(dev); - if (dev->power.irq_safe) { - spin_lock_irq(&dev->power.lock); - dev->power.irq_safe = 0; - spin_unlock_irq(&dev->power.lock); - if (dev->parent) - pm_runtime_put(dev->parent); } } + + if (dev->power.irq_safe) { + spin_lock_irq(&dev->power.lock); + dev->power.irq_safe = 0; + spin_unlock_irq(&dev->power.lock); + if (dev->parent) + pm_runtime_put(dev->parent); + } } /**