From patchwork Mon Jun 12 19:44:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9782687 X-Patchwork-Delegate: sboyd@codeaurora.org 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 6815D6038F for ; Mon, 12 Jun 2017 19:45:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 594AA284EE for ; Mon, 12 Jun 2017 19:45:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E02C286C8; Mon, 12 Jun 2017 19:45:03 +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 02000284EE for ; Mon, 12 Jun 2017 19:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752583AbdFLTpC (ORCPT ); Mon, 12 Jun 2017 15:45:02 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:34436 "EHLO mail-wr0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752534AbdFLTpB (ORCPT ); Mon, 12 Jun 2017 15:45:01 -0400 Received: by mail-wr0-f177.google.com with SMTP id g76so108163101wrd.1 for ; Mon, 12 Jun 2017 12:45:01 -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=NoQ5HLRrgYcjpvyutNz7OtlNMhx2bUQmaQUnS9n/Tzs=; b=Z+iBU5mZkG9RUwGIo7JLlK3l+vv+WBqvT9SZbw8SeUcuxZQmGdLrtg6tyEC7EUNShD F3OkwEfWPgKr9OGd3J8Lbxm/A5F13zSnDTpQBhxyGTyXwObBoucwy6QeOJiEMicFwIRD rLCnjKl6o8kXkX6Yo68zewW07pIWun9BQ0qDHDQBIT8pbEKlgKUNXZE6PmXcNcegsNkx NdjWGqgE6jLKBcASSuoJqPUKFWy8IVfkILATcCqaRDcXWcFQmyLECz6Ql1dxOolMTFjm WQuo5r3/RaXk7fcp5/QIZCWja7BhaHi+GvX/ox2Ccwa8aZdRCjFReHNxXxlZBYlFqplc PVLg== 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=NoQ5HLRrgYcjpvyutNz7OtlNMhx2bUQmaQUnS9n/Tzs=; b=CBfS+cwE+eGXGFPbz2QAa8M4r/029aXHdAVQG7uHIkyZDBKH+br8R4JR+ZF0ZcG206 UU5K0K6AYYLTlYY0uV21gTVFijaRS60JgAyjQkuPgIoe+yzXGOVdHmOvYIOJi2jKomq8 ipVgSK2sWS/5t0c8LwuNaFXrj3b5UgNE6wEzNRBywmfOo7cwg/f/ZYPLbWjYLUyiSDNw qqrtDEHd4oG6eRa3HluvlvUzqW8fr/QQS/6mchAg3HDgynd9QeIurVyAhZZUB1svVfQm 2yEEJBe0UhEb4ETHPGcS/pdCkc0sE38PjbnQq8m9NuT4QuuOM6HNXw7FdelJqhwxmRnK rKtw== X-Gm-Message-State: AKS2vOwVWiWzXKMOnk4E7YVxRX12GYrc6Kh4c7AI0UEP/pkDHR4Vr7re tg03dwPEH96HH/UF X-Received: by 10.28.109.220 with SMTP id b89mr331751wmi.97.1497296699834; Mon, 12 Jun 2017 12:44:59 -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 70sm13250797wmu.28.2017.06.12.12.44.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 12:44:59 -0700 (PDT) From: Jerome Brunet To: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org Cc: Jerome Brunet , Kevin Hilman , linux-amlogic@lists.infradead.org, Russell King , Linus Walleij , Boris Brezillon Subject: [PATCH v3 10/10] clk: fix CLK_SET_RATE_GATE with clock rate protection Date: Mon, 12 Jun 2017 21:44:38 +0200 Message-Id: <20170612194438.12298-11-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170612194438.12298-1-jbrunet@baylibre.com> References: <20170612194438.12298-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 5d545954c48f..971f39d4e879 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -587,6 +587,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; @@ -657,6 +660,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)