From patchwork Mon Sep 1 15:34:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4821091 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 8888F9F314 for ; Mon, 1 Sep 2014 15:38:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47A7E200F0 for ; Mon, 1 Sep 2014 15:38:53 +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 976B2200E0 for ; Mon, 1 Sep 2014 15:38:47 +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 1XOTeF-0002Vp-EE; Mon, 01 Sep 2014 15:36:03 +0000 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOTdZ-00006U-6P for linux-arm-kernel@lists.infradead.org; Mon, 01 Sep 2014 15:35:22 +0000 Received: by mail-la0-f43.google.com with SMTP id ty20so6246021lab.2 for ; Mon, 01 Sep 2014 08:34:58 -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=0VrlbTy4ho/lrjSpkk7ZY26xFvaMKECMS8/Sg0zif5I=; b=nBa6dFPFrxiECEucZOBr9AeIVZjiDNgdXysHnKs4DOYV6Os2Uba9ROymPRj4aKI8K6 SF4bfNaxXO4dl21XPV0ruXBTRbiSmMXx67MsYJMc6veC8gX4O9ZDmAEZqb8kOByfOsg2 hpxgS5stemoxPitZUPVjeWCgosr/bkdLlMwaa2hMtTDFfV57MKtdYJQ2Ja83KrryyyMS RtHECiMbnM2oHcOkBQnUvDjTep4ugtvKdnYwFpSKvD97ZEkuTY9Jm/Valz9qzm7fxN0W vBMGE8etaTMDbyxTv8THKd2acIfkMk7aGHHsk50mfzScm8a4EAgPkU/Ng8LGKUTDfOVw 1eHQ== X-Received: by 10.112.28.8 with SMTP id x8mr3042986lbg.104.1409585698659; Mon, 01 Sep 2014 08:34:58 -0700 (PDT) Received: from cizrna.lan (37-48-46-170.tmcz.cz. [37.48.46.170]) by mx.google.com with ESMTPSA id p3sm765337lap.14.2014.09.01.08.34.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Sep 2014 08:34:57 -0700 (PDT) From: Tomeu Vizoso To: Mike Turquette Subject: [PATCH v8 7/7] clk: Warn of unbalanced clk_prepare() calls Date: Mon, 1 Sep 2014 17:34:35 +0200 Message-Id: <1409585675-26894-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409585675-26894-1-git-send-email-tomeu.vizoso@collabora.com> References: <1409585377-26091-1-git-send-email-tomeu.vizoso@collabora.com> <1409585675-26894-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140901_083521_465258_E11D8C10 X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -0.7 (/) Cc: Tomeu Vizoso , Stephen Warren , Tomasz Figa , linux-kernel@vger.kernel.org, Javier Martinez Canillas , rabin@rab.in, Thierry Reding , Peter De Schrijver , 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=-3.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 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 13ee3dd..a3d2372 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;