From patchwork Mon Dec 17 19:37:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 1014721 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mUluHmlf"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="dWKECi2D"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43JWdn5YXTz9s1c for ; Tue, 18 Dec 2018 06:37:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:Message-Id :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=8vM/kaWL7BTUkC5cd3sC2l2vJ1PRrzWVRBmJN/tHLMI=; b=mUluHmlffilUm3 1beQTPu3tztzKn14JaShSKQ/GR2Pakfabn/807GyscHgvs0S6d3vDbYX5ArqBAeynSOI9R+mjHX8o LImQUuTneO2xbBtsAsJSl1s0ogd1v9QWbXRaq2N1ewacpe2dVxYk4DjtjsXEW0MxoQ1ls0DmTov2P tVszTTewHT5k/bCvW+z2RuRoqY4o4wp9L8iQsH3CfrGwFUuj8ctb9dm/KkEUUtNERqj+XuYeKqK9I Clg/rMeWH4dRzhpPswjUnlSoLHZj79eVZVpJmYHW5xgeaYHQF/iXXKy7cuok+c7cesA/ItEH1fa4P mPWxMcIWn1EhVvpat53w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYyhx-0006B8-Ue; Mon, 17 Dec 2018 19:37:41 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gYyhi-000629-Rd for linux-arm-kernel@lists.infradead.org; Mon, 17 Dec 2018 19:37:28 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43JWbH4RLgz9F; Mon, 17 Dec 2018 20:35:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545075339; bh=/56MsxFwaSjwK7/mt/Tkx+PibwmttCvRGbZJTSeRTC8=; h=Date:From:Subject:To:Cc:From; b=dWKECi2DpPxPmwe+wJ7l63SbcBQYpFyVnoM+YgPT2DyXaKDn+BQJ6XvRcv4/hn1Y+ eO9zTdGOiWfVVMb45afiKDgkaZ45GXaX1PZ9BHh6UmZthlr1nRGoQ6QLkbRDqvYZqx hJ7WrfPbrPhoVi8aY/B6DwV2I8ZkfhhBkefm1uS+tiIZp9OhlBx5gB7kjGXccdFYew wO/4OzAYVyH+OlL9zByDpTjIELlnbhn9GveJGqIreFEpz3rZ+jG69EbuC4DdVB5RBe QzOEQQTxIP+MeVWbcNYkO186MDJHh57ZOrBpT64sM9JIkqTj59iCpFGXCOweuG3c9k VayOJwZR/nISQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Mon, 17 Dec 2018 20:37:05 +0100 Message-Id: <772b3869cc992d894d8c1b4296f21100bcbed30d.1545075103.git.mirq-linux@rere.qmqm.pl> From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH] clk: at91: optimize clk_round_rate() for AUDIO_PLL MIME-Version: 1.0 To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181217_113727_064519_45516A9C X-CRM114-Status: UNSURE ( 8.81 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Boyd , Michael Turquette , Ludovic Desroches , Alexandre Belloni Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This makes for 3 clk_round_rate() calls instead of 64 of them on SAMA5D2-based board when searching for 12.288MHz clock. Signed-off-by: Michał Mirosław --- drivers/clk/at91/clk-audio-pll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/clk/at91/clk-audio-pll.c b/drivers/clk/at91/clk-audio-pll.c index 36d77146a3bd..3a358282784e 100644 --- a/drivers/clk/at91/clk-audio-pll.c +++ b/drivers/clk/at91/clk-audio-pll.c @@ -340,7 +340,11 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate, pr_debug("A PLL/PMC: %s, rate = %lu (parent_rate = %lu)\n", __func__, rate, *parent_rate); - for (div = 1; div <= AUDIO_PLL_QDPMC_MAX; div++) { + if (!rate) + return 0; + + best_parent_rate = clk_round_rate(pclk->clk, 1); + for (div = max(best_parent_rate / rate, 1ul); div <= AUDIO_PLL_QDPMC_MAX; div++) { best_parent_rate = clk_round_rate(pclk->clk, rate * div); tmp_rate = best_parent_rate / div; tmp_diff = abs(rate - tmp_rate); @@ -350,6 +354,8 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate, best_rate = tmp_rate; best_diff = tmp_diff; tmp_qd = div; + if (!best_diff) + break; /* got exact match */ } }