From patchwork Wed Apr 1 01:13:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 46607 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A13B216E5 for ; Wed, 1 Apr 2015 01:13:25 +0000 (UTC) Received: by lbfb1 with SMTP id b1sf7061802lbf.2 for ; Tue, 31 Mar 2015 18:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:content-type:mime-version :content-transfer-encoding:to:from:in-reply-to:cc:references :message-id:user-agent:subject:date:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Zpd/wk2u7y2e9HxBlQ+ltctgXsWpgHZnDN4Nqva1+VM=; b=fe5P68NHt812vzRvNejxSq3j6B9AjMnBsRMtOP6cllj2BFpP6c+Hsok3hPhzb3qzvU 6XFA5nOKCuOQIxpX+kh9YN/IPE9SA243PBeN5Gj2+ANIrv/vfhZDMLP1gqwmow2Vrqiu 3HfPA1hg9oGIW0beCHHGcrb+r4ej7SZ9uz820aYNSMJrn+0F82fCG100BB4JOjSP+IAM xOU8WZTFRLcr+nESh3/P/M6oDlk78Rp5SK8bsJD70KOeosSg3Dp302vI3HZBnoBNOTZF o6qy6p4UIQyLqI7VTol744JYxlx2+olhoLgX+pIedDNKjhfwEMjczxL6H3C3kXkIiZxO 3SiQ== X-Gm-Message-State: ALoCoQksLmor6yDwFDRxElPrGcuYzqI3LFS/yoaS6EmWe8YyRzoobF5pQyFVFiyKFkLzdwt2pcWw X-Received: by 10.112.167.131 with SMTP id zo3mr9083769lbb.7.1427850803932; Tue, 31 Mar 2015 18:13:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.163 with SMTP id r3ls8362laj.70.gmail; Tue, 31 Mar 2015 18:13:23 -0700 (PDT) X-Received: by 10.112.64.137 with SMTP id o9mr33191897lbs.15.1427850803319; Tue, 31 Mar 2015 18:13:23 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id kj12si232893lbb.98.2015.03.31.18.13.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 18:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labe2 with SMTP id e2so25562824lab.3 for ; Tue, 31 Mar 2015 18:13:22 -0700 (PDT) X-Received: by 10.152.36.169 with SMTP id r9mr10236582laj.29.1427850802793; Tue, 31 Mar 2015 18:13:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp334873lbq; Tue, 31 Mar 2015 18:13:21 -0700 (PDT) X-Received: by 10.70.125.129 with SMTP id mq1mr72759295pdb.70.1427850800628; Tue, 31 Mar 2015 18:13:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si458094pde.17.2015.03.31.18.13.19; Tue, 31 Mar 2015 18:13:20 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbbDABNR (ORCPT + 5 others); Tue, 31 Mar 2015 21:13:17 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:37956 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbbDABNQ convert rfc822-to-8bit (ORCPT ); Tue, 31 Mar 2015 21:13:16 -0400 Received: by igbqf9 with SMTP id qf9so33379495igb.1 for ; Tue, 31 Mar 2015 18:13:15 -0700 (PDT) X-Received: by 10.42.193.69 with SMTP id dt5mr39950886icb.42.1427850795233; Tue, 31 Mar 2015 18:13:15 -0700 (PDT) Received: from localhost (pool-71-119-96-202.lsanca.fios.verizon.net. [71.119.96.202]) by mx.google.com with ESMTPSA id m191sm244456ioe.23.2015.03.31.18.13.13 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 31 Mar 2015 18:13:14 -0700 (PDT) MIME-Version: 1.0 To: Lee Jones , "Maxime Coquelin" From: Michael Turquette In-Reply-To: <20150302081606.GC31325@x1> Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sboyd@codeaurora.org, kernel@stlinux.com, devicetree@vger.kernel.org References: <1425071674-16995-1-git-send-email-lee.jones@linaro.org> <1425071674-16995-4-git-send-email-lee.jones@linaro.org> <54F173B7.9030305@st.com> <20150302081606.GC31325@x1> Message-ID: <20150401011302.25195.55588@quantum> User-Agent: alot/0.3.5 Subject: Re: [STLinux Kernel] [PATCH 3/4] clk: Provide always-on clock support Date: Tue, 31 Mar 2015 18:13:02 -0700 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mturquette@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Quoting Lee Jones (2015-03-02 00:16:06) > On Sat, 28 Feb 2015, Maxime Coquelin wrote: > > > Hi Lee, > > > > On 02/27/2015 10:14 PM, Lee Jones wrote: > > >Lots of platforms contain clocks which if turned off would prove fatal. > > >The only way to recover from these catastrophic failures is to restart > > >the board(s). Now, when a clock is registered with the framework it is > > >compared against a list of provided always-on clock names which must be > > >kept ungated. If it matches, we enable the existing CLK_IGNORE_UNUSED > > >flag, which will prevent the common clk framework from attempting to > > >gate it during the clk_disable_unused() procedure. > > > > Please correct me if I'm wrong, but your patch does not fix the > > issue you had initially. > > Let's take an example: > > A clock is critical for the system, and should never be gated, so > > you add the CLK_IGNORE_UNUSED > > flag so that it is not disabled by clk_disable_unused() procedure. > > The same clock is also used by other IPs, for example spi 0 instance. > > When starting a spi transfer, clk_enable() is called on this clock, > > so its usecount becomes 1. > > Once transfer done, clk_disable() is called, usecount becomes 0 and > > the clock gets disabled: system freeze. > > You're right. I also need to extend clk_core_disable() to take notice > of CLK_IGNORE_UNUSED. Hi Lee, I'd like to combine elements of your V3 and this series (V4?). Firstly let's stay away from modifying the semantics around CLK_IGNORE_UNUSED. There was discussion around adding a new flag which I'd like to avoid if possible. If we're leaving clocks enabled then it would be best to reflect that reality with the prepare/enable refcounting in the core. The best way to do this is with clk_prepare_enable(my_alwon_clk). Drivers already do this today by hacking calls to clk_prepare_enable into their driver's probe function, and we can support it more explicitly in DT. Since we already have assigned-clock-rate and assigned-clock-parent in drivers/clk/clk-conf.c I propose that we add a third property here, assigned-clock-alwon. I don't really care about the name, so feel free to change it, so long as your suggestion is Measurably Better. This property can only be added to clock providers (not consumers), because if we have a clock consumer then that consumer should just call clk_prepare_enable. See the pseudo-code below: Amazing, I know. Is there any aspect of this approach which does not solve your use case? We should mark this new property (assigned-clk-alwon) as unstable since it can (and likely will) grow into more stuff in the future (e.g. Stephen Boyd mentioned a "hand-off" which tells the core to keep clocks enabled until the correct driver claims them). Regards, Mike --- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index 48a65b2..19dce89 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -115,6 +115,14 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) return 0; } +static int __set_clk_alwon(struct device_node *node, bool clk_supplier) +{ + if (!clk_supplier) + return -EINVAL; + + clk_prepare_enable(...); +} + /** * of_clk_set_defaults() - parse and set assigned clocks configuration * @node: device node to apply clock settings for @@ -138,6 +146,10 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier) if (rc < 0) return rc; - return __set_clk_rates(node, clk_supplier); + rc = __set_clk_rates(node, clk_supplier); + if (rc < 0) + return rc; + + return __set_clk_alwon(node, clk_supplier); } EXPORT_SYMBOL_GPL(of_clk_set_defaults);