From patchwork Wed Oct 3 23:00:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1543801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 2E7A3DFF71 for ; Wed, 3 Oct 2012 23:02:59 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TJXvq-0007S6-RA; Wed, 03 Oct 2012 23:00:46 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TJXvf-0007Qw-04 for linux-arm-kernel@lists.infradead.org; Wed, 03 Oct 2012 23:00:35 +0000 Received: by pbcxa7 with SMTP id xa7so9827923pbc.36 for ; Wed, 03 Oct 2012 16:00:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/DFGsg/ftzYL9SXopOIC+WmIy4Oor/bJn9R4kMhXCpc=; b=VCTmkfxoL/gbyMFa5isqYwv7D8OsbigciGTEZ7aDWXoxzMnlXLhqkBhcGmsYQSc8ij cn/ZHDlzMQZUl3yBJml0MnuQP7j9A7BdpD128iDfo+Zi8SUJesK4zgu/fTRJqVWPbVaO Hmsce8zILyw6kqpAeOfX+QLHzHB4cUxUyQxDh4HUODGOnAbKzTZFipexXKR9U6/QPw2f A4Aw97RsTuIjlqmNuCnMB/A4FByHJP1HDg9GETK/xuEu1fH90JFktf+8iGNAFKP0WJWj EoRj1kV8bXe2e7ZRKqtS3pAF1euCB2MFjCeCkIBfW2VEBhmKnqRk/9kiyg2Q3uWQns1C yHFw== Received: by 10.68.129.38 with SMTP id nt6mr16780476pbb.76.1349305234121; Wed, 03 Oct 2012 16:00:34 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id gj9sm3266876pbc.16.2012.10.03.16.00.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 16:00:33 -0700 (PDT) From: Kevin Hilman To: "Rafael J. Wysocki" , linux-omap@vger.kernel.org Subject: [PATCH 1/4] cpufreq: OMAP: ensure valid clock rate before scaling Date: Wed, 3 Oct 2012 16:00:26 -0700 Message-Id: <1349305229-28480-2-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <1349305229-28480-1-git-send-email-khilman@deeprootsystems.com> References: <1349305229-28480-1-git-send-email-khilman@deeprootsystems.com> X-Gm-Message-State: ALoCoQl14kayyTLxR/HBznUUTjy4FiPXRDotCYldOvQZ0LPSovWEiU7oy2RUX1Vp2ZfhnUNGNpcN X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Kevin Hilman Ensure the clock rate that will be used is a valid one before attempting to scale the voltage. Currently the driver assumes it has a valid frequency from the OPP table, but boards using different system oscillators might not have exact matches with the OPP table, and result in a failing call to clk_set_rate(). This is particularily bad because the voltage may be scaled even though the frequency is not. This will obviously lead to some unpredictable behavior, especially if the frequency is high and the voltage is dropped. Thanks to Joni Lapilainen for reporting crashes seen on 3430/n900. Reported-by: Joni Lapilainen Signed-off-by: Kevin Hilman --- drivers/cpufreq/omap-cpufreq.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 65f8e9a..0fe395a 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -108,6 +108,14 @@ static int omap_target(struct cpufreq_policy *policy, } freq = freqs.new * 1000; + ret = clk_round_rate(mpu_clk, freq); + if (IS_ERR_VALUE(ret)) { + dev_warn(mpu_dev, + "CPUfreq: Cannot find matching frequency for %lu\n", + freq); + return ret; + } + freq = ret; if (mpu_reg) { opp = opp_find_freq_ceil(mpu_dev, &freq);