From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756860AbdJKL0T (ORCPT ); Wed, 11 Oct 2017 07:26:19 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:12415 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750705AbdJKL0R (ORCPT ); Wed, 11 Oct 2017 07:26:17 -0400 X-AuditID: b6c32a39-a6fff7000000109f-d0-59ddffd7adb5 Mime-Version: 1.0 Subject: RE: [PATCH v3 4/8] PM / devfreq: Show the all available frequencies Reply-To: myungjoo.ham@samsung.com From: MyungJoo Ham To: Chanwoo Choi , Kyungmin Park CC: "rafael.j.wysocki@intel.com" , "chanwoo@kernel.org" , Inki Dae , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <1507691364-3899-5-git-send-email-cw00.choi@samsung.com> X-Drm-Type: N,general X-EPLocale: ko_KR.EUC-KR X-EPWebmail-Msg-Type: personal X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Illegal-Object: Syntax error in X-Sender: address found on vger.kernel.org: X-Sender: =?utf-8?B?U2Ftc3VuZyBFbGVjdHJvbmljcxtBcnRpZmljaWFsIEludA==?= ^-Extraneous program text X-Sender-IP: 10.113.73.204 X-Local-Sender: =?UTF-8?B?7ZWo66qF7KO8G0FydGlmaWNpYWwgSW50ZWxsaWdlbmNlIDNMYWIoUy9X?= =?UTF-8?B?7IS87YSwKRvsgrzshLHsoITsnpAbUHJpbmNpcGFsIEVuZ2lu?= =?UTF-8?B?ZWVy?= X-Global-Sender: =?UTF-8?B?TXl1bmdKb28gSGFtG0FydGlmaWNpYWwgSW50ZWxsaWdlbmNlIDNMYWIu?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbUHJpbmNpcGFsIEVuZ2lu?= =?UTF-8?B?ZWVy?= X-Sender-Code: =?UTF-8?B?QzEwGxtDMTBWODI5MQ==?= Message-ID: <20171011112615epcms1p4da3b251ebd1e4285d203ab5c3be58e37@epcms1p4> Date: Wed, 11 Oct 2017 11:26:15 +0000 X-CMS-MailID: 20171011112615epcms1p4da3b251ebd1e4285d203ab5c3be58e37 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-MTR: 20171011112615epcms1p4da3b251ebd1e4285d203ab5c3be58e37 CMS-TYPE: 101P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupik+LIzCtJLcpLzFFi42LZdlhTV/f6/7uRBpeXCVtMvHGFxeL6l+es FpPuT2CxONv0ht3i8q45bBafe48wWjxe8Zbdgd1j8Z6XTB6bVnWyefRtWcXo8XmTXABLVKpN RmpiSmqRQmpecn5KZl66rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtAFSgpliTml QKGAxOJiJX07m6L80pJUhYz84hJbpWhDQyM9QwNzPSMjIz0T41grI1OgkoTUjJ0HprMXnBep 2HntFUsD40aBLkZODgkBE4njlw8xdjFycQgJ7GCUmLt6KXsXIwcHr4CgxN8dwiA1wgI+En/O fGUFsYUElCQabu5jhojrS3Q82MYIYrMJ6Eps3XCXBcQWEQiV2L2gD6yGWaCVSWL/hCSIXbwS M9qfskDY0hLbl28F6+UUcJU4dm0pM0RcVOLm6rfsELaExJ3XF5ggbDmJaV/XwNW8PzafEcIW kWi9dxYqLijx4OdusF8kBFoZJe5seQY1SEri1uJrTBCJZYwSiy8/ZYdwljNKtC/ZyAbysQTQ Ozu3O4M08Ar4Shya+BpsKouAqsSphtlQ21wk3rU2s0F8Ji+x/e0cZpBWZgFNifW79CFKbCWu v9/OCFHCJ/Huaw8rzPM75j2BekZN4tDuJewTGJVnIYJ6FpKhsxCGLmBkXsUollpQnJueWmxY YKpXnJhbXJqXrpecn7uJEZwOtSx3MB4753OIUYCDUYmHd8eVO5FCrIllxZW5hxglOJiVRHjZ /t6NFOJNSaysSi3Kjy8qzUktPsRoCvTbRGYp0eR8YKrOK4k3NLE0MDEzAiY5S0NDJXFe0fXX IoQE0hNLUrNTUwtSi2D6mDg4pRoYLWWyn95a/7Sv01376guLexePnzcrtF9xQUW3SbyT9d3+ VZ8mRh+MEPETCvgW/oL/dUC6WkZwiVo/x2fRX7MDo0VeXQ5JTfYU9GjRSP/y6DZnJbezPZd8 kFKin2JA9Rf2u/N8FXZ+LXn98soZziOn/z20Sl12gbXjZNrjlc020/e9cHPLCTmsxFKckWio xVxUnAgAsK+HP50DAAA= DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20171011030946epcas1p30ca5f54e1dd4df92cefd19a385423a41 X-RootMTR: 20171011030946epcas1p30ca5f54e1dd4df92cefd19a385423a41 References: <1507691364-3899-5-git-send-email-cw00.choi@samsung.com> <1507691364-3899-1-git-send-email-cw00.choi@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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]); Is there a possibilty that PC will hit here? (If so, don't you need to worry about not being sorted at all?) At least, devfreq_set_freq_table sorts it in ascending order. And if you are worried about someone not using devfreq_set_freq_table and set freq_table on their own, we'd better simple put some comments to mandate it to be sorted in ascending order or not allowing to do it anyway. Cheers, MyungJoo. > + } > + > + mutex_unlock(&df->lock); > /* Truncate the trailing space */ > if (count) > count--;