From patchwork Sun May 21 21:59:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9739489 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 B7C0D6034C for ; Sun, 21 May 2017 22:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7F87285C9 for ; Sun, 21 May 2017 22:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CF0D285F3; Sun, 21 May 2017 22:01:00 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 54419285C9 for ; Sun, 21 May 2017 22:01:00 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8rfAR56fmpvABzmcDZw+qGKRVAgkvJ5QRaml4EUEo9Y=; b=ipju+22z0w5ilK+MZrBrlodoGj SOM8uEVxcgO/dIHFnCmHjPPi54No/VEtOi2LzECkncRD6UzxiysscEc6ojO/V+LhyRIArOp71gLQa Cc0fWCDzSWBubSsgWT+ShC+OylrXkb7SeCoq3g6c8Jazuy98mp/AcQKqGix9dhrZI9sS+PJSB+3H9 YwGotkBOECgJYrLTJCIxWWzW3y31lcbvVCt+GTwzUAOn4FkIH1XMp9rltxG44pORci/Gdpv01STUf aOvSC0U+aiadulNKCAFgmfsvJzVMGqTj1j7/j2WCHWKbVpbpHQzV20R4YRHykp6g64c+9PGBdZSsU Tz2UyBLw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dCYuC-0002ba-4b; Sun, 21 May 2017 22:00:52 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dCYtz-0002Lx-6u for linux-amlogic@lists.infradead.org; Sun, 21 May 2017 22:00:42 +0000 Received: by mail-wm0-x22c.google.com with SMTP id b84so278408509wmh.0 for ; Sun, 21 May 2017 15:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H++mFyXjCRxuJgVl/JizGKqguepkso0rnx2hewt6LEU=; b=Z4hKKsVuXl5o2It61hIJtgSXUv1+m9y9+lrvg4aHP7kpRQ55ColY/1vHyl7YUVJotc GMese6pwHikYR6vKwkdPdrbZoRZCuogHtRoO9lIHL2vm6zy7ox7qfi3r+ljIleNoRE/d QL3Chi+YpjE0z3jNKzjmJfCyiA4zeGH+CF2Wg0ANfPQH/t9zdVe8WGvdVVPaYc1Ll64L 9sfArJ0xHDvRxbYd/Hb7/Me+RwZZpgJcZ/DfilkTKhy9Cpsy0V//fFTDz7c0J1bqc+6D CL16+mjxMMSgIedg1cxqEEobiZQOQShoMthuCu9jLI/FGhFY4DzOXzxqo6D8H4Uvu891 +PEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H++mFyXjCRxuJgVl/JizGKqguepkso0rnx2hewt6LEU=; b=Wm+M9gEN0BP37ghApBtstDA2Wi4/DYWrrfU89bjB+JTfKgfpbx6oSI9ywmydVrJ2Hm vmTdp15VhBGUvyvJQ8FPRE6GWS0aMO7DULw5ej49t7/Ni9QpVSJ/I2dIkN1xr2dcDKpc 97vjt8BvLGLc1wEvRSqnVRTGdlwZnu7nZ7Dne8425mmUdLEmW5q8/tQYYF1dpBJKa4XF xa2EL8UEnjwaojOpTBZOPn/dNvKzDiUdoYzAy/E95kUgEC8GdPeDUNSmnN+D4H7ueqnc j2z5JOfceyIpx7zT3kUtlfXN0IF7wswDcWoILm5+JIrgiHGC5ZcXi282MwFGUJQ20Bs1 5/kQ== X-Gm-Message-State: AODbwcBqDLDTnS3ksw7OMpH/Xx/G8Z6ba4Ltm9uywHHx5KwDzTaZsbBP 07rMCNeNDaZCQML7 X-Received: by 10.223.133.182 with SMTP id 51mr9815631wrt.86.1495404016717; Sun, 21 May 2017 15:00:16 -0700 (PDT) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id a73sm12812579wrc.58.2017.05.21.15.00.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 15:00:16 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , Kevin Hilman Subject: [PATCH v2 04/11] clk: use round rate to bail out early in set_rate Date: Sun, 21 May 2017 23:59:51 +0200 Message-Id: <20170521215958.19743-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170521215958.19743-1-jbrunet@baylibre.com> References: <20170521215958.19743-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170521_150039_402859_7F04F7B8 X-CRM114-Status: GOOD ( 14.45 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, Linus Walleij , Boris Brezillon , linux-clk@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The current implementation of clk_core_set_rate_nolock bails out early if the requested rate is exactly the same as the one set. It should bail out if the request would not result in rate a change. This important when rate is not exactly what is requested, which is fairly common with PLLs. Ex: provider able to give any rate with steps of 100Hz - 1st consumer request 48000Hz and gets it. - 2nd consumer request 48010Hz as well. If we were to perform the usual mechanism, we would get 48000Hz as well. The clock would not change so there is no point performing any checks to make sure the clock can change, we know it won't. This is important to prepare the addition of the clock protection mechanism Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 100f72472e10..1a8c0d013238 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1570,15 +1570,34 @@ static void clk_change_rate(struct clk_core *core) clk_change_rate(core->new_child); } +static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core, + unsigned long req_rate) +{ + int ret; + struct clk_rate_request req; + + if (!core) + return 0; + + clk_core_get_boundaries(core, &req.min_rate, &req.max_rate); + req.rate = req_rate; + + ret = clk_core_round_rate_nolock(core, &req); + + return ret ? 0 : req.rate; +} + static int clk_core_set_rate_nolock(struct clk_core *core, unsigned long req_rate) { struct clk_core *top, *fail_clk; - unsigned long rate = req_rate; + unsigned long rate; if (!core) return 0; + rate = clk_core_req_round_rate_nolock(core, req_rate); + /* bail early if nothing to do */ if (rate == clk_core_get_rate_nolock(core)) return 0; @@ -1587,7 +1606,7 @@ static int clk_core_set_rate_nolock(struct clk_core *core, return -EBUSY; /* calculate new rates and get the topmost changed clock */ - top = clk_calc_new_rates(core, rate); + top = clk_calc_new_rates(core, req_rate); if (!top) return -EINVAL;