From patchwork Tue May 8 03:32:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10385265 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C10F26037F for ; Tue, 8 May 2018 03:32:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADF4228455 for ; Tue, 8 May 2018 03:32:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EB9128535; Tue, 8 May 2018 03:32:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0014C28C96 for ; Tue, 8 May 2018 03:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754194AbeEHDcu (ORCPT ); Mon, 7 May 2018 23:32:50 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:44629 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753785AbeEHDct (ORCPT ); Mon, 7 May 2018 23:32:49 -0400 Received: by mail-pl0-f66.google.com with SMTP id e6-v6so1363909plt.11 for ; Mon, 07 May 2018 20:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jAACgxh9shvzi7OccqDEzxv0HXsa0qiva5Ywr+0a2OM=; b=HMfeIGGjAPstF3Q5IhUs9HZX2pdY9i961ZUn9dLgu7uNrse+U2cQ6a6bUj5y8HH9NZ z1lrNpSp1YUL8SxdNnJ2NPK6erdlQhm3l6gM1HL6wCVwf/xB+yawihjAozAUWf0wzp1+ ufJtj9YL/r+OQluPELNe4/LUxCQFvOlg11SWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jAACgxh9shvzi7OccqDEzxv0HXsa0qiva5Ywr+0a2OM=; b=h3bSEB//zAbXMhgbRZFyWCS0/pjIsIuv9655qBgbG5az855lAxPgr7ISPW0eRgBZfE 7WcDFC0AI96/0Z/2JYmjHMpxe096qjlfSeXcNT+nHtt7HvhDoqk0wpdpquMrdMHQKmkK tgf0plYs3QJpFVKyDIs72UZEKywPt423yQe8qbM8DMfTCVD5j269Fkm0Kvgi7jBCtShH k++crZMJ+2VqDCOwJe00vR+qJVEEsTMrb0Din6ufI8SEuKEM7bbUzkURxQmMm6vJ/ufg /AnIwdv1E7huu6fPjhRUjclFXJDEZzEig/fKg7FnUrlkJDGEEFHpidh+lzjIkhXc5K5l bYEA== X-Gm-Message-State: ALQs6tC0NUPGiUw74BoOUIb4RQVBvmoj07na/IlxYgD9Z8iY4J/EEEsm XFj4kJtS/VQcSqu9IQFYFNiJSQ== X-Google-Smtp-Source: AB8JxZqExHukLzf+gTTVy5CWnMGaJG/97LWAFRnPrBnvjz5IilAxyQ1ty4UpyPny1QG3w9tHbPbF5g== X-Received: by 2002:a17:902:290a:: with SMTP id g10-v6mr39739374plb.155.1525750369291; Mon, 07 May 2018 20:32:49 -0700 (PDT) Received: from localhost ([122.167.163.112]) by smtp.gmail.com with ESMTPSA id v85-v6sm38591034pgb.71.2018.05.07.20.32.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 20:32:48 -0700 (PDT) Date: Tue, 8 May 2018 09:02:44 +0530 From: Viresh Kumar To: Ulf Hansson Cc: Stephen Boyd , "Rafael J. Wysocki" , Kevin Hilman , Len Brown , Pavel Machek , Rajendra Nayak , Vincent Guittot , Linux PM Subject: Re: [PATCH V2 09/11] PM / Domain: Implement of_dev_pm_genpd_opp_to_performance_state() Message-ID: <20180508033244.gzcl2riifawg4u7d@vireshk-i7> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180323-120-3dd1ac Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07-05-18, 14:10, Ulf Hansson wrote: > While working on multiple PM domains support, I decided to use your > series as a base from your opp tree. > > Assuming you are preparing a pull-request with this series to Rafael!? I was waiting for Rob to Ack one of the DT patches, it seems I should send the pull request now. > Anyway, my eyes got stuck looking at the very long function name > above, again :-). > > To keep names consistent with naming conventions for genpd, would you > mind renaming it to "of_genpd_opp_to_performance_state()"? It's long > enough. :-) > > No need to re-send, amending the patch before sending the PR is fine. -------------------------8<------------------------- Subject: [PATCH] PM / Domain: Implement of_genpd_opp_to_performance_state() This implements of_genpd_opp_to_performance_state() which can be used from the device drivers or the OPP core to find the performance state encoded in the "required-opps" property of a node. Normally this would be called only once for each OPP of the device for which the OPP table of the device is getting generated. 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 ->opp_to_performance_state() is implemented to allow platform specific drivers to convert the power domain OPP to a performance state value. Signed-off-by: Viresh Kumar Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 12 ++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5c0019d70d76..29e25dc0584c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2412,6 +2412,54 @@ int of_genpd_parse_idle_states(struct device_node *dn, } EXPORT_SYMBOL_GPL(of_genpd_parse_idle_states); +/** + * 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. + * @opp_node: 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). + * @state: Pointer to return performance state. + * + * 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 *opp_node) +{ + 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, opp_node); + if (IS_ERR(opp)) { + state = 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); + #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index aaacaa35005d..a2fa297e96f7 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 (*opp_to_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_genpd_opp_to_performance_state(struct device *dev, + struct device_node *opp_node); int genpd_dev_pm_attach(struct device *dev); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ @@ -279,6 +284,13 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn, return -ENODEV; } +static inline unsigned int +of_genpd_opp_to_performance_state(struct device *dev, + struct device_node *opp_node) +{ + return -ENODEV; +} + static inline int genpd_dev_pm_attach(struct device *dev) { return -ENODEV;