From patchwork Fri Dec 7 20:26:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunter, Jon" X-Patchwork-Id: 1851601 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A48F1400ED for ; Fri, 7 Dec 2012 20:26:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424173Ab2LGU0m (ORCPT ); Fri, 7 Dec 2012 15:26:42 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:49857 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753047Ab2LGU0m (ORCPT ); Fri, 7 Dec 2012 15:26:42 -0500 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id qB7KQbLL017678; Fri, 7 Dec 2012 14:26:37 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id qB7KQbJ2013979; Fri, 7 Dec 2012 14:26:37 -0600 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Fri, 7 Dec 2012 14:26:37 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id qB7KQb6K016385; Fri, 7 Dec 2012 14:26:37 -0600 Received: from localhost (h113-201.vpn.ti.com [172.24.113.201]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id qB7KQaw11709; Fri, 7 Dec 2012 14:26:36 -0600 (CST) From: Jon Hunter To: Paul Walmsley CC: linux-omap , linux-arm , Mike Turquette , Jon Hunter Subject: [PATCH] ARM: OMAP4: Fix EMU clock domain always on Date: Fri, 7 Dec 2012 14:26:34 -0600 Message-ID: <1354911994-20045-1-git-send-email-jon-hunter@ti.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Commit d043d87 (ARM: OMAP2+: clockdomain: bypass clockdomain handling when disabling unused clks) skips the decrementing of a clock-domains use count if the clocks use count is zero. However, for OMAP4 devices this is causing the EMU clock-domain to be stuck ON as the use count is not getting decremented correctly. The scenario that leads to this problem is described below ... omap_hwmod_setup_all --> _setup --> clkdm_hwmod_enable --> EMU clock domain usecount = 1 --> _enable_clocks --> clk_enable --> trace_clk_div_div usecount = 1 --> clkdm_hwmod_enable --> EMU clock domain usecount = 2 --> _idle --> _disable_clocks --> clk_disable --> trace_clk_div_div usecount = 0 --> clkdm_hwmod_disable --> skips decrement of EMU clock domain usecount because trace_clk_div_div is 0! --> EMU clock domain usecount = 2 --> clkdm_hwmod_disable --> EMU clock domain usecount = 1 Hence, due to the order that a clocks use count is decremented and the clock domain is disabled, it is possible that the clock domain can have a non-zero use count when the actual clock has a use count of 0. Therefore, we should only bypass the clock-domain handling when both the clock-domain and clock in the clock-domain have a use count of 0 and warn when the clock-domain has a zero use count and the clock has a non-zero use count. Signed-off-by: Jon Hunter --- Based and test on current linux-next tree. This has been boot tested on OMAP2420, OMAP3430 and OMAP4430. I have validated suspend is working on OMAP3430. arch/arm/mach-omap2/clockdomain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c index 3848735..0b5452d 100644 --- a/arch/arm/mach-omap2/clockdomain.c +++ b/arch/arm/mach-omap2/clockdomain.c @@ -998,7 +998,8 @@ int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk) spin_lock_irqsave(&clkdm->lock, flags); /* corner case: disabling unused clocks */ - if (__clk_get_enable_count(clk) == 0) + if ((__clk_get_enable_count(clk) == 0) && + (atomic_read(&clkdm->usecount) == 0)) goto ccd_exit; if (atomic_read(&clkdm->usecount) == 0) {