From patchwork Thu Oct 25 05:52:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 149517 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp913649ljp; Wed, 24 Oct 2018 22:53:39 -0700 (PDT) X-Google-Smtp-Source: AJdET5dfJ2jHCOnLBvNiUeyuqJl+InB1G7n4sZ64OHkaU75ZhN6JfdwlZDzflxwr6iwMMx7OVyPx X-Received: by 2002:a62:4151:: with SMTP id o78-v6mr224382pfa.66.1540446818976; Wed, 24 Oct 2018 22:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540446818; cv=none; d=google.com; s=arc-20160816; b=cz0RDly+oBXNUVLCoVglUvWu+TXFSGTspkSe/VzzQrSrR0vib6xcWSbmDDzAhQm5Pw r/WFD/pK6DUqc3dHQyqQkGeLvI1L/ubHsQ0uoxEdx5pTYdVDvYuay4WHV3IknpwK1ptO a7KOHtuyrTbPE62IU+VlzOrxOrYDVA6J7igbF1pppmxnUaBQ2AZOMLscMTfdOfci/8cG tTt1pn3ERiCrgcWejIt+hI3tfSdV5gkNl8r6JTxAf5AJ20/DeaYM56xKTiq7v5PcnyGu 91YPV7d4HOqp6wp1xxryZSMVetAyIegl33cCf/ygqqRUahwcHj6df9x4aWQ15W+r+idz Lelw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DREmCWfscdpbRmqLABL+1ARNsgewbNNclEM2YGn70QU=; b=ut1ow73WXNopY52SlMNhVTnQNAABDg5aRm+c2XqqE6i/b+XT4ZQsHdtHn2hTHeWf7i +nnA0RdRHE/g4w7AguBgupsziLfnDxhToLvzoz/tZn8hXGMVOyJdHo5AAhx0iqf8Vc4I wdYox10CiXdA+OYj8QdqZqo3xAnh0YJO6zCUqegCeSXHxiNJvwbPY32s8IJEgSdQrr71 1+0Bniff6U2Em/Ze7tPGXaKYHhET6NnuhbpYscBGpMFGLH7ibI2dptdPi2OlcDT7J0Ma II6Lfnu8LLsjgWHdmbCc44XZebZ/Rr9nxdziGGZHLyacqXqFhSSHdB4b28QxvS1vZoWO wNiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NyQEdTMm; 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 i187-v6si7821241pfc.25.2018.10.24.22.53.38; Wed, 24 Oct 2018 22:53:38 -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=NyQEdTMm; 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 S1727530AbeJYOYr (ORCPT + 32 others); Thu, 25 Oct 2018 10:24:47 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46935 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbeJYOYq (ORCPT ); Thu, 25 Oct 2018 10:24:46 -0400 Received: by mail-pl1-f194.google.com with SMTP id bb7-v6so3332522plb.13 for ; Wed, 24 Oct 2018 22:53:36 -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 :mime-version:content-transfer-encoding; bh=DREmCWfscdpbRmqLABL+1ARNsgewbNNclEM2YGn70QU=; b=NyQEdTMmA4psl6Bd/PFMDjhuAKsz4CEmaWHkW6frOoA/VWVk14rQoho2kvKnxP37Ut vQoY3wwxPCEb5nsUrKulHikjV1Uxh3Aqh1GN0xkQm5ugyZGgpGdsA0gvRsov08DrUm+V Tgfvv0idzTcGoOI4VeInxcNgth7u4VDflzUdg= 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:mime-version:content-transfer-encoding; bh=DREmCWfscdpbRmqLABL+1ARNsgewbNNclEM2YGn70QU=; b=Sfa5uSFo80gndrQw0ZqcfC038Wl7Tm3qkX+dtusFUzI8QY8x7HVqlkHa7OawojVmUP cL7nG/2TdGZU9A/je576L/Eq/LjeiWGIcNaSQ4a8pQD4Sh1i06jEsmlqpmRwHlg3CXtN zWwi8qOPFAnRU4g/HQSC5vItLgWjBOZuAZZ2PzBDq1eN0BEXccj6DbehbrtonrhMwIvI 9cGjj79JhTCEsb3Ywxg1ND99MBQ8Do00RXU4GKcMetvZahWWfg202dz3xLWiBx2G3JJp ZWRlj0EpmneYgayVFoK+Z5lZ7cHz0Bnr+yqIXbBJDwspigT3EhRZO6jTl0FWukwzckde lcTQ== X-Gm-Message-State: AGRZ1gK3FP4gITqyOjkGR/KkuDiWQY0PpgARRSN9MwXAAUG5rdqlrJS+ dmn0eojWrkEmHw8V8pW9ZrviKA== X-Received: by 2002:a17:902:7e03:: with SMTP id b3-v6mr202147plm.246.1540446815767; Wed, 24 Oct 2018 22:53:35 -0700 (PDT) Received: from localhost ([122.172.217.9]) by smtp.gmail.com with ESMTPSA id m20-v6sm7734646pfj.171.2018.10.24.22.53.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 22:53:35 -0700 (PDT) From: Viresh Kumar To: ulf.hansson@linaro.org, "Rafael J. Wysocki" , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , niklas.cassel@linaro.org, rnayak@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 06/10] PM / Domains: Add genpd_opp_to_performance_state() Date: Thu, 25 Oct 2018 11:22:43 +0530 Message-Id: X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The OPP core currently stores the performance state in the consumer device's OPP table, but that is going to change going forward and performance state will rather be set directly in the genpd's OPP table. For that we need to get the performance state for genpd's device structure (genpd->dev) instead of the consumer device's structure. Add a new helper to do that. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 32 ++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 9 +++++++++ 2 files changed, 41 insertions(+) -- 2.19.1.568.g152ad8e3369a Reviewed-by: Ulf Hansson diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index fe9b0527b161..7be8c94c6b7f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2520,6 +2520,38 @@ int of_genpd_parse_idle_states(struct device_node *dn, } EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); +/** + * pm_genpd_opp_to_performance_state - Gets performance state of the genpd from its OPP node. + * + * @genpd_dev: Genpd's device for which the performance-state needs to be found. + * @opp: struct dev_pm_opp of the OPP for which we need to find performance + * state. + * + * Returns performance state encoded in the OPP of the genpd. 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 pm_genpd_opp_to_performance_state(struct device *genpd_dev, + struct dev_pm_opp *opp) +{ + struct generic_pm_domain *genpd = NULL; + int state; + + genpd = container_of(genpd_dev, struct generic_pm_domain, dev); + + if (unlikely(!genpd->opp_to_performance_state)) + return 0; + + genpd_lock(genpd); + state = genpd->opp_to_performance_state(genpd, opp); + genpd_unlock(genpd); + + return state; +} +EXPORT_SYMBOL_GPL(pm_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. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 3b5d7280e52e..4f803f934308 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -258,6 +258,8 @@ int of_genpd_add_subdomain(struct of_phandle_args *parent, struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); int of_genpd_parse_idle_states(struct device_node *dn, struct genpd_power_state **states, int *n); +unsigned int pm_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); @@ -299,6 +301,13 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn, return -ENODEV; } +static inline unsigned int +pm_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)