From patchwork Fri Jun 14 04:17:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75608924 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6025127CF3 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A63B27DA4; Fri, 14 Jun 2019 04:18:01 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 DAD1D27CF3 for ; Fri, 14 Jun 2019 04:17:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725908AbfFNERm (ORCPT ); Fri, 14 Jun 2019 00:17:42 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:51119 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbfFNERm (ORCPT ); Fri, 14 Jun 2019 00:17:42 -0400 Received: by mail-qt1-f201.google.com with SMTP id g30so1044582qtm.17 for ; Thu, 13 Jun 2019 21:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=nT/RN++hgSEY1oFXDZU2+2vA7A3kNiWfnEI7MgbZhNk=; b=n5yi/fsSkLPZsXmOhD6VaVWd4K75Sp6QVYZWyYN4AtitTODNfEvka82I6ouh9pIllG dByhWETJ+8aEVnytSO/6g5UZ468kBNbvHIY8phwEkAWG2tZrVyIT0IsUTnuJQzR3aN5e XLV3Bp8RtbiNIhG4M2j+89d4S8rQhOaXxXhPxrP4R3GuFvA3KrIT2TCwKcbf5jWgDRdY hXKGsyRZDlYUqE42uRR1Cxv/vlIoapqsipres07YeHegPtQ6LxBQwOSWtvBOezOpgD3I Qu28AYiZTS3TgBTeUizjfUrhu0yM3b2DuiIp11SST0LVUveEP+ZUo3ggXGNYrpastq/N 2/jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nT/RN++hgSEY1oFXDZU2+2vA7A3kNiWfnEI7MgbZhNk=; b=JHeFzjd/sjCZST7lZ3ZVMaPP3XNOIxZyQeyugdzqikBOqhF93lITQ6+Hitov2dl8Gh IhUBZEMLsDcBkG4v9lNQXBSKLW9TWA4JipUc2vnq1x9g8KY/Qe4BrdFfA70+KPsr1ZAo yGMoDMYYrSvRuW4zHE+DWJOWZ0urEnSW50pXKyJyWmA2SKqI2qknIyV92GR+vBUchOHo 4Q0DOqggd1EiSX+TrUYV5EH6GNmH42wFoJcH49FTMiX0jXhwCo+1SaL1CWpTvJcV7wx3 qLgnhrUCKx1FEJ1FJ7REfc/ip24uTywo3ewgspYF9dSjVB1uhmwku7Tr0vNN1EqHuQaE l15Q== X-Gm-Message-State: APjAAAXlTuMoV+71FwZm18NLSXRBp1foz+nnFuxJyKJefwIwg8Jb5Y/i CYr0MeYk3zZy4WLDaQ8Dy/aX+RWbcqt61wM= X-Google-Smtp-Source: APXvYqyNMF63uMGGdRuluuVrT4/Cbxxxf47Mr3fg6agQhouB8jIcIqFEqN0r4I8WQRbVaepWXMQu0HlCnhutkjM= X-Received: by 2002:ac8:1a9d:: with SMTP id x29mr79446143qtj.128.1560485861512; Thu, 13 Jun 2019 21:17:41 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:23 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-2-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 01/11] OPP: Allow required-opps even if the device doesn't have power-domains From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 A Device-A can have a (minimum) performance requirement on another Device-B to be able to function correctly. This performance requirement on Device-B can also change based on the current performance level of Device-A. The existing required-opps feature fits well to describe this need. So, instead of limiting required-opps to point to only PM-domain devices, allow it to point to any device. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 2 +- drivers/opp/of.c | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0e7703fe733f..74c7bdc6f463 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -710,7 +710,7 @@ static int _set_required_opps(struct device *dev, return 0; /* Single genpd case */ - if (!genpd_virt_devs) { + if (!genpd_virt_devs && required_opp_tables[0]->is_genpd) { pstate = opp->required_opps[0]->pstate; ret = dev_pm_genpd_set_performance_state(dev, pstate); if (ret) { diff --git a/drivers/opp/of.c b/drivers/opp/of.c index c10c782d15aa..7c8336e94aff 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -195,9 +195,6 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table, */ count_pd = of_count_phandle_with_args(dev->of_node, "power-domains", "#power-domain-cells"); - if (!count_pd) - goto put_np; - if (count_pd > 1) { genpd_virt_devs = kcalloc(count, sizeof(*genpd_virt_devs), GFP_KERNEL); @@ -226,17 +223,6 @@ static void _opp_table_alloc_required_tables(struct opp_table *opp_table, if (IS_ERR(required_opp_tables[i])) goto free_required_tables; - - /* - * We only support genpd's OPPs in the "required-opps" for now, - * as we don't know how much about other cases. Error out if the - * required OPP doesn't belong to a genpd. - */ - if (!required_opp_tables[i]->is_genpd) { - dev_err(dev, "required-opp doesn't belong to genpd: %pOF\n", - required_np); - goto free_required_tables; - } } goto put_np; From patchwork Fri Jun 14 04:17:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CCBA924 for ; Fri, 14 Jun 2019 04:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F5D027B81 for ; Fri, 14 Jun 2019 04:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4386C27D0E; Fri, 14 Jun 2019 04:18:34 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 CBB8C27B81 for ; Fri, 14 Jun 2019 04:18:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726046AbfFNERp (ORCPT ); Fri, 14 Jun 2019 00:17:45 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:52862 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbfFNERp (ORCPT ); Fri, 14 Jun 2019 00:17:45 -0400 Received: by mail-pf1-f202.google.com with SMTP id i123so831278pfb.19 for ; Thu, 13 Jun 2019 21:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aquWBLmVdfTsfPmb1EWD0BsWvbkQBS182ArgyBvCIFk=; b=SALd+e5WH1k6h9KcX/9goKx7DKFiD/tzpEIBpi1VyWU7XvDu2xfmpkkCjFagLgLKso k1F40bZQT27d7k8eZ/rO9FhFjh+RR+wKxJlzQBp9VaLE8hPlY104nQTZUPgpBNn2mBPT ++1C4AFj9N2cFkqt3XQBxF6i5xX1XSSOJtAeBM2KoD1aCwZr+WpBiJTtGYSyIu8/SEA6 Ev3DN/C/EBTdnmu7GB6Qeihyh1trdVho2bgPh4i+MQk6bPv0Y3nBGorTJMx2a7I+qcye +Q96sesGXGqkm4m66kbYNy19Ae8APrRe2uRpJPw13DLMOyKylYFGNOgNFe/yzbhVkTk9 c4EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aquWBLmVdfTsfPmb1EWD0BsWvbkQBS182ArgyBvCIFk=; b=BxhKIgNId7aemUccDOlPSf9+Iibzy4tJjY1exGKSoW5QJ9tA6dV6hVYG/pOIvla0U+ lzCkjUezZ5N9mzeSDALeqZpRvI07xb5GhuWHMFDHCu8p+Q/3j5gcjbEQoSmjcgU/beDW Bgk6+WK2rfMsM+rJVwrK0ABV7uO8UvAFJoeo5Q8CY5os3w05V7Y35/9Vwnft0POe5WTt mP3szaW+xC6j4Aeiv9a7ze7/RZCJ7lXxquznNFRnvqnXIrBc0jrWawknzzlxjhulJHyn jX3sMTBWiriyA980pokkIoH5budC5XgnCWnG9pKzUxaqm8puMmhYGV5f9DZBGfwQcObb Jv2A== X-Gm-Message-State: APjAAAVtToBzxFIDqNERNF2PnUyxQCQRp970iqJpsJhPZE3Dda6yoTh2 1yrrYZ9DY20SXrlLXAzrc5t4iTnBlrCYDWg= X-Google-Smtp-Source: APXvYqym9Smv41BgCCmiAxP4QJzXUTCJZc6yClVmbeev+9UXzl8/lbDcRgOPKtGKnbxQirgLhVl4xHH9dmQ7rSQ= X-Received: by 2002:a63:de0e:: with SMTP id f14mr14823969pgg.348.1560485864345; Thu, 13 Jun 2019 21:17:44 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:24 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-3-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 02/11] OPP: Add function to look up required OPP's for a given OPP From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Add a function that allows looking up required OPPs given a source OPP table, destination OPP table and the source OPP. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 54 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 11 +++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 74c7bdc6f463..4f7870bffbf8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1830,6 +1830,60 @@ void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, dev_err(virt_dev, "Failed to find required device entry\n"); } +/** + * dev_pm_opp_xlate_opp() - Find required OPP for src_table OPP. + * @src_table: OPP table which has dst_table as one of its required OPP table. + * @dst_table: Required OPP table of the src_table. + * @pstate: OPP of the src_table. + * + * This function returns the OPP (present in @dst_table) pointed out by the + * "required-opps" property of the OPP (present in @src_table). + * + * The callers are required to call dev_pm_opp_put() for the returned OPP after + * use. + * + * Return: destination table OPP on success, otherwise NULL on errors. + */ +struct dev_pm_opp *dev_pm_opp_xlate_opp(struct opp_table *src_table, + struct opp_table *dst_table, + struct dev_pm_opp *src_opp) +{ + struct dev_pm_opp *opp, *dest_opp = NULL; + int i; + + if (!src_table || !dst_table || !src_opp) + return NULL; + + for (i = 0; i < src_table->required_opp_count; i++) { + if (src_table->required_opp_tables[i]->np == dst_table->np) + break; + } + + if (unlikely(i == src_table->required_opp_count)) { + pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", + __func__, src_table, dst_table); + return NULL; + } + + mutex_lock(&src_table->lock); + + list_for_each_entry(opp, &src_table->opp_list, node) { + if (opp == src_opp) { + dest_opp = opp->required_opps[i]; + dev_pm_opp_get(dest_opp); + goto unlock; + } + } + + pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, src_table, + dst_table); + +unlock: + mutex_unlock(&src_table->lock); + + return dest_opp; +} + /** * dev_pm_opp_xlate_performance_state() - Find required OPP's pstate for src_table. * @src_table: OPP table which has dst_table as one of its required OPP table. diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index b150fe97ce5a..bc5c68bdfc8d 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -134,6 +134,9 @@ void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev, struct device *virt_dev, int index); void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); +struct dev_pm_opp *dev_pm_opp_xlate_opp(struct opp_table *src_table, + struct opp_table *dst_table, + struct dev_pm_opp *src_opp); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -307,6 +310,14 @@ static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table return -ENOTSUPP; } +static inline struct dev_pm_opp *dev_pm_opp_xlate_opp( + struct opp_table *src_table, + struct opp_table *dst_table, + struct dev_pm_opp *src_opp) +{ + return NULL; +} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; From patchwork Fri Jun 14 04:17:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B599614E5 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A92DF27CF3 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C48227DA4; Fri, 14 Jun 2019 04:18:01 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 067BD27D0E for ; Fri, 14 Jun 2019 04:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbfFNERs (ORCPT ); Fri, 14 Jun 2019 00:17:48 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:57237 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726105AbfFNERs (ORCPT ); Fri, 14 Jun 2019 00:17:48 -0400 Received: by mail-qk1-f202.google.com with SMTP id j128so976564qkd.23 for ; Thu, 13 Jun 2019 21:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=SJIMb+Ux62XaD1zvTN7sgB8J991Gr80Gygm6D6H4n5w=; b=hghN2IFdVV5jQWGPzPZfj8N0Ul84C8eBuXKbdeQmfXQzCGBY5ZqbUuqpImEdmhWmIo 9qOU//XwKxDBz8ELfcENjG8S6e3Ef6obgwIFjcQgIaBIbwIV0iUk4hQVUaxc1E0RPs6j 4B9xobeLA/t4xbUsX/xYRsjJB8sXtHhWHikl9LulTCv4m1ziaHGzx7wSNqwwdsMQVOsn j/b1oMDv0cECZqjkMZPJEigAkUMZOeXATrxQNeFFMVyFcRcHLLw8tE9H0sS3z62rtfxV uZcH/amHURKnUuYj0dXECYNQ4NhskYS+atKwxbBeRUvUo72AlN2cAxa/+7QeaY1t/7NI aiUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SJIMb+Ux62XaD1zvTN7sgB8J991Gr80Gygm6D6H4n5w=; b=TJ3HK4KCWWScV25XLzwMmgMKOJU2car/+oLL7hcMj92R7ndAG0J32dIFM/bfnALz+2 PhUOQfBlZet51iYO3GjF01u6bsAKY3ID+rfsAybGOymz7//i3qZZt4WsVsiJUkiYFuxb fPx8bAHv+Ti5VBQwcDE5fIRiR6J3K3bwRvYQqh2ZeTiYbbJjlTbaV1wzTy+On+ewnuiv qMBgWX/E7z089xZkg69k+5g65c/srAWQUvmp0Vwlzjs8fMa+fv8EqnLiZhl3ODUSO9UN wSPY5Dq8qAL/47rYIgSN97bm5wB7UC46RbaQUQLxljiTiu1SpgK47yhfZDtM1y3jNfhC pKuw== X-Gm-Message-State: APjAAAUhiPonUcN3HVDWQvV3x8bGClfY6pspmUIcsOMy64vJsOm7TIYE 0LutfxdXUKrOQq11l6h17SFEXuXvWuyVXLk= X-Google-Smtp-Source: APXvYqy6txRryyUL2ABcJNZLNr6zXIbMUWDWOiEgQN6cFXelIVr9k5cMguvNDbpVLT6bi0d9sMNRQIXaJZ3YMfo= X-Received: by 2002:ac8:685:: with SMTP id f5mr4388547qth.9.1560485867363; Thu, 13 Jun 2019 21:17:47 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:25 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-4-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 03/11] PM / devfreq: Add required OPPs support to passive governor From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Look at the required OPPs of the "parent" device to determine the OPP that is required from the slave device managed by the passive governor. This allows having mappings between a parent device and a slave device even when they don't have the same number of OPPs. Signed-off-by: Saravana Kannan --- drivers/devfreq/governor_passive.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 3bc29acbd54e..bd4a98bb15b1 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -21,8 +21,9 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, struct devfreq_passive_data *p_data = (struct devfreq_passive_data *)devfreq->data; struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; + struct opp_table *opp_table = NULL, *c_opp_table = NULL; unsigned long child_freq = ULONG_MAX; - struct dev_pm_opp *opp; + struct dev_pm_opp *opp = NULL, *c_opp = NULL; int i, count, ret = 0; /* @@ -65,7 +66,20 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, goto out; } - dev_pm_opp_put(opp); + opp_table = dev_pm_opp_get_opp_table(parent_devfreq->dev.parent); + if (IS_ERR_OR_NULL(opp_table)) { + ret = PTR_ERR(opp_table); + goto out; + } + + c_opp_table = dev_pm_opp_get_opp_table(devfreq->dev.parent); + if (!IS_ERR_OR_NULL(c_opp_table)) + c_opp = dev_pm_opp_xlate_opp(opp_table, c_opp_table, opp); + if (c_opp) { + *freq = dev_pm_opp_get_freq(c_opp); + dev_pm_opp_put(c_opp); + goto out; + } /* * Get the OPP table's index of decided freqeuncy by governor @@ -92,6 +106,13 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, *freq = child_freq; out: + if (!IS_ERR_OR_NULL(opp_table)) + dev_pm_opp_put_opp_table(opp_table); + if (!IS_ERR_OR_NULL(c_opp_table)) + dev_pm_opp_put_opp_table(c_opp_table); + if (!IS_ERR_OR_NULL(opp)) + dev_pm_opp_put(opp); + return ret; } From patchwork Fri Jun 14 04:17:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E926E14E5 for ; Fri, 14 Jun 2019 04:18:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA89D27B81 for ; Fri, 14 Jun 2019 04:18:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE50927D0E; Fri, 14 Jun 2019 04:18:30 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 6F30527B81 for ; Fri, 14 Jun 2019 04:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbfFNERw (ORCPT ); Fri, 14 Jun 2019 00:17:52 -0400 Received: from mail-oi1-f202.google.com ([209.85.167.202]:33941 "EHLO mail-oi1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfFNERv (ORCPT ); Fri, 14 Jun 2019 00:17:51 -0400 Received: by mail-oi1-f202.google.com with SMTP id i16so402461oie.1 for ; Thu, 13 Jun 2019 21:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=yAz3k7OzPjxwzR5iBZENxEm1ewgrxin9ITMqtF0yTXk=; b=B7prBGnC/4Vibzh1aRMKAwrh4wPptRavvQYdcbMm4wH18w6FJ+mN2XrQWOTokqNNE1 2YQEPr15HP9wSksf1WcGXsHnVfqqqegk1AI4eEiroIavNFnRETAd2J8oE0N+RDr4nh6n AmmAr7cJQDsTXFqCR3AJrrk/CmgU6adsljmLmVCSPy0Y0sYMKMcgVM3kHNlj+tUdSMD/ BPjdbxJNKW2RflGqJzrpzuZ7sMm8HwAor8bGvpDaFEBr23p78S/TZxhHyFUjGMyT61Ng WGTkhSqWIQLHWc8uOIJGFcDV9ynqnhDOGqTgQwDVWczkizWy5FMQN2ha/gtdILPLq3uB rbJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=yAz3k7OzPjxwzR5iBZENxEm1ewgrxin9ITMqtF0yTXk=; b=fVC9G/wwYgVkfRAqO9RkLnMxV0sfF/ZpKT/gV52PqP2YmNd4YHPbX1Vm4Mt5jSGVJp ZCt6MoYe6Uja4rsGXRSno9P5CYCfzQwns8RTz7JPfqZ2F2R+54yXIkp7XDFR80tr6CZp NqOhny2QlcgfDIrLy4SZoBuHJWUiD+aAmt9oycqsEQcDwzuIm8zW8VCYCcGQy76YGNmA HxLeuKipWZMBDvYBG+nW+k5JO2oxx54au6y30l0mVsPH+wfAaLRRKy0bUPGE3m8RUtAh KgeyuNNkTQY+R+6k6/hbuWy+XTZlsaB1tzvOL30C9lPXQO3Wiq+fb232IJd6INvU84Yo djxw== X-Gm-Message-State: APjAAAVGaUe2+gXRH7fN4dqHDAOthHlOUx42ylUiX0Oe9YUtT4IITIyN AqOxH5HnzbReRruIfFWfrm3O8VwyzEcXjLs= X-Google-Smtp-Source: APXvYqxpQN0vGQmlYfHsDs37QAiaPht93jr4MuA/NrskO8HXbTJIyWknXV3GfSjQiUsAjTLL2awJ0YqhP7X0mIc= X-Received: by 2002:aca:b8d7:: with SMTP id i206mr618247oif.25.1560485870342; Thu, 13 Jun 2019 21:17:50 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:26 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-5-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 04/11] dt-bindings: opp: Introduce opp-peak-KBps and opp-avg-KBps bindings From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Interconnects often quantify their performance points in terms of bandwidth. So, add opp-peak-KBps (required) and opp-avg-KBps (optional) to allow specifying Bandwidth OPP tables in DT. opp-peak-KBps is a required property that replace opp-hz for Bandwidth OPP tables. opp-avg-KBps is an optional property that can be used in Bandwidth OPP tables. Signed-off-by: Saravana Kannan --- Documentation/devicetree/bindings/opp/opp.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt index 76b6c79604a5..c869e87caa2a 100644 --- a/Documentation/devicetree/bindings/opp/opp.txt +++ b/Documentation/devicetree/bindings/opp/opp.txt @@ -83,9 +83,14 @@ properties. Required properties: - opp-hz: Frequency in Hz, expressed as a 64-bit big-endian integer. This is a - required property for all device nodes but devices like power domains. The - power domain nodes must have another (implementation dependent) property which - uniquely identifies the OPP nodes. + required property for all device nodes but for devices like power domains or + bandwidth opp tables. The power domain nodes must have another (implementation + dependent) property which uniquely identifies the OPP nodes. The interconnect + opps are required to have the opp-peak-bw property. + +- opp-peak-KBps: Peak bandwidth in kilobytes per second, expressed as a 32-bit + big-endian integer. This is a required property for all devices that don't + have opp-hz. For example, bandwidth OPP tables for interconnect paths. Optional properties: - opp-microvolt: voltage in micro Volts. @@ -132,6 +137,10 @@ Optional properties: - opp-level: A value representing the performance level of the device, expressed as a 32-bit integer. +- opp-avg-KBps: Average bandwidth in kilobytes per second, expressed as a + 32-bit big-endian integer. This property is only meaningful in OPP tables + where opp-peak-KBps is present. + - clock-latency-ns: Specifies the maximum possible transition latency (in nanoseconds) for switching to this OPP from any other OPP. From patchwork Fri Jun 14 04:17:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEA3E18A6 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C152E27CF3 for ; Fri, 14 Jun 2019 04:18:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF5DD27DCD; Fri, 14 Jun 2019 04:18:01 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 2F7D427D29 for ; Fri, 14 Jun 2019 04:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726265AbfFNERz (ORCPT ); Fri, 14 Jun 2019 00:17:55 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:35204 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726213AbfFNERy (ORCPT ); Fri, 14 Jun 2019 00:17:54 -0400 Received: by mail-qt1-f201.google.com with SMTP id v58so1086159qta.2 for ; Thu, 13 Jun 2019 21:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=S7+vYKQUq5lZMW6Ri78n8SISGeuUnAv5G2fMh5MCCB0=; b=dm8bZhPEuM2wGtMvKc4gKqPZQ3mLqzd91ZsffM4nT/XjREXW8Zp4bMnDnbqJzhfGLA 38L5mApWLtGNnvt4U1sFjTigD+r4o8ZCWHbEzdrLoreO/Ra0fsuIhDLFfz01ha7AbinR RCScftofhtV1n6geuxrFD37xuQv6fN5f9yrnWiT64NUxZsHJS3/MmdzQh3FnTreCYKAq ymoehLzNzvJmSiIGmQrCerHzbhQqPJcplC1wBWgMpDk57VSNBAsybLBLHmVPTak18L3H uBBT8fjTIGFdD4gW08nssJhMgmUI9+Ws5ZsVpC9M9XM2YOLQA/YAm0+A2uLxXMq3a7rk K5BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=S7+vYKQUq5lZMW6Ri78n8SISGeuUnAv5G2fMh5MCCB0=; b=K0kTzdL0ejaJlSLfl4cQNsUbPwPQuMl2nMzHLaXLOWcMg7Syqlr13bh3dJqisw0Wc9 TuMHUtPlRvJTxTv4RAWz9FsooTrdP9M6WZKx+gnHo2Y7E1lBgh8uRA0AJ5sR7BK1ioqx salFvMQntlJx+epgM60NE60pUe7NNAhhWQjfZIXzw+Pf+zMxTqgrpi1Waxf0vlDFZgf/ 1LkR87IERshz/XXQ0o8bp9Mco57Cvz/qBMlhLjpnNrr88PkZN92edciM+bBST+gqehJW i4efvInQDZwEtQXxLGWHpnPL1PdcCNmzOt4HyOWcKJq5eA0FZoJw9abvXqStNEh5k190 ggwA== X-Gm-Message-State: APjAAAWmsy1ddXuLNmmUD4FQKOMwS3f9uV9j5aRzOxste7g4NlmPD9Lq BfcDqN6TzV/aBfT8KMU+tspkMiCeva1F6c8= X-Google-Smtp-Source: APXvYqy84WJSLdcYgVbelfornVEsFYGdJg0Map6EsugniuC3YG3dF2T6wu62r9y0K9Qd9AGonIqNHBExaURVdIU= X-Received: by 2002:a0c:9253:: with SMTP id 19mr6478264qvz.180.1560485873506; Thu, 13 Jun 2019 21:17:53 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:27 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-6-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 05/11] OPP: Add support for bandwidth OPP tables From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Not all devices quantify their performance points in terms of frequency. Devices like interconnects quantify their performance points in terms of bandwidth. We need a way to represent these bandwidth levels in OPP. So, add support for parsing bandwidth OPPs from DT. Signed-off-by: Saravana Kannan --- drivers/opp/of.c | 34 ++++++++++++++++++++++++++++++++-- drivers/opp/opp.h | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 7c8336e94aff..d5815289518a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -538,6 +538,35 @@ void dev_pm_opp_of_remove_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); +static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np) +{ + int ret; + u64 rate; + u32 bw; + + ret = of_property_read_u64(np, "opp-hz", &rate); + if (!ret) { + /* + * Rate is defined as an unsigned long in clk API, and so + * casting explicitly to its type. Must be fixed once rate is 64 + * bit guaranteed in clk API. + */ + new_opp->rate = (unsigned long)rate; + return 0; + } + + ret = of_property_read_u32(np, "opp-peak-KBps", &bw); + if (ret) + return ret; + new_opp->rate = (unsigned long) &bw; + + ret = of_property_read_u32(np, "opp-avg-KBps", &bw); + if (!ret) + new_opp->avg_bw = (unsigned long) &bw; + + return 0; +} + /** * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * @opp_table: OPP table @@ -575,11 +604,12 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (!new_opp) return ERR_PTR(-ENOMEM); - ret = of_property_read_u64(np, "opp-hz", &rate); + ret = _read_opp_key(new_opp, np); if (ret < 0) { /* "opp-hz" is optional for devices like power domains. */ if (!opp_table->is_genpd) { - dev_err(dev, "%s: opp-hz not found\n", __func__); + dev_err(dev, "%s: opp-hz or opp-peak-bw not found\n", + __func__); goto free_opp; } diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 569b3525aa67..ead2cdafe957 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -59,7 +59,8 @@ extern struct list_head opp_tables; * @turbo: true if turbo (boost) OPP * @suspend: true if suspend OPP * @pstate: Device's power domain's performance state. - * @rate: Frequency in hertz + * @rate: Frequency in hertz OR Peak bandwidth in kilobytes per second + * @avg_bw: Average bandwidth in kilobytes per second * @level: Performance level * @supplies: Power supplies voltage/current values * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's @@ -81,6 +82,7 @@ struct dev_pm_opp { bool suspend; unsigned int pstate; unsigned long rate; + unsigned long avg_bw; unsigned int level; struct dev_pm_opp_supply *supplies; From patchwork Fri Jun 14 04:17:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B46B314E5 for ; Fri, 14 Jun 2019 04:18:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A607C27B81 for ; Fri, 14 Jun 2019 04:18:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99F8327D0E; Fri, 14 Jun 2019 04:18:28 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 1753627B81 for ; Fri, 14 Jun 2019 04:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726296AbfFNESA (ORCPT ); Fri, 14 Jun 2019 00:18:00 -0400 Received: from mail-oi1-f201.google.com ([209.85.167.201]:48720 "EHLO mail-oi1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfFNER5 (ORCPT ); Fri, 14 Jun 2019 00:17:57 -0400 Received: by mail-oi1-f201.google.com with SMTP id a198so384697oii.15 for ; Thu, 13 Jun 2019 21:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pA88GQBtAGP1rgMV9ltyoIPWXgCzn/zukoiOtKtlP+A=; b=hofCja+avL07axE3R4McdlSXe7Uh1GlxOzhy0doUwhmYDuewv+768/I2/KGsCvyQpo M9xTviAi5haf2KYGdovWoHAcGJa7VbsrRtv/AjJKAZwrfpo8FVa5gl4mZhD7XQO8MMzn 6i6SfA2Zif1JxtMQVS/hnSNwJDVOcv6MPZj/Lm+G7QLJYcJcQevCABuIT5Rvj/HHBNkY ZuGV4njreHUAIUWt73jMnymqo3iIeshCrnHg7I3OFkKgIjb9kfLgvirLXt2K+9a+vEqC xdb9689SZkzVD9QCCLwB3sMV0UJ3zeXxW4A7eME2k2i/aaxwgVKaysFyt0f8HgTerpTn jNpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pA88GQBtAGP1rgMV9ltyoIPWXgCzn/zukoiOtKtlP+A=; b=YFmRt+cEJhA9ZzPvvF480Zo8+mGUAqFARAs4a/xhHQvhCBnJJt/4fFOATtXODYNKZf GrHaBWbgLovwVgONyy1fG1VUMir+cZgSM8aQZoaKT0ac2RczI370FM4USZ1ZDVQZf9Ha EuJrSv5n3RFHNO/puanwadON4BrclSrDj35O6+GxnOgGfZkjUfjrMKcprAbmWV+uBmHn ekewsYPrK+wMHII+LPZtLhVsD3ZU3HBpOqrYMpcX13dTg8uXWpRHuJQcWkYLwYYLLzjS LutEdQIkb2mkPFb5P+EX1aJPwVwqtpbBdHSm8oHZA5BCBzoBdQMFEHn2nRFmW3R5gMI3 c8vg== X-Gm-Message-State: APjAAAXPfxGhyQ8hxLndE+etNYWbqq9AvHSgEJ+m5NJ6nue353pzuNf0 4b0UujkHZdnlEKVYROcA1ZJsGHPZ1SAi78k= X-Google-Smtp-Source: APXvYqz3ylX7YKsVxmRmx0ILRl96jgFQUhX4Ot0Xk/v6CidHJ6fjT9LuNNkVqkxIwm4aW7E/2qf1NayfUQeABYk= X-Received: by 2002:aca:6c1:: with SMTP id 184mr563474oig.122.1560485876623; Thu, 13 Jun 2019 21:17:56 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:28 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-7-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 06/11] OPP: Add helper function for bandwidth OPP tables From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 The frequency OPP tables have helper functions to search for entries in the table based on frequency and get the frequency values for a given (or suspend) OPP entry. Add similar helper functions for bandwidth OPP tables to search for entries in the table based on peak bandwidth and to get the peak and average bandwidth for a given (or suspend) OPP entry. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 19 ++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4f7870bffbf8..c9914afd508a 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -130,6 +130,29 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); +/** + * dev_pm_opp_get_bw() - Gets the bandwidth corresponding to an available opp + * @opp: opp for which frequency has to be returned for + * @avg_bw: Pointer where the corresponding average bandwidth is stored. + * Can be NULL. + * + * Return: Peak bandwidth in KBps corresponding to the opp, else + * return 0 + */ +unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, unsigned long *avg_bw) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + if (avg_bw) + *avg_bw = opp->avg_bw; + + return opp->rate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_bw); + /** * dev_pm_opp_get_level() - Gets the level corresponding to an available opp * @opp: opp for which level value has to be returned for @@ -302,6 +325,34 @@ unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp_freq); +/** + * dev_pm_opp_get_suspend_opp_bw() - Get peak bandwidth of suspend opp in KBps + * @dev: device for which we do this operation + * @avg_bw: Pointer where the corresponding average bandwidth is stored. + * Can be NULL. + * + * Return: This function returns the peak bandwidth of the OPP marked as + * suspend_opp if one is available, else returns 0; + */ +unsigned long dev_pm_opp_get_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw) +{ + struct opp_table *opp_table; + unsigned long peak_bw = 0; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + if (opp_table->suspend_opp && opp_table->suspend_opp->available) + peak_bw = dev_pm_opp_get_bw(opp_table->suspend_opp, avg_bw); + + dev_pm_opp_put_opp_table(opp_table); + + return peak_bw; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp_bw); + int _get_opp_count(struct opp_table *opp_table) { struct dev_pm_opp *opp; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index bc5c68bdfc8d..2e122af26b8e 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -85,6 +85,7 @@ void dev_pm_opp_put_opp_table(struct opp_table *opp_table); unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, unsigned long *avg_bw); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); @@ -95,6 +96,8 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev); unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev); +unsigned long dev_pm_opp_get_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, @@ -164,6 +167,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) { return 0; } +static inline unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, + unsigned long *avg_bw) +{ + return 0; +} static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) { @@ -200,6 +208,12 @@ static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) return 0; } +static inline unsigned long dev_pm_opp_get_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw) +{ + return 0; +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) { @@ -343,6 +357,11 @@ static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask #endif /* CONFIG_PM_OPP */ +#define dev_pm_opp_find_peak_bw_exact dev_pm_opp_find_freq_exact +#define dev_pm_opp_find_peak_bw_floor dev_pm_opp_find_freq_floor +#define dev_pm_opp_find_peak_bw_ceil_by_volt dev_pm_opp_find_freq_ceil_by_volt +#define dev_pm_opp_find_peak_bw_ceil dev_pm_opp_find_freq_ceil + #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) int dev_pm_opp_of_add_table(struct device *dev); int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); From patchwork Fri Jun 14 04:17:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEFBF924 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0A0A27B81 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4F1327D0E; Fri, 14 Jun 2019 04:18:27 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 31A1827CF3 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbfFNESB (ORCPT ); Fri, 14 Jun 2019 00:18:01 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:53655 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfFNESB (ORCPT ); Fri, 14 Jun 2019 00:18:01 -0400 Received: by mail-qk1-f201.google.com with SMTP id i196so985225qke.20 for ; Thu, 13 Jun 2019 21:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UKBZW/bY8zOAr/plZn+Op1rwjT9HYs9LkDIRTy2D6w8=; b=aJ3aHcdgyVnfvaTZCyFu4eGhtPlvIdnTr1YbDdC8IqvSTbaV5ewzq119FXRdGWbyJk +Yst8x9/AsfJCx5639sTDPYrKeGCRmttk5NbC58YhiXeafdHie+sOslPi0/Zz7zzDBya M4GsRLTvGGaxvVaCrjNKBj6U5Tjc/LfI4gBDZOj4YhUg10KFe+8NaQx6dHmi0F8ZXjm3 DUyOpK3C5VKdCMYMXQ+681gBnCsF16o4dzAcD5DSdzBT1XCf1HS8f3UBsIsvxXg34cNn 7vONj4BSGXj9k+9P8xHyycMAqXTD6B+kiZmoQ9oIm+gm8qiJqeRlkDuRWaxoQTE+ILo0 TpFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UKBZW/bY8zOAr/plZn+Op1rwjT9HYs9LkDIRTy2D6w8=; b=F0zpoz3mTFJR62ulyQs31SYCVTcVKHO5yu+RG5RrTINLKLm07/trGHV6VTqgPLJvHb FXOso9G2LRhhXgUWHs1QC6QcLb7x+lo6qaWkkcQvi4U4cF/zJQZeRYDv3GhUOmJMKLyc vgp46glxtfpBc87NFSjLGtiLDbTpA6fEWKSzyUG4FUkbb2neciYPRQPw31siGrn6C5Zg EYbxmuMn2ZMQQJ9zGHbjEQlp2hQY9OEy7yz+F1xCGUbjWzWmBvLCOfpg9qNYEGhK0rYg 7qcQV2HHHKl48s18lYEfzEGZA9UUqrAvBkB05NRRiF0RG+QFSqSmkIjKCHw8e+GVEnsI p52Q== X-Gm-Message-State: APjAAAUKouyy5EeD1VKzRXCQdnyIzF7yz8dvmC9PWIkh1J6F2Cdx75ch y8WApRbnuW82Lnxz5SrnXOhUCMuvZphpsWg= X-Google-Smtp-Source: APXvYqwNHVV/7PLhJwj+svcCIUrPmY1jO7vEGuD4JG4BFATM2A8M3NqvS+XDruf4o0rfUbchRAqDV/hvtm9tcVE= X-Received: by 2002:a05:620a:1329:: with SMTP id p9mr6566138qkj.224.1560485880047; Thu, 13 Jun 2019 21:18:00 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:29 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-8-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 07/11] OPP: Add API to find an OPP table from its DT node From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 This allows finding a device's OPP table (when it has multiple) from a phandle to the OPP table in DT. Signed-off-by: Saravana Kannan --- drivers/opp/of.c | 42 ++++++++++++++++++++++++++++++++++-------- include/linux/pm_opp.h | 7 +++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index d5815289518a..e8697a4ca3bc 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -42,14 +42,9 @@ struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node); -struct opp_table *_managed_opp(struct device *dev, int index) +struct opp_table *_find_opp_table_from_node(struct device_node *np) { struct opp_table *opp_table, *managed_table = NULL; - struct device_node *np; - - np = _opp_of_get_opp_desc_node(dev->of_node, index); - if (!np) - return NULL; list_for_each_entry(opp_table, &opp_tables, node) { if (opp_table->np == np) { @@ -69,11 +64,42 @@ struct opp_table *_managed_opp(struct device *dev, int index) } } - of_node_put(np); - return managed_table; } +/** + * dev_pm_opp_of_find_table_from_node() - Find OPP table from its DT node + * @np: DT node used for finding the OPP table + * + * Return: OPP table corresponding to the DT node, else NULL on failure. + * + * The caller needs to put the node with of_node_put() after using it. + */ +struct opp_table *dev_pm_opp_of_find_table_from_node(struct device_node *np) +{ + struct opp_table *opp_table; + + mutex_lock(&opp_table_lock); + opp_table = _find_opp_table_from_node(np); + mutex_unlock(&opp_table_lock); + return opp_table; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_table_from_node); + +struct opp_table *_managed_opp(struct device *dev, int index) +{ + struct device_node *np; + struct opp_table *opp_table; + + np = _opp_of_get_opp_desc_node(dev->of_node, index); + if (!np) + return NULL; + + opp_table = _find_opp_table_from_node(np); + of_node_put(np); + return opp_table; +} + /* The caller must call dev_pm_opp_put() after the OPP is used */ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table, struct device_node *opp_np) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2e122af26b8e..d9156b62d966 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -370,6 +370,7 @@ int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); +struct opp_table *dev_pm_opp_of_find_table_from_node(struct device_node *np); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); int of_get_required_opp_performance_state(struct device_node *np, int index); void dev_pm_opp_of_register_em(struct cpumask *cpus); @@ -407,6 +408,12 @@ static inline struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device return NULL; } +static inline struct opp_table *dev_pm_opp_of_find_table_from_node( + struct device_node *np) +{ + return NULL; +} + static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) { return NULL; From patchwork Fri Jun 14 04:17:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AD3314E5 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C71627B81 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50EA727D16; Fri, 14 Jun 2019 04:18:27 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 00D4627B81 for ; Fri, 14 Jun 2019 04:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbfFNESZ (ORCPT ); Fri, 14 Jun 2019 00:18:25 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:33662 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbfFNESD (ORCPT ); Fri, 14 Jun 2019 00:18:03 -0400 Received: by mail-pg1-f201.google.com with SMTP id v62so969183pgb.0 for ; Thu, 13 Jun 2019 21:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=nYfthp2AfyfO7B9ZHl8Ammgshm5FNB69pWC4uzGdWTs=; b=GVJb8P57i8A8s2Q/xPGtRuqGml/T3Dc0WEw/F17bY2Wsfnclfx3eGoWReG2O2lx7Gg UqqGqa+5rSPj1HwW/apFO4TKxeR038gAsdmdb24fPQ1J2xlKNO3SQeHYcojtHMumKBTM WTe4FG2V1nSEKJ40YNvaiKOND86UFZPcLh+rhoVLkd9aaSK+qGkN6VsEgJZOwSN1d40U kCje8mYmJlqqIbPjDs7c3lcHZh5KyfWT17dG7WEjxtFaIU9RkqXXN1EbHmC4Jgfj5ia0 7vwvk2Tq6R5fIrgtS/V+ak2yQ4QVpk9qGxaCPye+fr3NR5F5nC1yY5k/l8BM9BA+quEd R3Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nYfthp2AfyfO7B9ZHl8Ammgshm5FNB69pWC4uzGdWTs=; b=e4Ru8/5JO8HETLYzRa52WcBTSPa+rUNQ3IX5QyQOz7iSIfcuNib71Bl6eK6ETKu/wd N1V5ovldo4gq0Omp4x8U9qRamlQCkyj5Ln66n85IcJ1R+1l6/1WC20YxwHwQhe1FLKF3 B+mMAfjXyhkBZn+yFmKupQtGW9bDlxb6TE9ultYM7Tied7jdiiuER/aBdmnm3W84jZwK busjgaQZZu2LewC2xu/1fXfnsDy428FgA2NuhpKGMaL/9yPKjMnjaGsUc1gOKusxX9cP eS7VTZNdPDJaOUf030dJwUohtkGTn8vVYAZnTI3UjwBkSOXZ1ArBwaOcZy2TLfTi5CJ8 s+cw== X-Gm-Message-State: APjAAAUsBNGrdNHXlF/PbsRaa+vcuoSCqC1eVX2PKwDJkQJtKeMgJBP8 sPlpibBM4HCJ2QQkD1JADwXt+mxeD3ZS83g= X-Google-Smtp-Source: APXvYqzUC9HlFhAxNmIuXsO0mETwrQGfBv0aMuyKBFgTaDc2h9LrsQyWa5pzvaoE3ygZQW3W2VXMmmglbK9s5ko= X-Received: by 2002:a63:1919:: with SMTP id z25mr34405308pgl.440.1560485882676; Thu, 13 Jun 2019 21:18:02 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:30 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-9-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 08/11] dt-bindings: interconnect: Add interconnect-opp-table property From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Add support for listing bandwidth OPP tables for each interconnect path listed using the interconnects property. Signed-off-by: Saravana Kannan --- .../devicetree/bindings/interconnect/interconnect.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/interconnect/interconnect.txt b/Documentation/devicetree/bindings/interconnect/interconnect.txt index 6f5d23a605b7..fc5b75b76a2c 100644 --- a/Documentation/devicetree/bindings/interconnect/interconnect.txt +++ b/Documentation/devicetree/bindings/interconnect/interconnect.txt @@ -55,10 +55,18 @@ interconnect-names : List of interconnect path name strings sorted in the same * dma-mem: Path from the device to the main memory of the system +interconnect-opp-table: List of phandles to OPP tables (bandwidth OPP tables) + that specify the OPPs for the interconnect paths listed + in the interconnects property. This property can only + point to OPP tables that belong to the device and are + listed in the device's operating-points-v2 property. + Example: sdhci@7864000 { + operating-points-v2 = <&sdhc_opp_table>, <&sdhc_mem_opp_table>; ... interconnects = <&pnoc MASTER_SDCC_1 &bimc SLAVE_EBI_CH0>; interconnect-names = "sdhc-mem"; + interconnect-opp-table = <&sdhc_mem_opp_table>; }; From patchwork Fri Jun 14 04:17:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07851924 for ; Fri, 14 Jun 2019 04:18:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED75727B81 for ; Fri, 14 Jun 2019 04:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E133727D0E; Fri, 14 Jun 2019 04:18:11 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 D111727B81 for ; Fri, 14 Jun 2019 04:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726442AbfFNESK (ORCPT ); Fri, 14 Jun 2019 00:18:10 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:39247 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfFNESH (ORCPT ); Fri, 14 Jun 2019 00:18:07 -0400 Received: by mail-qt1-f201.google.com with SMTP id o16so1076415qtj.6 for ; Thu, 13 Jun 2019 21:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qdT885hM1gH99LBPR29/QhPlOeEng+ZQVjJx3w/T2/A=; b=Dibo09Bp3kWBRUtDeP7IlyAc8I0wb5LIZgKw4P/3gbfzowHYQkp8KvALWATtiLifF/ OgCNRHwq7V+KkgVUnp2yHEc5qXgQOOZOU05XPJf5NBPt7CFtICrUUykTd+lcCKR2SeaH K8ap0c9N6Jtz99rLRSHAmXzVlbK7jOXBUJEHtsxFtyGsBLyuM5VIeZva8JKgYA23JX/N V86388Avy5hjadcoyqZyv0uUZa1C2g5SS1ewUTpb96wNgW5h0/gF+cwveNdnSk4KmXt2 AK0RwUJDKxDAAnSfec6Xw2aoL5IOX9brzOp4yMwqt66AqibDVqTYNc91iTNpUHDOSazs wxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qdT885hM1gH99LBPR29/QhPlOeEng+ZQVjJx3w/T2/A=; b=nGVSDUrvyrMi+et4r/B+4CcXNYpjH5bgrfSGeXPVK9/k9Y1KEO1B7QqFJ7gbR78uil UbutBUDG8mcsJrIzwvHwT+gyn4upY8tKzSuB6XV6+uBvVKSvzXQeI9gceQ/LBR+yKvgW ZDRZPlgXOiAL8oLja5juW/cTl/Na4Jnej/TLi4BQO/DNB/zoKPalLZEvjYMvsOjVC9n2 Szg+AI6rnwH3XZVYTxpDkkUVSjI/Ri2b6XXY434e2FzBvQmH8q0nEYX96Hnj3RzCW1iN K3YTJKM/y/6qRkFqrDcrvOQjkVZpv5HaLkhiESOEpr+QTxfyQ+bKiLGlQ8NwjWlRdrZT 7u5Q== X-Gm-Message-State: APjAAAX25GY+Stl4nL9wQXK0B2V5PPokj7dI8Ng/ox9zpPbZQ4B+3VZz 8YWgUGZN4AHtoT8JrVerpE1m36zvKAQkNPU= X-Google-Smtp-Source: APXvYqyAWOehY93Rqe16/u7/vHBPBduhgTp81nR2/LNC3uUbwpe11mkeC0KZI8SICRtKOwtW6xRTN9Xb5zISKBc= X-Received: by 2002:ac8:4619:: with SMTP id p25mr46145520qtn.73.1560485886113; Thu, 13 Jun 2019 21:18:06 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:31 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-10-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 09/11] interconnect: Add OPP table support for interconnects From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Interconnect paths can have different performance points. Now that OPP framework supports bandwidth OPP tables, add OPP table support for interconnects. Devices can use the interconnect-opp-table DT property to specify OPP tables for interconnect paths. And the driver can obtain the OPP table for an interconnect path by calling icc_get_opp_table(). Signed-off-by: Saravana Kannan --- drivers/interconnect/core.c | 27 ++++++++++++++++++++++++++- include/linux/interconnect.h | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 871eb4bc4efc..881bac80bc1e 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -47,6 +47,7 @@ struct icc_req { */ struct icc_path { size_t num_nodes; + struct opp_table *opp_table; struct icc_req reqs[]; }; @@ -313,7 +314,7 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) { struct icc_path *path = ERR_PTR(-EPROBE_DEFER); struct icc_node *src_node, *dst_node; - struct device_node *np = NULL; + struct device_node *np = NULL, *opp_node; struct of_phandle_args src_args, dst_args; int idx = 0; int ret; @@ -381,10 +382,34 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path)); mutex_unlock(&icc_lock); + opp_node = of_parse_phandle(np, "interconnect-opp-table", idx); + if (opp_node) { + path->opp_table = dev_pm_opp_of_find_table_from_node(opp_node); + of_node_put(opp_node); + } + + return path; } EXPORT_SYMBOL_GPL(of_icc_get); +/** + * icc_get_opp_table() - Get the OPP table that corresponds to a path + * @path: reference to the path returned by icc_get() + * + * This function will return the OPP table that corresponds to a path handle. + * If the interconnect API is disabled, NULL is returned and the consumer + * drivers will still build. Drivers are free to handle this specifically, but + * they don't have to. + * + * Return: opp_table pointer on success. NULL is returned when the API is + * disabled or the OPP table is missing. + */ +struct opp_table *icc_get_opp_table(struct icc_path *path) +{ + return path->opp_table; +} + /** * icc_set_bw() - set bandwidth constraints on an interconnect path * @path: reference to the path returned by icc_get() diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index dc25864755ba..0c0bc55f0e89 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -9,6 +9,7 @@ #include #include +#include /* macros for converting to icc units */ #define Bps_to_icc(x) ((x) / 1000) @@ -28,6 +29,7 @@ struct device; struct icc_path *icc_get(struct device *dev, const int src_id, const int dst_id); struct icc_path *of_icc_get(struct device *dev, const char *name); +struct opp_table *icc_get_opp_table(struct icc_path *path); void icc_put(struct icc_path *path); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); @@ -49,6 +51,11 @@ static inline void icc_put(struct icc_path *path) { } +static inline struct opp_table *icc_get_opp_table(struct icc_path *path) +{ + return NULL; +} + static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) { return 0; From patchwork Fri Jun 14 04:17:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 438B714E5 for ; Fri, 14 Jun 2019 04:18:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3520D27B81 for ; Fri, 14 Jun 2019 04:18:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28ECF27D0E; Fri, 14 Jun 2019 04:18:23 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 C651A27B81 for ; Fri, 14 Jun 2019 04:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbfFNESK (ORCPT ); Fri, 14 Jun 2019 00:18:10 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:49878 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbfFNESK (ORCPT ); Fri, 14 Jun 2019 00:18:10 -0400 Received: by mail-qk1-f201.google.com with SMTP id c4so991737qkd.16 for ; Thu, 13 Jun 2019 21:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VA7s9ly0lqdagUAyh1uYpw4qgEasvgJFlK1lzvkukqY=; b=TrEXlT8djNpXPJc0j8YuBg6jTcfItK6GjAaeUSewHjYjftr5gYxyJuqq3MGH1OUe1T F3xdsaC3oKrSs+dlLVQW3XrlXYI+1M2VVTmgutAgeR/C8BeBT2yPpIVqmYf0mybVrYxo wmtTS/hWV6UkMbpi0KH7Dgq3wWGTIZtkgefl5OGGmwKX/S5v6YwKVnVU3C1gpFDeO+2I FBr4uMGQpUMsUfh59BM9jW4yJHzxtr2LArxfDQbupQodPwMohSfxjbPi3RMe0hpBN2iX XKBIGUhfIgNitWDR3R/EHS75rmfuv6cnWhkdhva0AOGRbVQuo7nzNskKg+bmAYvCCtN7 zNcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VA7s9ly0lqdagUAyh1uYpw4qgEasvgJFlK1lzvkukqY=; b=BkMUWPH24j6DGb8+YyPWlCOikB5HWjJu3QB0m42Z1zlte8zUQLDs/Fxmc3RDS7ZRce +ftQZIWYpNvRGA3APkJ+e5iRUUtBi5UHVl1a7ft2Vv5V8Gzk6JhtP7uujPCColYrN2n0 Tsm6Wtr2D2ydN5RHwLvl5nRjz4kIpPoBKWxO82nxUuO/0y/MqtUuzM765xkLsR+H1HuB fLPQczDgNmqC8Lpp5sXrntN+icTFNid9gBVWjXJzw03L+2145OUl6V0B6Ru03Rhpw6LC y+g5jLqGl9FE1DQI8uhombF64mEC0rLy3N+KRyDXIqgv5+OyTIouXavKNh10zDnLNn+m xbsA== X-Gm-Message-State: APjAAAUOqmWgfZF6bXsS7L6FzHoGr/2/1Onxv4XFA0yWfa8i2BPkZSS4 hgYjuu1MaGsBrW+YoR/UzDUsGAC5Kt8vU7E= X-Google-Smtp-Source: APXvYqzEU9fWluswZw2wyE1N4COxp8I6V3iABbyGVjD++OlIlQ99JPYxbbaQ1U5BqOb5o+DCUfLqGIKFA8Ys39Q= X-Received: by 2002:ac8:1794:: with SMTP id o20mr80687898qtj.239.1560485889196; Thu, 13 Jun 2019 21:18:09 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:32 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-11-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 10/11] OPP: Allow copying OPPs tables between devices From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Some hardware devices might create multiple children devices to manage different components of the hardware. In these cases, it might be necessary for the original hardware device to copy specific OPP tables to a specific the new child device. Add dev_pm_opp_add_opp_table() to do that. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 8 ++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index c9914afd508a..668a377f59a5 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -943,6 +943,14 @@ struct opp_device *_add_opp_dev(const struct device *dev, return opp_dev; } +int dev_pm_opp_add_opp_table(struct device *dev, struct opp_table *opp_table) +{ + if (!dev || !opp_table) + return -EINVAL; + + return _add_opp_dev(dev, opp_table) ? 0 : -ENOMEM; +} + static struct opp_table *_allocate_opp_table(struct device *dev, int index) { struct opp_table *opp_table; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index d9156b62d966..3694d703817f 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -81,6 +81,7 @@ struct dev_pm_set_opp_data { struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index); void dev_pm_opp_put_opp_table(struct opp_table *opp_table); +int dev_pm_opp_add_opp_table(struct device *dev, struct opp_table *opp_table); unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); @@ -158,6 +159,12 @@ static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device * static inline void dev_pm_opp_put_opp_table(struct opp_table *opp_table) {} +static int dev_pm_opp_add_opp_table(struct device *dev, + struct opp_table *opp_table) +{ + return -ENOTSUPP; +} + static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) { return 0; From patchwork Fri Jun 14 04:17:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10994275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DCD4924 for ; Fri, 14 Jun 2019 04:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE95727B81 for ; Fri, 14 Jun 2019 04:18:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DECF927D0E; Fri, 14 Jun 2019 04:18:19 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 3670327B81 for ; Fri, 14 Jun 2019 04:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfFNESO (ORCPT ); Fri, 14 Jun 2019 00:18:14 -0400 Received: from mail-yw1-f74.google.com ([209.85.161.74]:48352 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbfFNESN (ORCPT ); Fri, 14 Jun 2019 00:18:13 -0400 Received: by mail-yw1-f74.google.com with SMTP id t128so1203400ywd.15 for ; Thu, 13 Jun 2019 21:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=XMHdLt0F/RebP7HWzdCoOFobZW4NF5SUvUmDw/iFZhM=; b=oTap/qZTUkne67PMlUoRRMatHHPoKZTDEI6qJcuLB9ihSS6zThbjemCxzkWFRfYDe4 9d5fipYW0JDjBZJeOHeskT7pfF+F2CeBpJ+4vA1yNvx2v0cvuNhnlf9B1F4czXrF6e1E 9KPWCEuAqkILo799F3zCy0q+meYFfDuPZ+paISctiLQNVa2A4nJsys8iaiFxlp3gmRhm ygQFxemjnu5T7BIut2Z9MFiKsjFKLfEJkIwabASqhhwBSNUs+h/RYpFnGb4bpGm7yI/f 5B2BR72PGxmfhE8Ty/RgPIDa2ouzpT0/02fA87EU5jCUGNpJNjPCTJCQihiOgCFU+Y66 Lgnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=XMHdLt0F/RebP7HWzdCoOFobZW4NF5SUvUmDw/iFZhM=; b=sNm0xojc/Cb6vqVLlwdObLQbIKYqYs7g8AKElO/T5yvZU+/WZcqy5YLnxP/sZhC5yo rY8q0OCjwN2TDMhvL3D0SnG/wrxUkO3JiUp3hm044k2nrOLeyN38cJj3SWogYAUZP7U4 hPOuM6Na8KcPplXJi7om51B83qXv7VbcjyFf1i9gc3Dxo39camd2yzg/sGn5LDso+cvz ypz2QLCrKaOQ57RpJIJGXXTdr8t1Ct2lrlJtEs4VV/14XZ7k6xe9/CnhlsQTxPBvN0sG HtjpbbgXbNv1pv13LzugT5/qt9vJBEr0DCnwqGMahdPo6lpTXOu5XaSe3zdOVLQyP/hJ 3dBg== X-Gm-Message-State: APjAAAXvdlwwB8k04hhrwKttwE/D8a0ckZ69+giZ+l+mawIB9a6gwE9t t6cZ59Aq053aitBhYlAdaNTpF9SCrQZwFAc= X-Google-Smtp-Source: APXvYqyzotUOqc78Ajag02/VO0hFFB2pIylM0aPaNgvpI75rUDbQ8p8l6vCV8TAGFIu1713tf9bDphp6hphaolQ= X-Received: by 2002:a81:35c9:: with SMTP id c192mr42314247ywa.193.1560485892382; Thu, 13 Jun 2019 21:18:12 -0700 (PDT) Date: Thu, 13 Jun 2019 21:17:33 -0700 In-Reply-To: <20190614041733.120807-1-saravanak@google.com> Message-Id: <20190614041733.120807-12-saravanak@google.com> Mime-Version: 1.0 References: <20190614041733.120807-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v2 11/11] interconnect: Add devfreq support From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org 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 Add a icc_create_devfreq() and icc_remove_devfreq() to create and remove devfreq devices for interconnect paths. A driver can create/remove devfreq devices for the interconnects needed for its device by calling these APIs. This would allow various devfreq governors to work with interconnect paths and the device driver itself doesn't have to actively manage the bandwidth votes for the interconnects. Signed-off-by: Saravana Kannan --- drivers/interconnect/Makefile | 2 +- drivers/interconnect/icc-devfreq.c | 156 +++++++++++++++++++++++++++++ include/linux/interconnect.h | 14 +++ 3 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 drivers/interconnect/icc-devfreq.c diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile index 28f2ab0824d5..ddfb65b7fa55 100644 --- a/drivers/interconnect/Makefile +++ b/drivers/interconnect/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -icc-core-objs := core.o +icc-core-objs := core.o icc-devfreq.o obj-$(CONFIG_INTERCONNECT) += icc-core.o obj-$(CONFIG_INTERCONNECT_QCOM) += qcom/ diff --git a/drivers/interconnect/icc-devfreq.c b/drivers/interconnect/icc-devfreq.c new file mode 100644 index 000000000000..608716fbe612 --- /dev/null +++ b/drivers/interconnect/icc-devfreq.c @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * A devfreq device driver for interconnect paths + * + * Copyright (C) 2019 Google, Inc + */ + +#include +#include +#include +#include +#include +#include +#include + +struct icc_devfreq { + struct device icc_dev; + struct icc_path *path; + struct devfreq_dev_profile dp; + struct devfreq *df; + unsigned long peak_bw; + unsigned long avg_bw; +#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) + struct devfreq_passive_data p_data; +#endif +}; + +static int icc_target(struct device *dev, unsigned long *freq, + u32 flags) +{ + struct icc_devfreq *d = dev_get_drvdata(dev); + struct dev_pm_opp *opp; + unsigned long peak_bw, avg_bw; + + opp = devfreq_recommended_opp(dev, &peak_bw, flags); + if (IS_ERR(opp)) { + dev_err(dev, "Failed to find opp for %lu KHz\n", *freq); + return PTR_ERR(opp); + } + peak_bw = dev_pm_opp_get_bw(opp, &avg_bw); + dev_pm_opp_put(opp); + + if (!icc_set_bw(d->path, avg_bw, peak_bw)) { + *freq = peak_bw; + d->peak_bw = peak_bw; + d->avg_bw = avg_bw; + } + + return 0; +} + +static int icc_get_dev_status(struct device *dev, + struct devfreq_dev_status *stat) +{ + struct icc_devfreq *d = dev_get_drvdata(dev); + + stat->current_frequency = d->peak_bw; + return 0; +} + +#define icc_dev_to_data(DEV) container_of((DEV), struct icc_devfreq, icc_dev) +static void icc_dev_release(struct device *dev) +{ + struct icc_devfreq *d = icc_dev_to_data(dev); + + kfree(d); +} + +struct icc_devfreq *icc_create_devfreq(struct device *dev, char *name, + struct devfreq *devf) +{ + struct icc_devfreq *d; + struct icc_path *path; + struct opp_table *opp_table; + struct dev_pm_opp *opp; + void *p_data = NULL; + unsigned long peak_bw = U32_MAX, avg_bw = U32_MAX; + int err; + + if (!name) + return ERR_PTR(-EINVAL); + + path = of_icc_get(dev, name); + if (IS_ERR(path)) + return (void *) path; + + opp_table = icc_get_opp_table(path); + if (!opp_table) { + err = -EINVAL; + goto out_path; + } + + d = kzalloc(sizeof(*d), GFP_KERNEL); + if (!d) { + err = -ENOMEM; + goto out_path; + } + d->path = path; + + d->icc_dev.parent = dev; + d->icc_dev.release = icc_dev_release; + dev_set_name(&d->icc_dev, "%s-icc-%s", dev_name(dev), name); + err = device_register(&d->icc_dev); + if (err) { + put_device(&d->icc_dev); + goto out_path; + } + + dev_pm_opp_add_opp_table(&d->icc_dev, opp_table); + opp = dev_pm_opp_find_peak_bw_floor(dev, &peak_bw); + peak_bw = dev_pm_opp_get_bw(opp, &avg_bw); + dev_pm_opp_put(opp); + + if (!icc_set_bw(d->path, avg_bw, peak_bw)) { + d->peak_bw = peak_bw; + d->avg_bw = avg_bw; + } + +#if !IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) + if (devf) { + d->p_data.parent = devf; + pdata = &d->p_data; + } +#endif + d->dp.initial_freq = peak_bw; + d->dp.polling_ms = 0; + d->dp.target = icc_target; + d->dp.get_dev_status = icc_get_dev_status; + d->df = devm_devfreq_add_device(&d->icc_dev, + &d->dp, + p_data ? "passive" : "performance", + p_data); + if (IS_ERR(d->df)) { + err = PTR_ERR(d->df); + goto out_dev; + } + + return d; +out_dev: + put_device(&d->icc_dev); +out_path: + icc_put(path); + return ERR_PTR(err); +} +EXPORT_SYMBOL_GPL(icc_create_devfreq); + +void icc_remove_devfreq(struct icc_devfreq *d) +{ + icc_put(d->path); + put_device(&d->icc_dev); +} +EXPORT_SYMBOL_GPL(icc_remove_devfreq); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("interconnect devfreq device driver"); +MODULE_AUTHOR("Saravana Kannan "); diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index 0c0bc55f0e89..ec5879a79301 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -10,6 +10,7 @@ #include #include #include +#include /* macros for converting to icc units */ #define Bps_to_icc(x) ((x) / 1000) @@ -23,6 +24,7 @@ struct icc_path; struct device; +struct icc_devfreq; #if IS_ENABLED(CONFIG_INTERCONNECT) @@ -32,6 +34,9 @@ struct icc_path *of_icc_get(struct device *dev, const char *name); struct opp_table *icc_get_opp_table(struct icc_path *path); void icc_put(struct icc_path *path); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); +struct icc_devfreq *icc_create_devfreq(struct device *dev, char *name, + struct devfreq *devf); +void icc_remove_devfreq(struct icc_devfreq *d); #else @@ -61,6 +66,15 @@ static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) return 0; } +static inline struct icc_devfreq *icc_create_devfreq(struct device *dev, + char *name, + struct devfreq *devf); +{ + return NULL; +} + +void icc_remove_devfreq(struct icc_devfreq *d) {} + #endif /* CONFIG_INTERCONNECT */ #endif /* __LINUX_INTERCONNECT_H */