From patchwork Sun May 21 21:59:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9739491 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 2BCFF6034C for ; Sun, 21 May 2017 22:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BDC1285C9 for ; Sun, 21 May 2017 22:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FD1A2863D; Sun, 21 May 2017 22:01: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham 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 92482285C9 for ; Sun, 21 May 2017 22:01:04 +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=p7fEAMNgbstdhJAl7p+0hmUz3c4jCEU78hiFRvsvPS0=; b=r7uMPVvXc5pIQMKJiGgGJzwO9C tMHDSehG9rhinj8Q2Po2t5hY5xESdsh7WftlxuX+ptr0Xhzau8fDF1XbXMigkKclbHLZE8BZ6WGHu tiQTJhdGVM3ihAS+ACxmVENN4v6QU2QeARdOrOLJMMNtXBevr/3Yk3iysZcq9x7exXhvBckDfy9/K tC/wy6lSZ9+EVz7UJfU0MI5hvDS8XqywvBpFG4bsY5s9cLmLWSmJJZ5ztYbVLP5B53pb0RPuLfZ+p wKPA9V+o+n8TWGzQ1fsJ0ojmGnYNqct2qHNhyh2H3tSk08ifWnvtPwQUD9b0NrNq+QGL7BdAI3u6m m49H7uuQ==; 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 1dCYuG-0002gc-PR; Sun, 21 May 2017 22:00:56 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dCYu2-0002MB-1o for linux-amlogic@lists.infradead.org; Sun, 21 May 2017 22:00:44 +0000 Received: by mail-wm0-x230.google.com with SMTP id b84so278410810wmh.0 for ; Sun, 21 May 2017 15:00:25 -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=+Cm0J5QXrOCm0LizBAxe2tREQ5Y7+e/sPxKoB/cZ0N8=; b=YlnD6AmyR/iVuNpX01y/Yc6UrLV1HLIDIj6gQq+M39e5Fukpr5Tozxq4l0cDxwE2OL GsP3Jwv8RA2V1bDBDHWP5nVJQAdxdNPuFOv/XWldwfTcip+uePVmAUf1JFh3r/XpOQpA rAmoU/H3rfE43Fnfw85Fx3E5HrpPF7Atf8S0W4x9uf5XmVZWe0ilezdlyigcia7W0dGv kRrgGmZg6PPkcbxH71XJYDVehNGa+ey3C2iz0JUz7TXotctTJsNxS8PSPKOfWmSQ+gvE SrQGyJClmlZSLNqUCVSUtJSEYrnjVCOs72Cz4/H2MhoTl9xnKo5Yu23Ivsv5+/jHt6eG N8kA== 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=+Cm0J5QXrOCm0LizBAxe2tREQ5Y7+e/sPxKoB/cZ0N8=; b=ZQOdBGVgsJILputYN8dXJRh7nz3LDdc15lD/ciNVQQULQaHBn5R0+6QNFb9U+kb+oM +qJtrRsWZ8+z/YG5+7so/i9cRjH7GcOt8ZREycLpEdpyIY/tOTDZpz4co4yaG3t2d5eE 2sNmHaJcCuwzZrdKiGU3Y8Yi0zIawPiq3ULzNDDX5F82J0oXSyENRKyx8ZAolGl8TXW9 lXO4PtGr6PU4GO6Bp3vvgr+z66UpI/7mCQJtG640tYXVNCmrAWNWqcp1Gy8APrIRhUbt e+S9KwclLnTvQGsH4HiJJvWgq03LdQoQkof/sUYabm+HTQ9i2TbAEgfI/5mwNpD3Rk0y R9Mg== X-Gm-Message-State: AODbwcDceTWTBpF87FD082LYAZFlc8k9UF5vtFRVmGqU8ueVatwvvsbN cF9B96/Z8IAYpPdV X-Received: by 10.28.5.196 with SMTP id 187mr11272569wmf.132.1495404024151; Sun, 21 May 2017 15:00:24 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 15:00:23 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , Kevin Hilman Subject: [PATCH v2 10/11] clk: fix CLK_SET_RATE_GATE with clock rate protection Date: Sun, 21 May 2017 23:59:57 +0200 Message-Id: <20170521215958.19743-11-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_150042_408389_38A84DA6 X-CRM114-Status: GOOD ( 10.74 ) 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 Using clock rate protection, we can now enforce CLK_SET_RATE_GATE along the clock tree Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 01306191133c..6ee5fc59cf1f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -491,6 +491,9 @@ static void clk_core_unprepare(struct clk_core *core) if (WARN_ON(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL)) return; + if (core->flags & CLK_SET_RATE_GATE) + clk_core_rate_unprotect(core); + if (--core->prepare_count > 0) return; @@ -561,6 +564,14 @@ static int clk_core_prepare(struct clk_core *core) core->prepare_count++; + /* + * CLK_SET_RATE_GATE is a special case of clock protection + * Instead of a consumer protection, the provider is protecting + * itself when prepared + */ + if (core->flags & CLK_SET_RATE_GATE) + clk_core_rate_protect(core); + return 0; } @@ -1738,9 +1749,6 @@ static int clk_core_set_rate_nolock(struct clk_core *core, if (clk_core_rate_is_protected(core)) return -EBUSY; - if ((core->flags & CLK_SET_RATE_GATE) && core->prepare_count) - return -EBUSY; - /* calculate new rates and get the topmost changed clock */ top = clk_calc_new_rates(core, req_rate); if (!top)