From patchwork Fri Dec 22 07:26:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 122631 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1909153qgn; Thu, 21 Dec 2017 23:30:55 -0800 (PST) X-Google-Smtp-Source: ACJfBouQNfC9O/8HNooohl+l1cJvE0RCKkMkKFhEh22KKFLOzYJlzyEY6fNaARPKIFkMDx2jCq7n X-Received: by 10.98.247.16 with SMTP id h16mr13225480pfi.242.1513927854978; Thu, 21 Dec 2017 23:30:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513927854; cv=none; d=google.com; s=arc-20160816; b=0p0L6b0T6q0LZQqtkaMfXvD7Qc7TEUrmBrW5h7zqHOkn7l1kYllbPnLHln6khEwljT wz+uU3kUFW+Pf8ewxZob2Yu0v/RJ4e34gxKl3cTK+8Ajh8S5QHtxFmMSo6BPlXZAWBxi yjhgTaVN3VxP3uuvxkRtB+jpmQkBpxOYer/6H7dn+SbPJZMqW9Bg3idxuhta6zV1BsuJ HLISqo2LhgJUkq1CaQagL7jdfP9S2/5/4Jfuua3/o+0BqcymlrKjhF4nQ9ClOCJ9cY0a 7cE4Yjmp8xj84bPNg4MPSi9i/DgOB6Ia7et4v/IAuezTUZZ2tCMQiNd0kvFVDevNo/Z1 xhvQ== 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=ExC73asIywp2Liwd6U/tX41Ktc+XpKrNEqPs2xq3pJc=; b=IkRWjrZj/O259sITURLatkZnTQDOlTut0VVyfEfXY694Jir1RP7hAXjzmL+1W8v8q7 Cutp8AS5FG7FgLOtmFlhVhfsFgGmhCki8mBSTOGOv6QGNE7PEN53gGucVlfv46AxMdfr 9Krb15Fo7LLhZth8TC/xd2QUuIA/OaZID7PQlOlJXmtsivm8hr9i7TTkMDEuKYjqzuR5 jTmOZ9HFvzC8ojP1u7irBGOP2TYyXvtsnEVSYLDKDesswb0sCw/WhXaBZe42LisW8kgS DtZDxmJbkp3A2oaaNxD4LTIYqM0O/k5lZOiPCXHqFkgTtO2M+iPdITVBPgHhPZOEc5Z8 G4ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FKWbUSn6; 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 e91si16288349plb.28.2017.12.21.23.30.54; Thu, 21 Dec 2017 23:30:54 -0800 (PST) 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=FKWbUSn6; 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 S1752198AbdLVHav (ORCPT + 28 others); Fri, 22 Dec 2017 02:30:51 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:32952 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755757AbdLVHaq (ORCPT ); Fri, 22 Dec 2017 02:30:46 -0500 Received: by mail-pl0-f66.google.com with SMTP id 1so11022259plv.0 for ; Thu, 21 Dec 2017 23:30:46 -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=ExC73asIywp2Liwd6U/tX41Ktc+XpKrNEqPs2xq3pJc=; b=FKWbUSn6+vvf9ZlQxhbLYmtNsVhNWRO/PESu2kzP6oz/2Z8FzDuGhYKzVxrl8uJPb+ OCwu4jV5LYyN0cTUnxy2xSqk0wK17B3MhObh71mL+f+3t3GGPl1E8YdQuL/IwSQwLNYi nsR1ZOm0m9BChkQGWoq2WIo9BvJrhSXR4gsY8= 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=ExC73asIywp2Liwd6U/tX41Ktc+XpKrNEqPs2xq3pJc=; b=IS0JxM7er7k8XB6TPyU0cLLPVQOj/BpU/rz/jekTjQdlUF/l7ryLcrFZC9WGFwzFgO CwerSS+4P+/W4FKj/3NX5OMHlbxQfoINnQQwJx5e8gg33wkr45RqZTuF+x1tlkrrQkEE 6/YVqf/Fm/89p0/gp6C2IZcwLzol6o63TepW9ZLL0AwT2bVLp6cqmaJ7iFVv+Gt3mzGO Gtr3jK37SU6MKJdgxlwO2jDF3RzsOmYv17X76L4MSwNbAOfqlYxupMrhUrq+PTsogyxj 0fqNItJllWpqXHoSwdx8G81M8VSPONvUHpvqub2NZeWxJz5KRQg3dbO9jHTpPe2j6Q1W P3QA== X-Gm-Message-State: AKGB3mIH+JMKKf7rorlyc/pPQHgAMNFxis+u5lYR+n4HKjczFB1L90r1 PnU4voa/ek0Dt4lor2HSTix8XQ== X-Received: by 10.84.217.131 with SMTP id p3mr13579747pli.270.1513927846049; Thu, 21 Dec 2017 23:30:46 -0800 (PST) Received: from localhost ([122.172.139.116]) by smtp.gmail.com with ESMTPSA id o70sm44031027pfk.79.2017.12.21.23.30.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:30:45 -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 5/7] PM / Domain: Implement of_dev_pm_genpd_get_performance_state() Date: Fri, 22 Dec 2017 12:56:29 +0530 Message-Id: <755aabf2ad16d3a2131483407d7f580431571a00.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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements of_dev_pm_genpd_get_performance_state() which can be used from the device drivers or the OPP core to find the performance state encoded in the "required-opp" property of a node. Different platforms may encode the performance state differently using the OPP table (they may simply return value of opp-hz or opp-microvolt, or apply some algorithm on top of those values) and so a new callback is implemented to allow platform specific drivers to convert the power domain OPP to a performance state. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 11 +++++++++++ 2 files changed, 59 insertions(+) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1ad4ad0b0de0..ef43b75982fa 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2415,6 +2415,54 @@ int of_genpd_parse_idle_states(struct device_node *dn, } EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); +/** + * of_dev_pm_genpd_get_performance_state- Gets performance state of device's + * power domain corresponding to a DT node's "required-opp" property. + * + * @dev: Device for which the performance-state needs to be found. + * @np: DT node where the "required-opp" 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). + * @state: Pointer to return performance state. + * + * Returns performance state corresponding to the "required-opp" property of + * a DT node. This calls platform specific genpd->get_performance_state() + * callback to translate power domain OPP to performance state. + * + * Returns performance state on success and 0 on failure. + */ +unsigned int of_dev_pm_genpd_get_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)) { + state = PTR_ERR(opp); + goto unlock; + } + + state = genpd->get_performance_state(genpd, opp); + dev_pm_opp_put(opp); + +unlock: + genpd_unlock(genpd); + + return state; +} +EXPORT_SYMBOL_GPL(of_dev_pm_genpd_get_performance_state); + #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index aaacaa35005d..4edbdaa54cec 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -47,6 +47,7 @@ struct genpd_power_state { }; struct genpd_lock_ops; +struct dev_pm_opp; struct generic_pm_domain { struct device dev; @@ -68,6 +69,8 @@ struct generic_pm_domain { unsigned int performance_state; /* Aggregated max performance state */ int (*power_off)(struct generic_pm_domain *domain); int (*power_on)(struct generic_pm_domain *domain); + unsigned int (*get_performance_state)(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); struct gpd_dev_ops dev_ops; @@ -244,6 +247,8 @@ extern int of_genpd_add_subdomain(struct of_phandle_args *parent, extern struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); extern int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); +extern unsigned int of_dev_pm_genpd_get_performance_state(struct device *dev, + struct device_node *np); int genpd_dev_pm_attach(struct device *dev); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ @@ -279,6 +284,12 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn, return -ENODEV; } +static inline unsigned int of_dev_pm_genpd_get_performance_state(struct device *dev, + struct device_node *np) +{ + return -ENODEV; +} + static inline int genpd_dev_pm_attach(struct device *dev) { return -ENODEV;