From patchwork Thu Nov 3 23:53:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?St=C3=A9phan_Rafin?= X-Patchwork-Id: 9411661 X-Patchwork-Delegate: sboyd@codeaurora.org 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 A03C1601C2 for ; Fri, 4 Nov 2016 00:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8946A2AFA0 for ; Fri, 4 Nov 2016 00:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CB8B2AFCD; Fri, 4 Nov 2016 00:00:47 +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 010002AFA0 for ; Fri, 4 Nov 2016 00:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759314AbcKDAAq (ORCPT ); Thu, 3 Nov 2016 20:00:46 -0400 Received: from mail.soliotek.com ([91.134.131.150]:46876 "EHLO mail.soliotek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758388AbcKDAAp (ORCPT ); Thu, 3 Nov 2016 20:00:45 -0400 X-Greylist: delayed 366 seconds by postgrey-1.27 at vger.kernel.org; Thu, 03 Nov 2016 20:00:45 EDT Received: from linux.local (ip140.ip-51-255-215.eu [51.255.215.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: stephan@soliotek.com) by mail.soliotek.com (Postfix) with ESMTPSA id 98D01C1DF; Thu, 3 Nov 2016 23:54:36 +0000 (UTC) From: =?UTF-8?q?St=C3=A9phan=20Rafin?= To: emilio@elopez.com.ar Cc: mturquette@baylibre.com, sboyd@codeaurora.org, maxime.ripard@free-electrons.com, wens@csie.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?St=C3=A9phan=20Rafin?= Subject: [PATCH] clk: sunxi: Fix M factor computation for APB1 Date: Fri, 4 Nov 2016 00:53:56 +0100 Message-Id: <1478217236-12831-1-git-send-email-stephan@soliotek.com> X-Mailer: git-send-email 2.6.6 MIME-Version: 1.0 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit cfa636886033 ("clk: sunxi: factors: Consolidate get_factors parameters into a struct") introduced a regression for m factor computation in sun4i_get_apb1_factors function. The old code reassigned the "parent_rate" parameter to the targeted divisor value and was buggy for the returned frequency but not for the computed factors. Now, returned frequency is good but m factor is incorrectly computed (its max value 31 is always set resulting in a significantly slower frequency than the requested one...) This patch simply restores the original proper computation for m while keeping the good changes for returned rate. Signed-off-by: Stéphan Rafin --- drivers/clk/sunxi/clk-sunxi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 838b22a..f2c9274 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -373,7 +373,7 @@ static void sun4i_get_apb1_factors(struct factors_request *req) else calcp = 3; - calcm = (req->parent_rate >> calcp) - 1; + calcm = (div >> calcp) - 1; req->rate = (req->parent_rate >> calcp) / (calcm + 1); req->m = calcm;