From patchwork Fri Jun 29 09:15:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 140537 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp598361ljj; Fri, 29 Jun 2018 02:15:53 -0700 (PDT) X-Received: by 2002:a2e:86d5:: with SMTP id n21-v6mr6131693ljj.48.1530263753845; Fri, 29 Jun 2018 02:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530263753; cv=none; d=google.com; s=arc-20160816; b=QzC6EhIVCUsC97bzbNaYkZyyVFNGkqkAg8WpbsWVvpOnfFE6luVs4mgxyy6utLoEz0 sAJaEVhRKbMm2YwRTZyfc7dHsgGRyzGjTHP+8poYfiW7Pv8N9XV6wG8i0z+MUHOb5cWY 5LmJCNZ0oPv7Mft+V2r+h8lsCyCr30qB0V29/72WgGIzmrH2USxgI8W+9RD/+Ywk3YLl 5x7k4WUcT1GPFQ9YrdKdvHihQ23QofnfPtIJ6jgdzR9+dwJW79TgSdSkuMATh/vZEXQM 0h5LGs+p5krRFkkFyOHLzDrCzfOAfKAHxQfKBxSGhPNtIsPKnDLpaMy1OaFD3Yd7RfX4 YglQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=CLMRKj5KWuRuKyfAm+vqQVbCS5qqfMLjSG1gP+Lq7Fo=; b=0Hh8n9ow9CExQCsRXQzH7KVVaDTsmomlwlE21SpB3+Js/i79cJY9w8yOglpUdfGKsB oyl8PQP07G8YCmg9wvwAU+L3b6bU+11uA+QBmj3vi+9ZxJMgl6Zw0VCFesXg2UVSlRFv UDUjFNjidSSdvFNk08Eti/gWobeT+GnObWZCP5Kx0ubkzaCcZfH9FtDWp8cEVgMY6TUR nsDhO7duNAcBmIQVYb4uiAiyocthPr4euzFhXMiUfwWsPjwOLA//9lynSqawOBqQ9RJ7 Nj64U+qxFqGn6AE2M2+Qn79WLlmBkatUYAuSZOs5+kmArLn28dPO0Z0yv8TZaIGSZ9px 7V4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T7JlmJ3a; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a139-v6sor2186367lfa.92.2018.06.29.02.15.53 for (Google Transport Security); Fri, 29 Jun 2018 02:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T7JlmJ3a; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=CLMRKj5KWuRuKyfAm+vqQVbCS5qqfMLjSG1gP+Lq7Fo=; b=T7JlmJ3adtCzonlNNnHELinEW8KnBamU7j6BidBXRIBYaSnPSEuuZf0bBViLm+xTdl /VEoHmt1ZGWb7591wRo2TgqKo77j0xgimXtVem6kwrCBZN5+37XUgAZBkaeEGc0RvK4U xy+eWbF3R56DguZty7SwvZzIifg/S+tSzLAtU= 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; bh=CLMRKj5KWuRuKyfAm+vqQVbCS5qqfMLjSG1gP+Lq7Fo=; b=bBmkqgZyeKiJpBOmMcsQBn02Hsv1OTuNq3doBM9iRVVK6z4Ko6UstcK7IaM3UCxWOQ DB3YOi9rYtTeSzcgQHSOaL95P/Jm5/sUb1mTs1gbGB90IMEVJNF1kmCIEyq6jF+dy+bH SVbkNqiYE6uJZa3AyeVOqbaTJqR7Yh6NkNskKyVVmlwSeap5YEL0rmSnmfGKtDqGLusl ECBR07BuVmjB6l0M1PCTFpA6g9tUPJu2kqZIHfjOdLLWaVvmRPWb1nXpxIj2gN1TAuzI 5fDf6erp7Pgr0tmgPy6Ax3kh8XE+9WW2NeJVqxLU0onIkqwjLYFSssSsVkKgNw8n+qTs EVIw== X-Gm-Message-State: APt69E11sb36RLs6HVzoYNvfSXAirIkCWz2SX/SKjVVu2ZDsqKx5SVp1 pwL7wIeiyibq+o3wmAmdmZh3jcpFOvLZlg== X-Google-Smtp-Source: AAOMgpfNgQ4PjMuSfKZNTVOV2edndrZ+ZOPkwqzKY7H1VKNkxaFzH/5caJY48ZAzoP9H34c5VbZymw== X-Received: by 2002:a19:dd81:: with SMTP id w1-v6mr9767661lfi.114.1530263753579; Fri, 29 Jun 2018 02:15:53 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v24-v6sm808963ljc.24.2018.06.29.02.15.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 02:15:52 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH] PM / Domains: Don't power on at attach for the multi PM domain case Date: Fri, 29 Jun 2018 11:15:37 +0200 Message-Id: <20180629091537.26864-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 There are no legacy behavior in drivers to consider while attaching a device to genpd - for the multiple PM domain case. For that reason, let's instead require the driver to runtime resume the device, via calling pm_runtime_get_sync() for example, when it needs to power on the corresponding PM domain. This allows us to improve the situation during attach. Instead of always power on the PM domain, which may be unnecessary, let's leave it in its current state. Additionally, to avoid the PM domain to stay powered on, let's schedule a power off work. Fixes: 3c095f32a92b ("PM / Domains: Add support for multi PM domains...") Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c298de8a8308..9e8484189034 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2235,7 +2235,7 @@ static void genpd_dev_pm_sync(struct device *dev) } static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, - unsigned int index) + unsigned int index, bool power_on) { struct of_phandle_args pd_args; struct generic_pm_domain *pd; @@ -2271,9 +2271,11 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np, dev->pm_domain->detach = genpd_dev_pm_detach; dev->pm_domain->sync = genpd_dev_pm_sync; - genpd_lock(pd); - ret = genpd_power_on(pd, 0); - genpd_unlock(pd); + if (power_on) { + genpd_lock(pd); + ret = genpd_power_on(pd, 0); + genpd_unlock(pd); + } if (ret) genpd_remove_device(pd, dev); @@ -2307,7 +2309,7 @@ int genpd_dev_pm_attach(struct device *dev) "#power-domain-cells") != 1) return 0; - return __genpd_dev_pm_attach(dev, dev->of_node, 0); + return __genpd_dev_pm_attach(dev, dev->of_node, 0, true); } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach); @@ -2359,14 +2361,14 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } /* Try to attach the device to the PM domain at the specified index. */ - ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index); + ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index, false); if (ret < 1) { device_unregister(genpd_dev); return ret ? ERR_PTR(ret) : NULL; } - pm_runtime_set_active(genpd_dev); pm_runtime_enable(genpd_dev); + genpd_queue_power_off_work(dev_to_genpd(genpd_dev)); return genpd_dev; }