From patchwork Fri Nov 7 18:51:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 5255001 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 873C49F387 for ; Fri, 7 Nov 2014 18:52:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B1336200DF for ; Fri, 7 Nov 2014 18:52:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9A82200DC for ; Fri, 7 Nov 2014 18:52:24 +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 1Xmoe0-0006w1-BV; Fri, 07 Nov 2014 18:52:24 +0000 Received: from mail-ie0-x22e.google.com ([2607:f8b0:4001:c03::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xmodx-0006s4-T0 for linux-rockchip@lists.infradead.org; Fri, 07 Nov 2014 18:52:23 +0000 Received: by mail-ie0-f174.google.com with SMTP id x19so5612707ier.5 for ; Fri, 07 Nov 2014 10:52:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=6mv57j7qM6KMn+CpUK44EKfSbm+625vmyhQG2X0VWYo=; b=RiYYwc5DYVkkR05W+TOjTUG/NGhpTgNZ423uggalrBnzJti8jKhhacDMERqT7G9I7I Qe00nO4L7qtjbt06Ajst8uvE6y5UyMgOMxumhAm0vJzP/M7F3PbEefuxEfbRwnGcm7yv n2z5Uv9W62d7Ysp8WfzIQ7YXlsdk5AllLMPiM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6mv57j7qM6KMn+CpUK44EKfSbm+625vmyhQG2X0VWYo=; b=B3aWWKsaHaPEq27wdhqvZERiOasbk25fRS4Z0eOnOKJJ0wWi5HrOHAWsIaIySC/bkm lnBouMy86z5g9GfATYr7rWt6KlehCmCoBydELiBcrm7BCfoQHhsZU4MrjAoe6/2H79Pd PM41TbFapmnaeMyH5WQKOKZZsKqjvQFKvke6j6LMN1v9qsoKHi0XQc/nd7EsKRRhkTGq 3CClyV1r5eKJL7VRLMBwFM8X0IR0/csLTWwEECOUHuAlWSJJYSRuKZcShh4GjLQ4ixiU bdLefdH8Wts0ctZVoPslMvjmwrcVAwa9LO19mMxUFBgcMPQO9yENqfHfTFWrpDnDpFz/ Dnxw== X-Gm-Message-State: ALoCoQkG9Lz0quVHLSySyq06Mxsltb88DechcSwtlrXGa9DX8FAlS81vvY6ha7wgiH8JGhKk1fgH X-Received: by 10.107.135.37 with SMTP id j37mr15025283iod.56.1415386319821; Fri, 07 Nov 2014 10:51:59 -0800 (PST) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by mx.google.com with ESMTPSA id xb4sm1015810igc.11.2014.11.07.10.51.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Nov 2014 10:51:58 -0800 (PST) From: Doug Anderson To: Mike Turquette Subject: [PATCH] clk: Propagate prepare and enable when reparenting orphans Date: Fri, 7 Nov 2014 10:51:52 -0800 Message-Id: <1415386312-23741-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141107_105222_115059_D143419E X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.8 (/) Cc: Heiko Stuebner , Dmitry Torokhov , linux-kernel@vger.kernel.org, Doug Anderson , linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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 With the existing code, if you find a parent for an orhpan that has already been prepared / enabled, you won't enable the parent. That can cause later problems since the clock tree isn't in a consistent state. Fix by propagating the prepare and enable. NOTE: this does bring up the question about whether the enable of the orphan actually made sense. If the orphan's parent wasn't enabled by default (by the bootloader or the default state of the hardware) then the original enable of the orphan probably didn't do what the caller though it would. Some users of the orphan might have preferred an EPROBE_DEFER be returned until we had a full path to a root clock. This patch doesn't address those concerns and really just syncs up the state. Tested on rk3288-evb-rk808 by temporarily considering "sclk_tsadc" as a critical clock (to simulate a driver enabling it at bootup). Before: clock enable_cnt prepare_cnt rate accuracy phase ---------------------------------------------------------------------------------------- xin32k 0 0 32768 0 0 sclk_hdmi_cec 0 0 32768 0 0 sclk_otg_adp 0 0 32768 0 0 sclk_tsadc 1 1 993 0 0 After: clock enable_cnt prepare_cnt rate accuracy phase ---------------------------------------------------------------------------------------- xin32k 1 1 32768 0 0 sclk_hdmi_cec 0 0 32768 0 0 sclk_otg_adp 0 0 32768 0 0 sclk_tsadc 1 1 993 0 0 Note that xin32k on rk808 is a clock that cannot be disabled in hardware (it's an always on clock), so really all we needed to do was to sync up the state. Signed-off-by: Doug Anderson --- drivers/clk/clk.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 4896ae9..a3d3d58 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1650,6 +1650,17 @@ void __clk_reparent(struct clk *clk, struct clk *new_parent) clk_reparent(clk, new_parent); __clk_recalc_accuracies(clk); __clk_recalc_rates(clk, POST_RATE_CHANGE); + + if (clk->prepare_count) { + unsigned long flags; + + __clk_prepare(new_parent); + + flags = clk_enable_lock(); + if (clk->enable_count) + __clk_enable(new_parent); + clk_enable_unlock(flags); + } } /**