From patchwork Thu Feb 11 00:41:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 8275841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B6B79F3CD for ; Thu, 11 Feb 2016 00:43:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32EAC201EF for ; Thu, 11 Feb 2016 00:43:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4246220154 for ; Thu, 11 Feb 2016 00:43:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTfKR-0004oM-I9; Thu, 11 Feb 2016 00:41:51 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTfKN-0004fl-IO for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 00:41:49 +0000 Received: by mail-pf0-x234.google.com with SMTP id q63so20437442pfb.0 for ; Wed, 10 Feb 2016 16:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=content-type:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=lpBnzOGyjZ1zLR9WLlfq5PnZVpclcpxGYPcnA8/Gaco=; b=aScbs6BoGxyy0WRFkFT5qNmKKk94CjJYk6dwuWpqv720Ay3QMKv64bVeY3t6VTG88s he/1JRMPHNtAQbq/x+9r2kCiccNojra8lGk5Hm9lak3t1xOu2l4xcWcMlTPTZmFjKlV1 bnzB1W8l5AohTNdcJJNMWDhyiJ1RfKGaeEDDNRwnI7XyzzhfqOMth7R6Tl3BQJyBBd/0 YWRTsX8U+l0mPTD6Nh3sVFysRpSwYZ773Y8joG9kDlqTFQ4LsCY25ikTq8o/8KtFxcTy fuocL4vEeRKMhhqCHrkxuvPsLoPqhUqQVKPJk5FAYzVn0d1ZxTC6efZZ4PI1FWPD/S0E PS+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version :content-transfer-encoding:to:from:in-reply-to:cc:references :message-id:user-agent:subject:date; bh=lpBnzOGyjZ1zLR9WLlfq5PnZVpclcpxGYPcnA8/Gaco=; b=Pb8V7ZxmFNjKe0fEhtcDZVqlYfE/AugmkFzmpI1lEC1hCylPgP0zGoi/ansE6iev74 945QlafT3CKf7XPH4cj3w7ZCbtg/rNOGCGcIBWNol+IZT2PIKWnWJAvuHQhsrNC/8w+K CXbw3uMZABB8L1HS5ci6ZaCwp78mwm+dwte4ylO5CMyhcAX4AgtpDrnyYArJSA26SFsM lEm/bWDWCQjloDovNVyIL6QrzHX5o9agk3s+Ej16LjXQxdHlzXFITYJ+FQXZ+4L9yhHN EnEkcZc4Ho6Qebo64gMaJgduj8SamFiSwCNV/jCsth8eKNn2/pOty7f/MgaZUENzPFX5 lkig== X-Gm-Message-State: AG10YOQkLzB7N+qtLII6gLPoIFQofz/x9/p//52FnQhHgOiAK/r4whWS61OBiUg3C/O+U6qv X-Received: by 10.98.8.200 with SMTP id 69mr63589157pfi.39.1455151286859; Wed, 10 Feb 2016 16:41:26 -0800 (PST) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id mk3sm7765540pab.20.2016.02.10.16.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Feb 2016 16:41:25 -0800 (PST) MIME-Version: 1.0 To: Lee Jones , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org From: Michael Turquette In-Reply-To: <1453127331-20616-2-git-send-email-lee.jones@linaro.org> References: <1453127331-20616-1-git-send-email-lee.jones@linaro.org> <1453127331-20616-2-git-send-email-lee.jones@linaro.org> Message-ID: <20160211004124.26445.47437@quark.deferred.io> User-Agent: alot/0.3.6 Subject: Re: [PATCH 1/3] clk: Allow clocks to be marked as CRITICAL Date: Wed, 10 Feb 2016 16:41:24 -0800 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160210_164147_678945_F543DEED X-CRM114-Status: GOOD ( 18.99 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@stlinux.com, s.hauer@pengutronix.de, sboyd@codeaurora.org, geert@linux-m68k.org, maxime.ripard@free-electrons.com, Lee Jones , maxime.coquelin@st.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Quoting Lee Jones (2016-01-18 06:28:49) > Critical clocks are those which must not be gated, else undefined > or catastrophic failure would occur. Here we have chosen to > ensure the prepare/enable counts are correctly incremented, so as > not to confuse users with enabled clocks with no visible users. > > Signed-off-by: Lee Jones > --- > drivers/clk/clk.c | 7 ++++++- > include/linux/clk-provider.h | 1 + > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c > index f13c3f4..835cb85 100644 > --- a/drivers/clk/clk.c > +++ b/drivers/clk/clk.c > @@ -2576,8 +2576,13 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) > } > > ret = __clk_init(dev, hw->clk); > - if (!ret) > + if (!ret) { > + if (core->flags & CLK_IS_CRITICAL) { > + clk_core_prepare(core); > + clk_core_enable(core); > + } > return hw->clk; > + } I moved the above code into __clk_init where we do similar sort of clk init-y type things. Modified patch below. Best regards, Mike From 83b4f533b581a386341cd0cf9dbce92286e41e75 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 18 Jan 2016 14:28:49 +0000 Subject: [PATCH 1/6] clk: Allow clocks to be marked as CRITICAL Critical clocks are those which must not be gated, else undefined or catastrophic failure would occur. Here we have chosen to ensure the prepare/enable counts are correctly incremented, so as not to confuse users with enabled clocks with no visible users. Signed-off-by: Lee Jones Signed-off-by: Michael Turquette --- drivers/clk/clk.c | 5 +++++ include/linux/clk-provider.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b4db67a..993f775 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2484,6 +2484,11 @@ static int __clk_init(struct device *dev, struct clk *clk_user) if (core->ops->init) core->ops->init(core->hw); + if (core->flags & CLK_IS_CRITICAL) { + clk_core_prepare(core); + clk_core_enable(core); + } + kref_init(&core->ref); out: clk_prepare_unlock(); diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 1143e38..1d986ea 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -32,6 +32,7 @@ #define CLK_GET_ACCURACY_NOCACHE BIT(8) /* do not use the cached clk accuracy */ #define CLK_RECALC_NEW_RATES BIT(9) /* recalc rates after notifications */ #define CLK_SET_RATE_UNGATE BIT(10) /* clock needs to run to set rate */ +#define CLK_IS_CRITICAL BIT(11) /* do not gate, ever */ struct clk; struct clk_hw;