From patchwork Fri Dec 1 21:51: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: 120395 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1679278qgn; Fri, 1 Dec 2017 13:53:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ8XMeW9QVLY7IUUTBgJiTNS4ayRWN+rjfZLj58oe1g+6fxQnHzm/rG0hoCyLQU91NnuYPO X-Received: by 10.84.244.75 with SMTP id e11mr7438499plt.18.1512165214407; Fri, 01 Dec 2017 13:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512165214; cv=none; d=google.com; s=arc-20160816; b=w0V+q/v0L5FrkR6d6udjpkzYPddPJkq7zHK7mfxhqXHnR5kdUIyfxe8L/60Af8GH97 SGI4X/DFKMv4sQEPvV68Zx5Vbr3virW/VrRCckk7Aalyc7O3gbwATJ6W6/vYr1AAe8ne 8QCFgllg7POoKTg1uEdp/I6iGzWDF3CSo9uHvgwpL5iZJVf5LUk6CBhzNrJx82PY2gcv HFp4IWsH6eljgzEAqSUlnK6tyg9bUC22nCdgYaWt7Us1M9AgOvgyKJvO4xOUGt6ZeZ7J CuH+Y3ov3i7H7wJIThsCbAbsCI8dbBGDyZU8fPhR3qIJa7SsXUNoMPV/J4zVLXMD41qv aJ2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=KJR4qwAneXORHY/UbNAQJF03pza6vZBlFhsS1f5LygI=; b=FGYOhoa1I0hHjXCy0cs1hAG39SXmlDjy3KJEqPLp+a7KNXLt5E2k/OboAjOFsTucpp tSZRjoBeboW62b1FgJ2+il3r5+O2dJ4w7X0Z0sicKiO2Zg05DXC5bredjs+FHRWEw1Hc fn/K5AnlGeXGYrol8gM/3xc9kljsmdbmOfQPvxSgt+BcvW1QL8WqR/INup/pngriVP5B MOIsQEAVumeZwvKnGWkaUM+9hwWeScb0GDJCpBneOeB+qbjN8vPLaUEJ3ls1IRWkzOag AZM2BP8fQvYbmbqFNyRmheAIosfGKbfQ9Kg1DdjIXWVFWsLeEe9pHYwSCQd0v4pQtt83 l8BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=eJTLRaiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si5545160plb.713.2017.12.01.13.53.34; Fri, 01 Dec 2017 13:53:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=eJTLRaiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbdLAVxG (ORCPT + 28 others); Fri, 1 Dec 2017 16:53:06 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36955 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751711AbdLAVwS (ORCPT ); Fri, 1 Dec 2017 16:52:18 -0500 Received: by mail-wm0-f66.google.com with SMTP id f140so5636116wmd.2 for ; Fri, 01 Dec 2017 13:52:18 -0800 (PST) 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=KJR4qwAneXORHY/UbNAQJF03pza6vZBlFhsS1f5LygI=; b=eJTLRaiB1Fe6gk3CiyB7x/jOCEGG9nrq137BHPeFOaohKYtMSYya5hqMMtuqwLa3K5 K/Khj+VnjHhgfT/3vKf1FHeIeRkr6K5lc1oTIe2jsWumxkvlXSteRyxtmbs7Ba11Ct2S VVsGq+B80nu7aYrB/obcicQuWxH5whD80GDYxvmhZFvAUD4BI08MIOnBIJwYtBmIU/jj SqcaezN7ascGD/8Kf31hyMmjq7sOje8GG2OJ1MIUVjAhrfLq2qfTBMMJ/FrGKx3TyGPn FOOfeK84p/aPw6j6orX3mSMgA9GKSSMuw25VaWOaNpYhu7r1wbE8/ccytun1mk0OIvcm SLUQ== 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=KJR4qwAneXORHY/UbNAQJF03pza6vZBlFhsS1f5LygI=; b=j1u2xzyrdzoUob8p47hPb2PvDGcjIW/rdfM604qmtSJ6UPHFYLa4+RnqSr87LzT8MI 2ZNVmgr6XUep1Z2VFxyar7TUh6c19PvMq+mYCc7gOeh40BoOXwPAIwImzY9jzlD2VNBA 3os5WlZY9i5frPF34WqkrMMkyYuF//vcLbB5ksNUREHWypNR/6CtOyAnSUNy2mukgysV LFZx3KldTB5g3yKYeIellxpadsYAU/w5fb++CudVX5hMfI2nfqj+zVxZYNLjKgJ2q7R0 DGjG7Q7IW39CmFBzIwzOQfl/BzgtzFRGr45kH6yYZ+BEJEaEzdQc4xEBq+wRRGrX4vCC sCWQ== X-Gm-Message-State: AKGB3mINySQXgL+pr0VN0u2BhuxgI8cPOALK+PxXci8MzPs6L2ryanw6 iBAWyMkeP412gxywjXa1qQ+MjC2m X-Received: by 10.28.69.197 with SMTP id l66mr2232973wmi.67.1512165137768; Fri, 01 Dec 2017 13:52:17 -0800 (PST) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id m134sm2078804wmg.6.2017.12.01.13.52.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Dec 2017 13:52:17 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Russell King , Linus Walleij , Quentin Schulz , Kevin Hilman , Maxime Ripard Subject: [PATCH v5 08/10] clk: fix CLK_SET_RATE_GATE with clock rate protection Date: Fri, 1 Dec 2017 22:51:58 +0100 Message-Id: <20171201215200.23523-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171201215200.23523-1-jbrunet@baylibre.com> References: <20171201215200.23523-1-jbrunet@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using clock rate protection, we can now enforce CLK_SET_RATE_GATE along the clock tree Acked-by: Linus Walleij Tested-by: Quentin Schulz Tested-by: Maxime Ripard Acked-by: Michael Turquette Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -- 2.14.3 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f6fe5e5595ca..1af843ae20ff 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -605,6 +605,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; @@ -679,6 +682,16 @@ 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 claiming exclusive rate control, it is + * actually the provider which prevents any consumer from making any + * operation which could result in a rate change or rate glitch while + * the clock is prepared. + */ + if (core->flags & CLK_SET_RATE_GATE) + clk_core_rate_protect(core); + return 0; unprepare: clk_core_unprepare(core->parent); @@ -1780,9 +1793,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)