From patchwork Wed Oct 21 09:55:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 55355 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 887E02303B for ; Wed, 21 Oct 2015 09:55:47 +0000 (UTC) Received: by lbbxe8 with SMTP id xe8sf14176926lbb.0 for ; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:subject:from:to:cc:date :content-type:mime-version:content-transfer-encoding:sender :precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=g4FpaRVFSGTaHA0sRsa+maVITgPrMj5rUoFbFKMFoA0=; b=SBx/fp7HB/pamcyPkSjbdi3gKsNdvrplaOD1CimpL7EbxZaSOHx49gMDMNVYpauJF1 a3Ll0wRH/ZgVqnRO+tSEMaNv8LZR8Q8m+nLAZVtiNo6apeYzWJqsg5/nrzCQ4J09jrGF WxAai0xztJfMKIEKwmf/0Q1vcex7MbHFyQr4UNVe0qir5N4h0LFS2nWDol2eKo8+zF7N pX1AAOMpG9SBrhJhI9s2+ZoMoFjqeTMvPmy71D+MYQ6OPP7EXWJXfPvP0Puk1ThFvIJA LyqBHx7r+EmnVM+jKWebdlcMFW0zb/svp4PSDg8JN3Oh/ooKozv2EROsqISUPYwVkwby Rezg== X-Gm-Message-State: ALoCoQnU7eJYL7K7bg9xX31v4M+tO8IApzklfSBDof+WcsP6tK5e8tVdv40gQXAGe2fMN/dU5zHE X-Received: by 10.112.173.170 with SMTP id bl10mr1927070lbc.7.1445421346501; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.153.9 with SMTP id b9ls169051lfe.85.gmail; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) X-Received: by 10.112.55.99 with SMTP id r3mr4630863lbp.64.1445421346324; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id m198si5739455lfb.78.2015.10.21.02.55.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2015 02:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbec13 with SMTP id ec13so32164423lbb.0 for ; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) X-Received: by 10.112.198.69 with SMTP id ja5mr3535681lbc.106.1445421346138; Wed, 21 Oct 2015 02:55:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2586094lbq; Wed, 21 Oct 2015 02:55:45 -0700 (PDT) X-Received: by 10.50.79.164 with SMTP id k4mr8957110igx.16.1445421345006; Wed, 21 Oct 2015 02:55:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s64si6655787ioi.19.2015.10.21.02.55.44; Wed, 21 Oct 2015 02:55:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932326AbbJUJzl (ORCPT + 28 others); Wed, 21 Oct 2015 05:55:41 -0400 Received: from smarthost01b.mail.zen.net.uk ([212.23.1.3]:55157 "EHLO smarthost01b.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932197AbbJUJzh (ORCPT ); Wed, 21 Oct 2015 05:55:37 -0400 Received: from [82.69.122.217] (helo=linaro1) by smarthost01b.mail.zen.net.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Zoq7J-000FRs-Qi; Wed, 21 Oct 2015 09:55:34 +0000 Message-ID: <1445421333.2916.13.camel@linaro.org> Subject: [PATCH v2] cpufreq: arm_big_little: fix frequency check when bL switcher is active From: "Jon Medhurst (Tixy)" To: Viresh Kumar , Sudeep Holla , "Rafael J. Wysocki" Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Turquette Date: Wed, 21 Oct 2015 10:55:33 +0100 X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-Originating-smarthost01b-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tixy@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The check for correct frequency being set in bL_cpufreq_set_rate is broken when the big.LITTLE switcher is active, for two reasons. 1. The 'new_rate' variable gets overwritten before the test by the code calculating the frequency of the old cluster. 2. The frequency returned by bL_cpufreq_get_rate will be the virtual frequency, not the actual one the intended version of new_rate contains. This means the function always returns an error causing an endless stream of: "cpufreq: __target_index: Failed to change cpu frequency: -5" As the intent is to check for errors that clk_set_rate doesn't report lets move the check to immediately after that and directly use clk_get_rate, rather than the arm_big_little helpers which only confuse matters. Also, update the comment to be hopefully clearer about the purpose of the code. Fixes: 0a95e630b49a ("cpufreq: arm_big_little: check if the frequency is set correctly") Signed-off-by: Jon Medhurst Acked-by: Sudeep Holla Acked-by: Viresh Kumar --- Changes since V1: - Check rate using clk_get_rate rather than disabling check when bL switcher active Sudeep, I added your Ack from the last comment on the previous patch. This final patch differs from what was discussed only in the commit message and in source comment which is hopefully more clear and is also satisfactory. I've also added Michael Turquette's correct email to the CC this time, rather than his old Linaro address which was bouncing. drivers/cpufreq/arm_big_little.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index f1e42f8..c5d256c 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -149,6 +149,19 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) __func__, cpu, old_cluster, new_cluster, new_rate); ret = clk_set_rate(clk[new_cluster], new_rate * 1000); + if (!ret) { + /* + * FIXME: clk_set_rate hasn't returned an error here however it + * may be that clk_change_rate failed due to hardware or + * firmware issues and wasn't able to report that due to the + * current design of the clk core layer. To work around this + * problem we will read back the clock rate and check it is + * correct. This needs to be removed once clk core is fixed. + */ + if (clk_get_rate(clk[new_cluster]) != new_rate * 1000) + ret = -EIO; + } + if (WARN_ON(ret)) { pr_err("clk_set_rate failed: %d, new cluster: %d\n", ret, new_cluster); @@ -189,15 +202,6 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) mutex_unlock(&cluster_lock[old_cluster]); } - /* - * FIXME: clk_set_rate has to handle the case where clk_change_rate - * can fail due to hardware or firmware issues. Until the clk core - * layer is fixed, we can check here. In most of the cases we will - * be reading only the cached value anyway. This needs to be removed - * once clk core is fixed. - */ - if (bL_cpufreq_get_rate(cpu) != new_rate) - return -EIO; return 0; }