From patchwork Thu Sep 11 14:26:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 4888281 Return-Path: X-Original-To: patchwork-linux-arm@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 BF19CC0338 for ; Thu, 11 Sep 2014 14:29:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82CCB201EF for ; Thu, 11 Sep 2014 14:29:45 +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 DCD38200FE for ; Thu, 11 Sep 2014 14:29:40 +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 1XS5LY-0001Te-1M; Thu, 11 Sep 2014 14:27:40 +0000 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XS5L1-0000jb-MA for linux-arm-kernel@lists.infradead.org; Thu, 11 Sep 2014 14:27:08 +0000 Received: by mail-we0-f179.google.com with SMTP id u56so6079796wes.38 for ; Thu, 11 Sep 2014 07:26:45 -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=vUrTC5akUEOr0gZBoqxzUQEezG1sQ6hXoX8jVKBS8XdRVhoogNSEgb87hvX6J5vlFo Q5Kj7uveL4qfs4rKuyzVEcNQCprHn/uFlIbFcNUfd68VQqpZJeM/APKzpul1x9Ydd93S +JJeZQgholV9qyrhbPShgT2se9H4dnff0b+L/qTdxgCH+ZVbCy2RV9HP7TtX4inzGZ2t zhciLX7UjOXJ0NizA6u2BUTYwYs8ZLo3PERUCNRhcpYNNM6nPm0rGo73lcYFrTZ8Wdq+ J9FaQmZCen6bZw3N1Q7KIl3UO/kGtMj6Pt5cByXN195iH0edXFdfXbvp+5sl+CHWJEE7 DrSA== X-Received: by 10.180.103.40 with SMTP id ft8mr2815626wib.52.1410445604061; Thu, 11 Sep 2014 07:26:44 -0700 (PDT) Received: from localhost.localdomain (37-48-42-23.tmcz.cz. [37.48.42.23]) by mx.google.com with ESMTPSA id ka3sm1421242wjc.3.2014.09.11.07.26.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Sep 2014 07:26:43 -0700 (PDT) From: Tomeu Vizoso To: Mike Turquette Subject: [PATCH v11 6/9] clk: Warn of unbalanced clk_prepare() calls Date: Thu, 11 Sep 2014 16:26:20 +0200 Message-Id: <1410445583-18626-4-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410445583-18626-1-git-send-email-tomeu.vizoso@collabora.com> References: <1410445421-18362-1-git-send-email-tomeu.vizoso@collabora.com> <1410445583-18626-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140911_072707_882034_F1ADA03E X-CRM114-Status: GOOD ( 14.75 ) 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;