From patchwork Wed Oct 1 14:41:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5012261 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62736BEEA7 for ; Wed, 1 Oct 2014 14:42:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 807FC2015D for ; Wed, 1 Oct 2014 14:42:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88BBA20260 for ; Wed, 1 Oct 2014 14:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107AbaJAOmK (ORCPT ); Wed, 1 Oct 2014 10:42:10 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:39932 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752115AbaJAOmH (ORCPT ); Wed, 1 Oct 2014 10:42:07 -0400 Received: by mail-lb0-f174.google.com with SMTP id p9so478046lbv.5 for ; Wed, 01 Oct 2014 07:42:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AMNb7AgvqziylkNACBuaB6l7SrgrHvcfYMFBsFBoWAc=; b=UIxLzg/6Og3H1+LheqIlDTaet8FPpBi9N92fOWe03+4nR+E+mmfGWokWqG/8x3L+N3 BUIjC3SICy4t7vGF+YD+ZrSvyksDUKpDlz1lFXOLgFbuedFhfWi8GPY8iKTC+tHW9ipz RxHB2o97hCCVJ5vIWJAwAnoUgYgZ45oO3CO11nxioDtb5slw/F3Bup4p+gnCnC2dW8Ls KvYd/zDu9u6fKaY/vAzxFwl8GZFQHTkwV3jg4pNKFS1yWuT5PXL4s4RJR2yT5w1oQcDn KhQ7Nisrs77upG0F4CrCXmqdyUYKI6PnMONTXMwG/PQKBvcC3oG+EKiK7oc017oVJO3u DCtA== X-Gm-Message-State: ALoCoQn3aidH0q7y38Fc5ZS2kI1dUAKbjFif5XvnCVvN65cO/F4rYzNrREQSzUFepcEOXiV6dJkq X-Received: by 10.152.88.43 with SMTP id bd11mr3700094lab.62.1412174525533; Wed, 01 Oct 2014 07:42:05 -0700 (PDT) Received: from uffe-Latitude-E6430s.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id rl6sm485466lac.17.2014.10.01.07.42.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Oct 2014 07:42:04 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven , Kevin Hilman , Alan Stern , Greg Kroah-Hartman , Tomasz Figa , Simon Horman , Magnus Damm , Ben Dooks , Kukjin Kim , Philipp Zabel , Mark Brown , Wolfram Sang , Russell King , Dmitry Torokhov , Jack Dai , Jinkun Hong , Ulf Hansson Subject: [PATCH v2 4/4] PM / Domains: Enforce PM domains to stay powered during boot Date: Wed, 1 Oct 2014 16:41:34 +0200 Message-Id: <1412174494-15346-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412174494-15346-1-git-send-email-ulf.hansson@linaro.org> References: <1412174494-15346-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 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 When there are more than one device in a PM domain these will obviously be probed at different times. Depending on timing and the implemented support for runtime PM in a driver/subsystem, genpd may be advised to power off a PM domain after a successful probe sequence. Ideally we should have relied on the driver/subsystem, through runtime PM, to bring their device's PM domain into powered state prior doing probing if such requirement exist. Since this is not a common practice by drivers/subsystems, enforcing such a change doesn't seem viable. Instead, let's improve the situation, by preventing genpd from powering off any of the PM domains until late_init. At that point genpd already tries to power off unused PM domains, so it seems like a decent match. Cases which can't be covered within the window of until late_init needs to be adressed separately and likely through a more common long term solution. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 17 ++++++++++++++++- include/linux/pm_domain.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cfb76e8..3dbadfd 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -451,10 +451,12 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd) * (2) The domain is waiting for its master to power up. * (3) One of the domain's devices is being resumed right now. * (4) System suspend is in progress. + * (5) late_init hasn't completed to allow it. */ if (genpd->status == GPD_STATE_POWER_OFF || genpd->status == GPD_STATE_WAIT_MASTER - || genpd->resume_count > 0 || genpd->prepared_count > 0) + || genpd->resume_count > 0 || genpd->prepared_count > 0 + || genpd->keep_power) return 0; if (atomic_read(&genpd->sd_count) > 0) @@ -724,6 +726,18 @@ void pm_genpd_poweroff_unused(void) static int __init genpd_poweroff_unused(void) { + struct generic_pm_domain *genpd; + + mutex_lock(&gpd_list_lock); + + list_for_each_entry(genpd, &gpd_list, gpd_list_node) { + genpd_acquire_lock(genpd); + genpd->keep_power = false; + genpd_release_lock(genpd); + } + + mutex_unlock(&gpd_list_lock); + pm_genpd_poweroff_unused(); return 0; } @@ -1854,6 +1868,7 @@ void pm_genpd_init(struct generic_pm_domain *genpd, genpd->status = GPD_STATE_ACTIVE; init_waitqueue_head(&genpd->status_wait_queue); genpd->poweroff_task = NULL; + genpd->keep_power = true; genpd->resume_count = 0; genpd->device_count = 0; genpd->max_off_time_ns = -1; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index ad4aa87..d87ef6a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -58,6 +58,7 @@ struct generic_pm_domain { enum gpd_status status; /* Current state of the domain */ wait_queue_head_t status_wait_queue; struct task_struct *poweroff_task; /* Powering off task */ + bool keep_power; /* Flag to keep power until late_init */ unsigned int resume_count; /* Number of devices being resumed */ unsigned int device_count; /* Number of devices */ unsigned int suspended_count; /* System suspend device counter */