From patchwork Thu Jun 17 06:05:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 462584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 212E7C49EA2 for ; Thu, 17 Jun 2021 05:46:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F0B16113C for ; Thu, 17 Jun 2021 05:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbhFQFtE (ORCPT ); Thu, 17 Jun 2021 01:49:04 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:58757 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbhFQFtC (ORCPT ); Thu, 17 Jun 2021 01:49:02 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210617054652epoutp041b604b73fd930caaad7c831fa7caaf78~JSHYGkiE73044730447epoutp04S for ; Thu, 17 Jun 2021 05:46:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210617054652epoutp041b604b73fd930caaad7c831fa7caaf78~JSHYGkiE73044730447epoutp04S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1623908812; bh=gVRnGh6/SwyclktozAcfjMAjxPKBukbpUhTca54XqGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLcYQUhuWm0Kesm/SZa9/Fv6dOdx+SW2HIyBTe8P719Ktbvxzxm0xgwwW7+yP+O8E 88ps8ocWzETtGAFbB2JDspIKUBA/7IzP421zZMZFprnLAjNONBbXxlHfABxvfc347M uzf17xbPSuAF4JJT/26ir18wUxwYtRDbEQVzVaPw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210617054651epcas1p4c62a0107d88eb4dc25e8fb6a564d57a6~JSHXg52dj2867228672epcas1p4L; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.152]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4G59zX1mJ9z4x9Q3; Thu, 17 Jun 2021 05:46:48 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id AF.3F.09578.8C1EAC06; Thu, 17 Jun 2021 14:46:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epcas1p265359058d489661e09d8d48d4937ca7b~JSHToGqYG2425124251epcas1p2Q; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210617054647epsmtrp1b361d3ef0ba09e61272fc5a3566cb508~JSHTmQ9Jo1936119361epsmtrp1E; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) X-AuditID: b6c32a35-fcfff7000000256a-28-60cae1c83b5e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B7.96.08163.7C1EAC06; Thu, 17 Jun 2021 14:46:47 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epsmtip14f56319522eff509fa05a559eed02f65~JSHTX__5P1533015330epsmtip1W; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) From: Chanwoo Choi To: andrew-sh.cheng@mediatek.com, hsinyi@chromium.org Cc: sibis@codeaurora.org, saravanak@google.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, chanwoo@kernel.org, cwchoi00@gmail.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] PM / devfreq: Export devfreq_get_freq_ragne symbol within devfreq Date: Thu, 17 Jun 2021 15:05:44 +0900 Message-Id: <20210617060546.26933-3-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617060546.26933-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPKsWRmVeSWpSXmKPExsWy7bCmru6Jh6cSDJYu5rbYvv4Fq8XEG1dY LK5/ec5q8eyotsWE1u3MFmeb3rBbXN41h83ic+8RRovbjSvYLLoO/WWzuLbwPasDt8fshoss Hpf7epk8ds66y+6xYFOpx6ZVnWweLSf3s3j0bVnF6PF5k1wAR1S2TUZqYkpqkUJqXnJ+SmZe uq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QnUoKZYk5pUChgMTiYiV9O5ui/NKS VIWM/OISW6XUgpScAssCveLE3OLSvHS95PxcK0MDAyNToMKE7IzWg22sBbOlK97vbGdtYHwu 1sXIySEhYCLRvmMPcxcjF4eQwA5GibafG5ggnE+MEtfWfYZyPjNKfL34nxGmZfHmS4wQiV2M EkfP/IByvjBKrJt7iBWkik1AS2L/ixtsILaIgKnEnsMTWUCKmAXuMUo8Wn4eLCEsECFx6NUy JhCbRUBV4tiu70A2BwevgJXE96MBENvkJVZvOMAMYn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UsMs8IpR4t7Zx2A1wgJhEnMfHmED sVkEVCWO7frOBFLPK2Al8f1oAMQqeYnVGw4wg9icAtYS55bcYQcpEQIqOf8qfQIj3wJGhlWM kqkFxbnpucWGBUZ5qeV6xYm5xaV56XrJ+bmbGMEhq6W1g3HPqg96hxiZOBgPMUpwMCuJ8OoW n0gQ4k1JrKxKLcqPLyrNSS0+xCjNwaIkznuh62S8kEB6YklqdmpqQWoRTJaJg1OqgUk1K89m +na7d2f6C/bn73Bw1pomfaxbt/z42TUHtXn81l+SljSZyXNL4MTsRVbHunMiM58zPvtx8OhP hT3RGp/OZZ5m8d7q+ezLiQnxX6sqvkdol0+ftmzSzFVZDhXal7nE/OW4Vt6+Hn722ZS7goHV vJ6/Ztiotvz6fIrLq6BvfdjeKNeMdO0/wRsezpN7ryQnqXl/i2Uy5/2aTnGv9NNPt+9Jrdu9 b/JN8QMBpX90zusuNFfhPSAx80L+sUnnGN5lM06+EFxjYNa9U7vU2Sch7Gz0rF+d0/fuD7s4 b9P6/z7zufX3hQUeLfCTVc/18992Ofa4eyLvwRmnZ28r9Kv/zbnwwuHwzW/ahWVyn6xWYinO SDTUYi4qTgQA3djmBcgCAAA= X-CMS-MailID: 20210617054647epcas1p265359058d489661e09d8d48d4937ca7b X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210617054647epcas1p265359058d489661e09d8d48d4937ca7b References: <20210617060546.26933-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In order to get frequency range within devfreq governors, export devfreq_get_freq_ragne symbol within devfreq. Signed-off-by: Chanwoo Choi Reviewed-by: Matthias Kaehlcke --- drivers/devfreq/devfreq.c | 17 +++++++++-------- drivers/devfreq/governor.h | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 28f3e0ba6cdd..a15545c42fc2 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -112,16 +112,16 @@ static unsigned long find_available_max_freq(struct devfreq *devfreq) } /** - * get_freq_range() - Get the current freq range + * devfreq_get_freq_range() - Get the current freq range * @devfreq: the devfreq instance * @min_freq: the min frequency * @max_freq: the max frequency * * This takes into consideration all constraints. */ -static void get_freq_range(struct devfreq *devfreq, - unsigned long *min_freq, - unsigned long *max_freq) +void devfreq_get_freq_range(struct devfreq *devfreq, + unsigned long *min_freq, + unsigned long *max_freq) { unsigned long *freq_table = devfreq->profile->freq_table; s32 qos_min_freq, qos_max_freq; @@ -158,6 +158,7 @@ static void get_freq_range(struct devfreq *devfreq, if (*min_freq > *max_freq) *min_freq = *max_freq; } +EXPORT_SYMBOL(devfreq_get_freq_range); /** * devfreq_get_freq_level() - Lookup freq_table for the frequency @@ -418,7 +419,7 @@ int devfreq_update_target(struct devfreq *devfreq, unsigned long freq) err = devfreq->governor->get_target_freq(devfreq, &freq); if (err) return err; - get_freq_range(devfreq, &min_freq, &max_freq); + devfreq_get_freq_range(devfreq, &min_freq, &max_freq); if (freq < min_freq) { freq = min_freq; @@ -1561,7 +1562,7 @@ static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, unsigned long min_freq, max_freq; mutex_lock(&df->lock); - get_freq_range(df, &min_freq, &max_freq); + devfreq_get_freq_range(df, &min_freq, &max_freq); mutex_unlock(&df->lock); return sprintf(buf, "%lu\n", min_freq); @@ -1615,7 +1616,7 @@ static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, unsigned long min_freq, max_freq; mutex_lock(&df->lock); - get_freq_range(df, &min_freq, &max_freq); + devfreq_get_freq_range(df, &min_freq, &max_freq); mutex_unlock(&df->lock); return sprintf(buf, "%lu\n", max_freq); @@ -1929,7 +1930,7 @@ static int devfreq_summary_show(struct seq_file *s, void *data) mutex_lock(&devfreq->lock); cur_freq = devfreq->previous_freq; - get_freq_range(devfreq, &min_freq, &max_freq); + devfreq_get_freq_range(devfreq, &min_freq, &max_freq); timer = devfreq->profile->timer; if (IS_SUPPORTED_ATTR(devfreq->governor->attrs, POLLING_INTERVAL)) diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index 2d69a0ce6291..9a9495f94ac6 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -86,6 +86,8 @@ int devfreq_remove_governor(struct devfreq_governor *governor); int devfreq_update_status(struct devfreq *devfreq, unsigned long freq); int devfreq_update_target(struct devfreq *devfreq, unsigned long freq); +void devfreq_get_freq_range(struct devfreq *devfreq, unsigned long *min_freq, + unsigned long *max_freq); static inline int devfreq_update_stats(struct devfreq *df) { From patchwork Thu Jun 17 06:05:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 462585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C220BC2B9F4 for ; Thu, 17 Jun 2021 05:46:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADFBD6113C for ; Thu, 17 Jun 2021 05:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229834AbhFQFtC (ORCPT ); Thu, 17 Jun 2021 01:49:02 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:20869 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbhFQFtA (ORCPT ); Thu, 17 Jun 2021 01:49:00 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210617054651epoutp02d82502037439c6cdc88065c10bf0c32c~JSHW67n_x0763307633epoutp02S for ; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210617054651epoutp02d82502037439c6cdc88065c10bf0c32c~JSHW67n_x0763307633epoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1623908811; bh=hwWTZ1zcrCBHmAHfjGm8GlblR5880x/jeAsPMHDxZh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jwSfpZ0jFgrN3RVOL6OMIktHrdz5QXvKZkN3ZIXv5s8B4d4BV6+6xnzL3FgZ7pi7S h0FEzBaOy8lUlhsVvxKa4/ByeOrqqo/ROYo11I4P/LRHSD/ZgclE20CF+0dSY4Q2zw /KUpoTAXc9pEy5mfYuQK5g4/t5MSo//sthluk7e0= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210617054650epcas1p141bafea5e22f2f3678d2fcac1ac4b659~JSHWNUgBI1952019520epcas1p1H; Thu, 17 Jun 2021 05:46:50 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.155]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4G59zX1QWJz4x9QK; Thu, 17 Jun 2021 05:46:48 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id B3.E4.09824.8C1EAC06; Thu, 17 Jun 2021 14:46:48 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epcas1p431edaffea5bf7f3792b55dc3d91289ae~JSHTs2uRt0153601536epcas1p4t; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210617054647epsmtrp13b78b339e85e09b32db3524f8064b4e9~JSHTr58G-1935819358epsmtrp1S; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) X-AuditID: b6c32a37-04bff70000002660-4c-60cae1c8c1a7 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B8.96.08163.7C1EAC06; Thu, 17 Jun 2021 14:46:47 +0900 (KST) Received: from localhost.localdomain (unknown [10.113.221.102]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epsmtip161f5cdda44ba310d5ace73227f1d7b66~JSHTeDLoJ1583415834epsmtip1i; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) From: Chanwoo Choi To: andrew-sh.cheng@mediatek.com, hsinyi@chromium.org Cc: sibis@codeaurora.org, saravanak@google.com, myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com, chanwoo@kernel.org, cwchoi00@gmail.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Saravana Kannan Subject: [PATCH 3/4] PM / devfreq: Add cpu based scaling support to passive governor Date: Thu, 17 Jun 2021 15:05:45 +0900 Message-Id: <20210617060546.26933-4-cw00.choi@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210617060546.26933-1-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmk+LIzCtJLcpLzFFi42LZdlhTX/fEw1MJBnO6WSy2r3/BajHxxhUW i+tfnrNaPDuqbTGhdTuzxdmmN+wWl3fNYbP43HuE0eJ24wo2i65Df9ksri18z2px4OJENgce j9kNF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647epcas1p431edaffea5bf7f3792b55dc3d91289ae X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210617054647epcas1p431edaffea5bf7f3792b55dc3d91289ae References: <20210617060546.26933-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Saravana Kannan Many CPU architectures have caches that can scale independent of the CPUs. Frequency scaling of the caches is necessary to make sure that the cache is not a performance bottleneck that leads to poor performance and power. The same idea applies for RAM/DDR. To achieve this, this patch adds support for cpu based scaling to the passive governor. This is accomplished by taking the current frequency of each CPU frequency domain and then adjust the frequency of the cache (or any devfreq device) based on the frequency of the CPUs. It listens to CPU frequency transition notifiers to keep itself up to date on the current CPU frequency. To decide the frequency of the device, the governor does one of the following: * Derives the optimal devfreq device opp from required-opps property of the parent cpu opp_table. * Scales the device frequency in proportion to the CPU frequency. So, if the CPUs are running at their max frequency, the device runs at its max frequency. If the CPUs are running at their min frequency, the device runs at its min frequency. It is interpolated for frequencies in between. Signed-off-by: Saravana Kannan [Sibi: Integrated cpu-freqmap governor into passive_governor] Signed-off-by: Sibi Sankar [Chanwoo: Fix conflict with latest code and clean code up] Signed-off-by: Chanwoo Choi --- drivers/devfreq/governor.h | 22 +++ drivers/devfreq/governor_passive.c | 264 ++++++++++++++++++++++++++++- include/linux/devfreq.h | 16 +- 3 files changed, 293 insertions(+), 9 deletions(-) diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index 9a9495f94ac6..3c36c92c89a9 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -47,6 +47,28 @@ #define DEVFREQ_GOV_ATTR_POLLING_INTERVAL BIT(0) #define DEVFREQ_GOV_ATTR_TIMER BIT(1) +/** + * struct devfreq_cpu_data - Hold the per-cpu data + * @dev: reference to cpu device. + * @first_cpu: the cpumask of the first cpu of a policy. + * @opp_table: reference to cpu opp table. + * @cur_freq: the current frequency of the cpu. + * @min_freq: the min frequency of the cpu. + * @max_freq: the max frequency of the cpu. + * + * This structure stores the required cpu_data of a cpu. + * This is auto-populated by the governor. + */ +struct devfreq_cpu_data { + struct device *dev; + unsigned int first_cpu; + + struct opp_table *opp_table; + unsigned int cur_freq; + unsigned int min_freq; + unsigned int max_freq; +}; + /** * struct devfreq_governor - Devfreq policy governor * @node: list node - contains registered devfreq governors diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index fc09324a03e0..07e864509b7e 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -8,11 +8,84 @@ */ #include +#include +#include +#include +#include #include #include #include "governor.h" -static int devfreq_passive_get_target_freq(struct devfreq *devfreq, +#define HZ_PER_KHZ 1000 + +static unsigned long get_taget_freq_by_required_opp(struct device *p_dev, + struct opp_table *p_opp_table, + struct opp_table *opp_table, + unsigned long freq) +{ + struct dev_pm_opp *opp = NULL, *p_opp = NULL; + + if (!p_dev || !p_opp_table || !opp_table || !freq) + return 0; + + p_opp = devfreq_recommended_opp(p_dev, &freq, 0); + if (IS_ERR(p_opp)) + return 0; + + opp = dev_pm_opp_xlate_required_opp(p_opp_table, opp_table, p_opp); + dev_pm_opp_put(p_opp); + + if (IS_ERR(opp)) + return 0; + + freq = dev_pm_opp_get_freq(opp); + dev_pm_opp_put(opp); + + return freq; +} + +static int get_target_freq_with_cpufreq(struct devfreq *devfreq, + unsigned long *target_freq) +{ + struct devfreq_passive_data *p_data = + (struct devfreq_passive_data *)devfreq->data; + struct devfreq_cpu_data *cpu_data; + unsigned long cpu, cpu_cur, cpu_min, cpu_max, cpu_percent; + unsigned long dev_min, dev_max; + unsigned long freq = 0; + + for_each_online_cpu(cpu) { + cpu_data = p_data->cpu_data[cpu]; + if (!cpu_data || cpu_data->first_cpu != cpu) + continue; + + /* Get target freq via required opps */ + cpu_cur = cpu_data->cur_freq * HZ_PER_KHZ; + freq = get_taget_freq_by_required_opp(cpu_data->dev, + cpu_data->opp_table, + devfreq->opp_table, cpu_cur); + if (freq) { + *target_freq = max(freq, *target_freq); + continue; + } + + /* Use Interpolation if required opps is not available */ + devfreq_get_freq_range(devfreq, &dev_min, &dev_max); + + cpu_min = cpu_data->min_freq; + cpu_max = cpu_data->max_freq; + cpu_cur = cpu_data->cur_freq; + + cpu_percent = ((cpu_cur - cpu_min) * 100) / (cpu_max - cpu_min); + freq = dev_min + mult_frac(dev_max - dev_min, cpu_percent, 100); + + *target_freq = max(freq, *target_freq); + } + + return 0; +} + +static int get_target_freq_with_devfreq(struct devfreq *devfreq, unsigned long *freq) { struct devfreq_passive_data *p_data @@ -99,6 +172,172 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, return 0; } +static int devfreq_passive_get_target_freq(struct devfreq *devfreq, + unsigned long *freq) +{ + struct devfreq_passive_data *p_data = + (struct devfreq_passive_data *)devfreq->data; + int ret; + + if (!p_data) + return -EINVAL; + + /* + * If the devfreq device with passive governor has the specific method + * to determine the next frequency, should use the get_target_freq() + * of struct devfreq_passive_data. + */ + if (p_data->get_target_freq) + return p_data->get_target_freq(devfreq, freq); + + switch (p_data->parent_type) { + case DEVFREQ_PARENT_DEV: + ret = get_target_freq_with_devfreq(devfreq, freq); + break; + case CPUFREQ_PARENT_DEV: + ret = get_target_freq_with_cpufreq(devfreq, freq); + break; + default: + ret = -EINVAL; + dev_err(&devfreq->dev, "Invalid parent type\n"); + break; + } + + return ret; +} + +static int cpufreq_passive_notifier_call(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct devfreq_passive_data *data = + container_of(nb, struct devfreq_passive_data, nb); + struct devfreq *devfreq = (struct devfreq *)data->this; + struct devfreq_cpu_data *cpu_data; + struct cpufreq_freqs *freqs = ptr; + unsigned int cur_freq; + int ret; + + if (event != CPUFREQ_POSTCHANGE || !freqs || + !data->cpu_data[freqs->policy->cpu]) + return 0; + + cpu_data = data->cpu_data[freqs->policy->cpu]; + if (cpu_data->cur_freq == freqs->new) + return 0; + + cur_freq = cpu_data->cur_freq; + cpu_data->cur_freq = freqs->new; + + mutex_lock(&devfreq->lock); + ret = devfreq_update_target(devfreq, freqs->new); + mutex_unlock(&devfreq->lock); + if (ret) { + cpu_data->cur_freq = cur_freq; + dev_err(&devfreq->dev, "failed to update the frequency.\n"); + return ret; + } + + return 0; +} + +static int cpufreq_passive_register_notifier(struct devfreq *devfreq) +{ + struct devfreq_passive_data *p_data + = (struct devfreq_passive_data *)devfreq->data; + struct device *dev = devfreq->dev.parent; + struct opp_table *opp_table = NULL; + struct devfreq_cpu_data *cpu_data; + struct cpufreq_policy *policy; + struct device *cpu_dev; + unsigned int cpu; + int ret; + + get_online_cpus(); + + p_data->nb.notifier_call = cpufreq_passive_notifier_call; + ret = cpufreq_register_notifier(&p_data->nb, CPUFREQ_TRANSITION_NOTIFIER); + if (ret) { + dev_err(dev, "failed to register cpufreq notifier\n"); + p_data->nb.notifier_call = NULL; + goto out; + } + + for_each_online_cpu(cpu) { + if (p_data->cpu_data[cpu]) + continue; + + policy = cpufreq_cpu_get(cpu); + if (policy) { + cpu_data = kzalloc(sizeof(*cpu_data), GFP_KERNEL); + if (!cpu_data) { + ret = -ENOMEM; + goto out; + } + + cpu_dev = get_cpu_device(cpu); + if (!cpu_dev) { + dev_err(dev, "failed to get cpu device\n"); + ret = -ENODEV; + goto out; + } + + opp_table = dev_pm_opp_get_opp_table(cpu_dev); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + goto out; + } + + cpu_data->dev = cpu_dev; + cpu_data->opp_table = opp_table; + cpu_data->first_cpu = cpumask_first(policy->related_cpus); + cpu_data->cur_freq = policy->cur; + cpu_data->min_freq = policy->cpuinfo.min_freq; + cpu_data->max_freq = policy->cpuinfo.max_freq; + + p_data->cpu_data[cpu] = cpu_data; + cpufreq_cpu_put(policy); + } else { + ret = -EPROBE_DEFER; + goto out; + } + } +out: + put_online_cpus(); + if (ret) + return ret; + + mutex_lock(&devfreq->lock); + ret = devfreq_update_target(devfreq, 0L); + mutex_unlock(&devfreq->lock); + if (ret) + dev_err(dev, "failed to update the frequency\n"); + + return ret; +} + +static int cpufreq_passive_unregister_notifier(struct devfreq *devfreq) +{ + struct devfreq_passive_data *p_data + = (struct devfreq_passive_data *)devfreq->data; + struct devfreq_cpu_data *cpu_data; + int cpu; + + if (p_data->nb.notifier_call) + cpufreq_unregister_notifier(&p_data->nb, CPUFREQ_TRANSITION_NOTIFIER); + + for_each_possible_cpu(cpu) { + cpu_data = p_data->cpu_data[cpu]; + if (cpu_data) { + if (cpu_data->opp_table) + dev_pm_opp_put_opp_table(cpu_data->opp_table); + kfree(cpu_data); + cpu_data = NULL; + } + } + + return 0; +} + static int devfreq_passive_notifier_call(struct notifier_block *nb, unsigned long event, void *ptr) { @@ -140,7 +379,7 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, struct notifier_block *nb = &p_data->nb; int ret = 0; - if (!parent) + if (p_data->parent_type == DEVFREQ_PARENT_DEV && !parent) return -EPROBE_DEFER; switch (event) { @@ -148,13 +387,24 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq, if (!p_data->this) p_data->this = devfreq; - nb->notifier_call = devfreq_passive_notifier_call; - ret = devfreq_register_notifier(parent, nb, - DEVFREQ_TRANSITION_NOTIFIER); + if (p_data->parent_type == DEVFREQ_PARENT_DEV) { + nb->notifier_call = devfreq_passive_notifier_call; + ret = devfreq_register_notifier(parent, nb, + DEVFREQ_TRANSITION_NOTIFIER); + } else if (p_data->parent_type == CPUFREQ_PARENT_DEV) { + ret = cpufreq_passive_register_notifier(devfreq); + } else { + ret = -EINVAL; + } break; case DEVFREQ_GOV_STOP: - WARN_ON(devfreq_unregister_notifier(parent, nb, - DEVFREQ_TRANSITION_NOTIFIER)); + if (p_data->parent_type == DEVFREQ_PARENT_DEV) + WARN_ON(devfreq_unregister_notifier(parent, nb, + DEVFREQ_TRANSITION_NOTIFIER)); + else if (p_data->parent_type == CPUFREQ_PARENT_DEV) + WARN_ON(cpufreq_passive_unregister_notifier(devfreq)); + else + ret = -EINVAL; break; default: break; diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 142474b4af96..cfa0ef54841e 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -38,6 +38,7 @@ enum devfreq_timer { struct devfreq; struct devfreq_governor; +struct devfreq_cpu_data; struct thermal_cooling_device; /** @@ -288,6 +289,11 @@ struct devfreq_simple_ondemand_data { #endif #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE) +enum devfreq_parent_dev_type { + DEVFREQ_PARENT_DEV, + CPUFREQ_PARENT_DEV, +}; + /** * struct devfreq_passive_data - ``void *data`` fed to struct devfreq * and devfreq_add_device @@ -299,8 +305,10 @@ struct devfreq_simple_ondemand_data { * using governors except for passive governor. * If the devfreq device has the specific method to decide * the next frequency, should use this callback. - * @this: the devfreq instance of own device. - * @nb: the notifier block for DEVFREQ_TRANSITION_NOTIFIER list + + * @parent_type parent type of the device + + * @this: the devfreq instance of own device. + + * @nb: the notifier block for DEVFREQ_TRANSITION_NOTIFIER list + + * @cpu_data: the state min/max/current frequency of all online cpu's * * The devfreq_passive_data have to set the devfreq instance of parent * device with governors except for the passive governor. But, don't need to @@ -314,9 +322,13 @@ struct devfreq_passive_data { /* Optional callback to decide the next frequency of passvice device */ int (*get_target_freq)(struct devfreq *this, unsigned long *freq); + /* Should set the type of parent device */ + enum devfreq_parent_dev_type parent_type; + /* For passive governor's internal use. Don't need to set them */ struct devfreq *this; struct notifier_block nb; + struct devfreq_cpu_data *cpu_data[NR_CPUS]; }; #endif