From patchwork Tue Jun 25 21:33:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11016431 X-Patchwork-Delegate: viresh.linux@gmail.com 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 8A68276 for ; Tue, 25 Jun 2019 21:34:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC4028564 for ; Tue, 25 Jun 2019 21:34:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FCD32856E; Tue, 25 Jun 2019 21:34:08 +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 188D728564 for ; Tue, 25 Jun 2019 21:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfFYVdq (ORCPT ); Tue, 25 Jun 2019 17:33:46 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:49715 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfFYVdq (ORCPT ); Tue, 25 Jun 2019 17:33:46 -0400 Received: by mail-pl1-f202.google.com with SMTP id 65so8659plf.16 for ; Tue, 25 Jun 2019 14:33: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=diT5j67eq/c/BsDoIxqIkGMzy6KvSDn7bQJLbufPm+c=; b=Qt2GyuTO7pTaIYstjFLkJ4UcWzoUKoZj4qXob3li6BuGiuKeH50eLMmsx/LxWdsWLA oecwexwecInCXpqVHrwJlB4oAOh+bGLiUQ7Ec4LJU+29OlER1pH1x3YVV0RvrcOgm7KW vI2ZTO9GPmN98FDlAFxgVgIwLUitzndyN5zxbeY1PhbYfBoi8r0f8IIAtmRh6ywTaa76 UpVrAJkLoVqes/Tv9AOUt81P8QMCOlNI3ggTX7v9EgbJIuZiRmlDd1k+MnS3316TxoeS gwcZxmG5mkTa+WNatLkSNvEXmvBi5LZgTzem7X7JYmp2q1tpK8W9NiJk7MDucsTcG70S 3ZwA== 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=diT5j67eq/c/BsDoIxqIkGMzy6KvSDn7bQJLbufPm+c=; b=Uctgs0J1xCB+lnHQc5bf/bxnPDcK7kyLMV/mCp/LorDF/iehhRUTgT0VIswgmj5/bV M9fiOVUpmw/tR8QcbLOlRc26ylBm88Z4REdIBx9ocJ4U/fAlNcVXzkdd2eOL91Stw1Fe Gs5le2+rMpWJbGlsWwe/GSZHE1tLg7v23rRLRiAwb2PM6H5diNx0qozgXLfcbUJjU0Us YNv9JG5VMOzveTTPcqL2DwJMgeUaZoEK7NSXudPfILtSgJYaipQY6O29fHaKsnPo//YO JXr4lElhw/8sFeJycH+G1aMXn69hn0UJA7gPKjL+fjZ9BiWnwHYq85IIwJYmX1iP9Oil RlCg== X-Gm-Message-State: APjAAAVNiTfRbqt3a2DrbDcVXJs1j1byeqDjD87hNtxGhKMkc1OcsKPI WYdX2Hsbhltp8Jo3fXq8ztRtIyiJwQSbSvc= X-Google-Smtp-Source: APXvYqzIHSXTSLsgydrPoSZc9EgXx53vFFhsfQ8jj9MTVHjjXWYgkmbSCbVTleIIJbzNNIH7BCg3E5ALTwZptWI= X-Received: by 2002:a63:231a:: with SMTP id j26mr40088869pgj.389.1561498425029; Tue, 25 Jun 2019 14:33:45 -0700 (PDT) Date: Tue, 25 Jun 2019 14:33:34 -0700 In-Reply-To: <20190625213337.157525-1-saravanak@google.com> Message-Id: <20190625213337.157525-2-saravanak@google.com> Mime-Version: 1.0 References: <20190625213337.157525-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2 1/4] OPP: Allow required-opps even if the device doesn't have power-domains From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , kernel-team@android.com, linux-pm@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 Tue Jun 25 21:33:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11016425 X-Patchwork-Delegate: viresh.linux@gmail.com 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 5983176 for ; Tue, 25 Jun 2019 21:33:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4996828564 for ; Tue, 25 Jun 2019 21:33:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D4432856E; Tue, 25 Jun 2019 21:33: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=-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 23DC728564 for ; Tue, 25 Jun 2019 21:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbfFYVdu (ORCPT ); Tue, 25 Jun 2019 17:33:50 -0400 Received: from mail-yw1-f73.google.com ([209.85.161.73]:38587 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfFYVdt (ORCPT ); Tue, 25 Jun 2019 17:33:49 -0400 Received: by mail-yw1-f73.google.com with SMTP id p76so390298ywg.5 for ; Tue, 25 Jun 2019 14:33:49 -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=55ECQLYpQeuYJFjToVK2bkLCDXOJV5cNzofiMV5ttzw=; b=Spli0ntDMpZ6dRXQDnlLhHi0fVx1WJuQhhfvcZPaGNmfW7Y/kXel+iFyKdsv2i5jfn CFQ2CGGfAQ9miZBR4q346MAMIACb09Gafnlrr1Onm9mlLpE/MV5UmAor4wbEgj4CS205 d/NmuMjGqTEkJwbO3TlKcTrFEf63tafgWWCWMrw/l5qzS6AvehlP0MmNi7JbgkGjBlwk s/kQ3B9QNKelCtt9BVx0DZ0UriXid+4I82Jz4XgbzE7qFgiAJCXVetqbRckxngxP+Qos QDfPN2FcKkTbrGon55ExRecGZsnBkbu8MrLHNkaeG2zSzf3Sj+o/h4bPNVM1DatH/rs2 iKLw== 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=55ECQLYpQeuYJFjToVK2bkLCDXOJV5cNzofiMV5ttzw=; b=Dwz1ISJO4BxNYkzWzPeQDyJi7WLJQPR2SY2gDG4XXou+eBirYE5AWIpygIIYRK9MhU 7NKLt/pNpRbf3PvT9CvoI7bTFPHgQogXIWC6PvOJTcwZnX3GdAWCFdpD78f3gbjJFF7K rYOoBMYcWNjisXc2nsrfoQkYTbVE2Fc+8H7vrYxInuPzYT8mU9UpScywR0V7vdmcmxgQ UnpXPRmBR/Fe39xXAbF9Iy5Y2Z6bQeVpI127j/ad3Ls2/7eO8Sgu3GT3mqP6BurbZ1R0 J9E9JYWRFmuPwfXTJlX/m5giJQDG6HgkFFehzPvlsOmBbxKYKbfzNP8rGlJd2rRi36mr k9Eg== X-Gm-Message-State: APjAAAX2PHmkpiQsihteKbUJvSNJhJHoLMDV2LWduL/ara5MyuYjqspW qwJV5uJ07VTI8jM6Sxuy1PI3xbUOEygDaI0= X-Google-Smtp-Source: APXvYqw+f9I5AdpreQTdWIxzunUw0GN0xNNYn4xBkvVphAfkvd6FHaFlAPqfXXr6EO/T4PdMGZ8Qho/qiU/ovqk= X-Received: by 2002:a81:7746:: with SMTP id s67mr563043ywc.257.1561498428384; Tue, 25 Jun 2019 14:33:48 -0700 (PDT) Date: Tue, 25 Jun 2019 14:33:35 -0700 In-Reply-To: <20190625213337.157525-1-saravanak@google.com> Message-Id: <20190625213337.157525-3-saravanak@google.com> Mime-Version: 1.0 References: <20190625213337.157525-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2 2/4] OPP: Add function to look up required OPP's for a given OPP From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , kernel-team@android.com, linux-pm@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 Tue Jun 25 21:33:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11016429 X-Patchwork-Delegate: viresh.linux@gmail.com 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 A535E13B4 for ; Tue, 25 Jun 2019 21:34:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D47728564 for ; Tue, 25 Jun 2019 21:34:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 814382856F; Tue, 25 Jun 2019 21:34:00 +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 220F228564 for ; Tue, 25 Jun 2019 21:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbfFYVdz (ORCPT ); Tue, 25 Jun 2019 17:33:55 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:44440 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbfFYVdw (ORCPT ); Tue, 25 Jun 2019 17:33:52 -0400 Received: by mail-qt1-f201.google.com with SMTP id x10so167269qti.11 for ; Tue, 25 Jun 2019 14:33:52 -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=lpO4xjO0dM1h5Blpl/u+aSxMu+4T0qkcqrt5hW3H2qY=; b=Ph4Tz/3vcNuZ/WoEa6GYfePulm3GVZ4kU2VTUl4xi8WiaIEzqgtKU6RkGGEnwHXhhZ 9vPvuryB17TSn9+Kp7LY1Gx5YrMIUz31583R/36kO/hMTIOoUV/sn5MclPgXsyQEdaLL WIe6divrdg6dWVjVEtjpiRsJwBEjA3bUGGFOMh4RHSgdB0xTwnKtTJwOoyaWrnMMYpAd QbMOf2mWXpegBj97lH2TEYZO3vf1dqaVfiROuXLySE89NxbGN8FrK94c3FRoqevPnQT7 /FP1bPaZab4eIe5MhuWr/0DIfUBi2MH8sIArazkMN18QtI3T40b8uhGx83jsqsSJRcDF EgKw== 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=lpO4xjO0dM1h5Blpl/u+aSxMu+4T0qkcqrt5hW3H2qY=; b=nkJ4ZMqVwXARPRMuyT0lpmRK/l4xOkbx9CnVMu/yn/QAkSZ94iCeubQejVHJdKTitl vBVFTAshCuE7UaSxQjN/1BbrnQIh9xEbaYEECiU1cJe5Cmxn2rfkBS1Tx0CJWF1FkHk/ ToqN2Xs2uHI5g1NiuV5hOja9AMaZNrUdusGnF3kdI5sypEpUQ2kT9a7d1IJqciikclTu ZMTLS7UeHhwA8PFlOm6ehZAiA7Ae4OybnwQWMp6lMsSV5zVrE+bXXs1sIS0khfUhpzcl h7OT3sq5YOYymTF1PR4E216ipmz/xDihzDEfWOpljv3vTFHAUbgJrvRNx2dNfM03/dOk WJmQ== X-Gm-Message-State: APjAAAWvBQV4MOUVhQEmRiN3vbk8Nvt931xr7pdSMCm1HSc217ouhn3h XoKb2XesAMy1dqFFnsaRTapjucpUuyFELXM= X-Google-Smtp-Source: APXvYqxpfEm4nfiU1Dwk713424NCd7N55o3hovecqBTIbBVv3igByEAc4gkvXHdQsHautnOyLfUSl1qXDiJbjhA= X-Received: by 2002:a37:a648:: with SMTP id p69mr815052qke.136.1561498431578; Tue, 25 Jun 2019 14:33:51 -0700 (PDT) Date: Tue, 25 Jun 2019 14:33:36 -0700 In-Reply-To: <20190625213337.157525-1-saravanak@google.com> Message-Id: <20190625213337.157525-4-saravanak@google.com> Mime-Version: 1.0 References: <20190625213337.157525-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2 3/4] PM / devfreq: Cache OPP table reference in devfreq From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , kernel-team@android.com, linux-pm@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 OPP table can be used often in devfreq. Trying to get it each time can be expensive, so cache it in the devfreq struct. Signed-off-by: Saravana Kannan Acked-by: MyungJoo Ham Reviewed-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 6 ++++++ include/linux/devfreq.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 6b6991f0e873..ac62b78dc035 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -597,6 +597,8 @@ static void devfreq_dev_release(struct device *dev) if (devfreq->profile->exit) devfreq->profile->exit(devfreq->dev.parent); + if (devfreq->opp_table) + dev_pm_opp_put_opp_table(devfreq->opp_table); mutex_destroy(&devfreq->lock); kfree(devfreq); } @@ -677,6 +679,10 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->max_freq = devfreq->scaling_max_freq; devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev); + devfreq->opp_table = dev_pm_opp_get_opp_table(dev); + if (IS_ERR(devfreq->opp_table)) + devfreq->opp_table = NULL; + atomic_set(&devfreq->suspend_count, 0); dev_set_name(&devfreq->dev, "devfreq%d", diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index fbffa74bfc1b..0d877c9513d7 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -156,6 +156,7 @@ struct devfreq { struct devfreq_dev_profile *profile; const struct devfreq_governor *governor; char governor_name[DEVFREQ_NAME_LEN]; + struct opp_table *opp_table; struct notifier_block nb; struct delayed_work work; From patchwork Tue Jun 25 21:33:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11016427 X-Patchwork-Delegate: viresh.linux@gmail.com 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 CE9E513B4 for ; Tue, 25 Jun 2019 21:33:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB1928564 for ; Tue, 25 Jun 2019 21:33:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B42152856E; Tue, 25 Jun 2019 21:33:57 +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 55EAD28564 for ; Tue, 25 Jun 2019 21:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbfFYVd4 (ORCPT ); Tue, 25 Jun 2019 17:33:56 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:37913 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726454AbfFYVdz (ORCPT ); Tue, 25 Jun 2019 17:33:55 -0400 Received: by mail-pg1-f202.google.com with SMTP id 3so161780pgc.5 for ; Tue, 25 Jun 2019 14:33:55 -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=pSd2SEQBNKQJHNErQavWSNgkmJEBQdH7SImGVZiADmI=; b=Nac5aiSPpKXkEoBjULWPNAHKlYVVswo8Sv+aG4Nke8sMPOVW/szdI6v3v2LjD3wyEj dSxGFXMq4R6/VUvASlerc0YHjxEciGlmfpvUQaqcj9qMSwHIIRpqZIrWJldrniWDW9Hg CyVQmYNhxjtZcDOdChKUCwLkP9gicQce4SEip766nU7aK7h7m17qe6A1M/GXpqAaVYZu xCtO7hBsnvfCOL+wvWBKWthJhv9Yi76HPcJxAiR7XIIb7WmR4GVwX5BVQP558AWcJlB6 LcSUR0W4OQfEKF47DlvQQlgePqeSjxEA9B7/QWoIUYLIMXjc+UQDI6N9vFjDEnXMypku M9zg== 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=pSd2SEQBNKQJHNErQavWSNgkmJEBQdH7SImGVZiADmI=; b=CCmdofbxgOsdWeU36hzn+d+TFSVxeaI/NlRb6rpkojeZ9755qv8j644vBSQ0QhKifk V5Lt6p+p3qnHUIeixHzD46BJNPTkvxKXxhFvtizF9zJCATJUntVm4oVUxIeD3ZzHwJq2 OgxGoVuVT0tEn312aoTjTBj9JkuAjrTZES0lHRDgkTOuEUxfQWd6zuqfWK4QJ1oxNKko iGEXNGGN+Kh+zl6uGWZb5S1/SbHYDcXEZhftYfgmFqaPXo8khCGXCtug8af6VNesJTQe T5D7TTgWzn6aRj6pD0sUyDvV7esmDiInnPgQv8+Crg7YWzfgv1zmaeAHXMd6qajzxF+k d+2w== X-Gm-Message-State: APjAAAUZTVY0SwCPJiU/kig0nmMnC4p38OMugEOV1SubnoqC+pi9wfDS ZOrJsn1psi6zDM1iNwVY76PJH6f7vPzuHEM= X-Google-Smtp-Source: APXvYqxiaI1A+FOWzhGL3gXUXbGdGJVhVOkRbDCDZJ1LQ4tDeB1cBg4isNNSqYgykqDQ7wiPiLWYdl6pW7jSYMI= X-Received: by 2002:a63:34c3:: with SMTP id b186mr507704pga.294.1561498434498; Tue, 25 Jun 2019 14:33:54 -0700 (PDT) Date: Tue, 25 Jun 2019 14:33:37 -0700 In-Reply-To: <20190625213337.157525-1-saravanak@google.com> Message-Id: <20190625213337.157525-5-saravanak@google.com> Mime-Version: 1.0 References: <20190625213337.157525-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2 4/4] PM / devfreq: Add required OPPs support to passive governor From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , kernel-team@android.com, linux-pm@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 Acked-by: MyungJoo Ham Acked-by: Chanwoo Choi --- drivers/devfreq/governor_passive.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 3bc29acbd54e..f6de03de7a64 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -22,7 +22,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, = (struct devfreq_passive_data *)devfreq->data; struct devfreq *parent_devfreq = (struct devfreq *)p_data->parent; unsigned long child_freq = ULONG_MAX; - struct dev_pm_opp *opp; + struct dev_pm_opp *opp = NULL, *p_opp = NULL; int i, count, ret = 0; /* @@ -59,13 +59,20 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, * list of parent device. Because in this case, *freq is temporary * value which is decided by ondemand governor. */ - opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); - if (IS_ERR(opp)) { - ret = PTR_ERR(opp); + p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent, freq, 0); + if (IS_ERR(p_opp)) { + ret = PTR_ERR(p_opp); goto out; } - dev_pm_opp_put(opp); + if (devfreq->opp_table && parent_devfreq->opp_table) + opp = dev_pm_opp_xlate_opp(parent_devfreq->opp_table, + devfreq->opp_table, p_opp); + if (opp) { + *freq = dev_pm_opp_get_freq(opp); + dev_pm_opp_put(opp); + goto out; + } /* * Get the OPP table's index of decided freqeuncy by governor @@ -92,6 +99,9 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, *freq = child_freq; out: + if (!IS_ERR_OR_NULL(opp)) + dev_pm_opp_put(p_opp); + return ret; }