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: 9739473 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 D1D706034C for ; Sun, 21 May 2017 22:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3171285C9 for ; Sun, 21 May 2017 22:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7F19285F3; Sun, 21 May 2017 22:00: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=-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 452D8285C9 for ; Sun, 21 May 2017 22:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757006AbdEUWA0 (ORCPT ); Sun, 21 May 2017 18:00:26 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:34913 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756988AbdEUWAZ (ORCPT ); Sun, 21 May 2017 18:00:25 -0400 Received: by mail-wm0-f42.google.com with SMTP id b84so278410808wmh.0 for ; Sun, 21 May 2017 15:00:24 -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=QiMEf9RVWYM4PYAUCqzsZoBvDk1ecKMR+QoHmdjuAKvc2ptuHjIY6BYnKMRmiqpce4 JcHIRw11TTDcyoKqJDGPYxy3zA/fbAOHKD5nkZePRSIFQfcvfDlG0fOK510hcAeOPe/5 yIxEpZ2rrxMc6HqOWA/Bju5dN45dvG6Q3HVZoSZ3YW0XkrRERRjugiIqrfjOAkcJqnN/ 68QO2Y0LNJGH2wDqIcNlD10TCM00p484IQ3hEnzz5hCn61hdfZFvQ9RvjYYdFZKkeHJN 2/EfI7pvFpTkQ4gWqCHKxZ7wpGnOchS/fpF9E47vAdygym1ldW+MYydwWSKcmcw5+zPK tJFQ== X-Gm-Message-State: AODbwcCIB236vw79sRDTqwfAlUaHWc39PtRbUodxLV0Tc6+WyPsQUsWl /zQ/G/cUqCWvzg/b 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 Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-amlogic@lists.infradead.org, Linus Walleij , Boris Brezillon 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> 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 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)