From patchwork Fri May 17 19:05:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Brandt X-Patchwork-Id: 2584191 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id EB6DC3FD4E for ; Fri, 17 May 2013 19:06:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756410Ab3EQTGL (ORCPT ); Fri, 17 May 2013 15:06:11 -0400 Received: from mga14.intel.com ([143.182.124.37]:27799 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755697Ab3EQTGJ convert rfc822-to-8bit (ORCPT ); Fri, 17 May 2013 15:06:09 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 17 May 2013 12:06:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,694,1363158000"; d="scan'208";a="243165400" Received: from fmsmsx107.amr.corp.intel.com ([10.19.9.54]) by AZSMGA002.ch.intel.com with ESMTP; 17 May 2013 12:05:35 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX107.amr.corp.intel.com (10.19.9.54) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 17 May 2013 12:05:34 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.3.220]) by FMSMSX112.amr.corp.intel.com ([169.254.3.140]) with mapi id 14.01.0355.002; Fri, 17 May 2013 12:05:34 -0700 From: "Brandt, Todd E" To: "linux-ide@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-pm@vger.kernel.org" CC: Jeff Garzik , Jens Axboe , Greg Kroah-Hartman , "Wysocki, Rafael J" , Arjan van de Ven Subject: [PATCH v2 2/2] Adds new device resume mode in PM core, async plus non-blocking Thread-Topic: [PATCH v2 2/2] Adds new device resume mode in PM core, async plus non-blocking Thread-Index: Ac5TMYHZ22pO0kasREOEfmhyP2YV4Q== Date: Fri, 17 May 2013 19:05:33 +0000 Message-ID: <11E08D716F0541429B7042699DD5C1A16B97BD8A@FMSMSX103.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.3.86.137] MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Updates the drivers/base/power subsystem to allow any devices which have registred as asynchronous and who have not registered "complete" callbacks to be non-blocking. i.e system resume can finish and return control to the user while these devices continue resuming. Changelog: v2: - Updated patch submission. Incorporates comments from Tejun Heo. Fixed comment format, removed camelcase. No functional changes. Signed-off-by: Todd Brandt --- drivers/base/power/main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 2b7f77d..1b16379 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -713,7 +713,6 @@ void dpm_resume(pm_message_t state) put_device(dev); } mutex_unlock(&dpm_list_mtx); - async_synchronize_full(); dpm_show_time(starttime, state, NULL); } @@ -726,11 +725,14 @@ static void device_complete(struct device *dev, pm_message_t state) { void (*callback)(struct device *) = NULL; char *info = NULL; + bool hascb = false; if (dev->power.syscore) return; - device_lock(dev); + docomplete: + if (hascb) + device_lock(dev); if (dev->pm_domain) { info = "completing power domain "; @@ -751,13 +753,21 @@ static void device_complete(struct device *dev, pm_message_t state) callback = dev->driver->pm->complete; } + /* + * if a callback exists, lock the device and call it + * otherwise don't even lock/unlock the device + */ if (callback) { + if (!hascb) { + hascb = true; + goto docomplete; + } + pm_dev_dbg(dev, state, info); callback(dev); + device_unlock(dev); } - device_unlock(dev); - pm_runtime_put_sync(dev); } @@ -1180,6 +1190,8 @@ int dpm_suspend(pm_message_t state) might_sleep(); mutex_lock(&dpm_list_mtx); + /* wait for any processes still resuming */ + async_synchronize_full(); pm_transition = state; async_error = 0; while (!list_empty(&dpm_prepared_list)) {