From patchwork Sun May 21 21:59:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9739475 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 257206034C for ; Sun, 21 May 2017 22:00:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 163D9285C9 for ; Sun, 21 May 2017 22:00:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AB43285F3; Sun, 21 May 2017 22:00:28 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB11F285C9 for ; Sun, 21 May 2017 22:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757070AbdEUWA1 (ORCPT ); Sun, 21 May 2017 18:00:27 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36709 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757009AbdEUWA0 (ORCPT ); Sun, 21 May 2017 18:00:26 -0400 Received: by mail-wm0-f41.google.com with SMTP id 7so44240454wmo.1 for ; Sun, 21 May 2017 15:00:26 -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=S55/ZQgIHJxBUM4RPe6CDDUZHEGIFUFQJiJ4jsGcKPk=; b=rViKP8qgRDvtWL1uKn9nJozJUF1WcUjjcwXshqKO1YzQ5v/KZGr9nO2aVLaXPQJ4zG G8t0r1vg1eOtwWS6QPlfIPNkQT90tuPXkJLVhKm6UJ4xwY4dJdzocZ9M0k+kPFD2n8eA JPVNrWbLBIyxXo9ehs2oUg76WFMFCYrxxnrQLPiGGRMOb6yUO+esFBzC/isabqvhJLMJ U9LkIBs4oyCqCnB+ThHusyjpdgViAoCnGkGgA5jcTEZTHk8c1d5bnsggWq1qvlJmWmva DQTadSOzNCCYoshEynxs/bAKxT10sc8Gq5wN0eYYE3yfcr5jiIKwazEagIR3JR8aTsUe rkcQ== 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=S55/ZQgIHJxBUM4RPe6CDDUZHEGIFUFQJiJ4jsGcKPk=; b=E07ehnCga8hZ01+V7ma68U63ynWmuWjUy6rCGG/AMX5KARm+c4R5eO1tuzjfpzchnL qXNzpcFIiDeEFTIUZJuuKfuan+ynoipNrBWvE2pvmoGFCG9SUo6iE29vj7SvfAoIVQgt k0iBeQ5o6WgxzYMi/9seKxzoTAY9hYpzBTos7PpOjRbnw26uszARz7O3NvZK1E/Jb9O/ c7lc8TT5xPIk4HYR8Zdkl9cBwZDqysNGN8jqGrUZrTgxhxmZVbfs5uFwIXmZbfOn0rDb KNSCU6g6vpyRdCF+zydKQVCPFb3+OwQ178/tV21arYP35HaxgrfsuCZK8wslkC2utfuV K6Zw== X-Gm-Message-State: AODbwcCs2/b0Ghm3JzxpXyfm0/+TRAtkser6JDGBN3nCJamiUGbsVHs1 5J+aeAuGmwdj4vCm X-Received: by 10.223.133.181 with SMTP id 50mr11444948wrt.4.1495404025566; Sun, 21 May 2017 15:00:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 15:00:25 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , Kevin Hilman Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, Linus Walleij , Boris Brezillon Subject: [PATCH v2 11/11] clk: move CLK_SET_RATE_GATE protection from prepare to enable Date: Sun, 21 May 2017 23:59:58 +0200 Message-Id: <20170521215958.19743-12-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> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CLK_SET_RATE_GATE name suggest that the rate can be set when the provider is gated (disabled). With the current implementation, the rate can only be set when the provider is unprepared, while it should be allowed to set a prepared and disable provider. Fix this by moving the rate protection mechanism in the enable/disable core functions Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 6ee5fc59cf1f..e6e5048ce186 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -491,9 +491,6 @@ 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; @@ -564,14 +561,6 @@ 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; } @@ -716,6 +705,9 @@ static void clk_core_disable(struct clk_core *core) if (WARN_ON(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL)) return; + if (core->flags & CLK_SET_RATE_GATE) + clk_core_rate_unprotect(core); + if (--core->enable_count > 0) return; @@ -791,6 +783,15 @@ static int clk_core_enable(struct clk_core *core) } core->enable_count++; + + /* + * CLK_SET_RATE_GATE is a special case of clock protection + * Instead of a consumer protection, the provider is protecting + * itself when enabled + */ + if (core->flags & CLK_SET_RATE_GATE) + clk_core_rate_protect(core); + return 0; }