From patchwork Mon May 2 16:36:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 8993761 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: X-Original-To: patchwork-linux-clk@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3BAEABF440 for ; Mon, 2 May 2016 16:36:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 616E92024C for ; Mon, 2 May 2016 16:36:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 704A120219 for ; Mon, 2 May 2016 16:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754445AbcEBQgl (ORCPT ); Mon, 2 May 2016 12:36:41 -0400 Received: from gloria.sntech.de ([95.129.55.99]:58548 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754407AbcEBQge (ORCPT ); Mon, 2 May 2016 12:36:34 -0400 Received: from ip9234b8f8.dynamic.kabel-deutschland.de ([146.52.184.248] helo=diego.sntech) by gloria.sntech.de with esmtpsa (TLS1.1:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1axGpf-0000Hp-MS; Mon, 02 May 2016 18:36:27 +0200 From: Heiko Stuebner To: mturquette@baylibre.com, sboyd@codeaurora.org Cc: linux-clk@vger.kernel.org, linux-rockchip@lists.infradead.org, zhengxing@rock-chips.com, zhangqing@rock-chips.com, tomeu.vizoso@collabora.com, Heiko Stuebner Subject: [RFC PATCH 2/3] clk: adjust clocks to their requested rate after parent changes Date: Mon, 2 May 2016 18:36:21 +0200 Message-Id: <1462206982-10444-3-git-send-email-heiko@sntech.de> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1462206982-10444-1-git-send-email-heiko@sntech.de> References: <1462206982-10444-1-git-send-email-heiko@sntech.de> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Given a hirarchy of clk1 -> [div] -> clk2, when the rate of clk1 gets changed, clk2 changes as well as the divider stays the same. There may be cases where a user of clk2 needs it at a specific rate, so clk2 needs to be readjusted for the changed rate of clk1. So if a rate was requested for the clock, and its rate changed during the underlying rate-change, with this change the clock framework now tries to readjust the rate back to/near the requested one. The whole process is protected by a new clock-flag to not force this behaviour change onto every clock defined in the ccf. Signed-off-by: Heiko Stuebner --- drivers/clk/clk.c | 13 +++++++++++-- include/linux/clk-provider.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 65e0aad..22be369 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1410,6 +1410,9 @@ static struct clk_core *clk_propagate_rate_change(struct clk_core *core, return fail_clk; } +static int clk_core_set_rate_nolock(struct clk_core *core, + unsigned long req_rate); + /* * walk down a subtree and set the new rates notifying the rate * change on the way @@ -1494,6 +1497,12 @@ static void clk_change_rate(struct clk_core *core) /* handle the new child who might not be in core->children yet */ if (core->new_child) clk_change_rate(core->new_child); + + /* handle a changed clock that needs to readjust its rate */ + if (core->flags & CLK_KEEP_REQ_RATE && core->req_rate + && core->new_rate != old_rate + && core->new_rate != core->req_rate) + clk_core_set_rate_nolock(core, core->req_rate); } static int clk_core_set_rate_nolock(struct clk_core *core, @@ -1529,11 +1538,11 @@ static int clk_core_set_rate_nolock(struct clk_core *core, return -EBUSY; } + core->req_rate = req_rate; + /* change the rates */ clk_change_rate(top); - core->req_rate = req_rate; - return ret; } diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 0c72204..06f189e 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -33,6 +33,7 @@ #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 */ +#define CLK_KEEP_REQ_RATE BIT(12) /* keep reqrate on parent rate change */ struct clk; struct clk_hw;