From patchwork Fri Feb 17 09:55:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9579369 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8CE0A600F6 for ; Fri, 17 Feb 2017 09:55:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 847B128491 for ; Fri, 17 Feb 2017 09:55:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 796EB2867A; Fri, 17 Feb 2017 09:55:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 242BF28491 for ; Fri, 17 Feb 2017 09:55:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933565AbdBQJzj (ORCPT ); Fri, 17 Feb 2017 04:55:39 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:36291 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933054AbdBQJzf (ORCPT ); Fri, 17 Feb 2017 04:55:35 -0500 Received: by mail-lf0-f43.google.com with SMTP id z134so20190518lff.3 for ; Fri, 17 Feb 2017 01:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=awgrw9/kDlVbjK79/l63CXzYb5IwMxyavFTDAXj78aY=; b=Wg4pmU21tRtE5vmNqCTqEM0lZqN1Mk+0CqTwtllB28dW8hazYPdzU1rD8PqvVhoZXV fWIqr87jwSWKYVAw9HH/cwkh9b0RinpTlHnCbfDEp6MDDWcX16oPoB2jVLrUrB10g6EA 9qkFM7J0muVRaAVdKuPjZy4O0aAYlD6MacRUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=awgrw9/kDlVbjK79/l63CXzYb5IwMxyavFTDAXj78aY=; b=ds9Q1DqjUu2CphGM5pQTNHDNCHUgUILM9M6KmaYhPCDndHhFQm86xddnVvGSdKyg61 Idr4XhGQjnbQ6C/IH6umW6e6ln8RuHF9PspIk7oCdl3XgfUprziYW8tnEx5oRmgZlr8R fg89ARDOUUSYYZ0LXcRRueU/0gRm4yQaTLUFarxX1/YeCAUhp3TtptqgTCd9sWk6Up5j WSmSUxyDyHBUp3kQRXQRGZpi0lIuPHl80Bj8s14wwKkNBzbHKnhugcSv+iYyMOGjGpv7 S6wFmMi9nDKy54xniUUrwqC/nG0EylPpJ1njQ5VcpiW/wy+41T22li13z4Og5/FWNfHo cYiA== X-Gm-Message-State: AMke39ns68jq7BkSdGnzMgRp0MLnQd2HLZCNfR5WiYZ3afTCW1mCH26Lstfdhgwplnu7QNrX X-Received: by 10.25.229.221 with SMTP id i90mr813639lfk.11.1487325333302; Fri, 17 Feb 2017 01:55:33 -0800 (PST) Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id f133sm2372773lfg.32.2017.02.17.01.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 01:55:32 -0800 (PST) From: Ulf Hansson To: "Rafael J. Wysocki" , Ulf Hansson , linux-pm@vger.kernel.org Cc: Len Brown , Pavel Machek , Kevin Hilman , Geert Uytterhoeven , Lina Iyer , Jon Hunter , Marek Szyprowski Subject: [PATCH 3/3] PM / Domains: Power off masters immediately in the power off sequence Date: Fri, 17 Feb 2017 10:55:25 +0100 Message-Id: <1487325325-18212-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1487325325-18212-1-git-send-email-ulf.hansson@linaro.org> References: <1487325325-18212-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Once a subdomain is powered off, genpd queues a power off work for each of the subdomain's corresponding masters, thus postponing the masters to be powered off to a later point. When genpd used intermediate power off states, which was removed in commit ba2bbfbf6307 ("PM / Domains: Remove intermediate states from the power off sequence"), this behaviour made sense, but now it simply doesn't. Genpd can easily try to power off the masters in the same context as the subdomain, of course by acquiring/releasing the lock. Then, let's convert to this behaviour, as it avoids unnecessary works from being queued. Signed-off-by: Ulf Hansson Tested-by: Lina Iyer --- drivers/base/power/domain.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 179bb26..e697dec 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -284,7 +284,8 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) * If all of the @genpd's devices have been suspended and all of its subdomains * have been powered down, remove power from @genpd. */ -static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on) +static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on, + unsigned int depth) { struct pm_domain_data *pdd; struct gpd_link *link; @@ -351,7 +352,9 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on) list_for_each_entry(link, &genpd->slave_links, slave_node) { genpd_sd_counter_dec(link->master); - genpd_queue_power_off_work(link->master); + genpd_lock_nested(link->master, depth + 1); + genpd_power_off(link->master, false, depth + 1); + genpd_unlock(link->master); } return 0; @@ -405,7 +408,9 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth) &genpd->slave_links, slave_node) { genpd_sd_counter_dec(link->master); - genpd_queue_power_off_work(link->master); + genpd_lock_nested(link->master, depth + 1); + genpd_power_off(link->master, false, depth + 1); + genpd_unlock(link->master); } return ret; @@ -462,7 +467,7 @@ static void genpd_power_off_work_fn(struct work_struct *work) genpd = container_of(work, struct generic_pm_domain, power_off_work); genpd_lock(genpd); - genpd_power_off(genpd, false); + genpd_power_off(genpd, false, 0); genpd_unlock(genpd); } @@ -581,7 +586,7 @@ static int genpd_runtime_suspend(struct device *dev) return 0; genpd_lock(genpd); - genpd_power_off(genpd, true); + genpd_power_off(genpd, true, 0); genpd_unlock(genpd); return 0; @@ -661,7 +666,7 @@ static int genpd_runtime_resume(struct device *dev) if (!pm_runtime_is_irq_safe(dev) || (pm_runtime_is_irq_safe(dev) && genpd_is_irq_safe(genpd))) { genpd_lock(genpd); - genpd_power_off(genpd, true); + genpd_power_off(genpd, true, 0); genpd_unlock(genpd); }