From patchwork Mon Apr 9 11:43:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10331157 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 94D4B6020F for ; Mon, 9 Apr 2018 11:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 875F8285F9 for ; Mon, 9 Apr 2018 11:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C05728B13; Mon, 9 Apr 2018 11:44:50 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, 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 0F031285F9 for ; Mon, 9 Apr 2018 11:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbeDILot (ORCPT ); Mon, 9 Apr 2018 07:44:49 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35305 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751851AbeDILod (ORCPT ); Mon, 9 Apr 2018 07:44:33 -0400 Received: by mail-pg0-f65.google.com with SMTP id j3so145201pgf.2 for ; Mon, 09 Apr 2018 04:44:33 -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=UNtc9YLsR9gj7PTNfDn6DdyccZp+9CPTGr/+AQJ4onM=; b=C++dqY8GhMqDIJVITgV+Mwn+g5eMxnuaNopuMMAAVLSX6WaBB1gABuhtppe+wnJthD 2TuQ8sLR4E/kYCEfX6hiWe7x+UAkbijHlaYl4pZYuUSKmep+X2LeR565qeMesZdVXzyC 2tJ6MWWKe6xHgsBgasHddOnR7v7snvGa4kcqw= 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=UNtc9YLsR9gj7PTNfDn6DdyccZp+9CPTGr/+AQJ4onM=; b=NZeo9jSUeKi1bwQEYYShHCO76V79tvT8sZM+8cKOiHm+fkvTxEJC6LApc180NZmYaw NLMbxhWe9aB9sw0ew+UDUoVvwGG+9FdP1voLT/J4cJdh8qHNwkNu3xCLNQJYXTB2JVnk FFETSGV72mr4FEML9vnQKKt9p9aohXa9NtjeaU4TP5ug2gp0BPpiZxO1hjm6I1PGGNpu hmH4OGq8i206qoyVl3CSjZ4Jypg3tvAt2/H+mffZGzIvPJFNMX03xZHQEv4y+zULk0ze G68rgm7dTOBsqJ3c4YbSdVfY7GJ3Ad/jf+P1iEgepf9YiVK9nLbw9RU5kIZB2kBTdoGe /1cw== X-Gm-Message-State: ALQs6tAh18nlml7+NHqECBWijCSV4YPhycfBJMWoXbvqx0Q6f92Wb96R CPdjaxIH8hktGMRAV1dG+yUsKg== X-Google-Smtp-Source: AIpwx4/8GcpthTAp1xVT/HQctXtT3fxv2GOk44KCxFGnW7XsAo+moI6/MsvNG1p7zt3r+BKSv+ijMA== X-Received: by 10.99.127.3 with SMTP id a3mr11489004pgd.267.1523274273362; Mon, 09 Apr 2018 04:44:33 -0700 (PDT) Received: from localhost ([122.171.228.188]) by smtp.gmail.com with ESMTPSA id p1sm681794pgc.15.2018.04.09.04.44.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 04:44:32 -0700 (PDT) From: Viresh Kumar To: Ulf Hansson , Stephen Boyd , "Rafael J. Wysocki" , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , Rajendra Nayak , Vincent Guittot , linux-pm@vger.kernel.org Subject: [PATCH V2 08/11] PM / Domain: Add support to parse domain's OPP table Date: Mon, 9 Apr 2018 17:13:48 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 The generic power domains can have an OPP table for themselves now, and phandle of their OPP nodes can be used by the devices powered by the domain. In order for the OPP core to translate requirements between the devices and their power domains, both need to have an OPP table in kernel. Parse the OPP table for power domains if they have their set_performance_state() callback set. With this patch, an OPP table would be created for the genpd in kernel based on the OPP table present in DT, if the genpd have its set_performance_state() callback set. Signed-off-by: Viresh Kumar Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 76 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 4a3dc9cc0848..5c0019d70d76 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1895,14 +1896,33 @@ int of_genpd_add_provider_simple(struct device_node *np, mutex_lock(&gpd_list_lock); - if (genpd_present(genpd)) { - ret = genpd_add_provider(np, genpd_xlate_simple, genpd); - if (!ret) { - genpd->provider = &np->fwnode; - genpd->has_provider = true; + if (!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; } } + ret = genpd_add_provider(np, genpd_xlate_simple, genpd); + if (ret) { + if (genpd->set_performance_state) + 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; @@ -1917,6 +1937,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; @@ -1929,13 +1950,27 @@ int of_genpd_add_provider_onecell(struct device_node *np, data->xlate = genpd_xlate_onecell; for (i = 0; i < data->num_domains; i++) { - if (!data->domains[i]) + genpd = data->domains[i]; + + if (!genpd) continue; - if (!genpd_present(data->domains[i])) + if (!genpd_present(genpd)) goto error; - data->domains[i]->provider = &np->fwnode; - data->domains[i]->has_provider = true; + 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->provider = &np->fwnode; + genpd->has_provider = true; } ret = genpd_add_provider(np, data->xlate, data); @@ -1948,10 +1983,16 @@ 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->set_performance_state) + dev_pm_opp_of_remove_table(&genpd->dev); } mutex_unlock(&gpd_list_lock); @@ -1978,10 +2019,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->set_performance_state) + continue; + + dev_pm_opp_of_remove_table(&gpd->dev); + } + } + list_del(&cp->link); of_node_put(cp->node); kfree(cp);