From patchwork Fri Jun 29 06:19:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 140505 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp451848ljj; Thu, 28 Jun 2018 23:21:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLB+Hzhs9RLfzGRKq0vZh9wCwn45xj1MaC9eWH3piW2BLoNY+b/K+Rx3nWJAi8R6r3LDjob X-Received: by 2002:a17:902:e00a:: with SMTP id ca10-v6mr13454138plb.224.1530253270213; Thu, 28 Jun 2018 23:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530253270; cv=none; d=google.com; s=arc-20160816; b=iYR9pSYabP1kY1q+s9iYrCZw9KMJD729sqQcmvYJFqo/agz9AFTZyneu++kfYfh3zc 73r8RW4Ng+R+iS+4Gr+t2mRfc/j2SNT24Xz/Fs2K3wc/sFam1dt2Xwm5hfFWZ66iOdCm IX0PQ7bGYTsVA+Q5Vodfec1WrXnLHe4qkQcE7+N2puBUUZhmZo89UOXAdOOVoiBtw5HG spfJUqzIlay4yUhPfaZC82lhMRrWTIdxfYH4yugo/4F4UVC+cwcjGDi7HoEXn9+4RQIT Kh+63ez8H7Lg7jBZGw8zQpmuDJC3XjAiPaFP3RW/f4d1HqLk4Jt0N4zI1IJz7iR0WSFg XF7Q== 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:arc-authentication-results; bh=nYL1CW04bSitJU9aZchvpfflvfV+miLBzuZ+X6mk+3s=; b=mCb2pS/w1nJrX2g4C0yL0mH7CmgFaNfIDrsFQIv4Mx4X+YTnifmezQfR96Lpw8NSij SMotiLlFlc1dCinffkki3b5PasZTol+DwjqKLoJlVHQWC7qqgEqMZ1dWu+s1chTQpQHk o/5OWdEr1AOO0EyUR+BsTCB0wNJ/n1oWKBfi1XUD+hREpYwTDosmuXcno7yG0hpFsR3e +OiE3/Mw3eqUWwVjxLZhLq650XzNd0CqYi/kyDiK7oN/k+nBFHPZOfyFF8Pmi/eu8Kq8 ZNoWSlWkuI4Ep6gFZIuoIz5GyQ3iL7tjk/5XlCrqXhsmej18IDf8awaQH2BU9esayRgx U3Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hd5h0+dC; 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 y16-v6si7965518pfl.11.2018.06.28.23.21.09; Thu, 28 Jun 2018 23:21:10 -0700 (PDT) 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=hd5h0+dC; 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 S933619AbeF2GVH (ORCPT + 10 others); Fri, 29 Jun 2018 02:21:07 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:41699 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933566AbeF2GUR (ORCPT ); Fri, 29 Jun 2018 02:20:17 -0400 Received: by mail-pg0-f68.google.com with SMTP id l65-v6so3538566pgl.8 for ; Thu, 28 Jun 2018 23:20:16 -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=nYL1CW04bSitJU9aZchvpfflvfV+miLBzuZ+X6mk+3s=; b=hd5h0+dC+9OjBYA6Bgt+gp9/Po5kiudhamXfCF6JLQ4Czxak/+7KYDgzXL3Fv9XSGR MnxaTyNbLoO9eGq+0C7OGNotUQ3fSv/PaqeeN1HRVn5lrYJx8GyNADOum5uD97MOGMEa 2ey4QiN5hbKt+TLZhPAbO/hqVWEzEYgyEXgUU= 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=nYL1CW04bSitJU9aZchvpfflvfV+miLBzuZ+X6mk+3s=; b=jCU9z3Lju4cPfkMh7NV55lEmy8GFyUWnI19hQsULV6EeBIn0qbfV1AObWOiZf6S2yP vnv2aAf8LsXf9sxMDQXJav6AfBRFoVkrhhyPKJnVd5PDFkimfAnQSkNtzB9OXgTxTCKb cae2jnQ6j4IjOV7nNfdagO0yLpedfPCWpR/c+IXkIF7E0NKBeKpVcTzLoD4CnLFeFYLX smpOPYwBTXGM7Ju2SsHZm7rEBPD3tprQ3eizikedr/hMIs4ZNACo5+zSw3M0s/rIw562 UUAgoz4l8sCrjz4eMN0oYYbV3bDNaNjne6FlcmKWsqFMCYUuPT4dp86ZNyshlBl1+2mH oJwg== X-Gm-Message-State: APt69E1TAM5THW7P4L8oXGQ12VIQBwKsoa5mG+8wO+1k3F2oRzhElpFw /bPIlVJj3cpfgZP8r22RDwt7bg== X-Received: by 2002:a63:a809:: with SMTP id o9-v6mr11679259pgf.313.1530253216409; Thu, 28 Jun 2018 23:20:16 -0700 (PDT) Received: from localhost ([122.172.117.17]) by smtp.gmail.com with ESMTPSA id d23-v6sm23810414pfe.2.2018.06.28.23.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 23:20:15 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , ulf.hansson@linaro.org, Kevin Hilman , Len Brown , Pavel Machek Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rajendra Nayak , Stephen Boyd , linux-kernel@vger.kernel.org Subject: [PATCH 07/10] PM / Domains: Add genpd_opp_to_performance_state() Date: Fri, 29 Jun 2018 11:49:37 +0530 Message-Id: <476e0a8c4bb54190f3019055b369110d0964b798.1530252803.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The OPP core currently stores the performance state in the end device's OPP structures, but that is going to change now and these values will be set directly in the genpd's OPP structures. For that we need to get the performance state genpd's device structure instead of the end user's device structure. Add a new helper to do that. Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 39 +++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 47 insertions(+) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e9c85c96580c..15ffac081b0e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2505,6 +2505,45 @@ int of_genpd_parse_idle_states(struct device_node *dn, } EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); +/** + * 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 genpd_opp_to_performance_state(struct device *genpd_dev, + struct dev_pm_opp *opp) +{ + struct generic_pm_domain *genpd = NULL, *temp; + int state; + + lockdep_assert_held(&gpd_list_lock); + + list_for_each_entry(temp, &gpd_list, gpd_list_node) { + if (&temp->dev == genpd_dev) { + genpd = temp; + break; + } + } + + if (unlikely(!genpd || !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(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 cb8d84090cfb..b3c5f1eaf16c 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -233,6 +233,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 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); @@ -272,6 +274,12 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn, return -ENODEV; } +static inline unsigned int +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)