From patchwork Fri Oct 16 22:45:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todd Brandt X-Patchwork-Id: 7421411 Return-Path: X-Original-To: patchwork-linux-pm@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 674F99F37F for ; Fri, 16 Oct 2015 22:45:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 918322060D for ; Fri, 16 Oct 2015 22:45:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D385C205BA for ; Fri, 16 Oct 2015 22:45:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbbJPWpS (ORCPT ); Fri, 16 Oct 2015 18:45:18 -0400 Received: from mga09.intel.com ([134.134.136.24]:1757 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752475AbbJPWpR (ORCPT ); Fri, 16 Oct 2015 18:45:17 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 16 Oct 2015 15:45:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,690,1437462000"; d="scan'208";a="666034073" Received: from tfhinds-mobl2.amr.corp.intel.com (HELO technocore.amr.corp.intel.com) ([10.252.133.102]) by orsmga003.jf.intel.com with ESMTP; 16 Oct 2015 15:45:15 -0700 From: Todd Brandt To: linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com Cc: rjw@rjwysocki.net, todd.e.brandt@intel.com, Todd Brandt Subject: [PATCH v3] PM: check for complete cb before device lock in dpm_complete Date: Fri, 16 Oct 2015 15:45:10 -0700 Message-Id: <6146fb8483239461040674927df2e71d4555c59e.1445035227.git.todd.e.brandt@linux.intel.com> X-Mailer: git-send-email 2.1.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 If a device has no pm_ops complete callback it shouldn't have to be locked in order to skip it in the dpm_complete call. This causes problems when a device without a complete callback has already begun operation after its resume cb is called. It can end up holding up the system resume as the pm subsystem tries to get a device lock just to check for a callback that isn't there. This is basically the original v1 patch but updated for the latest kernel. Signed-off-by: Todd Brandt --- drivers/base/power/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 1710c26..9bb8ff0 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -899,8 +899,6 @@ static void device_complete(struct device *dev, pm_message_t state) if (dev->power.syscore) return; - device_lock(dev); - if (dev->pm_domain) { info = "completing power domain "; callback = dev->pm_domain->ops.complete; @@ -920,13 +918,15 @@ static void device_complete(struct device *dev, pm_message_t state) callback = dev->driver->pm->complete; } - if (callback) { - pm_dev_dbg(dev, state, info); - callback(dev); - } + if (!callback) + goto Complete; + device_lock(dev); + pm_dev_dbg(dev, state, info); + callback(dev); device_unlock(dev); +Complete: pm_runtime_put(dev); }