From patchwork Mon Mar 20 09:32:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95483 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp852514qgd; Mon, 20 Mar 2017 02:33:24 -0700 (PDT) X-Received: by 10.84.233.200 with SMTP id m8mr38430122pln.92.1490002404616; Mon, 20 Mar 2017 02:33:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z190si11979390pfb.188.2017.03.20.02.33.24; Mon, 20 Mar 2017 02:33:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1753654AbdCTJdY (ORCPT + 23 others); Mon, 20 Mar 2017 05:33:24 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:36432 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753458AbdCTJc4 (ORCPT ); Mon, 20 Mar 2017 05:32:56 -0400 Received: by mail-pf0-f175.google.com with SMTP id o126so63458548pfb.3 for ; Mon, 20 Mar 2017 02:32:55 -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=VAtpsp66u03PA5o+V+1AuMFlVe2NFyiT+Q3mC376Mks=; b=WYKBVGd4F/uDYJmIST9NnWsBF3WSv44kRPRqM/+TLYZmaNnHY0LQVeUsZ0E7759hQy CVTYDv7GUpBaBVjOkoQ5AOmWHmBOt9xhwJtuzLiIZtEoghqk2KIJp+9UuUjGRkdK9qs9 EG2d6W+1xiq2tKA/V64G7Z5mRvfUIu5ZddqPU= 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=VAtpsp66u03PA5o+V+1AuMFlVe2NFyiT+Q3mC376Mks=; b=oA4kblj8xbGcxCmB7nMbzuoKBJQ5Hg+dw1XjBp8wINFnIHB65uVysqIAbgqO9/j1u1 k7ara9xXANHFImEVfKBRjV2n7ePcq9PJKKTWg8ZLJzW2x1AY2G+bu2b6D+uPIYCiy82i b3/6tSPCTwmAclCpcyAxGelDO9jQMddg8ZzIf3UnLK2tI5yqwR/ogkJM2XC+w6mR6M7k MP0iDeQjX82mF09oGJg83Estp4TQNW6UJ71ndAiBrCv4hB0Hj3EeV6fFR6XiWZKCje7U QPweMNpfenTvxaSsz6u/M0VhgMLOLsOGYMEGJrJNIVaKEzsuxKtCErzoRQOpAI7mFUUT 4DVw== X-Gm-Message-State: AFeK/H3dLzSsqqZSjtNu4H/sZG+xLQtwZCLGBYAu7Q9I71VVATZoGCHQ+wGit1slMIckv+cZ X-Received: by 10.84.139.195 with SMTP id 61mr39422710plr.109.1490002375090; Mon, 20 Mar 2017 02:32:55 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id c16sm31633620pfl.7.2017.03.20.02.32.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 02:32:54 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Kevin Hilman , Pavel Machek , Len Brown 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, Viresh Kumar Subject: [PATCH V4 9/9] PM / Domain: Add support to parse domain's OPP table Date: Mon, 20 Mar 2017 15:02:21 +0530 Message-Id: <4816e672e5f3495d87c85cda353e29df3885a0b1.1490001099.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Parse the OPP table from of_genpd_add_provider_simple() by calling dev_pm_opp_of_add_table(), if the power domain supports changing of performance states. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 46 +++++++++++++++++++++++++++++++++++++-------- include/linux/pm_domain.h | 1 + 2 files changed, 39 insertions(+), 8 deletions(-) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 51d3afc0476d..8155f95b0db2 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1806,15 +1807,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; @@ -1887,10 +1910,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 d55c0112dcde..821d7cf5974b 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -57,6 +57,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 */