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: 133035 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp168555ljb; Mon, 9 Apr 2018 04:44:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/9HkS9d9mNF9jiWdUDiHLOIb/SQ9kayVk2YB8YQXGvRj9gBb/hoG/2ECIepzvN1fteavQL X-Received: by 10.99.98.196 with SMTP id w187mr25317482pgb.307.1523274290367; Mon, 09 Apr 2018 04:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523274290; cv=none; d=google.com; s=arc-20160816; b=i2hWp7B5+UaigJQT5l+PzcWmepV2uvDamoMkmNQKi/4PE9T/mrKKV+J7CohknpeK4P F3qbsZmS05SIiTvld52w5cTLg+UJ7LRBikYq8UlzC/k2K8PHMVH/+knXBeRIbMnMF/5L Zghajm3VuumzNBaDhiLKQpsWS3DPKqkUz9FhMbaQMYe1RoKVA1wDh2YO0YVjcmnsk/G6 LrSsGtZ0C1BoXoYHvBZUXDltII7k3rs0NGqJIaI6xD5bQa2qJioksd0LxqRZS+rhHKZm rpYgK9GfECdegOOriXUQcIV6LeVSkRQhO7htKtj1S+NayXumAh9AWLU9EBwQiYYnuR+u LhFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=UNtc9YLsR9gj7PTNfDn6DdyccZp+9CPTGr/+AQJ4onM=; b=lgT4FN6QZ8V5K6TdO4UPd+zbRhpvnWD1pyVuH90Y+2Y7mNbun/La7WDYBIV0KXF4BX UOT0SG4aDjfNE4VgDF5JGcxkLGgquybh60WwCjW9w8A4GKs5sxJckbRcgQnaVUvpNqp0 bctb+u85Z7TR09z89ZFsHCVzBLNCar+ufOnnZHfQaR9evT2i7xTNcbwJX+HhCY0G6vcg onFSaOlm3AWaEMICjep3bXmSjKrNew7CRKaShSLjpVUIm9/bgdLdmD/Hm07OXuwdgdqk yQuUPSjYhMTQddGIdsAHL34AoMPH6c3ricUJ65sn3SEOK1AXwAdaHbg+A70RKp4cnJ8c 2eGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C++dqY8G; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si153720pls.422.2018.04.09.04.44.50; Mon, 09 Apr 2018 04:44:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C++dqY8G; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbeDILot (ORCPT + 11 others); 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-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 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(-) -- 2.15.0.194.g9af6a3dea062 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);