From patchwork Sat Nov 10 20:31:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10677417 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 8E03F14BD for ; Sat, 10 Nov 2018 20:31:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4BB2BFDF for ; Sat, 10 Nov 2018 20:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F1BB2C004; Sat, 10 Nov 2018 20:31:55 +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 1D1232BFDF for ; Sat, 10 Nov 2018 20:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726665AbeKKGRx (ORCPT ); Sun, 11 Nov 2018 01:17:53 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:55174 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbeKKGRw (ORCPT ); Sun, 11 Nov 2018 01:17:52 -0500 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=Wf/u8C0XrToxFFyDJHcHwb5Q4HKFOYNOE9vQVibkCE0=; b=aUnKtmTFxtHvV2fn4h6KxQGkG svdITzofToM7T0gTNPFiCYjORzReq/q3AUUw5/LvGEmLTkNYrw2UQANBaBzc2oTrWs7E9LeIy4Esv YWmayvdNviUHkjyy/pJ7w+qVUEyQkTMvSejoIYPFea7Yv+9EQRLzdCfRGujZR3n6KBTQk=; Received: from p200300ccfbcefb001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbce:fb00: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 1gLZuj-0000Au-Bf; Sat, 10 Nov 2018 21:31:29 +0100 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1gLZuj-0003Tp-1E; Sat, 10 Nov 2018 21:31:29 +0100 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 v2 1/3] clk: ti: add a usecount for autoidle Date: Sat, 10 Nov 2018 21:31:13 +0100 Message-Id: <20181110203115.13335-2-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181110203115.13335-1-andreas@kemnade.info> References: <20181110203115.13335-1-andreas@kemnade.info> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Multiple users might deny autoidle on a clock. So we should have some counting here, also according to the comment in _setup_iclk_autoidle(). Also setting autoidle regs is not atomic, so there is another reason for locking. Signed-off-by: Andreas Kemnade --- Changes since v1: - use spinlocks instead of mutexes - invert logic --- drivers/clk/ti/autoidle.c | 36 ++++++++++++++++++++++++++++-------- include/linux/clk/ti.h | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c index 7bb9afbe4058..161f67850393 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 lock for handling autoidle + * of all clocks + */ +static DEFINE_SPINLOCK(autoidle_spinlock); + /** * omap2_clk_deny_idle - disable autoidle on an OMAP clock * @clk: struct clk * to disable autoidle for @@ -48,8 +56,15 @@ 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) { + unsigned long irqflags; + + spin_lock_irqsave(&autoidle_spinlock, irqflags); + c->autoidle_count++; + if (c->autoidle_count == 1) + c->ops->deny_idle(c); + spin_unlock_irqrestore(&autoidle_spinlock, irqflags); + } return 0; } @@ -64,8 +79,15 @@ 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) { + unsigned long irqflags; + + spin_lock_irqsave(&autoidle_spinlock, irqflags); + c->autoidle_count--; + if (c->autoidle_count == 0) + c->ops->allow_idle(c); + spin_unlock_irqrestore(&autoidle_spinlock, irqflags); + } return 0; } @@ -201,8 +223,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 +244,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 eacc5df57b99..78872efc7be0 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -160,6 +160,7 @@ struct clk_hw_omap { struct clockdomain *clkdm; const struct clk_hw_omap_ops *ops; u32 context; + int autoidle_count; }; /* From patchwork Sat Nov 10 20:31:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10677407 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 DC8EB14BD for ; Sat, 10 Nov 2018 20:31:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C21372BFDF for ; Sat, 10 Nov 2018 20:31:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3CA32C00A; Sat, 10 Nov 2018 20:31:39 +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 883EA2BFDF for ; Sat, 10 Nov 2018 20:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725979AbeKKGRv (ORCPT ); Sun, 11 Nov 2018 01:17:51 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:55176 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbeKKGRv (ORCPT ); Sun, 11 Nov 2018 01:17:51 -0500 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=bkT6Tvgpqv1f+bqR/z7UZurhOG3dEwgC/MQ7DiTqGn0=; b=as+EzBEVbE5PEBH8tav8ZjqVh OWO73h29oavst3j58voN17vUJlsDtdfWuwhc5M3QxZjXvU9ENM6XBoVAY3fnXQs19PNJrcYii+0ba zAgQtYDGwPfYVeQhLrrlB9aLDS/3yhILf60GRIYIWRe9XNSQXWGOGAOjDZxYJpQIEWkcA=; Received: from p200300ccfbcefb001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbce:fb00: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 1gLZul-0000Ay-UL; Sat, 10 Nov 2018 21:31:32 +0100 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1gLZul-0003Ts-L2; Sat, 10 Nov 2018 21:31:31 +0100 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 v2 2/3] clk: ti: check clock type before doing autoidle ops Date: Sat, 10 Nov 2018 21:31:14 +0100 Message-Id: <20181110203115.13335-3-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181110203115.13335-1-andreas@kemnade.info> References: <20181110203115.13335-1-andreas@kemnade.info> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Code might use autoidle api with clocks not being omap2 clocks, so check if clock type is not basic Signed-off-by: Andreas Kemnade --- New in v2 --- drivers/clk/ti/autoidle.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/clk/ti/autoidle.c b/drivers/clk/ti/autoidle.c index 161f67850393..5bdae5552d38 100644 --- a/drivers/clk/ti/autoidle.c +++ b/drivers/clk/ti/autoidle.c @@ -54,8 +54,12 @@ static DEFINE_SPINLOCK(autoidle_spinlock); int omap2_clk_deny_idle(struct clk *clk) { struct clk_hw_omap *c; + struct clk_hw *hw = __clk_get_hw(clk); - c = to_clk_hw_omap(__clk_get_hw(clk)); + if (clk_hw_get_flags(hw) & CLK_IS_BASIC) + return -EINVAL; + + c = to_clk_hw_omap(hw); if (c->ops && c->ops->deny_idle) { unsigned long irqflags; @@ -77,8 +81,12 @@ int omap2_clk_deny_idle(struct clk *clk) int omap2_clk_allow_idle(struct clk *clk) { struct clk_hw_omap *c; + struct clk_hw *hw = __clk_get_hw(clk); - c = to_clk_hw_omap(__clk_get_hw(clk)); + if (clk_hw_get_flags(hw) & CLK_IS_BASIC) + return -EINVAL; + + c = to_clk_hw_omap(hw); if (c->ops && c->ops->allow_idle) { unsigned long irqflags; From patchwork Sat Nov 10 20:31:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 10677411 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 83A5513BF for ; Sat, 10 Nov 2018 20:31:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70F692BFDF for ; Sat, 10 Nov 2018 20:31:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6518F2C004; Sat, 10 Nov 2018 20:31: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=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 0E0502BFDF for ; Sat, 10 Nov 2018 20:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbeKKGRz (ORCPT ); Sun, 11 Nov 2018 01:17:55 -0500 Received: from mail.andi.de1.cc ([85.214.239.24]:55208 "EHLO h2641619.stratoserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726687AbeKKGRy (ORCPT ); Sun, 11 Nov 2018 01:17:54 -0500 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=d0Z4wDFvJUTZrDNbdh0j0zfJTsQdVVzl/1whxXolpLM=; b=VZIjn4a8qDha3p+74pN37tu3B Kay/2snRuXsMCEb0uu4e5TmrJiRUKWIm1HgBoAe0PeVobi5GyYmeIN6WAWw12TptBp9F8KqrtXekQ Cw5S0WCK2StGd22SrINYrqmRxIc/ZVZc+mG1alXTXJfA3kIMV1WHfhqOJdOPp2yncDyVI=; Received: from p200300ccfbcefb001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:fbce:fb00: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 1gLZun-0000BM-JV; Sat, 10 Nov 2018 21:31:33 +0100 Received: from andi by aktux with local (Exim 4.89) (envelope-from ) id 1gLZun-0003Tv-9x; Sat, 10 Nov 2018 21:31:33 +0100 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 v2 3/3] arm: omap_hwmod disable ick autoidling when a hwmod requires that Date: Sat, 10 Nov 2018 21:31:15 +0100 Message-Id: <20181110203115.13335-4-andreas@kemnade.info> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181110203115.13335-1-andreas@kemnade.info> References: <20181110203115.13335-1-andreas@kemnade.info> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@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 --- Comments to v1 to this patch were worked into a new 2/3 --- 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 083dcd9942ce..3a86ba414973 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -1002,8 +1002,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. */ @@ -1055,8 +1057,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) @@ -2425,9 +2429,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); } }