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: 9782709 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 628E36038F for ; Mon, 12 Jun 2017 19:45:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5405927F86 for ; Mon, 12 Jun 2017 19:45:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48F3127FB6; Mon, 12 Jun 2017 19:45:33 +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=ham 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 0511B284F1 for ; Mon, 12 Jun 2017 19:45:33 +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=oOP5Fi1FZ4xfksBD9intTaD8m8iFXctvPqxZ23XmX/o=; b=i/GDwF7XMblpsvDExUoVCtM/rx TYFZzIf8TnZew5K96QIzILFkrHFacoiZNCRwBCJs8yGJ4ONQfiGurP4mNBJnmGcL/Djd5pp3DiNkB XoeCtPdwiDCrOVoRoF7SO61dvlvSVgVY2eMMYlTf1b2ECuwGcf6v1JSC06nneeitk0zGBlyOjunfH 5/0W14ylVDYWoIb/sl9QZYyDO9zKTCiqhZ0Reys0Cvj5P9H5frvx+3SY21qCsthPP1saXbsydJwFS cSJz5JbryZ2IDIIPRBysGax6h0KbQ8jXGbLgPRmWr4WK6m73/JHDMcT/G9z+o/mFqhPkScKPLXVkN 7Dxuz48Q==; 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 1dKVHC-0004wu-Ho; Mon, 12 Jun 2017 19:45:26 +0000 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dKVH7-0003Rd-3h for linux-amlogic@lists.infradead.org; Mon, 12 Jun 2017 19:45:23 +0000 Received: by mail-wr0-x236.google.com with SMTP id v104so108345083wrb.0 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=LSS4XiR+UzSqzUnLmu8oiF89hE+vEdT49/HRInRGV2dZ/bAjrZGA8+/PNglxzUyPQK x8dYe5WUyaAZaoOztiJfPGukOttOiOY0cAcTatx0FlO/s1wAEfN7s00ZjFZk9d87TyaY qHFivgVcN9oC7EczrNad2cM1p8RvGKkhHETmUVcwTuiSDK3s0uone8jfZBWnMkZdBjZ8 NJkJpqW7xGVPZSey3Dbex9SXy1izM/9QIQuStUqajL+28Ep6zYI5Nr18RyGjndPZ5pf8 ROu5vHSu7UjQGnBI8M518bHiCWV1dbgLNljL4Ja2F1EemI01wPcSoHG3l92vzGSb0oEX droA== X-Gm-Message-State: AKS2vOwW/bAQgr3vMs/UDlEWsWfeUYPHOO+PspntEvp/+v9FvUDs/E6k JIJZ+NyeUwxHaRpk 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170612_124521_391183_CF20B83D X-CRM114-Status: GOOD ( 10.73 ) 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: Boris Brezillon , Kevin Hilman , Linus Walleij , Russell King , linux-amlogic@lists.infradead.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 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)