From patchwork Fri Dec 22 07:26:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 122630 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1909031qgn; Thu, 21 Dec 2017 23:30:45 -0800 (PST) X-Google-Smtp-Source: ACJfBouIDS7uufPfKuZ/Zzw3+Xg2w5Xzn1pc9SuoeMwJJjAwKJpP+Am69gtFj+o4SyJjs60Z/jY1 X-Received: by 10.99.176.3 with SMTP id h3mr12219479pgf.207.1513927845615; Thu, 21 Dec 2017 23:30:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513927845; cv=none; d=google.com; s=arc-20160816; b=OZnYyOuZlJhoGKNqsPCm/TXclGkHSwyhuv/ALPzp5tQoFSbxHyH2ofCt358/k8AwCm dsgAXcNNt8TBI3FQDgFesxB2gsnLnT/vj+DHtukGDxgqSCGwLjZrnFs7zoPds6WyFtoN jqzYEqJeQU1LSncNsbx+uatexj/WTYWVn2nPAyZ5D1Zba+nup93THOkr3fwKXXmKBHRQ WE+NCV6hK59R/W5gQc1Q98dwBCWOhr+iwxSlbKrVYTYpnk2lwBqo3iisXKcZsVSJr1AW WMu/9931vINRDAQqvpdD43WUz5adRDBRHVTKvFYbpw+cLsCSwtGRoxnT0K46sleNXvoR c9Tw== 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=Vfd0xksIA8RyZZZu0XL12rpoDokLKjx9XKZtzoHvtqM=; b=WwHc8exMY/67L7PQVKGpqbcxASBcqtNhm+zEeMDGf5zOsraLufmVv9WZUf4HrgxLiW Zu2fVUNyYp9yT6zOAdWKj8Crr1clzeViH1n+POLENNtbstjGJqp39C1plgI+nMBW97vb tg4ywFk4IdYbvpZP0FdZzcUJoLK0vfkvdqnYvyBx/M6iX+D9ZjV922f4XWiCThEDEvIW OUaSm0EzO86MpQNAAFgogd9RgyyjvtNXyDEr//db8oWBsCwzqg/0SNLiiUeouf+ljPP/ JE0ycqqMZHYT0H+pwZ+gW8zFeJ9ds6eKwQUqPZBWHii3838m/ioCfjj/CVMVTbZbjfOg ZVYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R8Mgfo4f; 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 i187si8044784pgc.532.2017.12.21.23.30.45; Thu, 21 Dec 2017 23:30:45 -0800 (PST) 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=R8Mgfo4f; 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 S1755501AbdLVHan (ORCPT + 11 others); Fri, 22 Dec 2017 02:30:43 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:45292 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755386AbdLVHaj (ORCPT ); Fri, 22 Dec 2017 02:30:39 -0500 Received: by mail-pg0-f67.google.com with SMTP id m25so14205762pgv.12 for ; Thu, 21 Dec 2017 23:30:39 -0800 (PST) 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=Vfd0xksIA8RyZZZu0XL12rpoDokLKjx9XKZtzoHvtqM=; b=R8Mgfo4foPwEk1MiNeQMyK2qwiBIaej9meYz+QyV/Nb5BIBYWwlC3v4d7TWl5GUHCH q//IGfd1qOaLmiPhFwA2bxWddokQ4Hv7XMtHFx/el5KE0mXx39oHoRW73Aai5pH+yPHx ML9KxpJ3FuYqrh2ZHZKchwJTEhi2JPatzTP1M= 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=Vfd0xksIA8RyZZZu0XL12rpoDokLKjx9XKZtzoHvtqM=; b=Ejmpc01Mr4K0frHRM9iV97nEBp7oeREYzIip0Ug5WKert9f0a3folfbOrvJf7LMf8i G9sZl0/2+ilxa8fswpTh8JUo/Nhl44B5oA6gkygDnV7zgDNcaJLc24Sw0WJs+mTmLQcX N0R9iAzmnFa5e+6dITW/hdEkWllOn7X6Rj78Cqx0C8pMGmcOWCdgP4pSA/1PsG30tqor dRi1peVg4vLC7bD4ZbFk0sWeOvcmgUOL6E2SOsVhe5IsBXKmcXMEV8SGblfhszqByAf6 Z6ltCerfdbInmQY/40GEVQWCAB/bcggoPnqlkJaEeaa6Utga97+K3yFb36JVs3Zn17Mv sX+A== X-Gm-Message-State: AKGB3mLtldHoIxDSBruGO8pycPoWMPUP1LjV7QUcfYz/G6UYKoXso0m0 Rfwy6/z4jxLl0Y6+3MBk4bUTrg== X-Received: by 10.99.164.25 with SMTP id c25mr11998381pgf.280.1513927838882; Thu, 21 Dec 2017 23:30:38 -0800 (PST) Received: from localhost ([122.172.139.116]) by smtp.gmail.com with ESMTPSA id q68sm40893866pfb.1.2017.12.21.23.30.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:30:38 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Kevin Hilman , "Rafael J. Wysocki" , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Stephen Boyd , Nishanth Menon , Vincent Guittot , robh+dt@kernel.org, rnayak@codeaurora.org, sudeep.holla@arm.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] PM / Domain: Add support to parse domain's OPP table Date: Fri, 22 Dec 2017 12:56:28 +0530 Message-Id: <596dd0d16dcb31fd35d6a38835d1a3d56254b6ce.1513926033.git.viresh.kumar@linaro.org> 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 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 | 78 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 16 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 013c1e206167..1ad4ad0b0de0 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1900,15 +1901,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; - genpd->dev.of_node = np; + 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; @@ -1923,6 +1942,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; @@ -1935,14 +1955,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; - 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->provider = &np->fwnode; + genpd->has_provider = true; } ret = genpd_add_provider(np, data->xlate, data); @@ -1955,10 +1988,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); @@ -1985,10 +2024,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);