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: 38245 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9AE06202E7 for ; Wed, 1 Oct 2014 14:42:07 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id b13sf726806wgh.0 for ; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=AMNb7AgvqziylkNACBuaB6l7SrgrHvcfYMFBsFBoWAc=; b=gVQ1ghoYXVfL6u31tLeYnos5x9+f7/jphZlCB5U+diSwgaYorgcd3tXM1qHWnOV3nk zvv4aZY1tECD6XFh+CZxG5pl7oLSJ62Kz0TL0KV2JVkWHbxIhw8QPtMeH3KkJXMZhIYO 9kBZ0tmb1KLBu2YBV850fe4qQK/qgJ34uhs2S/mhGO9o4cpBgWDHbmXyFuLM7mlpGv3c Q5wS/vyDKXz73Bivx1xjoz4rEccZ6i3Jh0k8EpJU5D0pFlYLge3cLbHPR2MagXEP6Wiw 3ZpVhDFClkD2N8arIs+nVK6kKJFq2I17CwWC8TeSuaD1UK/6Kk6ws4Of0nzEsMl0+IKU DIHg== X-Gm-Message-State: ALoCoQllOY3M2TNLDp8wUvHCt+rQr3I5M1vl64bxJjOn6f8Al6XlLc+7rR9gHi01ybvQbT6JYwyT X-Received: by 10.180.87.226 with SMTP id bb2mr1957548wib.0.1412174526300; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.233 with SMTP id uh9ls176184lac.70.gmail; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) X-Received: by 10.152.9.132 with SMTP id z4mr56309566laa.8.1412174526180; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by mx.google.com with ESMTPS id m8si1969615lah.97.2014.10.01.07.42.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Oct 2014 07:42:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id p9so478067lbv.5 for ; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) X-Received: by 10.152.7.73 with SMTP id h9mr23924657laa.27.1412174526047; Wed, 01 Oct 2014 07:42:06 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.130.169 with SMTP id of9csp543899lbb; Wed, 1 Oct 2014 07:42:05 -0700 (PDT) X-Received: by 10.112.63.70 with SMTP id e6mr18951564lbs.92.1412174525661; Wed, 01 Oct 2014 07:42:05 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id ap7si2030525lac.63.2014.10.01.07.42.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Oct 2014 07:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id w7so456862lbi.37 for ; Wed, 01 Oct 2014 07:42:05 -0700 (PDT) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */