From patchwork Thu Jun 17 06:05:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 12326657 X-Patchwork-Delegate: cw00.choi@samsung.com 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 48696C49361 for ; Thu, 17 Jun 2021 05:46:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 354C961209 for ; Thu, 17 Jun 2021 05:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbhFQFtC (ORCPT ); Thu, 17 Jun 2021 01:49:02 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:20889 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbhFQFtB (ORCPT ); Thu, 17 Jun 2021 01:49:01 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210617054651epoutp029f6e4722829e61df898ae7694d84fe4c~JSHXcTV_G0798407984epoutp02N for ; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210617054651epoutp029f6e4722829e61df898ae7694d84fe4c~JSHXcTV_G0798407984epoutp02N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1623908811; bh=6yTdXCtcMhIWw57WbRSwU6NBc0qFsTyI3S96cv8gatc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbV18WkIx18uV0EuYgKKD5cFQPmSLZ9eEbLqnxHy7iEAlUZDkzeW8lkpaEVjPJPOb ifEG5MxdyV4bLllYxRphS13kkvT5c4kzDX4p1+FBdGjCojN0h6wSl9dy/dOj8BOApM D3bmOZFhauexz58CTVIxcyKqS9LC4keyBgmmQI6g= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210617054651epcas1p2374af237de7a1e641dfa5f31f18c2de1~JSHXAStug2425124251epcas1p2d; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.152]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4G59zX0y0dz4x9QJ; Thu, 17 Jun 2021 05:46:48 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id AE.3F.09578.8C1EAC06; Thu, 17 Jun 2021 14:46:48 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210617054647epcas1p4d2e5b1fa1ec35487701189808178da18~JSHThFDxO2867228672epcas1p49; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210617054647epsmtrp2ce77117d4c3e7da576649933a306743b~JSHTgMPuf2416724167epsmtrp2_; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) X-AuditID: b6c32a35-58cdfa800000256a-25-60cae1c83607 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id F6.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 20210617054647epsmtip1e8df5f7be061f5db532fb458eccbd409~JSHTRkLrK1583415834epsmtip1g; 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, stable@vger.kernel.org Subject: [PATCH 1/4] PM / devfreq: passive: Fix get_target_freq when not using required-opp Date: Thu, 17 Jun 2021 15:05:43 +0900 Message-Id: <20210617060546.26933-2-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+NgFmpik+LIzCtJLcpLzFFi42LZdlhTT/fEw1MJBnvPMFtsX/+C1WLijSss Fte/PGe1eHZU22JC63Zmi7NNb9gtLu+aw2bxufcIo8XtxhVsFl2H/rJZXFv4ntViwcZHjA48 HrMbLrJ4XO7rZfLYOesuu8eCTaUem1Z1snm0nNzP4tG3ZRWjx+dNcgEcUdk2GamJKalFCql5 yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUDHKimUJeaUAoUCEouLlfTt bIryS0tSFTLyi0tslVILUnIKLAv0ihNzi0vz0vWS83OtDA0MjEyBChOyMxb+W8dScIWr4v7n I0wNjO84uhg5OCQETCRmvErqYuTkEBLYwSix8HR9FyMXkP2JUeLb08VMEM5nRonPFw+yg1SB NJya08UGkdjFKLHz50EWCOcLo8SLnU1sIFVsAloS+1/cALNFBEwl9hyeCFbELPCDUWLS0RY2 kN3CArESe+4WgdSwCKhKT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HDxRA1nxgl3qyYAFbDJqAlsf/FDTaQGhEBc4njV6JBapgFWpgkNn7uYAapERaI lthzawoLiM0ioCox/eBfMJtXwEpi4pz1bBC75CVWbzgAVs8pYC1xbskddpCZQkA151+lT2Dk W8DIsIpRMrWgODc9t9iwwCgvtVyvODG3uDQvXS85P3cTIzh8tbR2MO5Z9UHvECMTB+MhRgkO ZiURXt3iEwlCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeS90nYwXEkhPLEnNTk0tSC2CyTJxcEo1 MO0vXJwofojTgH/6RNnvDM8diibOb9i6qPHhPI0Zqtwp5y+JSK4OZNBtO/G6yEDlo+LSjdx9 ihKnOQP2n5t+Ir6b9e8ki7KGi5GVr6ZyVbQdcXeu/al7cI5Yz99jOfM2LujdxL9Ckasqw9H0 sOl9gZKW0yfSvMSEHtr5zv23/Mb8CLXNEmejkx5qtKo/4z6ypvu5ld3hff91ehx8mPc4KYfx zVq/8MJ529Xuzs6mhkkvvryVC/rgsU5i4WG5aZEFXO8Ld5tWPQ6Sr9FcHuOrfffC5pb3uYcd im5tZvds6f1ozK+bxS6wfddOuehnmz/P/JBq66yqfOyLNu+mxoN/PTWmFeyayXmlu49HnWX3 DSWW4oxEQy3mouJEAOQ9JDLOAgAA X-CMS-MailID: 20210617054647epcas1p4d2e5b1fa1ec35487701189808178da18 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210617054647epcas1p4d2e5b1fa1ec35487701189808178da18 References: <20210617060546.26933-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The 86ad9a24f21e ("PM / devfreq: Add required OPPs support to passive governor") supported the required-opp property for using devfreq passive governor. But, 86ad9a24f21e has caused the problem on use-case when required-opp is not used such as exynos-bus.c devfreq driver. So that fix the get_target_freq of passive governor for supporting the case of when required-opp is not used. Cc: stable@vger.kernel.org Fixes: 86ad9a24f21e ("PM / devfreq: Add required OPPs support to passive governor") Signed-off-by: Chanwoo Choi --- drivers/devfreq/governor_passive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index b094132bd20b..fc09324a03e0 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -65,7 +65,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, dev_pm_opp_put(p_opp); if (IS_ERR(opp)) - return PTR_ERR(opp); + goto no_required_opp; *freq = dev_pm_opp_get_freq(opp); dev_pm_opp_put(opp); @@ -73,6 +73,7 @@ static int devfreq_passive_get_target_freq(struct devfreq *devfreq, return 0; } +no_required_opp: /* * Get the OPP table's index of decided frequency by governor * of parent device. 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: 12326659 X-Patchwork-Delegate: cw00.choi@samsung.com 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/ec5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xWYinO 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: 12326655 X-Patchwork-Delegate: cw00.choi@samsung.com 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 j9kNF1k8Lvf1MnnsnHWX3WPBplKPTas62TxaTu5n8ejbsorR4/MmuQCOqGybjNTElNQihdS8 5PyUzLx0WyXv4HjneFMzA0NdQ0sLcyWFvMTcVFslF58AXbfMHKBjlRTKEnNKgUIBicXFSvp2 NkX5pSWpChn5xSW2SqkFKTkFlgV6xYm5xaV56XrJ+blWhgYGRqZAhQnZGZO7lzAVrEurWHb+ PnsD48zgLkZODgkBE4nll2+xdTFycQgJ7GCUmLP8GCuE84lRYu+Xk8wQzmdGifmXH7PAtBzt fMIOYgsJ7GKUWLa+BKLoC6PEzXOdjCAJNgEtif0vbrCB2CICphJ7Dk9kASliFuhikth87hcT SEJYIEyicdosZhCbRUBVYkrDb7CpvAJWEr/azzNDbJOXWL3hAJjNKWAtcW7JHXaQQRICrRwS bTuWAG3jAHJcJPZdZYOoF5Z4dXwLO4QtJfGyvw3KrpZYefIIG0RvB6PElv0XWCESxhL7l05m ApnDLKApsX6XPkRYUWLn77lgzzAL8Em8+9rDCrGKV6KjTQiiRFni8oO7TBC2pMTi9k6oEzwk Tm04BQ25PkaJP3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3QO8TIxMF4iFGC g1lJhFe3+ESCEG9KYmVValF+fFFpTmrxIUZpDhYlcd4LXSfjhQTSE0tSs1NTC1KLYLJMHJxS DUzLDq4O+bZgaiObrf7W2ARdp1cX1gnLHbjYU+N4oNPXelHfaQtZj4nZezYGpJw74asX/edZ Qta0RckXli5U2ClRuiSjXPvsxN9dnCHnw+9vmXUx5R9/0savh28yuF2vXj/VTuxv7aNK219/ dr3sPB9l0b/IxcqqcGNqZczNetUb++8wcL59Y1r6zv2FqUbiLLEj/DEFIhVPEg0UXz4VSf3W d1nqxiuexTX7ilKn+y1em7K980eP88eD7ttf3Oti8tiw64vIc7tdef8Z1qg3B5Q5nEk6zftx Z6wlg7TezIVqQVqTTBZH9W5jO2i81vE5w4/vWTbGZmXSE2dvnKa2Y8UZn+cnpUSnrTEv7ebY HpegxFKckWioxVxUnAgApo1Jt84CAAA= X-CMS-MailID: 20210617054647epcas1p431edaffea5bf7f3792b55dc3d91289ae 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 From patchwork Thu Jun 17 06:05:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 12326661 X-Patchwork-Delegate: cw00.choi@samsung.com 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 B4780C49EA3 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 988446113C for ; Thu, 17 Jun 2021 05:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbhFQFtE (ORCPT ); Thu, 17 Jun 2021 01:49:04 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:17924 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbhFQFtC (ORCPT ); Thu, 17 Jun 2021 01:49:02 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210617054652epoutp033f4aa76d1b85f5ca624ad667bd0f7581~JSHX0DeEZ2103621036epoutp03G for ; Thu, 17 Jun 2021 05:46:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210617054652epoutp033f4aa76d1b85f5ca624ad667bd0f7581~JSHX0DeEZ2103621036epoutp03G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1623908812; bh=YkhycMwItQsXct9Ie+LrHnOaX0bytSrZJ0ISUxzczEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+sIcHSUsLVdQtmd7yWB3shodo3u6/siS43XR0+f8ORkd8m/aYZdzrEBnVsOo5d1G zbbXFqtP7+VJj1HK50PxODDcUGdOfoZBXmm5ijM+GJ3PgYL186x0cnbXKBMuPRxuzq WlWsJgexH260WqiYa6ZTHdgc73yhn93lSdBd3EB4= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210617054651epcas1p2cd5037b5a294d98fa445b9a9343b64b1~JSHXVZnUB2425124251epcas1p2g; Thu, 17 Jun 2021 05:46:51 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.158]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4G59zX2353z4x9Pr; Thu, 17 Jun 2021 05:46:48 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id E7.AA.09736.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 20210617054647epcas1p41cd87f03bc6f5b44b6f2d7a3e5924860~JSHT1Od_t3132231322epcas1p4x; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210617054647epsmtrp1920595a8995e3e5b262cbf3240932e44~JSHT0SzjX1935819358epsmtrp1T; Thu, 17 Jun 2021 05:46:47 +0000 (GMT) X-AuditID: b6c32a39-ea97ca8000002608-f8-60cae1c83c74 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B9.9D.08637.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 20210617054647epsmtip11ecc08f069d1ddecb288a933acbeb5ff~JSHTkh6dd1533015330epsmtip1X; 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 4/4] PM / devfreq: passive: Reduce duplicate code when passive_devfreq case Date: Thu, 17 Jun 2021 15:05:46 +0900 Message-Id: <20210617060546.26933-5-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+NgFvrLKsWRmVeSWpSXmKPExsWy7bCmnu6Jh6cSDNat5bXYvv4Fq8XEG1dY LK5/ec5q8eyotsWE1u3MFmeb3rBbXN41h83ic+8RRovbjSvYLLoO/WWzuLbwPasDt8fshoss Hpf7epk8ds66y+6xYFOpx6ZVnWweLSf3s3j0bVnF6PF5k1wAR1S2TUZqYkpqkUJqXnJ+SmZe uq2S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-Loop: Reflected X-CMS-RootMailID: 20210617054647epcas1p41cd87f03bc6f5b44b6f2d7a3e5924860 References: <20210617060546.26933-1-cw00.choi@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In order to keep the consistent coding style between passive_devfreq and passive_cpufreq, use common code for handling required opp property. Also remove the unneed conditional statement and unify the comment of both passive_devfreq and passive_cpufreq when getting the target frequency. Signed-off-by: Chanwoo Choi --- drivers/devfreq/governor_passive.c | 80 ++++++------------------------ 1 file changed, 15 insertions(+), 65 deletions(-) diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c index 07e864509b7e..7102cb7eb30d 100644 --- a/drivers/devfreq/governor_passive.c +++ b/drivers/devfreq/governor_passive.c @@ -91,66 +91,17 @@ static int get_target_freq_with_devfreq(struct devfreq *devfreq, struct devfreq_passive_data *p_data = (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, *p_opp; - int i, count; - - /* - * 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); - - /* - * If the parent and passive devfreq device uses the OPP table, - * get the next frequency by using the OPP table. - */ - - /* - * - parent devfreq device uses the governors except for passive. - * - passive devfreq device uses the passive governor. - * - * Each devfreq has the OPP table. After deciding the new frequency - * from the governor of parent devfreq device, the passive governor - * need to get the index of new frequency on OPP table of parent - * device. And then the index is used for getting the suitable - * new frequency for passive devfreq device. - */ - if (!devfreq->profile || !devfreq->profile->freq_table - || devfreq->profile->max_state <= 0) - return -EINVAL; - - /* - * The passive governor have to get the correct frequency from OPP - * list of parent device. Because in this case, *freq is temporary - * value which is decided by ondemand governor. - */ - if (devfreq->opp_table && parent_devfreq->opp_table) { - p_opp = devfreq_recommended_opp(parent_devfreq->dev.parent, - freq, 0); - if (IS_ERR(p_opp)) - return PTR_ERR(p_opp); - - opp = dev_pm_opp_xlate_required_opp(parent_devfreq->opp_table, - devfreq->opp_table, p_opp); - dev_pm_opp_put(p_opp); - - if (IS_ERR(opp)) - goto no_required_opp; - - *freq = dev_pm_opp_get_freq(opp); - dev_pm_opp_put(opp); - - return 0; - } + unsigned long target_freq; + int i; + + /* Get target freq via required opps */ + target_freq = get_taget_freq_by_required_opp(parent_devfreq->dev.parent, + parent_devfreq->opp_table, + devfreq->opp_table, *freq); + if (target_freq) + goto out; -no_required_opp: - /* - * Get the OPP table's index of decided frequency by governor - * of parent device. - */ + /* Use Interpolation if required opps is not available */ for (i = 0; i < parent_devfreq->profile->max_state; i++) if (parent_devfreq->profile->freq_table[i] == *freq) break; @@ -158,16 +109,15 @@ static int get_target_freq_with_devfreq(struct devfreq *devfreq, if (i == parent_devfreq->profile->max_state) return -EINVAL; - /* Get the suitable frequency by using index of parent device. */ if (i < devfreq->profile->max_state) { - child_freq = devfreq->profile->freq_table[i]; + target_freq = devfreq->profile->freq_table[i]; } else { - count = devfreq->profile->max_state; - child_freq = devfreq->profile->freq_table[count - 1]; + i = devfreq->profile->max_state; + target_freq = devfreq->profile->freq_table[i - 1]; } - /* Return the suitable frequency for passive device. */ - *freq = child_freq; +out: + *freq = target_freq; return 0; }