From patchwork Tue Dec 18 11:20:48 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: 10735425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E326A14E2 for ; Tue, 18 Dec 2018 11:21:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42582A484 for ; Tue, 18 Dec 2018 11:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5A342A499; Tue, 18 Dec 2018 11:21:05 +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=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6520A2A484 for ; Tue, 18 Dec 2018 11:21:05 +0000 (UTC) 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=cuTfTE7JkOI0r+h0jh9Q46UUNbDIVj0jSTyuH2Pz3MM=; b=CqNjjGoECVeUcO uPTV7qyZkaF+f4bskPw3ShIWcja5LuMl7wdqEy6ROsFHNtsJVcxhfF5UzW0WiMKNvRTlLTuefIKeS 2mWTd2VJQVgXeSZ/nAI70RDiZ2fdxQ1jGKyY5ikSeVsUIOh3owg5q7Ps7K7nYbGQ9kwC8rT7RPPkz IrWMdSMvH8qVwZq3xDNZDMZNqhhGlln+I2LLo7jIizkJ3FNrQ02bdqp4vlNV6IfK2vH3TdXbp+TNM neBGCgJWHXNsqGtedjthGRREukIGhfGbsy680gc66VpjUmDH8/SwGhfeCXR3DzRa5WDsySviygiJe ZipXuf/50buZWPSt/tHw==; 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 1gZDQt-0005OP-Hc; Tue, 18 Dec 2018 11:21:03 +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 1gZDQq-0005ND-BJ for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2018 11:21:01 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43JwX96CXdzHb; Tue, 18 Dec 2018 12:19:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545131961; bh=jycAhEYzEBtnnZoIZGaZbJ1DFaTdDSu9LD2wajM16/g=; h=Date:From:Subject:To:Cc:From; b=mpAwMMApmN8uoG4xh979VO7RlITGhfUDRY4C/AYkXJ4K5BZJ+OXay+LL5POTqAbt3 0UjdSzIyA+0uzA/4evpexUK/07teX32fw4L+Ll43r6z5VojB6RnFDx0veErQ9FZSBN F4B4p6Zlk/NTjDTozhBvqVkQV/f5vMK43eVZKfAD6Q+XAs8n9nlTYmHeAlYh/HDNPq naA4jx9CCdiEDQialJIy4tJxjKMbqG00nbLPNiLlNi0BGFnwUP7EVTG8mZr7zBAOqr OqGBX50kCJVHjIgsjtwfslt7Y9KwbkjD/iVENEEpvTP/qG40zbH6JrwVLnlgXDHt/f lqioPEpTnFUmw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Tue, 18 Dec 2018 12:20:48 +0100 Message-Id: <70db24a03b552ca553e6435306d895644fb08545.1545131728.git.mirq-linux@rere.qmqm.pl> From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v3] 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-20181218_032100_562679_8583D42F X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Stop the search for parent rate when exact match is found. 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 Reviewed-by: Nicolas Ferre --- v2: rebased on v4.20-rc7 v3: formatting and commit description changes --- drivers/clk/at91/clk-audio-pll.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/clk/at91/clk-audio-pll.c b/drivers/clk/at91/clk-audio-pll.c index 36d77146a3bd..3cc4a82f4e9f 100644 --- a/drivers/clk/at91/clk-audio-pll.c +++ b/drivers/clk/at91/clk-audio-pll.c @@ -340,7 +340,12 @@ 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); + div = max(best_parent_rate / rate, 1UL); + for (; 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 +355,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 */ } }