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: 5012311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4A559F327 for ; Wed, 1 Oct 2014 14:45:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE22F20221 for ; Wed, 1 Oct 2014 14:45:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2D0420268 for ; Wed, 1 Oct 2014 14:44:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZL7T-0005Og-GJ; Wed, 01 Oct 2014 14:43:07 +0000 Received: from mail-la0-f52.google.com ([209.85.215.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZL6p-0004Pe-6D for linux-arm-kernel@lists.infradead.org; Wed, 01 Oct 2014 14:42:27 +0000 Received: by mail-la0-f52.google.com with SMTP id hz20so482366lab.25 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=bEE81SO3K3iJzip9zF7TQIr+7x3RHAE6AR68bVytMbo47ykxdMxzfr0Ea9BiAp6z51 HCXnVLgoNig0LBEfbbdXRRay0vmMWHd+DQGzonRCGOoH2uqTrAsJr2bdjCG1LgTQ1wdG UsVX0wWAzUXZ4VwegiO5KDE8jCiVS/blIDS+icwNZGTKnl17Rj9OYPTFezfwcbqRABrx QfHVin2psbKCinVKBlLqwm7GPENXWVeFz1jDnA7MeOFwaO0bipfNtJGab5C8JIjY8krN E2+8hoZ3C2Djb+/sUpR27UzvNIHnYWnMmz55Iy4+y/scomDIO+WoXhhgDUkgBBatJ4jG Qs+w== X-Gm-Message-State: ALoCoQlW3NVJ4e2n9cftb0y6DOY86OxasGGeZHWM1Ph7GbgCpwArKt1/zTUq8BLG+pkWVnUWM3OP 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141001_074227_431515_7BFD6D0F X-CRM114-Status: GOOD ( 19.03 ) X-Spam-Score: -0.7 (/) Cc: Simon Horman , Ulf Hansson , Kevin Hilman , Russell King , Philipp Zabel , Geert Uytterhoeven , Wolfram Sang , Greg Kroah-Hartman , Mark Brown , Dmitry Torokhov , Magnus Damm , Tomasz Figa , linux-samsung-soc@vger.kernel.org, Alan Stern , Ben Dooks , Jinkun Hong , Kukjin Kim , Jack Dai , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 */