From patchwork Tue Sep 30 12:43:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 38141 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B2BA2032C for ; Tue, 30 Sep 2014 12:44:14 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id w7sf1995680lbi.6 for ; Tue, 30 Sep 2014 05:44:13 -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=FFsz6dbMRrifCK1YsgSCvek4dm9i0U7VJy04BR9CKuVZ+u+VzxtQ7/Bm7Lvyryb+vG aNg8yhFa8+FfiYFr+cEu96P1jktRJLGQxpXhkH7fbHwexXr01inRh1G4HZU2x5/BhcFn 0uWsfQ49EscrBtiC4z3XxMHS085qcr1KDx4Ocl4qQqYcvSvmxnC/0LARKXoM9bF/M9S1 6tVI7vAj9NOa5lv3ttjTFlcYjU62JuisUe8zJTah1jR7fFLK9VIsmQRf5/8r+pKFzhnw u4qNcOGZWKgiGKNNvZ3NpBO7rHJ/se/TdR1LaXSH4DAFZGejKNGAzjYl8eF86VON/M0w Emlw== X-Gm-Message-State: ALoCoQlX3TBoO2TMBYFjtOjKJTVACGKuW5aAYRIMQkVsqRSIqqLMRkG50gzyUAKAFGQ/EevXXfj8 X-Received: by 10.112.225.41 with SMTP id rh9mr3566015lbc.5.1412081053297; Tue, 30 Sep 2014 05:44:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.133 with SMTP id q5ls42305laj.80.gmail; Tue, 30 Sep 2014 05:44:13 -0700 (PDT) X-Received: by 10.112.145.100 with SMTP id st4mr34754099lbb.17.1412081053197; Tue, 30 Sep 2014 05:44:13 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id o6si22556309lbc.99.2014.09.30.05.44.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 05:44:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id p9so4363277lbv.35 for ; Tue, 30 Sep 2014 05:44:12 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr43522637lbh.67.1412081052203; Tue, 30 Sep 2014 05:44:12 -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 of9csp338461lbb; Tue, 30 Sep 2014 05:44:11 -0700 (PDT) X-Received: by 10.152.170.227 with SMTP id ap3mr46855330lac.15.1412081051818; Tue, 30 Sep 2014 05:44:11 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx.google.com with ESMTPS id v5si22624100lae.56.2014.09.30.05.44.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 05:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id l4so528403lbv.4 for ; Tue, 30 Sep 2014 05:44:11 -0700 (PDT) X-Received: by 10.152.5.100 with SMTP id r4mr24844449lar.41.1412081051669; Tue, 30 Sep 2014 05:44:11 -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 mn4sm6034586lbb.4.2014.09.30.05.44.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Sep 2014 05:44:10 -0700 (PDT) From: Ulf Hansson To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Kevin Hilman , Tomasz Figa , Philipp Zabel , Russell King , Mark Brown , Wolfram Sang , Greg Kroah-Hartman , Dmitry Torokhov , Jack Dai , Jinkun Hong , Ulf Hansson Subject: [PATCH 4/4] PM / Domains: Enforce PM domains to stay powered during boot Date: Tue, 30 Sep 2014 14:43:53 +0200 Message-Id: <1412081033-8136-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412081033-8136-1-git-send-email-ulf.hansson@linaro.org> References: <1412081033-8136-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.176 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 */