From patchwork Thu Sep 20 21:29:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1487941 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D6300DF2D2 for ; Thu, 20 Sep 2012 21:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753374Ab2ITV3H (ORCPT ); Thu, 20 Sep 2012 17:29:07 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:46417 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752936Ab2ITV3E (ORCPT ); Thu, 20 Sep 2012 17:29:04 -0400 Received: by pbbrr4 with SMTP id rr4so1077991pbb.19 for ; Thu, 20 Sep 2012 14:29:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=Tzd31nCNEOhy/Z6qqCKFB8Y9CDfktj96LAC0Sm/tAzs=; b=T4GqKvovz5q40jn9M/DtJ+1EswoFGDf2P0S7qdgt10njYMvdNGvfIJ7fr76JPpp1DE KxGj3oCkgjRIBEf52hbYFubrfKKDxue83UEa4Zz9GXpYzx/h31h4eqUxSpDbrELEpPhc gSTPsfS+1+vn6JYCc8OFg7NCbAj3Rb5MzGJO4HrSpIOqLa6ScGZyQZPxV2fSDfbDAPWy 04BoJXkc+hBNASqlCrhvbE0cVIvfrj7pFJBrx+smF2HHOSstKT+tRQ619p9DZGMqtRvo 3Kt44TsYtdPzD/8IqXweH2GmL16zQDGOw7I5Nb9HLT6m2W8eJdoyB3Tf5DPgx+q+7nQf b5yA== Received: by 10.66.88.40 with SMTP id bd8mr8355632pab.36.1348176544443; Thu, 20 Sep 2012 14:29:04 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id m9sm2986435paw.16.2012.09.20.14.29.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 14:29:03 -0700 (PDT) From: Kevin Hilman To: "Rafael J. Wysocki" , linux-pm@vger.kernel.org Cc: linux-omap@vger.kernel.org, Santosh Shilimkar , Grygorii Strashko , Nishanth Menon Subject: [PATCH RESEND] PM / Runtime: let rpm_resume() succeed if RPM_ACTIVE, even when disabled Date: Thu, 20 Sep 2012 14:29:02 -0700 Message-Id: <1348176542-28983-1-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.7.9.2 X-Gm-Message-State: ALoCoQkrpO3LVyvhLJORloTIAU9teCfszDB+SxEr8FiUCM2waTjSSwWJhmZ6+tTNyHqdKxauUge/ Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Kevin Hilman When runtime PM is disabled, what we want is for callbacks not to be called from then on. However, currently, when runtime PM is disabled, operations such as 'get' will also fail even if the device is currently active. Since calling 'get' on a device that is already RPM_ACTIVE does not involve calling the callbacks, it should be allowed to succeed, even if runtime PM is disabled. This is particularily useful in runtime PM enabled drivers that are used during system suspend. Because runtime PM is disabled during system suspend, currently any driver's use of pm_runtime_get* will fail with -EACCES. This is expected if the device was already runtime suspended, but if the device is actually active (due to recent usage, autosuspend timeout not expired, or pm_runtime_resume() called in ->suspend() method), the pm_runtime_get*() call should actually succeed. To permit the usage described above, add a check to rpm_resume() so that success is returned in the case where a driver is suspended (it's ->suspend callback has been called) but is still RPM_ACTIVE. This patch was developed in close collaboration with Rafael J. Wysocki Tested on AM3730/Beagle-xM where wakeup IRQ firing during the late suspend phase triggers runtime PM activity in the I2C driver since the wakeup IRQ is on an I2C-connected PMIC. Cc: Rafael J. Wysocki Signed-off-by: Kevin Hilman --- This version is just a resend with the vger address for linux-pm. drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 7d9c1cb..dafa5ec 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -510,7 +510,8 @@ static int rpm_resume(struct device *dev, int rpmflags) if (dev->power.runtime_error) retval = -EINVAL; else if (dev->power.disable_depth > 0) - retval = -EACCES; + retval = dev->power.is_suspended && + dev->power.runtime_status == RPM_ACTIVE ? 1 : -EACCES; if (retval) goto out;