From patchwork Thu May 18 16:38:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9734793 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 56754601C8 for ; Thu, 18 May 2017 16:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 458C128775 for ; Thu, 18 May 2017 16:38:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A75928812; Thu, 18 May 2017 16:38:21 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 2480E28833 for ; Thu, 18 May 2017 16:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932620AbdERQiS (ORCPT ); Thu, 18 May 2017 12:38:18 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37018 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932460AbdERQiQ (ORCPT ); Thu, 18 May 2017 12:38:16 -0400 Received: by mail-wm0-f49.google.com with SMTP id d127so58626177wmf.0 for ; Thu, 18 May 2017 09:38:16 -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=JNg2mLuvWQ6dV8tkHJSHrA+9zUJ0jbCWVJ18uOBII+I=; b=zfRpW44wJQddAPjxrvN4Ze0pUxbt2WkPqHiQaQmr9zSc7AbFJ+yP02U5a2BH0UsC8f nwAESdYZZuuJMwNCV/bIsyxLLChMcTlm5z4nStqQxIGyl3NwhXV5ZEBOUHAG6F0WdSOv ih3laLbCANoQUFNm5q2IXd/n7I7yrDnecZUt5Gy2ouT38e43yTa3uGvQMpk1LgmHSD8L vhmupXK2DKXj0shsENPaerNs8XbslSTB9O2e4kolrAD9TvHSr9jmOvJErnVPBRKG8C69 FVRvRviLl6KD3ZPAT5siVLX5CievIRjnc70uEighH1S99V3X5abIaaAnMuIxaug1ySkZ oJSQ== 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=JNg2mLuvWQ6dV8tkHJSHrA+9zUJ0jbCWVJ18uOBII+I=; b=KiXUVNMLZ0SJ8dSocqwjRi/ulYRZLEUvyyrPfdGkkr7J5ICdrStmEu2PCH8H20/Gmr zgcsc7iYoHGUOYgXKOtrdkctpk8CvQLdlTAhB2gaH5UNNXd4TjBx9ynhrS7vxnS2epkV hLjGWCT1uJHf2aoCAZV8+E9RWrN170BRc5M2JoDDbNxh2RtkmVI3MH2qBbvEQkVqdEA7 uy61imHZ1RgD7fj4Swzb0aMe90+y6H1/sJ21AcpeaXdTWZpG1Hm91Z4gZZXgQugMLbxq iPBV/MMhF5nLNp/l7e71r/cncja2oAUkwtqOPhQM8nI+ggoVDep+UciV4OJyzakWa+lR WIeg== X-Gm-Message-State: AODbwcAmWX9qODq0I1/wjaOJptngbVdn43UFDER+W1hA2uJSLTn2zU7Y jFh3N+qVNHrfw12o X-Received: by 10.28.10.6 with SMTP id 6mr14125167wmk.5.1495125495513; Thu, 18 May 2017 09:38:15 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 4sm7357655wrv.33.2017.05.18.09.38.14 (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 Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 09/10] clk: fix CLK_SET_RATE_GATE with clock rate protection Date: Thu, 18 May 2017 18:38:03 +0200 Message-Id: <20170518163804.14123-10-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> 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 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 5980080a86c0..1db3ad28dd85 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; } @@ -1710,9 +1721,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, rate); if (!top)