From patchwork Fri Feb 17 09:55:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 94134 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp89032qgi; Fri, 17 Feb 2017 01:55:31 -0800 (PST) X-Received: by 10.46.22.81 with SMTP id 17mr1821135ljw.13.1487325331699; Fri, 17 Feb 2017 01:55:31 -0800 (PST) Return-Path: Received: from mail-lf0-x235.google.com (mail-lf0-x235.google.com. [2a00:1450:4010:c07::235]) by mx.google.com with ESMTPS id i30si4742880ljb.119.2017.02.17.01.55.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 01:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) client-ip=2a00:1450:4010:c07::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x235.google.com with SMTP id x1so20213445lff.0 for ; Fri, 17 Feb 2017 01:55:31 -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=6RUmNvLGKADJ18DWAOm4UuDsfpio7yRChXph+k/cSCs=; b=gGSK6JQ/345OI7oogG/l8eWbGGmzZDICThRVP5dqCTFWLzGLim/S0qxbMAWkyknkMc pYXee+FyUo52XnkfCPxm3AiJKjQvoYUANX8nuV3J7kyY2r4c89h3UDt8OAy4qpJPNTac q9aZrQxj/0EUBLliekPBsVQNTKXzn0IpOhFDA= 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=6RUmNvLGKADJ18DWAOm4UuDsfpio7yRChXph+k/cSCs=; b=qm6ylPV2iBUgzkHaqC4kS//SkkVxlk0Jp4j3j9WTBwiFqNDJZ4g0xde6G610gp3Eu0 uEZI6h0U9PFGgOaZyxc67gkhrmWqTbWYVYbGyUh2jAD+HMZAMTNGMJWqeYpS+hWL3ND+ pgjQgNUxLblflLum45C7CLL69SJ/aMpaeL2KHwdJ62kFBNkSYSeofE2AsOG0rTvEyKva Q3OTAwBpxpBmgxztFjFzzbqunwPamHzX7qOi/KD2ErnWRB6r2pt0CrO0TXnmUrdYsxUB w3WZ3DExddt7sgWGAHCHFF9O3I4qLg/VsgYISavTweSKus/u1vBsD3MKLduKH5iAM+6E TdeQ== X-Gm-Message-State: AMke39kb4VS/a4nxxFoUTacSN6EP9JsCcXhPaUj1uqc3OxgvuXIKBAGP9DFzKS35RbSuS3ZEYK4= X-Received: by 10.25.29.195 with SMTP id d186mr2054046lfd.72.1487325331243; Fri, 17 Feb 2017 01:55:31 -0800 (PST) Return-Path: 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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 01:55:30 -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 1/3] PM / Domains: Move genpd_power_off() above genpd_power_on() Date: Fri, 17 Feb 2017 10:55:23 +0100 Message-Id: <1487325325-18212-2-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> Following changes in genpd_power_on() makes it invoke genpd_power_off(). To enable these changes and avoiding to declare genpd_power_off(), let's move its implementation above genpd_power_on(). In this way, following changes should become easier to review. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 162 ++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 81 deletions(-) -- 1.9.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 3a75fb1..3dc44f2 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -274,6 +274,87 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) } /** + * genpd_power_off - Remove power from a given PM domain. + * @genpd: PM domain to power down. + * @is_async: PM domain is powered down from a scheduled work + * + * 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 is_async) +{ + struct pm_domain_data *pdd; + struct gpd_link *link; + unsigned int not_suspended = 0; + + /* + * Do not try to power off the domain in the following situations: + * (1) The domain is already in the "power off" state. + * (2) System suspend is in progress. + */ + if (genpd->status == GPD_STATE_POWER_OFF + || genpd->prepared_count > 0) + return 0; + + if (atomic_read(&genpd->sd_count) > 0) + return -EBUSY; + + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + enum pm_qos_flags_status stat; + + stat = dev_pm_qos_flags(pdd->dev, + PM_QOS_FLAG_NO_POWER_OFF + | PM_QOS_FLAG_REMOTE_WAKEUP); + if (stat > PM_QOS_FLAGS_NONE) + return -EBUSY; + + /* + * Do not allow PM domain to be powered off, when an IRQ safe + * device is part of a non-IRQ safe domain. + */ + if (!pm_runtime_suspended(pdd->dev) || + irq_safe_dev_in_no_sleep_domain(pdd->dev, genpd)) + not_suspended++; + } + + if (not_suspended > 1 || (not_suspended == 1 && is_async)) + return -EBUSY; + + if (genpd->gov && genpd->gov->power_down_ok) { + if (!genpd->gov->power_down_ok(&genpd->domain)) + return -EAGAIN; + } + + if (genpd->power_off) { + int ret; + + if (atomic_read(&genpd->sd_count) > 0) + return -EBUSY; + + /* + * If sd_count > 0 at this point, one of the subdomains hasn't + * managed to call genpd_power_on() for the master yet after + * incrementing it. In that case genpd_power_on() will wait + * for us to drop the lock, so we can call .power_off() and let + * the genpd_power_on() restore power for us (this shouldn't + * happen very often). + */ + ret = _genpd_power_off(genpd, true); + if (ret) + return ret; + } + + genpd->status = GPD_STATE_POWER_OFF; + + list_for_each_entry(link, &genpd->slave_links, slave_node) { + genpd_sd_counter_dec(link->master); + genpd_queue_power_off_work(link->master); + } + + return 0; +} + +/** * genpd_power_on - Restore power to a given PM domain and its masters. * @genpd: PM domain to power up. * @depth: nesting count for lockdep. @@ -368,87 +449,6 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, } /** - * genpd_power_off - Remove power from a given PM domain. - * @genpd: PM domain to power down. - * @is_async: PM domain is powered down from a scheduled work - * - * 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 is_async) -{ - struct pm_domain_data *pdd; - struct gpd_link *link; - unsigned int not_suspended = 0; - - /* - * Do not try to power off the domain in the following situations: - * (1) The domain is already in the "power off" state. - * (2) System suspend is in progress. - */ - if (genpd->status == GPD_STATE_POWER_OFF - || genpd->prepared_count > 0) - return 0; - - if (atomic_read(&genpd->sd_count) > 0) - return -EBUSY; - - list_for_each_entry(pdd, &genpd->dev_list, list_node) { - enum pm_qos_flags_status stat; - - stat = dev_pm_qos_flags(pdd->dev, - PM_QOS_FLAG_NO_POWER_OFF - | PM_QOS_FLAG_REMOTE_WAKEUP); - if (stat > PM_QOS_FLAGS_NONE) - return -EBUSY; - - /* - * Do not allow PM domain to be powered off, when an IRQ safe - * device is part of a non-IRQ safe domain. - */ - if (!pm_runtime_suspended(pdd->dev) || - irq_safe_dev_in_no_sleep_domain(pdd->dev, genpd)) - not_suspended++; - } - - if (not_suspended > 1 || (not_suspended == 1 && is_async)) - return -EBUSY; - - if (genpd->gov && genpd->gov->power_down_ok) { - if (!genpd->gov->power_down_ok(&genpd->domain)) - return -EAGAIN; - } - - if (genpd->power_off) { - int ret; - - if (atomic_read(&genpd->sd_count) > 0) - return -EBUSY; - - /* - * If sd_count > 0 at this point, one of the subdomains hasn't - * managed to call genpd_power_on() for the master yet after - * incrementing it. In that case genpd_power_on() will wait - * for us to drop the lock, so we can call .power_off() and let - * the genpd_power_on() restore power for us (this shouldn't - * happen very often). - */ - ret = _genpd_power_off(genpd, true); - if (ret) - return ret; - } - - genpd->status = GPD_STATE_POWER_OFF; - - list_for_each_entry(link, &genpd->slave_links, slave_node) { - genpd_sd_counter_dec(link->master); - genpd_queue_power_off_work(link->master); - } - - return 0; -} - -/** * genpd_power_off_work_fn - Power off PM domain whose subdomain count is 0. * @work: Work structure used for scheduling the execution of this function. */ From patchwork Fri Feb 17 09:55:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 94135 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp89039qgi; Fri, 17 Feb 2017 01:55:32 -0800 (PST) X-Received: by 10.25.215.5 with SMTP id o5mr1548973lfg.132.1487325332650; Fri, 17 Feb 2017 01:55:32 -0800 (PST) Return-Path: Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com. [2a00:1450:4010:c07::22d]) by mx.google.com with ESMTPS id p76si4722416lfd.413.2017.02.17.01.55.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 01:55:32 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) client-ip=2a00:1450:4010:c07::22d; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22d as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22d.google.com with SMTP id o140so6096664lff.1 for ; Fri, 17 Feb 2017 01:55:32 -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=bz1cQZd+817a4AA/NO0OxMpxjJEcrMcdvPu4Agsg2r8=; b=fS/mVkUb8SCmcRliW6Yu2o8KgI8cwz+zp1AkjGejiagYxO8zku2SswojQDM3+LB+nk klc9YZTKN0Iql7VKspMo40IHLxi7fdl/w+vCCTYdbCilik5mKL0bR4Yc4RmfAapy9eWt 4r3v9hFK8Jxh6aJcFEPVg0OFHWsjCoc6PjIfY= 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=bz1cQZd+817a4AA/NO0OxMpxjJEcrMcdvPu4Agsg2r8=; b=mkB5H9PwHiQ+nBe51wV+sReOAPPUn5cCIM84oDm3cgDQY1H3yDA4fBTqf+tM1Ox9oF 48xjyN3UroqHkwwpnkxDYyJnoLo9Hw74f9sjJJy9I6AUJ7BegibKlDT/BArJ3cuV0EKD MOXCQ2ldruO3k56OaX4YfC4WOoszoxxtkD1Kw25Z5hSIGEbZXCxjxdRqMQPq2AZhq6UC XOG1omd7JOBGz1oz7S+dQxQhHsiqIZ9Pszq4oYzCRamg04hLpYSZYYCHMVWL1VeryJA7 YEsvBUfqFn2aZpQbLS2dFGSmvVBpjHd0c+8igqASMhDJ6b46gp41UVjjYV0i1hXsezfP hSuA== X-Gm-Message-State: AMke39mLyUMva6NyuWePIpTLWJhLnl51b05600y/SwtnfsMpmhciOiCy8NqkXmvZRoT75fbrKNs= X-Received: by 10.25.33.21 with SMTP id h21mr1984543lfh.114.1487325332251; Fri, 17 Feb 2017 01:55:32 -0800 (PST) Return-Path: 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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Feb 2017 01:55:31 -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 2/3] PM / Domains: Rename is_async to one_dev_on for genpd_power_off() Date: Fri, 17 Feb 2017 10:55:24 +0100 Message-Id: <1487325325-18212-3-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> The parameter name is_async, for genpd_power_off() gives a poor description of its purpose. To clarify, let's rename it to one_dev_on and update the documentation of it in the function header. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 3dc44f2..179bb26 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -276,12 +276,15 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) /** * genpd_power_off - Remove power from a given PM domain. * @genpd: PM domain to power down. - * @is_async: PM domain is powered down from a scheduled work + * @one_dev_on: If invoked from genpd's ->runtime_suspend|resume() callback, the + * RPM status of the releated device is in an intermediate state, not yet turned + * into RPM_SUSPENDED. This means genpd_power_off() must allow one device to not + * be RPM_SUSPENDED, while it tries to power off the PM domain. * * 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 is_async) +static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on) { struct pm_domain_data *pdd; struct gpd_link *link; @@ -317,7 +320,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool is_async) not_suspended++; } - if (not_suspended > 1 || (not_suspended == 1 && is_async)) + if (not_suspended > 1 || (not_suspended == 1 && !one_dev_on)) return -EBUSY; if (genpd->gov && genpd->gov->power_down_ok) { @@ -459,7 +462,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, true); + genpd_power_off(genpd, false); genpd_unlock(genpd); } @@ -578,7 +581,7 @@ static int genpd_runtime_suspend(struct device *dev) return 0; genpd_lock(genpd); - genpd_power_off(genpd, false); + genpd_power_off(genpd, true); genpd_unlock(genpd); return 0; @@ -658,7 +661,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, 0); + genpd_power_off(genpd, true); genpd_unlock(genpd); } 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: 94136 Delivered-To: patches@linaro.org Received: by 10.140.20.99 with SMTP id 90csp89048qgi; Fri, 17 Feb 2017 01:55:33 -0800 (PST) X-Received: by 10.25.74.196 with SMTP id x187mr2101348lfa.30.1487325333666; Fri, 17 Feb 2017 01:55:33 -0800 (PST) Return-Path: Received: from mail-lf0-x231.google.com (mail-lf0-x231.google.com. [2a00:1450:4010:c07::231]) by mx.google.com with ESMTPS id f1si4747269lfa.81.2017.02.17.01.55.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 01:55:33 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) client-ip=2a00:1450:4010:c07::231; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x231.google.com with SMTP id z127so20155804lfa.2 for ; Fri, 17 Feb 2017 01:55:33 -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=NeYImrCAnouc/bna7xdA1man79bN4TEOecvM8/TOEhd/tIVWAMmP2+mdyv0Q/jCYxN f83EG4bgUAtKBzUG3AbiWA7XupPE2Ql9MlI2ciIUGiJMWK+ZhNGZdCewCouldCvNC7qp xRt4/DwH+F+tiJH7AOSn8s2ZNODcyIV+lh41D/xrVpOFaqPDNQ2fZeBAAQ2OIwuRehK2 VVR9Q1az+cvmPnLuTIwqPnKqbU7FXOXPyO/q0s0E2450ovmDPgxFmrIPYrJT2mDkI50J BNfdGAR17505XQS76j8XpMZN585MemTt5ReZ5snLoWkS5n/HqZ76PWkgMZrYQpvPzGKQ MTEw== X-Gm-Message-State: AMke39kIjk54xoHgBFpObQByfQXuN+m2CZyjCgWPfG91Kn/iJNAsUb1lq2KwfAwIdNEx74bRARo= X-Received: by 10.25.229.221 with SMTP id i90mr813639lfk.11.1487325333302; Fri, 17 Feb 2017 01:55:33 -0800 (PST) Return-Path: 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> 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 --- drivers/base/power/domain.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 1.9.1 Tested-by: Lina Iyer 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); }