From patchwork Thu Oct 2 15:22:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 5019071 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B6C0C11AB for ; Thu, 2 Oct 2014 15:22:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 788A72020F for ; Thu, 2 Oct 2014 15:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9E4472020E for ; Thu, 2 Oct 2014 15:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754325AbaJBPWY (ORCPT ); Thu, 2 Oct 2014 11:22:24 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:52602 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754319AbaJBPWY (ORCPT ); Thu, 2 Oct 2014 11:22:24 -0400 Received: from weser.hi.pengutronix.de ([2001:67c:670:100:fa0f:41ff:fe58:4010]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XZiCz-0003RL-0o; Thu, 02 Oct 2014 17:22:21 +0200 Message-ID: <1412263338.2313.1.camel@pengutronix.de> Subject: Re: cpufreq: Unable to set cpufreq to maximum From: Lucas Stach To: Stefan Wahren Cc: "Rafael J. Wysocki" , gregkh@linuxfoundation.org, festevam@gmail.com, Viresh Kumar , linux-pm@vger.kernel.org Date: Thu, 02 Oct 2014 17:22:18 +0200 In-Reply-To: <878902771.162556.1412262099998.JavaMail.open-xchange@oxbaltgw01.schlund.de> References: <936524880.154802.1412255867221.JavaMail.open-xchange@oxbaltgw07.schlund.de> <1412258352.4875.5.camel@pengutronix.de> <878902771.162556.1412262099998.JavaMail.open-xchange@oxbaltgw01.schlund.de> X-Mailer: Evolution 3.12.6-1 Mime-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:fa0f:41ff:fe58:4010 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-pm@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Am Donnerstag, den 02.10.2014, 17:01 +0200 schrieb Stefan Wahren: > Hi Lucas, > > > Lucas Stach hat am 2. Oktober 2014 um 15:59 > > geschrieben: > > > > > > Am Donnerstag, den 02.10.2014, 15:17 +0200 schrieb Stefan Wahren: > > > Hi, > > > > > > i currently try to get cpufreq-cpu0 aka cpufreq-dt running on Freescale > > > i.MX28 > > > (ARM). First i ported the regulator driver and now i want to test it with > > > cpufreq-cpu0. Everything works fine except changing back to maximum > > > frequency > > > 454736 kHz. I get the following error: > > > > >> [...] > > > > > > Any ideas? > > > > Isn't your highest OPP just wrong? Apparently the CPU clock (which is a > > fixed PLL plus a divider on MX28 if I'm not mistaken) is only able to > > provide a slightly higher frequency than your OPP. cpufreq handles that > > as an error, which is valid behavior as going higher than the defined > > OPP may not be qualified by the vendor. > > I hope so. > > > > > Does it work if you just change this OPP to 454737 kHz? > > > > Yes after that i can change it with userspace governor. But i get this warning > during modprobe: > > root@duckbill:~# modprobe cpufreq-cpu0 > [ 48.573808] cpufreq: __cpufreq_add_dev: CPU0: Running at unlisted freq: > 454736 KHz > [ 48.604871] cpufreq: __cpufreq_add_dev: CPU0: Unlisted initial frequency > changed to: 454737 KHz > > I'm not sure if it's okay. > It's harmless in your case. But to get rid of it you might try the attached patch which may be an acceptable solution. ------------------------------>8----------------------------------- From db9e708edf6451b619ee73f68c3fcde2eccd7b0c Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 2 Oct 2014 17:20:09 +0200 Subject: [PATCH] cpufreq: generic: try preserve some accuracy while converting from Hz to kHz --- drivers/cpufreq/cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d9fdeddcef96..459830c6576f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -187,7 +187,7 @@ unsigned int cpufreq_generic_get(unsigned int cpu) return 0; } - return clk_get_rate(policy->clk) / 1000; + return DIV_ROUND_CLOSEST(clk_get_rate(policy->clk), 1000); } EXPORT_SYMBOL_GPL(cpufreq_generic_get);