From patchwork Thu May 18 16:38:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9734811 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 A8FE96022E for ; Thu, 18 May 2017 16:38:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 978E1285EC for ; Thu, 18 May 2017 16:38:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C83628775; Thu, 18 May 2017 16:38:56 +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 4A0562879E for ; Thu, 18 May 2017 16:38:56 +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=78a1Lzjxte55qNo2W7zrrCjc2bQ5f+3HwIZIOhayZe0=; b=M2zcfbj5bCWXc02Sr+I5ORVcD+ AtxEZ6XprMijBruAMCazX3DjntZZCNJFtxF7doyN5Mo+WU/tBajDJgro1gnZx0WIi4CwTABkmbSeJ 3+IX5ah5bkeW9oKHTCjqIMDpzeFoEPmLxq9JZ1M1ko+ir6H/YXYN5zvaww6ZpHDgFI5BIZDLIiq8G en0SHFJRIeoohBdIid8xZdobcBcm14FnP13Ybusvzd19PpKc4KFE1IaKyGxmztvCcf/RVdAp44VkK 7KQHFo+FxQ6uYpB99SwV/XT9TwSNM8HIoIvwCp005lVfhjsSpaoEBjA75FVPLUxENea8gqWtT8AYe HdWrpR7A==; 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 1dBORs-0003Vx-NY; Thu, 18 May 2017 16:38:48 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBORh-0003G5-6j for linux-amlogic@lists.infradead.org; Thu, 18 May 2017 16:38:39 +0000 Received: by mail-wm0-x231.google.com with SMTP id v15so58897844wmv.1 for ; Thu, 18 May 2017 09:38: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=ofHJwx+KMJzy8ycXcJAmRIJdSsP2Bop2R7qbfF/r0OM=; b=vQHhcKrBpeV+IJT+QIy5u9LY5JSSy5zVu/rZbfDfjLZBFCnop1us6JgBga3Q7XA3YI ezPYx2akAHlyXpdiVQQX2MFeV75HL3q2Nnv6wEXJFcUSNLQWg7AjVhZ5aqECR2pGuHXr ZRRWufXPnBzHzzEpm7xX3/llURa7XVcbLPB9pMv+vyntwC2PDqhDvABZJZg8o/SBsEPU 8Tfedaus1EW9WyzZ/pRR35+maWA5k1UJcnvHZwmpXroaEP3mDLeqmQuoL+hOzP0HYY3I KkUvnZ/a7Wz5dpjqmUkbbrtEhUkUj55+7puzTvHs28uXnCFOo8bhexmnl9mwy/FT0kIs 6GXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ofHJwx+KMJzy8ycXcJAmRIJdSsP2Bop2R7qbfF/r0OM=; b=dB8FlvL71CMH5QLvx6obmXwSM/Bh9b+axtr46FNcilWBHsNl3eKW9IRskMHsJou3gs qj0muDg0hryThzXISGtXnXESeISFpw0uhqAwWFw0PbVIFdW+GECee8Ki2wOREaR1Gzuc Wimz+cOqziBo7mM9jUFrzdv4ffCqa5rGhT2Dwcj4/PwFXEvzWWESlGAb4ScEFmsOZWSx sOIXc2xO1vetzWjch4U4OKxZ9r+BwnwkckRFJ7NEyQ4fP9Ru5O9hxpeXcF7GgkRTN1uH RBcO1moeBQ2cnQIR2xEosb2sIJI0D3kU9uEsbrJykt6WRmLdCXR1dMgQxyFOP1yPgrrV ftOg== X-Gm-Message-State: AODbwcAvVHFpD9nwFb0SMk0X0ullbydd646K3R93B+cdgOl2CDKRV3oi Z3obA6Rf+OxH8Z5EUNE= X-Received: by 10.28.186.65 with SMTP id k62mr583906wmf.0.1495125496202; Thu, 18 May 2017 09:38:16 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 4sm7357655wrv.33.2017.05.18.09.38.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 09:38:15 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , Kevin Hilman Subject: [PATCH 10/10] clk: move CLK_SET_RATE_GATE protection from prepare to enable Date: Thu, 18 May 2017 18:38:04 +0200 Message-Id: <20170518163804.14123-11-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170518163804.14123-1-jbrunet@baylibre.com> References: <20170518163804.14123-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170518_093837_596652_FA083E6D X-CRM114-Status: GOOD ( 12.61 ) 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, 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 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 1db3ad28dd85..3e2eb21ca8cd 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; }