From patchwork Tue Aug 16 09:49:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 9283115 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 9C1BE607FD for ; Tue, 16 Aug 2016 09:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C87F29134 for ; Tue, 16 Aug 2016 09:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80D7F29136; Tue, 16 Aug 2016 09:52:15 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 03ACA29134 for ; Tue, 16 Aug 2016 09:52:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753343AbcHPJwN (ORCPT ); Tue, 16 Aug 2016 05:52:13 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:11976 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753163AbcHPJug (ORCPT ); Tue, 16 Aug 2016 05:50:36 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com id ; Tue, 16 Aug 2016 02:50:29 -0700 Received: from HQHUB102.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Tue, 16 Aug 2016 02:46:40 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 16 Aug 2016 02:46:40 -0700 Received: from HQMAIL112.nvidia.com (172.18.146.18) by HQHUB102.nvidia.com (172.20.187.25) with Microsoft SMTP Server (TLS) id 8.3.406.0; Tue, 16 Aug 2016 02:50:24 -0700 Received: from HQMAIL103.nvidia.com (172.20.187.11) by HQMAIL112.nvidia.com (172.18.146.18) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 16 Aug 2016 09:50:24 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL103.nvidia.com (172.20.187.11) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Tue, 16 Aug 2016 09:50:24 +0000 Received: from jonathanh-lm.nvidia.com (Not Verified[10.26.11.90]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,5,8150) id ; Tue, 16 Aug 2016 02:50:23 -0700 From: Jon Hunter To: "Rafael J. Wysocki" , Kevin Hilman , Ulf Hansson CC: Thierry Reding , Kukjin Kim , Krzysztof Kozlowski , Alexander Aring , Eric Anholt , , , , Jon Hunter Subject: [PATCH 09/10] PM / Domains: Store the provider in the PM domain structure Date: Tue, 16 Aug 2016 10:49:35 +0100 Message-ID: <1471340976-5379-10-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1471340976-5379-1-git-send-email-jonathanh@nvidia.com> References: <1471340976-5379-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 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 It is possible that a device has more than one provider of PM domains and to support the removal of a PM domain by provider, it is necessary to store a reference to the provider in the PM domain structure. Therefore, store a reference to the firmware node handle in the PM domain structure and populate it when providers (only device-tree based providers are currently supported by PM domains) are registered. Signed-off-by: Jon Hunter --- drivers/base/power/domain.c | 18 ++++++++++++++---- include/linux/pm_domain.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 72b973539205..0bc145e8e902 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1539,6 +1539,8 @@ int of_genpd_add_provider_simple(struct device_node *np, return -EINVAL; } + genpd->provider = &np->fwnode; + ret = genpd_add_provider(np, genpd_xlate_simple, genpd); mutex_unlock(&gpd_list_lock); @@ -1564,10 +1566,10 @@ int of_genpd_add_provider_onecell(struct device_node *np, mutex_lock(&gpd_list_lock); for (i = 0; i < data->num_domains; i++) { - if (!pm_genpd_present(data->domains[i])) { - mutex_unlock(&gpd_list_lock); - return -EINVAL; - } + if (!pm_genpd_present(data->domains[i])) + goto error; + + data->domains[i]->provider = &np->fwnode; } ret = genpd_add_provider(np, genpd_xlate_onecell, data); @@ -1575,6 +1577,14 @@ int of_genpd_add_provider_onecell(struct device_node *np, mutex_unlock(&gpd_list_lock); return ret; + +error: + while (i--) + data->domains[i]->provider = NULL; + + mutex_unlock(&gpd_list_lock); + + return -EINVAL; } EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index fbdc5c4588ef..4aa285e44eb0 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -51,6 +51,7 @@ struct generic_pm_domain { struct mutex lock; struct dev_power_governor *gov; struct work_struct power_off_work; + struct fwnode_handle *provider; /* Identity of the domain provider */ const char *name; atomic_t sd_count; /* Number of subdomains with power "on" */ enum gpd_status status; /* Current state of the domain */