From patchwork Mon Jun 12 19:44:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9782695 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 9AEF66038F for ; Mon, 12 Jun 2017 19:45:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B81E27FB6 for ; Mon, 12 Jun 2017 19:45:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8019427F86; Mon, 12 Jun 2017 19:45:26 +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 3FB32284F1 for ; Mon, 12 Jun 2017 19:45:26 +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=QynWFm0EBGCKqmILGV/QJA00GQIUUPfmvDNBPiR8DTY=; b=KjORHmcu3XW/XzcZ2E9rIcPm20 9IIZZdMVlWtw5sUPcnXf+HarTGZyvBTDoXVf0DqvypcljFtRpdjFK8PR5mvCxsrZtBHCcUu0ex3tb LD/ebysp77mA3ervJzYxk2ygu+zNwsrkdIXGxzQHjBEPN8B7GLCTusSDYrRBRebwURczO9GxyOFIn Si9jg4Zb/IAX7HijecFWjmp8fhBKT9HqE/fpzAD3tstnjS08skdhu4w14a0hV7UNGlbKKl5x4nzBu Pat2VraWydwvtDRL1wzmoCRDR/QdqgLy0af/twOndDsKYF4Be2OWO38RKK8ry5Dff4aS0igeu4Yv/ UipPY2hQ==; 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 1dKVH4-0004m3-0u; Mon, 12 Jun 2017 19:45:18 +0000 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dKVGz-0003R7-1J for linux-amlogic@lists.infradead.org; Mon, 12 Jun 2017 19:45:14 +0000 Received: by mail-wr0-x232.google.com with SMTP id q97so111393609wrb.2 for ; Mon, 12 Jun 2017 12:44:52 -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=9ZtDRLCdIYqQS5bxAU+BwYaGGlG91iLP8T/13TEEjZ4=; b=Go9kqlpQLFJlr0eTpj7LsqWO2ph+dR3KPzpadEKyUMLUeYFUKXhn3hAKYmotZ5wW7O C5HAdcH7KOFPIeszIFvF5XYanNIAPf8dFnsCBWHewDROydLiNEmcEnRUQm9ah3m39G8s ER48SEUsno7xJu5W4dY/or7ORwo3fiaNFpuea5AL3y0q5Xc7PMi+lhCLJhv8zdcg2CuS MTwZHvCBW9zmGPrVMVqTfIvCUCODidZJV9OpiJMldYOBTzwPRby3HhH9YVe+9Ovw/iXx GD3d50qo3NrI+tQRhMkRzL+5eG2bKTVg3hkHMamyzEtD3tx1HsF9j1O4bt847dyGZll6 dYNQ== 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=9ZtDRLCdIYqQS5bxAU+BwYaGGlG91iLP8T/13TEEjZ4=; b=KvU2ZnnK3xhGvHa02ocBC0KEEBnjepI8qGF+HSjafzju3Zdg9UIat4R8gifK/svB3W 3zO6qQ+9S+wGT+/f5pj7/PJhmupx2KGC29j2meSBtsAF0zZYFgfMWFY+oZWgchNmcRiY 2nH4CXxbIb3PgfRDqj/sJkwEo/6Yqv88yY4W8MYLsNgh9rDB9IgHfjNsYqqhXKaQrMsl GpQuTdodZ82Yz3SBvJzvyUzrGZ5of4GBZpyT2yEsMX8WgRSt/33Z9Ib9ryHmF//9VJS5 reaeZBHxnyh8Iegwbby3ru8E96CCxUoo1a8ShHucYGroMyibDiU7ou1YIEAdcZxOrCIq n8HA== X-Gm-Message-State: AKS2vOwP2UYVZXtFDEyvRabM28iHH/K3KpMbSInl2gNzClFx2szlJJza DjizdS94ZymMjsE/ X-Received: by 10.28.19.11 with SMTP id 11mr8845863wmt.123.1497296691140; Mon, 12 Jun 2017 12:44:51 -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 70sm13250797wmu.28.2017.06.12.12.44.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 12:44:50 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org Subject: [PATCH v3 04/10] clk: use round rate to bail out early in set_rate Date: Mon, 12 Jun 2017 21:44:32 +0200 Message-Id: <20170612194438.12298-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170612194438.12298-1-jbrunet@baylibre.com> References: <20170612194438.12298-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170612_124513_241062_572008D4 X-CRM114-Status: GOOD ( 14.44 ) 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: Boris Brezillon , Kevin Hilman , Linus Walleij , Russell King , linux-amlogic@lists.infradead.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 8cc4672414be..163cb9832f10 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;