From patchwork Fri Apr 17 15:24:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6234651 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 75A069F1AC for ; Fri, 17 Apr 2015 15:26:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CCAD20398 for ; Fri, 17 Apr 2015 15:26:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0423B20396 for ; Fri, 17 Apr 2015 15:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933473AbbDQP0H (ORCPT ); Fri, 17 Apr 2015 11:26:07 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:38506 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754220AbbDQPZu (ORCPT ); Fri, 17 Apr 2015 11:25:50 -0400 Received: by wiun10 with SMTP id n10so24383812wiu.1; Fri, 17 Apr 2015 08:25:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8bqguXF5YxHC8D79NE1Y5wCtqDThupodi/sXB4HLq1c=; b=NADrDEh8QWFXgsVDl7IJgro8qJdg6tQ4CgfoaeSBmH9vormQF1xbdoeV15VM4Gk2WV RVHlF+iog9f0tuFc8C9w1/e3B+jwPPcsD9M+1u3EpFGpcBab059KVOovO+kR93PYAU48 NBXHkv9d2wPHUjwiPxzAlgzWarza/8PtbD+mRi6Y5ciygEThQJKz6JbZ3l0johdl+8Dk /bjQkeU745fRGpuJhPvsk7GgQQqTGLERtZL1Rpi6q07nN5XPAsgsAUXkOELkBG+PWkQR 1qx6xX77/VROW3cNApX2DaXGQ5t2sChQO3AGAZPXxfuj8cXxcev3CfSQwdXfhyrLdK4e dVxA== X-Received: by 10.194.104.71 with SMTP id gc7mr6834693wjb.114.1429284348412; Fri, 17 Apr 2015 08:25:48 -0700 (PDT) Received: from cizrna.lan ([109.72.12.111]) by mx.google.com with ESMTPSA id eh5sm3074810wic.20.2015.04.17.08.25.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2015 08:25:47 -0700 (PDT) From: Tomeu Vizoso To: linux-pm@vger.kernel.org Cc: Laurent Pinchart , Dmitry Torokhov , Alan Stern , Tomeu Vizoso , "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] PM / sleep: Let devices force direct_complete Date: Fri, 17 Apr 2015 17:24:49 +0200 Message-Id: <1429284290-25153-2-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1429284290-25153-1-git-send-email-tomeu.vizoso@collabora.com> References: <1429284290-25153-1-git-send-email-tomeu.vizoso@collabora.com> 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 Introduce a new per-device flag power.force_direct_complete that will instruct the PM core to ignore the runtime PM status of its descendants when deciding whether to let this device remain in runtime suspend when the system goes into a sleep power state. This is needed because otherwise it would be needed to get dozens of drivers to implement the prepare() callback and be runtime PM active even if they don't have a 1-to-1 relationship with a piece of HW. Signed-off-by: Tomeu Vizoso --- drivers/base/power/main.c | 13 +++++++++---- include/linux/pm.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 3d874ec..728c2dc 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1438,7 +1438,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async) if (parent) { spin_lock_irq(&parent->power.lock); - dev->parent->power.direct_complete = false; + if (!dev->parent->power.force_direct_complete) + dev->parent->power.direct_complete = false; + if (dev->power.wakeup_path && !dev->parent->power.ignore_children) dev->parent->power.wakeup_path = true; @@ -1605,9 +1607,12 @@ static int device_prepare(struct device *dev, pm_message_t state) * will do the same thing with all of its descendants". This only * applies to suspend transitions, however. */ - spin_lock_irq(&dev->power.lock); - dev->power.direct_complete = ret > 0 && state.event == PM_EVENT_SUSPEND; - spin_unlock_irq(&dev->power.lock); + if (state.event == PM_EVENT_SUSPEND) { + spin_lock_irq(&dev->power.lock); + dev->power.direct_complete = ret > 0 || + dev->power.force_direct_complete; + spin_unlock_irq(&dev->power.lock); + } return 0; } diff --git a/include/linux/pm.h b/include/linux/pm.h index 2d29c64..2e41cfd 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -553,6 +553,7 @@ struct dev_pm_info { bool ignore_children:1; bool early_init:1; /* Owned by the PM core */ bool direct_complete:1; /* Owned by the PM core */ + bool force_direct_complete:1; spinlock_t lock; #ifdef CONFIG_PM_SLEEP struct list_head entry;