From patchwork Fri Oct 12 11:11:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 148755 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp599173lji; Fri, 12 Oct 2018 04:12:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV635nKBhiOPVdDlQgTh4pY0yE3nfCvAquzqA19xgwtGQ0bvOn9HRZz9KDMqKuWZQSD7iyIZF X-Received: by 2002:a17:902:5e3:: with SMTP id f90-v6mr5643182plf.286.1539342731996; Fri, 12 Oct 2018 04:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539342731; cv=none; d=google.com; s=arc-20160816; b=GE22DqE0zOwTqexT5Nw+Mg4DFcqNNQxCJfUQi3P7Vdi5SXuy2hkXh1GcIsICsN9JeP 7wSrSeimEYNrevI1ZMXHr9vv8v9D5XRqng+FozBPaN6QrUHFvMEm+I2FIx9pjnLvmKAe NP8NnLsRKBxbannRF+SjYpBM43choxTzHvpxLQo15mo9JWZvLQuISVzvQhMUJ0wbTlNd n0NR6MkNmBtxnYmAAun5S/T4XlxM8kMt66lOmPrhp22RtBTBXnLXaDnplpB+c/q9sASb u/3vfpwg1WJrAPBdabMr4Nwnrbr/6Nsu3rKC5HAVovDHYxWttqT2FRDuSguEq94xwibs jaJA== 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:message-id:date :subject:cc:to:from:dkim-signature; bh=tFludSDWfmu59Yda7wPTpBXSCzbJ9HkYZfHCRf1lMuA=; b=Klj4Cf1ocW7+KSDA8CW3kZSGqosAMV/ooLqSuxQop7I1yOk4oe+gwYhPYnHhak6KKA XIjqtzAI4+1pLwVsueNq3FsdCIeNG0XQikH9kuMqeYYZotsImq51X0INRDbiwSDAqVdt nAWgiQQhVbLKUPo0/nfeWndJQe0ByGYTNCiQBx9rnwtUczTBapPrZgy7o2WFh3eVraJX 8WXZoOLXLnWj4IW/rpmscjF5uxVk4O46JHQJGqazMo1BE4eJsb8l2+Yi61hDgjab8BvN g6orTVoa7o7DAuFze7/Em8kDD5ovPK6aAhIDRWcSTwlGMb8K+BhAbSLhFvnpL601Z5PD N3eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Jmt2y/NC"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r198-v6si970181pgr.456.2018.10.12.04.12.11; Fri, 12 Oct 2018 04:12:11 -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 header.s=google header.b="Jmt2y/NC"; 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 S1728585AbeJLSoF (ORCPT + 32 others); Fri, 12 Oct 2018 14:44:05 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46243 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbeJLSoE (ORCPT ); Fri, 12 Oct 2018 14:44:04 -0400 Received: by mail-pl1-f195.google.com with SMTP id v5-v6so5775582plz.13 for ; Fri, 12 Oct 2018 04:12:08 -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; bh=tFludSDWfmu59Yda7wPTpBXSCzbJ9HkYZfHCRf1lMuA=; b=Jmt2y/NCLwN416KNrQMN17HrZZlZnY2TvYunD+RbJmi2hIvKbxFBH1DopThfxTEpwp z6cLd3UkobbUBsvKWvsVZHvjZAs0cYQ3kcynbVaEtT7Po28AWAy1X8Mh19Hk2qqTzxPU n8OXeTSsdTIqdLThOplthf9IGJCIWRwrSp8eA= 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; bh=tFludSDWfmu59Yda7wPTpBXSCzbJ9HkYZfHCRf1lMuA=; b=kY+Kotrgxxbhc6/dWK7Nv0bY3DvVneWvQFVlHa599VtrVbIxp/64jv1dLnKgYES913 XXVYFaKmgEqfpHGlP+cFR7TeVKDFQdQLBFkpdk1UNe2BtBmLvFJwitzeKbjH7nbA4odM 7sgVANgn1JNSaXAUrX2mXHMuw8GMBiPZIr5YS0v/uOyRO1/Q3WVyAUHapQTSPVi+vTMo bOTmozbUl6z/Z6ToIKVcgsIZOceHITuhLDmUlJdw3YwL7ea/HciRPamkroG84c3ZbRha sx1EirQnw2wBCwTI/QxK6p6yLQOTy47jYG8koDVjABLbJPG8GXdVeGDg//sJzIMowGGK 9v4A== X-Gm-Message-State: ABuFfohAVyAEy7uycfc8glSOpQ9vNi8ejkLl0Ud58c4giMyH5ZA4QL++ AFogbaRlotHfni5BfLSHwkRXWg== X-Received: by 2002:a17:902:3a2:: with SMTP id d31-v6mr5496193pld.287.1539342728164; Fri, 12 Oct 2018 04:12:08 -0700 (PDT) Received: from localhost ([122.171.67.41]) by smtp.gmail.com with ESMTPSA id l83-v6sm3043645pfi.172.2018.10.12.04.12.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 04:12:07 -0700 (PDT) From: Viresh Kumar To: ulf.hansson@linaro.org, "Rafael J. Wysocki" , Kevin Hilman , Pavel Machek , Len Brown , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , niklas.cassel@linaro.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 8/9] OPP: Rename and relocate of_genpd_opp_to_performance_state() Date: Fri, 12 Oct 2018 16:41:16 +0530 Message-Id: X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The OPP core already has the performance state values for each of the genpd's OPPs and there is no need to call the genpd callback again to get the performance state for the case where the end device doesn't have an OPP table and has the "required-opps" property directly in its node. This commit renames of_genpd_opp_to_performance_state() as of_get_required_opp_performance_state() and moves it to the OPP core, as it is all about OPP stuff now. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 48 ------------------------------------- drivers/opp/of.c | 44 ++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 9 ------- include/linux/pm_opp.h | 5 ++++ 4 files changed, 49 insertions(+), 57 deletions(-) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 2c82194d2a30..55f3a172f6b4 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2547,54 +2547,6 @@ unsigned int genpd_opp_to_performance_state(struct device *genpd_dev, } EXPORT_SYMBOL_GPL(genpd_opp_to_performance_state); -/** - * of_genpd_opp_to_performance_state- Gets performance state of device's - * power domain corresponding to a DT node's "required-opps" property. - * - * @dev: Device for which the performance-state needs to be found. - * @np: DT node where the "required-opps" property is present. This can be - * the device node itself (if it doesn't have an OPP table) or a node - * within the OPP table of a device (if device has an OPP table). - * - * Returns performance state corresponding to the "required-opps" property of - * a DT node. This calls platform specific genpd->opp_to_performance_state() - * callback to translate power domain OPP to performance state. - * - * Returns performance state on success and 0 on failure. - */ -unsigned int of_genpd_opp_to_performance_state(struct device *dev, - struct device_node *np) -{ - struct generic_pm_domain *genpd; - struct dev_pm_opp *opp; - int state = 0; - - genpd = dev_to_genpd(dev); - if (IS_ERR(genpd)) - return 0; - - if (unlikely(!genpd->set_performance_state)) - return 0; - - genpd_lock(genpd); - - opp = of_dev_pm_opp_find_required_opp(&genpd->dev, np); - if (IS_ERR(opp)) { - dev_err(dev, "Failed to find required OPP: %ld\n", - PTR_ERR(opp)); - goto unlock; - } - - state = genpd->opp_to_performance_state(genpd, opp); - dev_pm_opp_put(opp); - -unlock: - genpd_unlock(genpd); - - return state; -} -EXPORT_SYMBOL_GPL(of_genpd_opp_to_performance_state); - static int __init genpd_bus_init(void) { return bus_register(&genpd_bus_type); diff --git a/drivers/opp/of.c b/drivers/opp/of.c index f4e8895542ca..b059d833f920 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -969,6 +969,50 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, } EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus); +/** + * of_get_required_opp_performance_state() - Search for required OPP and return its performance state. + * @np: Node that contains the "required-opps" property. + * @index: Index of the phandle to parse. + * + * Returns the performance state of the OPP pointed out by the "required-opps" + * property at @index in @np. + * + * Return: Positive performance state on success, otherwise 0 on errors. + */ +unsigned int of_get_required_opp_performance_state(struct device_node *np, + int index) +{ + struct dev_pm_opp *opp; + struct device_node *required_np; + struct opp_table *opp_table; + unsigned int pstate = 0; + + required_np = of_parse_required_opp(np, index); + if (!required_np) + return -ENODEV; + + opp_table = _find_table_of_opp_np(required_np); + if (IS_ERR(opp_table)) { + pr_err("%s: Failed to find required OPP table %pOF: %ld\n", + __func__, np, PTR_ERR(opp_table)); + goto put_required_np; + } + + opp = _find_opp_of_np(opp_table, required_np); + if (opp) { + pstate = opp->pstate; + dev_pm_opp_put(opp); + } + + dev_pm_opp_put_opp_table(opp_table); + +put_required_np: + of_node_put(required_np); + + return pstate; +} +EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state); + /** * of_dev_pm_opp_find_required_opp() - Search for required OPP. * @dev: The device whose OPP node is referenced by the 'np' DT node. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index e03f300f7468..80672bcb1216 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -235,8 +235,6 @@ int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); unsigned int genpd_opp_to_performance_state(struct device *genpd_dev, struct dev_pm_opp *opp); -unsigned int of_genpd_opp_to_performance_state(struct device *dev, - struct device_node *np); int genpd_dev_pm_attach(struct device *dev); struct device *genpd_dev_pm_attach_by_id(struct device *dev, @@ -282,13 +280,6 @@ genpd_opp_to_performance_state(struct device *genpd_dev, struct dev_pm_opp *opp) return 0; } -static inline unsigned int -of_genpd_opp_to_performance_state(struct device *dev, - struct device_node *np) -{ - return 0; -} - static inline int genpd_dev_pm_attach(struct device *dev) { return 0; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index b14600ce078f..f440e625f1fd 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -315,6 +315,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpuma struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); +unsigned int of_get_required_opp_performance_state(struct device_node *np, int index); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -357,6 +358,10 @@ static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) { return NULL; } +static inline unsigned int of_get_required_opp_performance_state(struct device_node *np, int index) +{ + return 0; +} #endif #endif /* __LINUX_OPP_H__ */