From patchwork Tue Sep 9 14:06:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4869981 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C02F39F3EC for ; Tue, 9 Sep 2014 14:10:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97C5820166 for ; Tue, 9 Sep 2014 14:10:31 +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 E14F5200E5 for ; Tue, 9 Sep 2014 14:10:26 +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 1XRM5b-0006Po-OP; Tue, 09 Sep 2014 14:08:11 +0000 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRM5B-0005uJ-Pl for linux-arm-kernel@lists.infradead.org; Tue, 09 Sep 2014 14:07:46 +0000 Received: by mail-wg0-f42.google.com with SMTP id x12so4670646wgg.13 for ; Tue, 09 Sep 2014 07:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=tBpq90C5GZYE8labcIC7Xs13D3Rm+GicMesq0tpA4F0=; b=ZZ+0DGNbeGPjxd/tXp5RSWh0zTVIHEVCXi4eQh7onG8ME94LoqWJfkXB9OC/h+6Qvm 0SYBDkwnRgCUvjyr65xsoHYwSogMvFrKOirZimln1VLN2lz0qwKKMMbBWPimvOdyHqLQ poB57rh0zXoJRm93jEQQmPuxWoRLiW9W2Xz1Sagaf1XNV65zQHHYKL2ZsASioyurIy++ zJ0CLp9kkCwJEesokJVx8HYlLKUODUYdfgt3Bit22dQ+snbNUipkK2ywLxtnj//YCQOR z5M7cqssLE2vy1B6KiBCBLM2sFAD7L9WjwblZX1tclg7Jiz4I6Hvmd+PU/sP2Yi60qcd U/XQ== X-Received: by 10.180.9.41 with SMTP id w9mr29750458wia.62.1410271643285; Tue, 09 Sep 2014 07:07:23 -0700 (PDT) Received: from cizrna.lan (37-48-42-146.tmcz.cz. [37.48.42.146]) by mx.google.com with ESMTPSA id bt9sm15019977wjc.44.2014.09.09.07.07.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Sep 2014 07:07:22 -0700 (PDT) From: Tomeu Vizoso To: Mike Turquette Subject: [PATCH v10 6/9] clk: Warn of unbalanced clk_prepare() calls Date: Tue, 9 Sep 2014 16:06:49 +0200 Message-Id: <1410271612-27389-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410271612-27389-1-git-send-email-tomeu.vizoso@collabora.com> References: <1410271329-26637-1-git-send-email-tomeu.vizoso@collabora.com> <1410271612-27389-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140909_070746_018345_A94B921E X-CRM114-Status: GOOD ( 14.68 ) X-Spam-Score: -0.7 (/) Cc: Tomeu Vizoso , Stephen Warren , Peter De Schrijver , linux-kernel@vger.kernel.org, tomasz.figa@gmail.com, rabin@rab.in, Thierry Reding , Javier Martinez Canillas , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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_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 The warning will display the clock user that is trying to unprepare the clock, and the location of the last unprepare call. Signed-off-by: Tomeu Vizoso --- v8: * Patch added --- drivers/clk/clk.c | 22 ++++++++++++++++++++-- include/linux/clk-private.h | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 3a961c6..3018f37 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -834,7 +834,17 @@ void clk_unprepare(struct clk *clk_user) if (IS_ERR_OR_NULL(clk_user)) return; - clk_provider_unprepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + if (!WARN(clk_user->prepare_count == 0, + "incorrect unprepare clk dev %s con %s last caller of unprepare %pF\n", + clk_user->dev_id, clk_user->con_id, clk_user->last_unprepare)) { + + clk_user->last_unprepare = __builtin_return_address(0); + clk_user->prepare_count--; + + __clk_unprepare(clk_to_clk_core(clk_user)); + } + clk_prepare_unlock(); } EXPORT_SYMBOL_GPL(clk_unprepare); @@ -890,10 +900,18 @@ EXPORT_SYMBOL_GPL(clk_provider_prepare); */ int clk_prepare(struct clk *clk_user) { + int ret; + if (!clk_user) return 0; - return clk_provider_prepare(clk_to_clk_core(clk_user)); + clk_prepare_lock(); + ret = __clk_prepare(clk_to_clk_core(clk_user)); + if (!ret) + clk_user->prepare_count++; + clk_prepare_unlock(); + + return ret; } EXPORT_SYMBOL_GPL(clk_prepare); diff --git a/include/linux/clk-private.h b/include/linux/clk-private.h index 8126046..cf93bde 100644 --- a/include/linux/clk-private.h +++ b/include/linux/clk-private.h @@ -64,6 +64,9 @@ struct clk { unsigned int enable_count; void *last_disable; + unsigned int prepare_count; + void *last_unprepare; + unsigned long floor_constraint; unsigned long ceiling_constraint; struct hlist_node child_node;