From patchwork Fri Dec 14 10:15:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153805 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881732ljp; Fri, 14 Dec 2018 02:15:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/XR4/fPR8PxB5ZNBz2cv9rQV1GqH8rALxgtsxiJqKwcaZ0c/jAPBfSw1gjAAne9Sxg3BVH8 X-Received: by 2002:a17:902:5601:: with SMTP id h1mr2382872pli.160.1544782548108; Fri, 14 Dec 2018 02:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782548; cv=none; d=google.com; s=arc-20160816; b=XgchhnIxEuaOCg7uKrW8ySeFXXxr+Qu9P88TbME6IBNQojOuFkvWPnJQrb/GvohmsG O4ieqHZHlGOxLo0tNJhCl0xpkCIVUWLhpyHG5F5+j77PKZ9nkEIzKPIQJoeDj3kpzK9x thfTuvbFOJEE54QhgpbG2pqeYyKv26PoxHdXzKQMuAQRwBuAwAfnQtlKHJMp4nEf3mtM dW4Ax7Hj+0HOiMwz1s9TQE70VF3IpYbn5FEnzmwXpmkmaMveMJ34L4NInpl31lXZvI0q JvGrgagJ42rn86cFQeHxtH2ugjlaMSfovzJx7HhuGml8EVEoLNHawwttfgmfpk5RpWT1 DCKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=XD5aPJDvHRZ581FcCUpgoeC6urUyEEoQWOeuEQ8rbv/59y08IGONbdds0TYsjms7pB X+kiOnJwGwnpMXklYSY/1eK/MYNNuYPK7NVnNI2GOZHEL7MLXOkDB75srfNMZnLprzdK uurtdrRDGjOyUyuoCMtY3ZxG6CGVIWcZpG5bFr1ygaK+f01g67ysY/me4a4KwmGzHm78 XPqeHDknCDNiRMazSVFioLC/FE+uBDsKFLJlMLtyu3MbxYjgcZisNUuOmWcakedzVWgp 06Or59pqVf8V5DnsKp6lMDPiWnYDw7yItjywN4yO633G7qQR2bTojW3RZET2kpGpu6TN 9Teg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Uw/P9maD"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si3778037pfm.71.2018.12.14.02.15.47; Fri, 14 Dec 2018 02:15:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Uw/P9maD"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729491AbeLNKPq (ORCPT + 11 others); Fri, 14 Dec 2018 05:15:46 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40685 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729488AbeLNKPp (ORCPT ); Fri, 14 Dec 2018 05:15:45 -0500 Received: by mail-pf1-f196.google.com with SMTP id i12so2619614pfo.7 for ; Fri, 14 Dec 2018 02:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=Uw/P9maDkd8VqTiGsuCXmhrm+JkG2Noyk0z/Jgyk1x2hz0BnnLzjDvJV6QgYGzd8kR Rsm0s6bTTIeIOJXgXQBmW3VFkYiEU1Qj3b5uWSCYFoFYcxi7WP4q0/ZCI0I879BwlNIo fQV/3AQ36xDGa68tMmkM5gISuDLbxbB5py6+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2LwDno6pPq3+62WWHDum9qZ80rXO5n5aGPdUmxZHq/s=; b=YNRg+9jRZrtBaZ3nCD53ut8080E19+hK4mTIN2UgwwDpnn9RB5r28Z6SWVGzseh4fJ H+6MHQ5+6ItvNZQMUMFLU8IxdfRxyXi6FeaBer/F9jL1Q5pts4oQ2xz29KWhQJ0ADb8N 5rhKSQ6vDXqaGs8+1h6XEWPfOm1ZMOUmgMAa7ilLvTkcMBGCwBmpCM/u5XnNy4+x7J4q MMaGENkfqKyOABy5Rk4ep88zF+es/maCy8tH7+YhNb5846laRb0Wk5Vis/2nPjx6Enk7 9+xMR/Dckr44Azx1dexPIvTFrf1DbA0OfKSH0hfRYn+0PR4Ptl9MrZtti0ALgaBQ/liO 6dnA== X-Gm-Message-State: AA+aEWZddNPtx4FQ8ls87Q0j59+L1HLxlvzJOXKWneaKHdow36uo7v5n zSv7M10wR/ATGXoPkqFZSGQ7Cg== X-Received: by 2002:a65:47ca:: with SMTP id f10mr2243734pgs.166.1544782544631; Fri, 14 Dec 2018 02:15:44 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id c81sm13095642pfb.107.2018.12.14.02.15.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:44 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 2/7] OPP: Improve _find_table_of_opp_np() Date: Fri, 14 Dec 2018 15:45:28 +0530 Message-Id: <184bbc28f982752cc040f0b9286516c3897e2808.1544782279.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Make _find_table_of_opp_np() more efficient by using of_get_parent() to find the parent OPP table node. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/opp/of.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 3ef7f38c0986..8e57d257be77 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -114,19 +114,25 @@ static struct device_node *of_parse_required_opp(struct device_node *np, static struct opp_table *_find_table_of_opp_np(struct device_node *opp_np) { struct opp_table *opp_table; - struct dev_pm_opp *opp; + struct device_node *opp_table_np; lockdep_assert_held(&opp_table_lock); + opp_table_np = of_get_parent(opp_np); + if (!opp_table_np) + goto err; + + /* It is safe to put the node now as all we need now is its address */ + of_node_put(opp_table_np); + list_for_each_entry(opp_table, &opp_tables, node) { - opp = _find_opp_of_np(opp_table, opp_np); - if (opp) { - dev_pm_opp_put(opp); + if (opp_table_np == opp_table->np) { _get_opp_table_kref(opp_table); return opp_table; } } +err: return ERR_PTR(-ENODEV); } From patchwork Fri Dec 14 10:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153806 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1881762ljp; Fri, 14 Dec 2018 02:15:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/U9DMPXvRho0D71Aa2k6IdekoDCLiwaSbyJzwjnfnhVrGTNNbnc7ei32ink7lLf+vHg7Byb X-Received: by 2002:a63:1157:: with SMTP id 23mr2170555pgr.245.1544782549693; Fri, 14 Dec 2018 02:15:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782549; cv=none; d=google.com; s=arc-20160816; b=EmmXGp4v0+f8X0erGx4vKRp6sYwlt4fMJP8GlzB0IqulmrVbCcm3qtMGI+AT0sFzrd uM02X9JNhWMNZNmJ7q6bDs7vZRBqQvXQ5GDhn0YF84bUDGSU/cJQ4e7PvM9nq/MTgvsE x2J8HYuS0zZ+nL0cpbAIvQSWfV8B1IZHw5xeI4F6GFoNqOkg8gR4bA9MoBxbxC7alfr6 kso2atAhW1fNuiRjFNTSLOv/zgBbzGF8jLKQLOtkgEWgv79Q54k4C8+Nlj4yAouxF71h 5bnvIck27DGSDCyInCp01ztPIHFO69MNFz+k3L/cOX+4mTexo4UeXzMpKg+NY7zPUi0v EGZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GkuIX39i4rCYkrrJtZv3mmFIkfBIoBUxRhe9gw4VKQg=; b=eVK5q/fdl+FdWzaEL/eTmooucXUTPLVhxguk5qEqttVg3AMX5OHy8CncbbtkdZfzv2 S0urev/h2gp1W7MN6C8jlkowo2q1RFiF6C2w35u58f0aIf08TdjWlBAWa+7PdiOlLuE6 QGSUlbEE+jUnO2oDuEaFRFZ7ArLVjQmIZy2HAS1i7k1b5aN1vwocExxs803QVnTIBwyY eJAGI3dlcv2bFU0UScefZsyn1asarZwVIrOkWD5Cscd6Lwm8M8yNHYPuf1JsR8xHHt55 LeePooRq07GXqiNHA+FpeYRhEvhT6hQ75tXVWEX0IzB3+/r4Re4uOvPN6bqqmfhsGHyu Hsvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4tdvChz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si3778037pfm.71.2018.12.14.02.15.49; Fri, 14 Dec 2018 02:15:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4tdvChz; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729499AbeLNKPs (ORCPT + 11 others); Fri, 14 Dec 2018 05:15:48 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:39855 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729488AbeLNKPs (ORCPT ); Fri, 14 Dec 2018 05:15:48 -0500 Received: by mail-pg1-f194.google.com with SMTP id w6so2501382pgl.6 for ; Fri, 14 Dec 2018 02:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkuIX39i4rCYkrrJtZv3mmFIkfBIoBUxRhe9gw4VKQg=; b=F4tdvChzO67jzzhDjYAYnpTanNNJ4rOvWFk+/gzYQHsB5ENhaVc0yIYK2i+MpdkJBb l9vN/I3jDp0rjKOs65VHOW0xdnULsMaU7ZFvkV7SHrE7zyc+cbT4mOd6siINiG23fC/+ xwyVpkXjE8BKL1AGJstHuBqmtdLtzpbyqTz3g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GkuIX39i4rCYkrrJtZv3mmFIkfBIoBUxRhe9gw4VKQg=; b=fuRvcux5lcaxccFKalKhOj5hDpE3l08hJvKQbcgcyp5vaE3UcfOVT7S2HcCw4vyFq1 vSRZRHV+sk+2OA+6HI2Q9m5oMVM1/Bjxb7ewOGgOLT60QVqHFHBXOiSTAeMNjKoy0YdF MbfCAimNT5MQjVSAv6Zhi8+xDEOxNDpyISGe+h7TJ4IFMCCUjhyLpWYGeXSDDTzZGWkr oSbsd+/I8f8M9lcl4fouq7LqJTVWoYgvJVHw4Ghvwind2Xyv5BTZxaFzFV9Bvz1vZoy1 axWL+ItjwohlshFwKFzaUqDi0MfMgiFpBaJnIYGqDIlZja60zcqPHZhhIRVkSrVT5Z0X g5kA== X-Gm-Message-State: AA+aEWZDfXCHmUyAlBURkcOVb4Ror/XNo4HxqVGNCiBXJZU9GNuE3iOb s0nA635xWQstVUyyrqLqo0Nq9A== X-Received: by 2002:a63:2054:: with SMTP id r20mr2165843pgm.328.1544782547498; Fri, 14 Dec 2018 02:15:47 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id l69sm10100872pfb.75.2018.12.14.02.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:46 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 3/7] OPP: Add dev_pm_opp_xlate_performance_state() helper Date: Fri, 14 Dec 2018 15:45:29 +0530 Message-Id: <135e59ab6353cc086b15ef96e2882aaec08e3322.1544782279.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_genpd_set_performance_state() needs to handle performance state propagation going forward. Currently this routine only gets the required performance state of the device's genpd as an argument, but it doesn't know how to translate that to master genpd(s) of the device's genpd. Introduce a new helper dev_pm_opp_xlate_performance_state() which will be used to translate from performance state of a device (or genpd sub-domain) to another device (or master genpd). Normally the src_table (of genpd sub-domain) will have the "required_opps" property set to point to one of the OPPs in the dst_table (of master genpd), but in some cases the genpd and its master have one to one mapping of performance states and so none of them have the "required-opps" property set. Return the performance state of the src_table as it is in such cases. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 63 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++ 2 files changed, 70 insertions(+) -- 2.19.1.568.g152ad8e3369a diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 98e60f0ed8b0..e5507add8f04 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1713,6 +1713,69 @@ 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_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. + * @dst_table: Required OPP table of the src_table. + * @pstate: Current performance state of the src_table. + * + * This Returns pstate of the OPP (present in @dst_table) pointed out by the + * "required-opps" property of the OPP (present in @src_table) which has + * performance state set to @pstate. + * + * Return: Zero or positive performance state on success, otherwise negative + * value on errors. + */ +int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, + struct opp_table *dst_table, + unsigned int pstate) +{ + struct dev_pm_opp *opp; + int dest_pstate = -EINVAL; + int i; + + if (!pstate) + return 0; + + /* + * Normally the src_table will have the "required_opps" property set to + * point to one of the OPPs in the dst_table, but in some cases the + * genpd and its master have one to one mapping of performance states + * and so none of them have the "required-opps" property set. Return the + * pstate of the src_table as it is in such cases. + */ + if (!src_table->required_opp_count) + return pstate; + + 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 -EINVAL; + } + + mutex_lock(&src_table->lock); + + list_for_each_entry(opp, &src_table->opp_list, node) { + if (opp->pstate == pstate) { + dest_pstate = opp->required_opps[i]->pstate; + 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_pstate; +} + /** * dev_pm_opp_add() - Add an OPP table from a table definitions * @dev: device for which we do this operation diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 2b2c3fd985ab..0b04c2093eb9 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -128,6 +128,7 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*s 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); 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); @@ -280,6 +281,12 @@ static inline struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev } static inline void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev) {} + +static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) +{ + return -ENOTSUPP; +} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; From patchwork Fri Dec 14 10:15:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 153810 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1882074ljp; Fri, 14 Dec 2018 02:16:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/X4Kdzmnj8d/TOlfW0sShA6cXcC3OXdxEZzas1TUyqIR/UM66aSfrHuoBiNnomX7Y3c2tVx X-Received: by 2002:a17:902:2868:: with SMTP id e95mr2284830plb.317.1544782573252; Fri, 14 Dec 2018 02:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544782573; cv=none; d=google.com; s=arc-20160816; b=ZFdM38jqQ1uyNRItcy1/e0TykQTCK3qsi/KyMsFHRpeSUxPp49oIBCNB1sOGDF3jag 2IxrjpBDjMm5TlLYQmUDjEvooA7WKaG5xygH9jMAQqm4K7lQSYSIjN025vDv3un01C63 swgPCdbaYInhbkypzDfB7h1+1vN4Oy2C1J4v33rwVOquzPtU+l0Y8FNdqIKpE07Yfd/T XcIuQ8Bz8sOYf9IQoKvLt6n0HlMRxmGu43mCqx2ffn5dCWkyH6Rm2QpvQifyQMbxm5jD e9PGi8iweOIR+KmgCiepgz49+4VauN9k8CLkY4Dur3Rd/GE1G/AU7zwdabHHB7lhXc0T yKPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=sJu1Q+Qj7a41OzUe9k37rm8sWDU2aXYW/sout5JMJyTlMgUu2JFjuGhQpWTQB1+gQf +Y3ciqD/+Ud7O+7IYU8jZgbDGsnAqQLU21cF4olGj55fwFWoy/qLUTtwdAZgnp5bVkc1 Tq3DQgxrTJKei1TKLfyCtdVPzUdpZLUky5OUuytldpPSfWAsbbfCEJA/BpMUAlFbxPNW NxVs7q8EfpPAiqqYcZbFQnaXNQYkh24SZFt/lTxK0qrsFccEDl5PHK1Ya+cr8jHYdNPd RoQUiRg+Fgz/UahVvGHtK4L/oohYnEUAiul4EQbkMA69P6jhXQ5V6klubgvML3Jg4xPK HKzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M067d3ml; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r197si4254426pfc.116.2018.12.14.02.16.12; Fri, 14 Dec 2018 02:16:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M067d3ml; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbeLNKQM (ORCPT + 11 others); Fri, 14 Dec 2018 05:16:12 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41248 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729601AbeLNKP5 (ORCPT ); Fri, 14 Dec 2018 05:15:57 -0500 Received: by mail-pf1-f196.google.com with SMTP id b7so2613463pfi.8 for ; Fri, 14 Dec 2018 02:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=M067d3mlqJZnjoZ6EfwLLzsP0gOVKArU5HUpi9pSuQQwWwKtbwfhoSZAj16RvErXA0 +ozZSMVoLrL+OOnAJhFn85fqIajezry3r1RNBLHY5qoHeMW1y7hD0bcHogfN2NvoxhMe 8GzGbec6hmUnBDxrcmXceXeePzBOmbmpuK13U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oMuVu8n3ZWdRbQbhEMy90Uj7CKk0/3mUfjD2e/MUMn0=; b=n1XwVTDp39ZkRPWi3XGwcbN890XSlpur66wChIX+jHpx3kMwA+NpVGtY1sKiCEzcIu d5TXqF9l2cU5xjDZICnwUbodq+lUUYJrWuPUh+jvuzrrTA5ezQsl+Ww8qUovng0ZmYq+ lzTGLxCFTHCoXepIac5AGX/iH2B6xA2MJNB7LZVHgd1fMppmW1gePJx7R2BTNHyY6maQ 8NaRflWDsgOxr6csegGQ/zOdGaEWXeZWGJcjfjp7iCO6oLS3sFtnPbPIerhQNG12bW/V u/QpqlXDkrTvP+4+y4h0F8K6TOMrCV8R+EtdbBaF/VLdfSvWBNta8u+7niz538aKsfDb Q8/w== X-Gm-Message-State: AA+aEWZwyafC0D+RomW8RRShxEpilvPHUIZErhVbUCJXwJIJM2QFUwTD Gffg9Vf4kx4v0uSRGQdpgeqapw== X-Received: by 2002:a62:de06:: with SMTP id h6mr2339573pfg.158.1544782556201; Fri, 14 Dec 2018 02:15:56 -0800 (PST) Received: from localhost ([122.172.23.29]) by smtp.gmail.com with ESMTPSA id y71sm9960187pfi.123.2018.12.14.02.15.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 02:15:55 -0800 (PST) From: Viresh Kumar To: ulf.hansson@linaro.org, Rafael Wysocki , Kevin Hilman , Pavel Machek , Len Brown Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rnayak@codeaurora.org, niklas.cassel@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V4 6/7] PM / Domains: Factorize dev_pm_genpd_set_performance_state() Date: Fri, 14 Dec 2018 15:45:32 +0530 Message-Id: X-Mailer: git-send-email 2.19.1.568.g152ad8e3369a In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Separate out _genpd_set_performance_state() and _genpd_reeval_performance_state() from dev_pm_genpd_set_performance_state() to handle performance state update related stuff. This will be used by a later commit. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/power/domain.c | 95 +++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 40 deletions(-) -- 2.19.1.568.g152ad8e3369a Reviewed-by: Ulf Hansson diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 1e98c637e069..808ba41b6580 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -239,6 +239,56 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd) static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} #endif +static int _genpd_reeval_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + struct generic_pm_domain_data *pd_data; + struct pm_domain_data *pdd; + + /* New requested state is same as Max requested state */ + if (state == genpd->performance_state) + return state; + + /* New requested state is higher than Max requested state */ + if (state > genpd->performance_state) + return state; + + /* Traverse all devices within the domain */ + list_for_each_entry(pdd, &genpd->dev_list, list_node) { + pd_data = to_gpd_data(pdd); + + if (pd_data->performance_state > state) + state = pd_data->performance_state; + } + + /* + * We aren't propagating performance state changes of a subdomain to its + * masters as we don't have hardware that needs it. Over that, the + * performance states of subdomain and its masters may not have + * one-to-one mapping and would require additional information. We can + * get back to this once we have hardware that needs it. For that + * reason, we don't have to consider performance state of the subdomains + * of genpd here. + */ + return state; +} + +static int _genpd_set_performance_state(struct generic_pm_domain *genpd, + unsigned int state) +{ + int ret; + + if (state == genpd->performance_state) + return 0; + + ret = genpd->set_performance_state(genpd, state); + if (ret) + return ret; + + genpd->performance_state = state; + return 0; +} + /** * dev_pm_genpd_set_performance_state- Set performance state of device's power * domain. @@ -257,10 +307,9 @@ static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {} int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { struct generic_pm_domain *genpd; - struct generic_pm_domain_data *gpd_data, *pd_data; - struct pm_domain_data *pdd; + struct generic_pm_domain_data *gpd_data; unsigned int prev; - int ret = 0; + int ret; genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) @@ -281,45 +330,11 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) prev = gpd_data->performance_state; gpd_data->performance_state = state; - /* New requested state is same as Max requested state */ - if (state == genpd->performance_state) - goto unlock; - - /* New requested state is higher than Max requested state */ - if (state > genpd->performance_state) - goto update_state; - - /* Traverse all devices within the domain */ - list_for_each_entry(pdd, &genpd->dev_list, list_node) { - pd_data = to_gpd_data(pdd); - - if (pd_data->performance_state > state) - state = pd_data->performance_state; - } - - if (state == genpd->performance_state) - goto unlock; - - /* - * We aren't propagating performance state changes of a subdomain to its - * masters as we don't have hardware that needs it. Over that, the - * performance states of subdomain and its masters may not have - * one-to-one mapping and would require additional information. We can - * get back to this once we have hardware that needs it. For that - * reason, we don't have to consider performance state of the subdomains - * of genpd here. - */ - -update_state: - ret = genpd->set_performance_state(genpd, state); - if (ret) { + state = _genpd_reeval_performance_state(genpd, state); + ret = _genpd_set_performance_state(genpd, state); + if (ret) gpd_data->performance_state = prev; - goto unlock; - } - genpd->performance_state = state; - -unlock: genpd_unlock(genpd); return ret;