From patchwork Wed Sep 3 15:33:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4835401 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 3EFFC9F38D for ; Wed, 3 Sep 2014 15:41:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4AC820148 for ; Wed, 3 Sep 2014 15:41:06 +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 4E2EF2021A for ; Wed, 3 Sep 2014 15:41:05 +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 1XPCaH-0004bR-FY; Wed, 03 Sep 2014 15:34:57 +0000 Received: from mail-wg0-x22b.google.com ([2a00:1450:400c:c00::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPCZv-0004H7-SC for linux-arm-kernel@lists.infradead.org; Wed, 03 Sep 2014 15:34:37 +0000 Received: by mail-wg0-f43.google.com with SMTP id a1so8578467wgh.2 for ; Wed, 03 Sep 2014 08:34:12 -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=MWv5Ybx2DT1jua+efSfIRV1k4VWhLOJ0LeTAmE/ia9V4Smc35bd9fMqsdW8u5NYP0U w5Hyr2DzddQ7RpQgrGHeDsc0EdV5jWRRej0GBcBF892QthHM0UaXqikwKku1xQC44sGy nXpvrtsBIGeI5iijHszDhmPnyXRWCMpAZoxhJmYsXarS4x/PMfnGHv9wbODlriZnVwXq TdNznrIFci3ewTW9POsLKtesaIBbSgPLsc4oiAmCj4/LpO6u3OCRVbMXRN4f0qFpqns+ n9U0PY4/hCBNYuxDW/5Jze9Y7x6Xpt454SHPSwTY7nrbYh87OCHZak2tZ/SlJYSi8e9o JiKQ== X-Received: by 10.194.118.201 with SMTP id ko9mr46182195wjb.26.1409758452652; Wed, 03 Sep 2014 08:34:12 -0700 (PDT) Received: from cizrna.lan (37-48-33-23.tmcz.cz. [37.48.33.23]) by mx.google.com with ESMTPSA id xm4sm5379572wib.9.2014.09.03.08.34.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Sep 2014 08:34:11 -0700 (PDT) From: Tomeu Vizoso To: Mike Turquette Subject: [PATCH v9 6/6] clk: Warn of unbalanced clk_prepare() calls Date: Wed, 3 Sep 2014 17:33:54 +0200 Message-Id: <1409758434-20810-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1409758434-20810-1-git-send-email-tomeu.vizoso@collabora.com> References: <1409758148-20104-1-git-send-email-tomeu.vizoso@collabora.com> <1409758434-20810-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140903_083436_057542_A151BB03 X-CRM114-Status: GOOD ( 14.38 ) 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=-3.5 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;