From patchwork Thu Oct 4 20:38:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10626673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 466DA174A for ; Thu, 4 Oct 2018 20:38:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392CE296DD for ; Thu, 4 Oct 2018 20:38:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CD00296E9; Thu, 4 Oct 2018 20:38:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3F1296DD for ; Thu, 4 Oct 2018 20:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbeJEDd3 (ORCPT ); Thu, 4 Oct 2018 23:33:29 -0400 Received: from mail.andi.de1.cc ([85.214.239.24]:33926 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbeJEDd3 (ORCPT ); Thu, 4 Oct 2018 23:33:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hxKaBbQP9Ohf6unfmS5C4E5JDsTkQe6IxUA7qgDVBQc=; b=AU1VWG6c6U0Tcj29nA5TnaB9i yf4HzBgo0h+2bKYXNSnhpf3lj0a4NtcoVGVBrXWLH8DxemA4oiPT7q6XF0laRSRMGb1kzKABT2+Cs wtSGEbhs1MhP7951I3K/trG7ArKgYwTwPOrx0xCH/q3WxJPjzObu7tT1f2JRQWgWU6ZMc=; Received: from p200300ccfbcbd5001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbcb:d500:1a3d:a2ff:febf:d33a] helo=aktux) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8AOA-0007GZ-C4; Thu, 04 Oct 2018 22:38:26 +0200 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1g8AOA-0005mB-1h; Thu, 04 Oct 2018 22:38:26 +0200 From: Andreas Kemnade To: t-kristo@ti.com, mturquette@baylibre.com, sboyd@kernel.org, linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, bcousson@baylibre.com, paul@pwsan.com, tony@atomide.com, letux-kernel@openphoenux.org Cc: Andreas Kemnade Subject: [PATCH 1/2] clk: ti: add a usecount for autoidle Date: Thu, 4 Oct 2018 22:38:16 +0200 Message-Id: <20181004203817.22101-2-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181004203817.22101-1-andreas@kemnade.info> References: <20181004203817.22101-1-andreas@kemnade.info> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have the scenario that first autoidle is disabled for all clocks, then it is disabled for selected ones and then enabled for all. So we should have some counting here, also according to the comment in _setup_iclk_autoidle() Signed-off-by: Andreas Kemnade --- drivers/clk/ti/autoidle.c | 32 ++++++++++++++++++++++++-------- include/linux/clk/ti.h | 1 + 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c index 7bb9afbe4058..bb6cff168e73 100644 --- a/drivers/clk/ti/autoidle.c +++ b/drivers/clk/ti/autoidle.c @@ -37,6 +37,14 @@ struct clk_ti_autoidle { static LIST_HEAD(autoidle_clks); static LIST_HEAD(clk_hw_omap_clocks); +/* + * we have some non-atomic read/write + * operations behind it, so lets + * take one mutex for handling autoidle + * of all clocks + */ +static DEFINE_MUTEX(autoidle_mutex); + /** * omap2_clk_deny_idle - disable autoidle on an OMAP clock * @clk: struct clk * to disable autoidle for @@ -48,8 +56,13 @@ int omap2_clk_deny_idle(struct clk *clk) struct clk_hw_omap *c; c = to_clk_hw_omap(__clk_get_hw(clk)); - if (c->ops && c->ops->deny_idle) - c->ops->deny_idle(c); + if (c->ops && c->ops->deny_idle) { + mutex_lock(&autoidle_mutex); + c->autoidle_count--; + if (c->autoidle_count == -1) + c->ops->deny_idle(c); + mutex_unlock(&autoidle_mutex); + } return 0; } @@ -64,8 +77,13 @@ int omap2_clk_allow_idle(struct clk *clk) struct clk_hw_omap *c; c = to_clk_hw_omap(__clk_get_hw(clk)); - if (c->ops && c->ops->allow_idle) - c->ops->allow_idle(c); + if (c->ops && c->ops->allow_idle) { + mutex_lock(&autoidle_mutex); + c->autoidle_count++; + if (c->autoidle_count == 0) + c->ops->allow_idle(c); + mutex_unlock(&autoidle_mutex); + } return 0; } @@ -201,8 +219,7 @@ int omap2_clk_enable_autoidle_all(void) struct clk_hw_omap *c; list_for_each_entry(c, &clk_hw_omap_clocks, node) - if (c->ops && c->ops->allow_idle) - c->ops->allow_idle(c); + omap2_clk_allow_idle(c->hw.clk); _clk_generic_allow_autoidle_all(); @@ -223,8 +240,7 @@ int omap2_clk_disable_autoidle_all(void) struct clk_hw_omap *c; list_for_each_entry(c, &clk_hw_omap_clocks, node) - if (c->ops && c->ops->deny_idle) - c->ops->deny_idle(c); + omap2_clk_deny_idle(c->hw.clk); _clk_generic_deny_autoidle_all(); diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h index a8faa38b1ed6..c460355419c0 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -159,6 +159,7 @@ struct clk_hw_omap { const char *clkdm_name; struct clockdomain *clkdm; const struct clk_hw_omap_ops *ops; + int autoidle_count; }; /* From patchwork Thu Oct 4 20:38:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10626677 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60727174A for ; Thu, 4 Oct 2018 20:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54C64296E7 for ; Thu, 4 Oct 2018 20:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48F65296F2; Thu, 4 Oct 2018 20:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0FC2296E7 for ; Thu, 4 Oct 2018 20:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbeJEDdg (ORCPT ); Thu, 4 Oct 2018 23:33:36 -0400 Received: from mail.andi.de1.cc ([85.214.239.24]:33974 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727499AbeJEDdf (ORCPT ); Thu, 4 Oct 2018 23:33:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gsrVQYqOvt6bHEaGNBZ3ivI+imRg6+0o4MIOMQo5To4=; b=ZeBFcSu2Hx1koLT2PIh73dYHu jPtkOI5GZ4A3vQqPOip3WbsbqBQuOXL6a7pl6sVMRKQvigEUWEv/gj1sX0JHgt2HZY8KHZaBmYftz I8SKgTmAGsw5/qS9qdNkhfI02qaMqmMFGnPNVvdBLfMciucd4zBaYijGNIzUD4sSQKWhk=; Received: from p200300ccfbcbd5001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbcb:d500:1a3d:a2ff:febf:d33a] helo=aktux) by h2641619.stratoserver.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8AOG-0007Gy-FE; Thu, 04 Oct 2018 22:38:32 +0200 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1g8AOG-0005mE-71; Thu, 04 Oct 2018 22:38:32 +0200 From: Andreas Kemnade To: t-kristo@ti.com, mturquette@baylibre.com, sboyd@kernel.org, linux-omap@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, bcousson@baylibre.com, paul@pwsan.com, tony@atomide.com, letux-kernel@openphoenux.org Cc: Andreas Kemnade Subject: [PATCH 2/2] arm: omap_hwmod disable ick autoidling when a hwmod requires that Date: Thu, 4 Oct 2018 22:38:17 +0200 Message-Id: <20181004203817.22101-3-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181004203817.22101-1-andreas@kemnade.info> References: <20181004203817.22101-1-andreas@kemnade.info> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Deny autoidle for hwmods with the OCPIF_SWSUP_IDLE flag, that makes hwmods working properly which cannot handle autoidle properly in lower power states. Affected is e. g. the omap_hdq. Since an ick might have mulitple users, autoidle is disabled when an individual user requires that rather than in _setup_iclk_autoidle. dss_ick is an example for that. Signed-off-by: Andreas Kemnade --- arch/arm/mach-omap2/omap_hwmod.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index bb641e6c93d0..0078b0e1d242 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -986,8 +986,10 @@ static int _enable_clocks(struct omap_hwmod *oh) clk_enable(oh->_clk); list_for_each_entry(os, &oh->slave_ports, node) { - if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) + if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { + omap2_clk_deny_idle(os->_clk); clk_enable(os->_clk); + } } /* The opt clocks are controlled by the device driver. */ @@ -1039,8 +1041,10 @@ static int _disable_clocks(struct omap_hwmod *oh) clk_disable(oh->_clk); list_for_each_entry(os, &oh->slave_ports, node) { - if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) + if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE)) { clk_disable(os->_clk); + omap2_clk_allow_idle(os->_clk); + } } if (oh->flags & HWMOD_OPT_CLKS_NEEDED) @@ -2410,9 +2414,13 @@ static void __init _setup_iclk_autoidle(struct omap_hwmod *oh) continue; if (os->flags & OCPIF_SWSUP_IDLE) { - /* XXX omap_iclk_deny_idle(c); */ + /* + * we might have multiple users of one iclk with + * different requirements, disable autoidle when + * the module is enabled, e.g. dss iclk + */ } else { - /* XXX omap_iclk_allow_idle(c); */ + /* we are enabling autoidle afterwards anyways */ clk_enable(os->_clk); } }