From patchwork Wed Apr 26 10:57:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9701111 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 D0428603F7 for ; Wed, 26 Apr 2017 10:58:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7D9827F90 for ; Wed, 26 Apr 2017 10:58:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB9E428488; Wed, 26 Apr 2017 10:58:30 +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 3CC3527F90 for ; Wed, 26 Apr 2017 10:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2998985AbdDZK62 (ORCPT ); Wed, 26 Apr 2017 06:58:28 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:36357 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2998906AbdDZK5z (ORCPT ); Wed, 26 Apr 2017 06:57:55 -0400 Received: by mail-pg0-f44.google.com with SMTP id t7so3631790pgt.3 for ; Wed, 26 Apr 2017 03:57:54 -0700 (PDT) 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 :in-reply-to:references; bh=FXJeXEklpTI2HOkCxHSnegIIoW+qE6oMPvFq9gq7Wf0=; b=dn55QwYWI60wQzniH9SjCVbHu6+s5jn6HUh4mIH15vYW9mVVT91pF8ahwGNu6CA5E6 wEODYyClWJo1asT/6MPDs9Xtcvlwm2LNGItcC/2srbmToE9vzdein+aqdgwl0fmnSZuN gU0Zr/HQm2XjfrpvHKp0pKvjxjLrj4iw4F+jo= 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:in-reply-to:references; bh=FXJeXEklpTI2HOkCxHSnegIIoW+qE6oMPvFq9gq7Wf0=; b=tgElh1y+f25YgtCKgOgJ0baTS03c/FbIUnn8UJakyqZesSphdCSAE0mebYuoeGNOWJ CnrncpGpzwxTiefafRA7mQGh0fggfC3IpY+KdQ6X1oYEDUPG/1WUmddF25J1Yzha4JcE VCxIRPGKaouIOCj50xTKos1jJ44TnMk3jYETuSqCkrh+1pVb0Nmh7wSUi+cKmOUL+P4i ccAWb0Pbno8VdO1mWwkeBRL05i8LL3cNANwe89xBevXNkaxAKpPPfw8YxkJjjANcDLky 9wc8xN0emFTeYYLVyGcvPmgsOdlo1XuJZWy5b9yaoydOjWkGKhRlKPGEZ2MC1jMAq8Mn UNBg== X-Gm-Message-State: AN3rC/4qVWD3Jn18m5iP8YZochnKKQhfDS4kB7+T//reN8dQit2Lp0af IOS0gR/lA681R7+A X-Received: by 10.98.57.71 with SMTP id g68mr31838039pfa.53.1493204274166; Wed, 26 Apr 2017 03:57:54 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id r1sm41799901pfg.12.2017.04.26.03.57.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Apr 2017 03:57:53 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Len Brown , Pavel Machek Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , robh+dt@kernel.org, lina.iyer@linaro.org, rnayak@codeaurora.org, sudeep.holla@arm.com, Viresh Kumar Subject: [PATCH V6 9/9] PM / Domain: Add support to parse domain's OPP table Date: Wed, 26 Apr 2017 16:27:13 +0530 Message-Id: X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: 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 Parse the OPP table for power domains if they have their set_performance_state() callback set. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 86 ++++++++++++++++++++++++++++++++++++--------- include/linux/pm_domain.h | 1 + 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 85365611b258..17ba541ec3c8 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1818,15 +1819,37 @@ int of_genpd_add_provider_simple(struct device_node *np, mutex_lock(&gpd_list_lock); - if (pm_genpd_present(genpd)) { - ret = genpd_add_provider(np, genpd_xlate_simple, genpd); - if (!ret) { - genpd->provider = &np->fwnode; - genpd->has_provider = true; - genpd->dev.of_node = np; + if (!pm_genpd_present(genpd)) + goto unlock; + + genpd->dev.of_node = np; + + /* Parse genpd OPP table */ + if (genpd->set_performance_state) { + ret = dev_pm_opp_of_add_table(&genpd->dev); + if (ret) { + dev_err(&genpd->dev, "Failed to add OPP table: %d\n", + ret); + goto unlock; + } + + genpd->has_opp_table = true; + } + + ret = genpd_add_provider(np, genpd_xlate_simple, genpd); + if (ret) { + if (genpd->has_opp_table) { + genpd->has_opp_table = false; + dev_pm_opp_of_remove_table(&genpd->dev); } + + goto unlock; } + genpd->provider = &np->fwnode; + genpd->has_provider = true; + +unlock: mutex_unlock(&gpd_list_lock); return ret; @@ -1841,6 +1864,7 @@ EXPORT_SYMBOL_GPL(of_genpd_add_provider_simple); int of_genpd_add_provider_onecell(struct device_node *np, struct genpd_onecell_data *data) { + struct generic_pm_domain *genpd; unsigned int i; int ret = -EINVAL; @@ -1850,14 +1874,29 @@ int of_genpd_add_provider_onecell(struct device_node *np, mutex_lock(&gpd_list_lock); for (i = 0; i < data->num_domains; i++) { - if (!data->domains[i]) + genpd = data->domains[i]; + + if (!genpd) continue; - if (!pm_genpd_present(data->domains[i])) + if (!pm_genpd_present(genpd)) goto error; - data->domains[i]->provider = &np->fwnode; - data->domains[i]->has_provider = true; - data->domains[i]->dev.of_node = np; + genpd->dev.of_node = np; + + /* Parse genpd OPP table */ + if (genpd->set_performance_state) { + ret = dev_pm_opp_of_add_table_indexed(&genpd->dev, i); + if (ret) { + dev_err(&genpd->dev, "Failed to add OPP table for index %d: %d\n", + i, ret); + goto error; + } + + genpd->has_opp_table = true; + } + + genpd->provider = &np->fwnode; + genpd->has_provider = true; } ret = genpd_add_provider(np, genpd_xlate_onecell, data); @@ -1870,10 +1909,18 @@ int of_genpd_add_provider_onecell(struct device_node *np, error: while (i--) { - if (!data->domains[i]) + genpd = data->domains[i]; + + if (!genpd) continue; - data->domains[i]->provider = NULL; - data->domains[i]->has_provider = false; + + genpd->provider = NULL; + genpd->has_provider = false; + + if (genpd->has_opp_table) { + genpd->has_opp_table = false; + dev_pm_opp_of_remove_table(&genpd->dev); + } } mutex_unlock(&gpd_list_lock); @@ -1900,10 +1947,17 @@ void of_genpd_del_provider(struct device_node *np) * provider, set the 'has_provider' to false * so that the PM domain can be safely removed. */ - list_for_each_entry(gpd, &gpd_list, gpd_list_node) - if (gpd->provider == &np->fwnode) + list_for_each_entry(gpd, &gpd_list, gpd_list_node) { + if (gpd->provider == &np->fwnode) { gpd->has_provider = false; + if (!gpd->has_opp_table) + continue; + + dev_pm_opp_of_remove_table(&gpd->dev); + } + } + list_del(&cp->link); of_node_put(cp->node); kfree(cp); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index c01f12b370d2..60fc5b165b91 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -58,6 +58,7 @@ struct generic_pm_domain { struct work_struct power_off_work; struct fwnode_handle *provider; /* Identity of the domain provider */ bool has_provider; + bool has_opp_table; const char *name; atomic_t sd_count; /* Number of subdomains with power "on" */ enum gpd_status status; /* Current state of the domain */