From patchwork Thu Sep 21 00:33:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 9963063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DF9D6056A for ; Thu, 21 Sep 2017 00:34:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FCC729286 for ; Thu, 21 Sep 2017 00:34:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2349D2927E; Thu, 21 Sep 2017 00:34:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AB4129280 for ; Thu, 21 Sep 2017 00:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbdIUAeE (ORCPT ); Wed, 20 Sep 2017 20:34:04 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:55654 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751937AbdIUAd6 (ORCPT ); Wed, 20 Sep 2017 20:33:58 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20170921003357epoutp01e915b477603db173b7387ce604343c2e~mOTe-ntiC1470514705epoutp01e; Thu, 21 Sep 2017 00:33:57 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.65]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20170921003356epcas1p11dae535e023216d392a32215f723f9b9~mOTeiLx-X2825428254epcas1p13; Thu, 21 Sep 2017 00:33:56 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 58.90.22848.4F803C95; Thu, 21 Sep 2017 09:33:56 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43~mOTeMT3ri0781607816epcas1p4C; Thu, 21 Sep 2017 00:33:56 +0000 (GMT) X-AuditID: b6c32a35-f798c6d000005940-ca-59c308f4ca5b Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id C8.02.11757.3F803C95; Thu, 21 Sep 2017 09:33:56 +0900 (KST) Received: from localhost.localdomain ([10.113.62.212]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OWL00BYOTKJX990@mmp1.samsung.com>; Thu, 21 Sep 2017 09:33:55 +0900 (KST) From: Chanwoo Choi To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com Cc: rafael.j.wysocki@intel.com, chanwoo@kernel.org, inki.dae@samsung.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] PM / devfreq: Show the all available frequencies Date: Thu, 21 Sep 2017 09:33:48 +0900 Message-id: <1505954032-3327-5-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1505954032-3327-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEKsWRmVeSWpSXmKPExsWy7bCmnu4XjsORBo+nyFpMvHGFxeL6l+es FpPuT2CxONv0ht3i8q45bBafe48wWtxuXMFm8XjFW3YHDo/Fe14y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TmZZalF+nYJXBl7T0UV7BGoaF94kKmBcRVvFyMHh4SAicSnK3xdjFwcQgI7GSWO 7b3AAuH8YJS4dfcsexcjJwebgJbE/hc32EBsEQE/ie3z1zOCFDELNDFKbHx2gAkkISzgIbH1 2QwmkKksAqoSi3YHg4R5BVwk2levBJsjISAn8WHPIzCbU8BV4tvZLrCZQkA1Z1+8ZpvAyLOA kWEVo2RqQXFuem6xUYFhXmq5XnFibnFpXrpecn7uJkZgCG07rNW3g/H+kvhDjAIcjEo8vAFW ByOFWBPLiitzDzFKcDArifDGPDwUKcSbklhZlVqUH19UmpNafIhRmoNFSZw3s29GpJBAemJJ anZqakFqEUyWiYNTqoExoChoh9N6QceVE9fv3v9w3k7lZsHPUnrs32+u/tsb05HRkCXqcOu+ h3ZPz9zv07+d5I3tucXsH/zIw0792Zbwquacpoarj464/1zBn5VnqxO66dWGf52avSY9CUEV fyf/dbg52/Ws/RsZ3bXOTr8OnhffXnDmxVOtX54fn8gGBNTXnbEJMjqnxFKckWioxVxUnAgA 8V0BLB0CAAA= X-CMS-MailID: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 X-Msg-Generator: CA X-Sender-IP: 182.195.42.142 X-Local-Sender: =?UTF-8?B?7LWc7LCs7JqwG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?Q2hhbndvbyBDaG9pG1RpemVuIFBsYXRmb3JtIExhYi4bU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtTZW5pb3IgRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG1RFTEUbQzEwVjgxMTE=?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 X-RootMTR: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 References: <1505954032-3327-1-git-send-email-cw00.choi@samsung.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The commit a76caf55e5b35 ("thermal: Add devfreq cooling") allows the devfreq device to use the cooling device. When the cooling down are required, the devfreq_cooling.c disables the OPP entry with the dev_pm_opp_disable(). In result, 'available_frequencies'[1] sysfs node never came to show the all available frequencies. [1] /sys/class/devfreq/.../available_frequencies So, this patch uses the 'freq_table' in the 'struct devfreq_dev_profile' in order to show the all available frequencies. - If 'freq_table' is NULL, devfreq core initializes them by using OPP values. - If 'freq_table' is initialized, devfreq core just uses the 'freq_table'. Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 799a0cf75d39..1c4b377cacfb 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1185,22 +1185,26 @@ static ssize_t available_frequencies_show(struct device *d, char *buf) { struct devfreq *df = to_devfreq(d); - struct device *dev = df->dev.parent; - struct dev_pm_opp *opp; ssize_t count = 0; - unsigned long freq = 0; + unsigned long *freq_table; + int i, max_state; - do { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - if (IS_ERR(opp)) - break; + mutex_lock(&df->lock); - dev_pm_opp_put(opp); - count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), - "%lu ", freq); - freq++; - } while (1); + freq_table = df->profile->freq_table; + max_state = df->profile->max_state; + if (freq_table[0] < freq_table[max_state - 1]) { + for (i = 0; i < max_state; i++) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq_table[i]); + } else { + for (i = max_state - 1; i >= 0 ; i--) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq_table[i]); + } + + mutex_unlock(&df->lock); /* Truncate the trailing space */ if (count) count--;