From patchwork Thu Sep 4 01:01:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 4841441 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 477EFC0338 for ; Thu, 4 Sep 2014 01:01:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 756D820221 for ; Thu, 4 Sep 2014 01:01:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 598C220170 for ; Thu, 4 Sep 2014 01:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933110AbaIDBBL (ORCPT ); Wed, 3 Sep 2014 21:01:11 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:39501 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933099AbaIDBBK (ORCPT ); Wed, 3 Sep 2014 21:01:10 -0400 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id DDD4513F8A8; Thu, 4 Sep 2014 01:01:09 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id D0A7E13F8AC; Thu, 4 Sep 2014 01:01:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from sboyd-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: sboyd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6E0A313F8A8; Thu, 4 Sep 2014 01:01:09 +0000 (UTC) From: Stephen Boyd To: Mike Turquette Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/4] clk: Recalc rate and accuracy in underscore functions if not caching Date: Wed, 3 Sep 2014 18:01:03 -0700 Message-Id: <1409792466-5092-2-git-send-email-sboyd@codeaurora.org> X-Mailer: git-send-email 2.1.0.rc2.4.g1a517f0 In-Reply-To: <1409792466-5092-1-git-send-email-sboyd@codeaurora.org> References: <1409792466-5092-1-git-send-email-sboyd@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When we move this code to use ww_mutex we'll need to call __clk_get_rate() and __clk_get_accuracy(), instead of their non-underscore counterparts, while holding the clock's prepare mutex. Move the recalculation of these values into the underscore functions so that we can call __clk_get_rate() and __clk_get_accuracy() while holding locks. Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b76fa69b44cb..1feaf708aa49 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -591,6 +591,8 @@ unsigned int __clk_get_prepare_count(struct clk *clk) return !clk ? 0 : clk->prepare_count; } +static void __clk_recalc_rates(struct clk *clk, unsigned long msg); + unsigned long __clk_get_rate(struct clk *clk) { unsigned long ret; @@ -600,6 +602,9 @@ unsigned long __clk_get_rate(struct clk *clk) goto out; } + if (clk->flags & CLK_GET_RATE_NOCACHE) + __clk_recalc_rates(clk, 0); + ret = clk->rate; if (clk->flags & CLK_IS_ROOT) @@ -613,11 +618,16 @@ out: } EXPORT_SYMBOL_GPL(__clk_get_rate); +static void __clk_recalc_accuracies(struct clk *clk); + unsigned long __clk_get_accuracy(struct clk *clk) { if (!clk) return 0; + if (clk->flags & CLK_GET_ACCURACY_NOCACHE) + __clk_recalc_accuracies(clk); + return clk->accuracy; } @@ -1083,9 +1093,6 @@ long clk_get_accuracy(struct clk *clk) unsigned long accuracy; clk_prepare_lock(); - if (clk && (clk->flags & CLK_GET_ACCURACY_NOCACHE)) - __clk_recalc_accuracies(clk); - accuracy = __clk_get_accuracy(clk); clk_prepare_unlock(); @@ -1151,10 +1158,6 @@ unsigned long clk_get_rate(struct clk *clk) unsigned long rate; clk_prepare_lock(); - - if (clk && (clk->flags & CLK_GET_RATE_NOCACHE)) - __clk_recalc_rates(clk, 0); - rate = __clk_get_rate(clk); clk_prepare_unlock();